21 #include <QTableWidgetItem>
22 #include <QPushButton>
26 QWidget* parent, Qt::WFlags fl )
27 : QDialog( parent, fl ), mName( name )
33 setWindowTitle(
tr(
"Select vector layers to add..." ) );
34 layersTable->setHeaderLabels( QStringList() <<
tr(
"Layer ID" ) <<
tr(
"Layer name" )
35 <<
tr(
"Number of features" ) <<
tr(
"Geometry type" ) );
39 setWindowTitle(
tr(
"Select raster layers to add..." ) );
40 layersTable->setHeaderLabels( QStringList() <<
tr(
"Layer ID" ) <<
tr(
"Layer name" ) );
44 setWindowTitle(
tr(
"Select layers to add..." ) );
45 layersTable->setHeaderLabels( QStringList() <<
tr(
"Layer ID" ) <<
tr(
"Layer name" )
50 QPushButton* button =
new QPushButton(
tr(
"Select All" ) );
51 buttonBox->addButton( button, QDialogButtonBox::ActionRole );
52 connect( button, SIGNAL( pressed() ), layersTable, SLOT( selectAll() ) );
56 restoreGeometry( settings.value(
"/Windows/" +
mName +
"SubLayers/geometry" ).toByteArray() );
62 settings.setValue(
"/Windows/" +
mName +
"SubLayers/geometry", saveGeometry() );
63 settings.setValue(
"/Windows/" +
mName +
"SubLayers/headerState",
64 layersTable->header()->saveState() );
70 for (
int i = 0; i < layersTable->selectedItems().size(); i++ )
75 QString name = layersTable->selectedItems().at( i )->text( 1 );
77 for (
int j = 0; j < layersTable->topLevelItemCount(); j++ )
79 if ( layersTable->topLevelItem( j )->text( 1 ) == name )
86 name +=
":" + layersTable->selectedItems().at( i )->text( 3 );
96 for (
int i = 0; i < layersTable->selectedItems().size(); i++ )
98 list << layersTable->selectedItems().at( i )->text( 0 ).toInt();
105 foreach ( QString item, theList )
107 layersTable->addTopLevelItem(
new QTreeWidgetItem( item.split( delim ) ) );
112 QByteArray ba = settings.value(
"/Windows/" +
mName +
"SubLayers/headerState" ).toByteArray();
115 layersTable->header()->restoreState( ba );
119 for (
int i = 0; i < layersTable->columnCount(); i++ )
120 layersTable->resizeColumnToContents( i );
121 layersTable->setColumnWidth( 1, layersTable->columnWidth( 1 ) + 10 );
131 QString promptLayers = settings.value(
"/qgis/promptForSublayers", 1 ).toString();
134 if ( layersTable->topLevelItemCount() == 0 )
135 return QDialog::Rejected;
138 if ( promptLayers ==
"no" )
139 return QDialog::Rejected;
140 else if ( promptLayers ==
"all" )
142 layersTable->selectAll();
143 return QDialog::Accepted;
147 if ( layersTable->topLevelItemCount() == 1 )
149 layersTable->selectAll();
150 return QDialog::Accepted;
156 bool override = ( QApplication::overrideCursor() != 0 );
159 cursor = QCursor( * QApplication::overrideCursor() );
160 QApplication::restoreOverrideCursor();
164 QApplication::setOverrideCursor( cursor );