QGIS API Documentation  3.37.0-Master (a5b4d9743e8)
qgssublayersdialog.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgssublayersdialog.h - dialog for selecting sublayers
3  ---------------------
4  begin : January 2009
5  copyright : (C) 2009 by Florian El Ahdab
6  email : felahdab at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSSUBLAYERSDIALOG_H
17 #define QGSSUBLAYERSDIALOG_H
18 
19 #include <QDialog>
20 #include <QCheckBox>
21 #include "ui_qgssublayersdialogbase.h"
22 #include "qgis_sip.h"
23 #include "qgis_gui.h"
24 #include "qgis.h"
25 
31 class GUI_EXPORT QgsSublayersDialog : public QDialog, private Ui::QgsSublayersDialogBase
32 {
33  Q_OBJECT
34  public:
35 
41  {
42 
47 
52 
57 
61  PromptLoadAll
62  };
63  Q_ENUM( PromptMode )
64 
66  {
67  Ogr,
70  Mdal
71  };
72 
77  {
79  int layerId = -1;
80 
82  QString layerName;
83 
85  int count = -1;
86 
88  QString type;
89 
95  QString description;
96  };
97 
101  typedef QList<QgsSublayersDialog::LayerDefinition> LayerDefinitionList;
102 
104 
116  Q_DECL_DEPRECATED QgsSublayersDialog( ProviderType providerType,
117  const QString &name,
118  QWidget *parent SIP_TRANSFERTHIS = nullptr,
119  Qt::WindowFlags fl = Qt::WindowFlags(),
120  const QString &dataSourceUri = QString() ) SIP_DEPRECATED;
121 
122  ~QgsSublayersDialog() override;
123 
127  void populateLayerTable( const LayerDefinitionList &list );
128 
132  LayerDefinitionList selection();
133 
137  void setShowAddToGroupCheckbox( bool showAddToGroupCheckbox ) { mShowAddToGroupCheckbox = showAddToGroupCheckbox; }
138 
142  bool showAddToGroupCheckbox() const { return mShowAddToGroupCheckbox; }
143 
147  bool addToGroupCheckbox() const { return mCbxAddToGroup->isChecked(); }
148 
152  int countColumn() const { return mShowCount ? 2 : -1; }
153 
154  public slots:
155  int exec() override;
156 
157  private slots:
158  void layersTable_selectionChanged( const QItemSelection &, const QItemSelection & );
159  void mBtnDeselectAll_pressed();
160 
161  protected:
162 
166  QString mName;
167  QStringList mSelectedSubLayers;
168 
170  bool mShowCount = false;
172  bool mShowType = false;
174  bool mShowDescription = false;
175 
176  private:
178  bool mShowAddToGroupCheckbox = false;
179 };
180 
181 #endif
QList< QgsSublayersDialog::LayerDefinition > LayerDefinitionList
List of layer definitions for the purpose of this dialog.
PromptMode
Prompt behavior of the QgsSublayersDialog.
@ PromptNever
never prompt, will not load anything
@ PromptAlways
always ask if there are existing sublayers
@ PromptIfNeeded
always ask if there are existing sublayers, but skip if there are bands for rasters
bool showAddToGroupCheckbox() const
If we should display the add to group checkbox.
QStringList mSelectedSubLayers
int countColumn() const
Returns column with count or -1.
bool addToGroupCheckbox() const
If we should add layers in a group.
QString mName
Provider type name.
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
A structure that defines layers for the purpose of this dialog.
QString layerName
Name of the layer (not necessarily unique)
QString type
Extra type depending on the use (e.g. geometry type for vector sublayers)