21 #include <QTableWidgetItem> 22 #include <QPushButton> 37 layersTable->setHeaderLabels(
QStringList() <<
tr(
"Layer ID" ) <<
tr(
"Layer name" )
38 <<
tr(
"Number of features" ) <<
tr(
"Geometry type" ) );
45 layersTable->setHeaderLabels(
QStringList() <<
tr(
"Layer ID" ) <<
tr(
"Layer name" ) );
50 layersTable->setHeaderLabels(
QStringList() <<
tr(
"Layer ID" ) <<
tr(
"Layer name" )
57 buttonBox->addButton( button, QDialogButtonBox::ActionRole );
58 connect( button, SIGNAL( pressed() ), layersTable, SLOT( selectAll() ) );
69 settings.
setValue(
"/Windows/" +
mName +
"SubLayers/headerState",
70 layersTable->header()->saveState() );
89 for (
int i = 0; i < layersTable->selectedItems().size(); i++ )
119 elements << item.
type;
128 layersTable->header()->restoreState( ba );
132 for (
int i = 0; i < layersTable->columnCount(); i++ )
133 layersTable->resizeColumnToContents( i );
134 layersTable->setColumnWidth( 1, layersTable->columnWidth( 1 ) + 10 );
142 for (
int i = 0; i < layersTable->selectedItems().size(); i++ )
147 QString name = layersTable->selectedItems().at( i )->text( 1 );
149 for (
int j = 0; j < layersTable->topLevelItemCount(); j++ )
151 if ( layersTable->topLevelItem( j )->text( 1 ) ==
name )
159 name +=
':' + layersTable->selectedItems().
at( i )->text( 3 );
174 for (
int i = 0; i < layersTable->selectedItems().size(); i++ )
176 list << layersTable->selectedItems().
at( i )->text( 0 ).toInt();
183 Q_FOREACH (
const QString& item, theList )
186 while ( elements.
size() > 4 )
188 elements[1] += delim + elements[2];
199 layersTable->header()->restoreState( ba );
203 for (
int i = 0; i < layersTable->columnCount(); i++ )
204 layersTable->resizeColumnToContents( i );
205 layersTable->setColumnWidth( 1, layersTable->columnWidth( 1 ) + 10 );
218 if ( layersTable->topLevelItemCount() == 0 )
219 return QDialog::Rejected;
222 if ( promptLayers ==
"no" )
223 return QDialog::Rejected;
224 else if ( promptLayers ==
"all" )
226 layersTable->selectAll();
227 return QDialog::Accepted;
231 if ( layersTable->topLevelItemCount() == 1 )
233 layersTable->selectAll();
234 return QDialog::Accepted;
237 layersTable->sortByColumn( 1, Qt::AscendingOrder );
238 layersTable->setSortingEnabled(
true );
244 if ( overrideCursor )
250 if ( overrideCursor )
QByteArray toByteArray() const
QString layerName
name of the layer (not necessarily unique)
int layerId
identifier of the layer (one unique layer id may have multiple types though)
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
const T & at(int i) const
Q_DECL_DEPRECATED QStringList selectionNames()
bool mShowType
whether to show type in the table
QString tr(const char *sourceText, const char *disambiguation, int n)
bool mShowCount
whether to show number of features in the table
void setValue(const QString &key, const QVariant &value)
const char * name() const
QString number(int n, int base)
int count
number of features (might be unused)
int toInt(bool *ok, int base) const
void populateLayerTable(const LayerDefinitionList &list)
Populate the table with layers.
QgsSublayersDialog(ProviderType providerType, const QString &name, QWidget *parent=nullptr, const Qt::WindowFlags &fl=nullptr)
void setOverrideCursor(const QCursor &cursor)
void restoreOverrideCursor()
Q_DECL_DEPRECATED QList< int > selectionIndexes()
QString type
extra type depending on the use (e.g. geometry type for vector sublayers)
QVariant value(const QString &key, const QVariant &defaultValue) const
LayerDefinitionList selection()
Returns list of selected layers.
const QChar at(int position) const
static bool _isLayerIdUnique(int layerId, QTreeWidget *layersTable)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
A structure that defines layers for the purpose of this dialog.
QString text(int column) const
QCursor * overrideCursor()