/
qgssublayersdialog.h
95 lines (77 loc) · 3.42 KB
/
qgssublayersdialog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/***************************************************************************
qgssublayersdialog.h - dialog for selecting sublayers
---------------------
begin : January 2009
copyright : (C) 2009 by Florian El Ahdab
email : felahdab at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSSUBLAYERSDIALOG_H
#define QGSSUBLAYERSDIALOG_H
#include <QDialog>
#include <QCheckBox>
#include <ui_qgssublayersdialogbase.h>
#include "qgscontexthelp.h"
#include "qgis_gui.h"
/** \ingroup gui
* \class QgsSublayersDialog
*/
class GUI_EXPORT QgsSublayersDialog : public QDialog, private Ui::QgsSublayersDialogBase
{
Q_OBJECT
public:
enum ProviderType
{
Ogr,
Gdal,
Vsifile
};
//! A structure that defines layers for the purpose of this dialog
//! @note added in 2.16
typedef struct LayerDefinition
{
LayerDefinition() : layerId( -1 ), count( -1 ) {}
int layerId; //!< Identifier of the layer (one unique layer id may have multiple types though)
QString layerName; //!< Name of the layer (not necessarily unique)
int count; //!< Number of features (might be unused)
QString type; //!< Extra type depending on the use (e.g. geometry type for vector sublayers)
} LayerDefinition;
//! List of layer definitions for the purpose of this dialog
//! @note added in 2.16
typedef QList<LayerDefinition> LayerDefinitionList;
QgsSublayersDialog( ProviderType providerType, const QString &name, QWidget *parent = nullptr, Qt::WindowFlags fl = 0 );
~QgsSublayersDialog();
//! Populate the table with layers
//! @note added in 2.16
void populateLayerTable( const LayerDefinitionList &list );
//! Returns list of selected layers
//! @note added in 2.16
LayerDefinitionList selection();
//! Set if we should display the add to group checkbox
//! @note added in 3.0
void setShowAddToGroupCheckbox( bool showAddToGroupCheckbox ) { mShowAddToGroupCheckbox = showAddToGroupCheckbox; }
//! If we should display the add to group checkbox
//! @note added in 3.0
bool showAddToGroupCheckbox() const { return mShowAddToGroupCheckbox; }
//! If we should add layers in a group
//! @note added in 3.0
bool addToGroupCheckbox() const { return mCheckboxAddToGroup->isChecked(); }
public slots:
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
int exec();
protected:
QString mName;
QStringList mSelectedSubLayers;
bool mShowCount = false; //!< Whether to show number of features in the table
bool mShowType = false; //!< Whether to show type in the table
private:
bool mShowAddToGroupCheckbox = false; //!< Whether to show the add to group checkbox
QCheckBox *mCheckboxAddToGroup = nullptr;
};
#endif