@@ -49,7 +49,6 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
49
49
#endif
50
50
51
51
QSettings settings;
52
- QAction* a; // used as a temporary variable before passing ownership of a created action.
53
52
54
53
restoreGeometry ( settings.value ( " /Windows/StyleV2Manager/geometry" ).toByteArray () );
55
54
mSplitter ->setSizes ( QList<int >() << 170 << 540 );
@@ -66,6 +65,8 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
66
65
connect ( btnEditItem, SIGNAL ( clicked () ), this , SLOT ( editItem () ) );
67
66
connect ( btnRemoveItem, SIGNAL ( clicked () ), this , SLOT ( removeItem () ) );
68
67
68
+ btnRemoveItem->setEnabled ( false );
69
+
69
70
QMenu *shareMenu = new QMenu ( tr ( " Share menu" ), this );
70
71
QAction *exportAsPNGAction = shareMenu->addAction ( tr ( " Export selected symbols as PNG" ) );
71
72
QAction *exportAsSVGAction = shareMenu->addAction ( tr ( " Export selected symbols as SVG" ) );
@@ -74,7 +75,9 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
74
75
QAction *importAction = new QAction ( tr ( " Import..." ), this );
75
76
shareMenu->addAction ( importAction );
76
77
exportAsPNGAction->setIcon ( QIcon ( QgsApplication::iconPath ( " mActionSharingExport.svg" ) ) );
78
+ exportAsPNGAction->setEnabled ( false );
77
79
exportAsSVGAction->setIcon ( QIcon ( QgsApplication::iconPath ( " mActionSharingExport.svg" ) ) );
80
+ exportAsSVGAction->setEnabled ( false );
78
81
exportAction->setIcon ( QIcon ( QgsApplication::iconPath ( " mActionSharingExport.svg" ) ) );
79
82
importAction->setIcon ( QIcon ( QgsApplication::iconPath ( " mActionSharingImport.svg" ) ) );
80
83
connect ( exportAsPNGAction, SIGNAL ( triggered () ), this , SLOT ( exportItemsPNG () ) );
@@ -93,6 +96,8 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
93
96
connect ( model, SIGNAL ( itemChanged ( QStandardItem* ) ), this , SLOT ( itemChanged ( QStandardItem* ) ) );
94
97
connect ( listItems->selectionModel (), SIGNAL ( currentChanged ( const QModelIndex&, const QModelIndex& ) ),
95
98
this , SLOT ( symbolSelected ( const QModelIndex& ) ) );
99
+ connect ( listItems->selectionModel (), SIGNAL ( selectionChanged ( const QItemSelection, const QItemSelection ) ),
100
+ this , SLOT ( selectedSymbolsChanged ( const QItemSelection&, const QItemSelection& ) ) );
96
101
97
102
populateTypes ();
98
103
@@ -115,8 +120,6 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
115
120
connect ( btnAddGroup, SIGNAL ( clicked () ), this , SLOT ( addGroup () ) );
116
121
connect ( btnRemoveGroup, SIGNAL ( clicked () ), this , SLOT ( removeGroup () ) );
117
122
118
- on_tabItemType_currentChanged ( 0 );
119
-
120
123
connect ( searchBox, SIGNAL ( textChanged ( QString ) ), this , SLOT ( filterSymbols ( QString ) ) );
121
124
tagsLineEdit->installEventFilter ( this );
122
125
@@ -144,10 +147,12 @@ QgsStyleV2ManagerDialog::QgsStyleV2ManagerDialog( QgsStyleV2* style, QWidget* pa
144
147
mGroupMenu = new QMenu ( this );
145
148
mGroupListMenu = new QMenu ( mGroupMenu );
146
149
mGroupListMenu ->setTitle ( tr ( " Apply Group" ) );
150
+ mGroupListMenu ->setEnabled ( false );
147
151
mGroupMenu ->addMenu ( mGroupListMenu );
148
- a = new QAction ( tr ( " Un-group" ), mGroupMenu );
149
- a->setData ( 0 );
150
- mGroupMenu ->addAction ( a );
152
+ actnUngroup->setData ( 0 );
153
+ mGroupMenu ->addAction ( actnUngroup );
154
+
155
+ on_tabItemType_currentChanged ( 0 );
151
156
}
152
157
153
158
void QgsStyleV2ManagerDialog::onFinished ()
@@ -260,6 +265,8 @@ void QgsStyleV2ManagerDialog::populateSymbols( const QStringList& symbolNames, b
260
265
}
261
266
delete symbol;
262
267
}
268
+ selectedSymbolsChanged ( QItemSelection (), QItemSelection () );
269
+ symbolSelected ( listItems->currentIndex () );
263
270
}
264
271
265
272
@@ -1219,10 +1226,25 @@ void QgsStyleV2ManagerDialog::symbolSelected( const QModelIndex& index )
1219
1226
{
1220
1227
// Populate the tags for the symbol
1221
1228
tagsLineEdit->clear ();
1222
- QStandardItem *item = static_cast <QStandardItemModel*>( listItems->model () )->itemFromIndex ( index );
1223
- QgsStyleV2::StyleEntity type = ( currentItemType () < 3 ) ? QgsStyleV2::SymbolEntity : QgsStyleV2::ColorrampEntity;
1224
- mTagList = mStyle ->tagsOfSymbol ( type, item->data ().toString () );
1225
- tagsLineEdit->setText ( mTagList .join ( " ," ) );
1229
+ if ( index.isValid () )
1230
+ {
1231
+ QStandardItem *item = static_cast <QStandardItemModel*>( listItems->model () )->itemFromIndex ( index );
1232
+ QgsStyleV2::StyleEntity type = ( currentItemType () < 3 ) ? QgsStyleV2::SymbolEntity : QgsStyleV2::ColorrampEntity;
1233
+ mTagList = mStyle ->tagsOfSymbol ( type, item->data ().toString () );
1234
+ tagsLineEdit->setText ( mTagList .join ( " ," ) );
1235
+ }
1236
+ }
1237
+
1238
+ void QgsStyleV2ManagerDialog::selectedSymbolsChanged ( const QItemSelection& selected, const QItemSelection& deselected )
1239
+ {
1240
+ Q_UNUSED ( selected );
1241
+ Q_UNUSED ( deselected );
1242
+ bool nothingSelected = listItems->selectionModel ()->selectedIndexes ().empty ();
1243
+ btnRemoveItem->setDisabled ( nothingSelected );
1244
+ mGroupListMenu ->setDisabled ( nothingSelected );
1245
+ actnUngroup->setDisabled ( nothingSelected );
1246
+ btnShare->menu ()->actions ().at ( 0 )->setDisabled ( nothingSelected );
1247
+ btnShare->menu ()->actions ().at ( 1 )->setDisabled ( nothingSelected );
1226
1248
}
1227
1249
1228
1250
void QgsStyleV2ManagerDialog::enableSymbolInputs ( bool enable )
0 commit comments