Skip to content

Commit 1da400a

Browse files
committedNov 16, 2016
Rename enum values for consistency
1 parent fc65334 commit 1da400a

File tree

5 files changed

+27
-27
lines changed

5 files changed

+27
-27
lines changed
 

‎python/core/qgsmaplayermodel.sip

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ class QgsMapLayerModel : QAbstractItemModel
1919
{
2020
LayerIdRole, /*!< Stores the map layer ID */
2121
LayerRole, /*!< Stores pointer to the map layer itself */
22-
IsEmptyRole, //!< True if index corresponds to the empty (not set) value
23-
IsAdditionalRole, //!< True if index corresponds to an additional (non map layer) item
22+
EmptyRole, //!< True if index corresponds to the empty (not set) value
23+
AdditionalRole, //!< True if index corresponds to an additional (non map layer) item
2424
};
2525

2626
/**

‎src/core/qgsmaplayermodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,10 @@ QVariant QgsMapLayerModel::data( const QModelIndex &index, int role ) const
257257
return QVariant::fromValue<QgsMapLayer*>( static_cast<QgsMapLayer*>( index.internalPointer() ) );
258258
}
259259

260-
if ( role == IsEmptyRole )
260+
if ( role == EmptyRole )
261261
return isEmpty;
262262

263-
if ( role == IsAdditionalRole )
263+
if ( role == AdditionalRole )
264264
return additionalIndex >= 0;
265265

266266
if ( role == Qt::CheckStateRole && mItemCheckable )

‎src/core/qgsmaplayermodel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ class CORE_EXPORT QgsMapLayerModel : public QAbstractItemModel
4545
{
4646
LayerIdRole = Qt::UserRole + 1, //!< Stores the map layer ID
4747
LayerRole, //!< Stores pointer to the map layer itself
48-
IsEmptyRole, //!< True if index corresponds to the empty (not set) value
49-
IsAdditionalRole, //!< True if index corresponds to an additional (non map layer) item
48+
EmptyRole, //!< True if index corresponds to the empty (not set) value
49+
AdditionalRole, //!< True if index corresponds to an additional (non map layer) item
5050
};
5151

5252
/**

‎src/core/qgsmaplayerproxymodel.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ bool QgsMapLayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex
8787

8888
QModelIndex index = sourceModel()->index( source_row, 0, source_parent );
8989

90-
if ( sourceModel()->data( index, QgsMapLayerModel::IsEmptyRole ).toBool()
91-
|| sourceModel()->data( index, QgsMapLayerModel::IsAdditionalRole ).toBool() )
90+
if ( sourceModel()->data( index, QgsMapLayerModel::EmptyRole ).toBool()
91+
|| sourceModel()->data( index, QgsMapLayerModel::AdditionalRole ).toBool() )
9292
return true;
9393

9494
QgsMapLayer* layer = static_cast<QgsMapLayer*>( index.internalPointer() );
@@ -143,14 +143,14 @@ bool QgsMapLayerProxyModel::filterAcceptsRow( int source_row, const QModelIndex
143143
bool QgsMapLayerProxyModel::lessThan( const QModelIndex &left, const QModelIndex &right ) const
144144
{
145145
// empty row is always first
146-
if ( sourceModel()->data( left, QgsMapLayerModel::IsEmptyRole ).toBool() )
146+
if ( sourceModel()->data( left, QgsMapLayerModel::EmptyRole ).toBool() )
147147
return true;
148-
else if ( sourceModel()->data( right, QgsMapLayerModel::IsEmptyRole ).toBool() )
148+
else if ( sourceModel()->data( right, QgsMapLayerModel::EmptyRole ).toBool() )
149149
return false;
150150

151151
// additional rows are always last
152-
bool leftAdditional = sourceModel()->data( left, QgsMapLayerModel::IsAdditionalRole ).toBool();
153-
bool rightAdditional = sourceModel()->data( right, QgsMapLayerModel::IsAdditionalRole ).toBool();
152+
bool leftAdditional = sourceModel()->data( left, QgsMapLayerModel::AdditionalRole ).toBool();
153+
bool rightAdditional = sourceModel()->data( right, QgsMapLayerModel::AdditionalRole ).toBool();
154154

155155
if ( leftAdditional && !rightAdditional )
156156
return false;

‎tests/src/python/test_qgsmaplayermodel.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,15 @@ def testIsEmptyRole(self):
242242
l2 = create_layer('l2')
243243
QgsMapLayerRegistry.instance().addMapLayers([l1, l2])
244244
m = QgsMapLayerModel()
245-
self.assertFalse(m.data(m.index(0, 0), QgsMapLayerModel.IsEmptyRole))
246-
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.IsEmptyRole))
245+
self.assertFalse(m.data(m.index(0, 0), QgsMapLayerModel.EmptyRole))
246+
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.EmptyRole))
247247
m.setAllowEmptyLayer(True)
248-
self.assertTrue(m.data(m.index(0, 0), QgsMapLayerModel.IsEmptyRole))
249-
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.IsEmptyRole))
250-
self.assertFalse(m.data(m.index(2, 0), QgsMapLayerModel.IsEmptyRole))
248+
self.assertTrue(m.data(m.index(0, 0), QgsMapLayerModel.EmptyRole))
249+
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.EmptyRole))
250+
self.assertFalse(m.data(m.index(2, 0), QgsMapLayerModel.EmptyRole))
251251

252252
m.setAdditionalItems(['a'])
253-
self.assertFalse(m.data(m.index(3, 0), QgsMapLayerModel.IsEmptyRole))
253+
self.assertFalse(m.data(m.index(3, 0), QgsMapLayerModel.EmptyRole))
254254

255255
QgsMapLayerRegistry.instance().removeMapLayers([l1.id(), l2.id()])
256256

@@ -259,18 +259,18 @@ def testIsAdditionalRole(self):
259259
l2 = create_layer('l2')
260260
QgsMapLayerRegistry.instance().addMapLayers([l1, l2])
261261
m = QgsMapLayerModel()
262-
self.assertFalse(m.data(m.index(0, 0), QgsMapLayerModel.IsAdditionalRole))
263-
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.IsAdditionalRole))
262+
self.assertFalse(m.data(m.index(0, 0), QgsMapLayerModel.AdditionalRole))
263+
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.AdditionalRole))
264264
m.setAllowEmptyLayer(True)
265-
self.assertFalse(m.data(m.index(0, 0), QgsMapLayerModel.IsAdditionalRole))
266-
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.IsAdditionalRole))
267-
self.assertFalse(m.data(m.index(2, 0), QgsMapLayerModel.IsAdditionalRole))
265+
self.assertFalse(m.data(m.index(0, 0), QgsMapLayerModel.AdditionalRole))
266+
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.AdditionalRole))
267+
self.assertFalse(m.data(m.index(2, 0), QgsMapLayerModel.AdditionalRole))
268268

269269
m.setAdditionalItems(['a'])
270-
self.assertFalse(m.data(m.index(0, 0), QgsMapLayerModel.IsAdditionalRole))
271-
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.IsAdditionalRole))
272-
self.assertFalse(m.data(m.index(2, 0), QgsMapLayerModel.IsAdditionalRole))
273-
self.assertTrue(m.data(m.index(3, 0), QgsMapLayerModel.IsAdditionalRole))
270+
self.assertFalse(m.data(m.index(0, 0), QgsMapLayerModel.AdditionalRole))
271+
self.assertFalse(m.data(m.index(1, 0), QgsMapLayerModel.AdditionalRole))
272+
self.assertFalse(m.data(m.index(2, 0), QgsMapLayerModel.AdditionalRole))
273+
self.assertTrue(m.data(m.index(3, 0), QgsMapLayerModel.AdditionalRole))
274274

275275
QgsMapLayerRegistry.instance().removeMapLayers([l1.id(), l2.id()])
276276

0 commit comments

Comments
 (0)