Skip to content

Commit 12e44b2

Browse files
committedDec 14, 2017
Notify model of changes when renaming data items
1 parent 8df6711 commit 12e44b2

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed
 

‎python/core/qgsdataitem.sip

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,22 @@ Create new data item.
255255
%Docstring
256256
:rtype: QIcon
257257
%End
258+
258259
QString name() const;
259260
%Docstring
261+
Returns the name of the item (the displayed text for the item).
262+
263+
.. seealso:: :py:func:`setName()`
260264
:rtype: str
261265
%End
266+
262267
void setName( const QString &name );
268+
%Docstring
269+
Sets the ``name`` of the item (the displayed text for the item).
270+
271+
.. seealso:: :py:func:`name()`
272+
%End
273+
263274
QString path() const;
264275
%Docstring
265276
:rtype: str

‎src/core/qgsdataitem.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ QIcon QgsDataItem::icon()
229229
return mIconMap.value( mIconName );
230230
}
231231

232+
void QgsDataItem::setName( const QString &name )
233+
{
234+
mName = name;
235+
emit dataChanged( this );
236+
}
237+
232238
QVector<QgsDataItem *> QgsDataItem::createChildren()
233239
{
234240
return QVector<QgsDataItem *>();

‎src/core/qgsdataitem.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,21 @@ class CORE_EXPORT QgsDataItem : public QObject
248248
void setParent( QgsDataItem *parent );
249249
QVector<QgsDataItem *> children() const { return mChildren; }
250250
virtual QIcon icon();
251+
252+
/**
253+
* Returns the name of the item (the displayed text for the item).
254+
*
255+
* \see setName()
256+
*/
251257
QString name() const { return mName; }
252-
void setName( const QString &name ) { mName = name; }
258+
259+
/**
260+
* Sets the \a name of the item (the displayed text for the item).
261+
*
262+
* \see name()
263+
*/
264+
void setName( const QString &name );
265+
253266
QString path() const { return mPath; }
254267
void setPath( const QString &path ) { mPath = path; }
255268
//! Create path component replacing path separators

0 commit comments

Comments
 (0)
Please sign in to comment.