@@ -162,6 +162,16 @@ bool QgsColorSchemeList::exportColorsToGpl( QFile &file )
162
162
return QgsSymbolLayerV2Utils::saveColorsToGpl ( file, QString (), mModel ->colors () );
163
163
}
164
164
165
+ bool QgsColorSchemeList::isDirty () const
166
+ {
167
+ if ( !mModel )
168
+ {
169
+ return false ;
170
+ }
171
+
172
+ return mModel ->isDirty ();
173
+ }
174
+
165
175
//
166
176
// QgsColorSchemeModel
167
177
//
@@ -171,6 +181,7 @@ QgsColorSchemeModel::QgsColorSchemeModel( QgsColorScheme *scheme, const QString
171
181
, mScheme( scheme )
172
182
, mContext( context )
173
183
, mBaseColor( baseColor )
184
+ , mIsDirty( false )
174
185
{
175
186
if ( scheme )
176
187
{
@@ -297,11 +308,13 @@ bool QgsColorSchemeModel::setData( const QModelIndex &index, const QVariant &val
297
308
case ColorSwatch:
298
309
mColors [ index .row ()].first = value.value <QColor>();
299
310
emit dataChanged ( index , index );
311
+ mIsDirty = true ;
300
312
return true ;
301
313
302
314
case ColorLabel:
303
315
mColors [ index .row ()].second = value.toString ();
304
316
emit dataChanged ( index , index );
317
+ mIsDirty = true ;
305
318
return true ;
306
319
307
320
default :
@@ -425,6 +438,7 @@ bool QgsColorSchemeModel::dropMimeData( const QMimeData *data, Qt::DropAction ac
425
438
setData ( labelIdx, !( *colorIt ).second .isEmpty () ? ( *colorIt ).second : QgsSymbolLayerV2Utils::colorToName (( *colorIt ).first ) );
426
439
beginRow++;
427
440
}
441
+ mIsDirty = true ;
428
442
429
443
return true ;
430
444
}
@@ -434,6 +448,7 @@ void QgsColorSchemeModel::setScheme( QgsColorScheme *scheme, const QString conte
434
448
mScheme = scheme;
435
449
mContext = context;
436
450
mBaseColor = baseColor;
451
+ mIsDirty = false ;
437
452
beginResetModel ();
438
453
mColors = scheme->fetchColors ( mContext , mBaseColor );
439
454
endResetModel ();
@@ -462,6 +477,8 @@ bool QgsColorSchemeModel::removeRows( int row, int count, const QModelIndex &par
462
477
mColors .removeAt ( i );
463
478
endRemoveRows ();
464
479
}
480
+
481
+ mIsDirty = true ;
465
482
return true ;
466
483
}
467
484
@@ -481,6 +498,7 @@ bool QgsColorSchemeModel::insertRows( int row, int count, const QModelIndex& par
481
498
mColors .insert ( i, newColor );
482
499
}
483
500
endInsertRows ();
501
+ mIsDirty = true ;
484
502
return true ;
485
503
}
486
504
@@ -497,6 +515,7 @@ void QgsColorSchemeModel::addColor( const QColor color, const QString label )
497
515
setData ( colorIdx, QVariant ( color ) );
498
516
QModelIndex labelIdx = index ( row, 1 , QModelIndex () );
499
517
setData ( labelIdx, QVariant ( label ) );
518
+ mIsDirty = true ;
500
519
}
501
520
502
521
0 commit comments