46
46
QgsStyleManagerDialog::QgsStyleManagerDialog ( QgsStyle *style, QWidget *parent )
47
47
: QDialog( parent )
48
48
, mStyle( style )
49
- , mModified( false )
50
49
{
51
50
setupUi ( this );
52
51
connect ( tabItemType, &QTabWidget::currentChanged, this , &QgsStyleManagerDialog::tabItemType_currentChanged );
@@ -98,9 +97,6 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent )
98
97
connect ( importAction, &QAction::triggered, this , &QgsStyleManagerDialog::importItems );
99
98
btnShare->setMenu ( shareMenu );
100
99
101
- // Set editing mode off by default
102
- mGrouppingMode = false ;
103
-
104
100
QStandardItemModel *model = new QStandardItemModel ( listItems );
105
101
listItems->setModel ( model );
106
102
listItems->setSelectionMode ( QAbstractItemView::ExtendedSelection );
@@ -150,7 +146,7 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent )
150
146
rampTypes << tr ( " Gradient" ) << tr ( " Color presets" ) << tr ( " Random" ) << tr ( " Catalog: cpt-city" );
151
147
rampTypes << tr ( " Catalog: ColorBrewer" );
152
148
mMenuBtnAddItemColorRamp = new QMenu ( this );
153
- Q_FOREACH ( const QString &rampType, rampTypes )
149
+ for ( const QString &rampType : qgis::as_const ( rampTypes ) )
154
150
mMenuBtnAddItemColorRamp ->addAction ( new QAction ( rampType, this ) );
155
151
connect ( mMenuBtnAddItemColorRamp , &QMenu::triggered,
156
152
this , static_cast <bool ( QgsStyleManagerDialog::* )( QAction * )>( &QgsStyleManagerDialog::addColorRamp ) );
@@ -769,7 +765,7 @@ void QgsStyleManagerDialog::removeItem()
769
765
770
766
bool QgsStyleManagerDialog::removeSymbol ()
771
767
{
772
- QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
768
+ const QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
773
769
if ( QMessageBox::Yes != QMessageBox::question ( this , tr ( " Remove Symbol" ),
774
770
QString ( tr ( " Do you really want to remove %n symbol(s)?" , nullptr , indexes.count () ) ),
775
771
QMessageBox::Yes,
@@ -778,7 +774,7 @@ bool QgsStyleManagerDialog::removeSymbol()
778
774
779
775
QgsTemporaryCursorOverride override ( Qt::WaitCursor );
780
776
781
- Q_FOREACH ( const QModelIndex &index , indexes )
777
+ for ( const QModelIndex &index : indexes )
782
778
{
783
779
QString symbolName = index .data ().toString ();
784
780
// delete from style and update list
@@ -791,7 +787,7 @@ bool QgsStyleManagerDialog::removeSymbol()
791
787
792
788
bool QgsStyleManagerDialog::removeColorRamp ()
793
789
{
794
- QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
790
+ const QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
795
791
if ( QMessageBox::Yes != QMessageBox::question ( this , tr ( " Remove Color Ramp" ),
796
792
QString ( tr ( " Do you really want to remove %n ramp(s)?" , nullptr , indexes.count () ) ),
797
793
QMessageBox::Yes,
@@ -800,7 +796,7 @@ bool QgsStyleManagerDialog::removeColorRamp()
800
796
801
797
QgsTemporaryCursorOverride override ( Qt::WaitCursor );
802
798
803
- Q_FOREACH ( const QModelIndex &index , indexes )
799
+ for ( const QModelIndex &index : indexes )
804
800
{
805
801
QString rampName = index .data ().toString ();
806
802
// delete from style and update list
@@ -863,8 +859,8 @@ void QgsStyleManagerDialog::exportSelectedItemsImages( const QString &dir, const
863
859
if ( dir.isEmpty () )
864
860
return ;
865
861
866
- QModelIndexList indexes = listItems->selectionModel ()->selection ().indexes ();
867
- Q_FOREACH ( const QModelIndex &index , indexes )
862
+ const QModelIndexList indexes = listItems->selectionModel ()->selection ().indexes ();
863
+ for ( const QModelIndex &index : indexes )
868
864
{
869
865
QString name = index .data ().toString ();
870
866
QString path = dir + ' /' + name + ' .' + format;
@@ -917,7 +913,7 @@ void QgsStyleManagerDialog::populateGroups()
917
913
taggroup->setEditable ( false );
918
914
QStringList tags = mStyle ->tags ();
919
915
tags.sort ();
920
- Q_FOREACH ( const QString &tag, tags )
916
+ for ( const QString &tag : qgis::as_const ( tags ) )
921
917
{
922
918
QStandardItem *item = new QStandardItem ( tag );
923
919
item->setData ( mStyle ->tagId ( tag ) );
@@ -1269,10 +1265,10 @@ void QgsStyleManagerDialog::regrouped( QStandardItem *item )
1269
1265
void QgsStyleManagerDialog::setSymbolsChecked ( const QStringList &symbols )
1270
1266
{
1271
1267
QStandardItemModel *model = qobject_cast<QStandardItemModel *>( listItems->model () );
1272
- Q_FOREACH ( const QString &symbol, symbols )
1268
+ for ( const QString &symbol : symbols )
1273
1269
{
1274
- QList<QStandardItem *> items = model->findItems ( symbol );
1275
- Q_FOREACH ( QStandardItem *item, items )
1270
+ const QList<QStandardItem *> items = model->findItems ( symbol );
1271
+ for ( QStandardItem *item : items )
1276
1272
item->setCheckState ( Qt::Checked );
1277
1273
}
1278
1274
}
@@ -1381,7 +1377,7 @@ void QgsStyleManagerDialog::listitemsContextMenu( QPoint point )
1381
1377
QAction *a = nullptr ;
1382
1378
QStringList tags = mStyle ->tags ();
1383
1379
tags.sort ();
1384
- Q_FOREACH ( const QString &tag, tags )
1380
+ for ( const QString &tag : qgis::as_const ( tags ) )
1385
1381
{
1386
1382
a = new QAction ( tag, mGroupListMenu );
1387
1383
a->setData ( tag );
@@ -1411,8 +1407,8 @@ void QgsStyleManagerDialog::addFavoriteSelectedSymbols()
1411
1407
return ;
1412
1408
}
1413
1409
1414
- QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
1415
- Q_FOREACH ( const QModelIndex &index , indexes )
1410
+ const QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
1411
+ for ( const QModelIndex &index : indexes )
1416
1412
{
1417
1413
mStyle ->addFavorite ( type, index .data ().toString () );
1418
1414
}
@@ -1428,8 +1424,8 @@ void QgsStyleManagerDialog::removeFavoriteSelectedSymbols()
1428
1424
return ;
1429
1425
}
1430
1426
1431
- QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
1432
- Q_FOREACH ( const QModelIndex &index , indexes )
1427
+ const QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
1428
+ for ( const QModelIndex &index : indexes )
1433
1429
{
1434
1430
mStyle ->removeFavorite ( type, index .data ().toString () );
1435
1431
}
@@ -1464,8 +1460,8 @@ void QgsStyleManagerDialog::tagSelectedSymbols( bool newTag )
1464
1460
tag = selectedItem->data ().toString ();
1465
1461
}
1466
1462
1467
- QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
1468
- Q_FOREACH ( const QModelIndex &index , indexes )
1463
+ const QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
1464
+ for ( const QModelIndex &index : indexes )
1469
1465
{
1470
1466
mStyle ->tagSymbol ( type, index .data ().toString (), QStringList ( tag ) );
1471
1467
}
@@ -1487,8 +1483,8 @@ void QgsStyleManagerDialog::detagSelectedSymbols()
1487
1483
QgsDebugMsg ( QStringLiteral ( " unknown entity type" ) );
1488
1484
return ;
1489
1485
}
1490
- QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
1491
- Q_FOREACH ( const QModelIndex &index , indexes )
1486
+ const QModelIndexList indexes = listItems->selectionModel ()->selectedIndexes ();
1487
+ for ( const QModelIndex &index : indexes )
1492
1488
{
1493
1489
mStyle ->detagSymbol ( type, index .data ().toString () );
1494
1490
}
0 commit comments