diff --git a/python/gui/symbology-ng/qgsstylev2managerdialog.sip b/python/gui/symbology-ng/qgsstylev2managerdialog.sip index b285fcc328d..5a4370f11e9 100644 --- a/python/gui/symbology-ng/qgsstylev2managerdialog.sip +++ b/python/gui/symbology-ng/qgsstylev2managerdialog.sip @@ -55,6 +55,9 @@ class QgsStyleV2ManagerDialog : QDialog //! Perform symbol specific tasks when selected void symbolSelected( const QModelIndex& ); + //! Perform tasks when the selected symbols change + void selectedSymbolsChanged( const QItemSelection& selected, const QItemSelection& deselected ); + //! Context menu for the groupTree void grouptreeContextMenu( const QPoint& ); diff --git a/src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp b/src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp index 7bda1b54e11..360751418c1 100644 --- a/src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp +++ b/src/gui/symbology-ng/qgsstylev2exportimportdialog.cpp @@ -51,6 +51,8 @@ QgsStyleV2ExportImportDialog::QgsStyleV2ExportImportDialog( QgsStyleV2* style, Q QStandardItemModel* model = new QStandardItemModel( listItems ); listItems->setModel( model ); + connect( listItems->selectionModel(), SIGNAL( selectionChanged( const QItemSelection&, const QItemSelection& ) ), + this, SLOT( selectionChanged( const QItemSelection&, const QItemSelection& ) ) ); mTempStyle = new QgsStyleV2(); // TODO validate @@ -109,6 +111,7 @@ QgsStyleV2ExportImportDialog::QgsStyleV2ExportImportDialog( QgsStyleV2* style, Q // use Ok button for starting import and export operations disconnect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( buttonBox, SIGNAL( accepted() ), this, SLOT( doExportImport() ) ); + buttonBox->button( QDialogButtonBox::Ok )->setEnabled( false ); } void QgsStyleV2ExportImportDialog::doExportImport() @@ -594,3 +597,11 @@ void QgsStyleV2ExportImportDialog::downloadCanceled() mTempFile->remove(); mFileName = ""; } + +void QgsStyleV2ExportImportDialog::selectionChanged( const QItemSelection & selected, const QItemSelection & deselected ) +{ + Q_UNUSED( selected ); + Q_UNUSED( deselected ); + bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty(); + buttonBox->button( QDialogButtonBox::Ok )->setDisabled( nothingSelected ); +} diff --git a/src/gui/symbology-ng/qgsstylev2exportimportdialog.h b/src/gui/symbology-ng/qgsstylev2exportimportdialog.h index 2027dc2696c..b288a3c7c87 100644 --- a/src/gui/symbology-ng/qgsstylev2exportimportdialog.h +++ b/src/gui/symbology-ng/qgsstylev2exportimportdialog.h @@ -100,6 +100,7 @@ class GUI_EXPORT QgsStyleV2ExportImportDialog : public QDialog, private Ui::QgsS void fileReadyRead(); void updateProgress( qint64, qint64 ); void downloadCanceled(); + void selectionChanged( const QItemSelection & selected, const QItemSelection & deselected ); private: void downloadStyleXML( const QUrl& url ); diff --git a/src/gui/symbology-ng/qgsstylev2managerdialog.cpp b/src/gui/symbology-ng/qgsstylev2managerdialog.cpp index 62cb8ede2a2..7dc7d64d7cf 100644 --- a/src/gui/symbology-ng/qgsstylev2managerdialog.cpp +++ b/src/gui/symbology-ng/qgsstylev2managerdialog.cpp @@ -49,7 +49,6 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa #endif QSettings settings; - QAction* a; // used as a temporary variable before passing ownership of a created action. restoreGeometry( settings.value( "/Windows/StyleV2Manager/geometry" ).toByteArray() ); mSplitter->setSizes( QList() << 170 << 540 ); @@ -66,6 +65,8 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa connect( btnEditItem, SIGNAL( clicked() ), this, SLOT( editItem() ) ); connect( btnRemoveItem, SIGNAL( clicked() ), this, SLOT( removeItem() ) ); + btnRemoveItem->setEnabled( false ); + QMenu *shareMenu = new QMenu( tr( "Share menu" ), this ); QAction *exportAsPNGAction = shareMenu->addAction( tr( "Export selected symbols as PNG" ) ); QAction *exportAsSVGAction = shareMenu->addAction( tr( "Export selected symbols as SVG" ) ); @@ -74,7 +75,9 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa QAction *importAction = new QAction( tr( "Import..." ), this ); shareMenu->addAction( importAction ); exportAsPNGAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingExport.svg" ) ) ); + exportAsPNGAction->setEnabled( false ); exportAsSVGAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingExport.svg" ) ) ); + exportAsSVGAction->setEnabled( false ); exportAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingExport.svg" ) ) ); importAction->setIcon( QIcon( QgsApplication::iconPath( "mActionSharingImport.svg" ) ) ); connect( exportAsPNGAction, SIGNAL( triggered() ), this, SLOT( exportItemsPNG() ) ); @@ -93,6 +96,8 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa connect( model, SIGNAL( itemChanged( QStandardItem* ) ), this, SLOT( itemChanged( QStandardItem* ) ) ); connect( listItems->selectionModel(), SIGNAL( currentChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( symbolSelected( const QModelIndex& ) ) ); + connect( listItems->selectionModel(), SIGNAL( selectionChanged( const QItemSelection, const QItemSelection ) ), + this, SLOT( selectedSymbolsChanged( const QItemSelection&, const QItemSelection& ) ) ); populateTypes(); @@ -115,8 +120,6 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa connect( btnAddGroup, SIGNAL( clicked() ), this, SLOT( addGroup() ) ); connect( btnRemoveGroup, SIGNAL( clicked() ), this, SLOT( removeGroup() ) ); - on_tabItemType_currentChanged( 0 ); - connect( searchBox, SIGNAL( textChanged( QString ) ), this, SLOT( filterSymbols( QString ) ) ); tagsLineEdit->installEventFilter( this ); @@ -144,10 +147,12 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa mGroupMenu = new QMenu( this ); mGroupListMenu = new QMenu( mGroupMenu ); mGroupListMenu->setTitle( tr( "Apply Group" ) ); + mGroupListMenu->setEnabled( false ); mGroupMenu->addMenu( mGroupListMenu ); - a = new QAction( tr( "Un-group" ), mGroupMenu ); - a->setData( 0 ); - mGroupMenu->addAction( a ); + actnUngroup->setData( 0 ); + mGroupMenu->addAction( actnUngroup ); + + on_tabItemType_currentChanged( 0 ); } void QgsStyleV2ManagerDialog::onFinished() @@ -260,6 +265,8 @@ void QgsStyleV2ManagerDialog::populateSymbols( const QStringList& symbolNames, b } delete symbol; } + selectedSymbolsChanged( QItemSelection(), QItemSelection() ); + symbolSelected( listItems->currentIndex() ); } @@ -1219,10 +1226,25 @@ void QgsStyleV2ManagerDialog::symbolSelected( const QModelIndex& index ) { // Populate the tags for the symbol tagsLineEdit->clear(); - QStandardItem *item = static_cast( listItems->model() )->itemFromIndex( index ); - QgsStyleV2::StyleEntity type = ( currentItemType() < 3 ) ? QgsStyleV2::SymbolEntity : QgsStyleV2::ColorrampEntity; - mTagList = mStyle->tagsOfSymbol( type, item->data().toString() ); - tagsLineEdit->setText( mTagList.join( "," ) ); + if ( index.isValid() ) + { + QStandardItem *item = static_cast( listItems->model() )->itemFromIndex( index ); + QgsStyleV2::StyleEntity type = ( currentItemType() < 3 ) ? QgsStyleV2::SymbolEntity : QgsStyleV2::ColorrampEntity; + mTagList = mStyle->tagsOfSymbol( type, item->data().toString() ); + tagsLineEdit->setText( mTagList.join( "," ) ); + } +} + +void QgsStyleV2ManagerDialog::selectedSymbolsChanged( const QItemSelection& selected, const QItemSelection& deselected ) +{ + Q_UNUSED( selected ); + Q_UNUSED( deselected ); + bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty(); + btnRemoveItem->setDisabled( nothingSelected ); + mGroupListMenu->setDisabled( nothingSelected ); + actnUngroup->setDisabled( nothingSelected ); + btnShare->menu()->actions().at( 0 )->setDisabled( nothingSelected ); + btnShare->menu()->actions().at( 1 )->setDisabled( nothingSelected ); } void QgsStyleV2ManagerDialog::enableSymbolInputs( bool enable ) diff --git a/src/gui/symbology-ng/qgsstylev2managerdialog.h b/src/gui/symbology-ng/qgsstylev2managerdialog.h index 165dbfbf7e6..5660f703d5f 100644 --- a/src/gui/symbology-ng/qgsstylev2managerdialog.h +++ b/src/gui/symbology-ng/qgsstylev2managerdialog.h @@ -81,6 +81,9 @@ class GUI_EXPORT QgsStyleV2ManagerDialog : public QDialog, private Ui::QgsStyleV //! Perform symbol specific tasks when selected void symbolSelected( const QModelIndex& ); + //! Perform tasks when the selected symbols change + void selectedSymbolsChanged( const QItemSelection& selected, const QItemSelection& deselected ); + //! Context menu for the groupTree void grouptreeContextMenu( const QPoint& ); diff --git a/src/ui/qgsstylev2managerdialogbase.ui b/src/ui/qgsstylev2managerdialogbase.ui index b9019603348..2e892f66bfe 100644 --- a/src/ui/qgsstylev2managerdialogbase.ui +++ b/src/ui/qgsstylev2managerdialogbase.ui @@ -420,6 +420,17 @@ QMenu::item:selected { background-color: gray; } */ + + + false + + + Ungroup + + + Ungroup + +