Skip to content

Commit

Permalink
Notify model of changes when renaming data items
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Dec 14, 2017
1 parent 8df6711 commit 12e44b2
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
11 changes: 11 additions & 0 deletions python/core/qgsdataitem.sip
Expand Up @@ -255,11 +255,22 @@ Create new data item.
%Docstring
:rtype: QIcon
%End

QString name() const;
%Docstring
Returns the name of the item (the displayed text for the item).

.. seealso:: :py:func:`setName()`
:rtype: str
%End

void setName( const QString &name );
%Docstring
Sets the ``name`` of the item (the displayed text for the item).

.. seealso:: :py:func:`name()`
%End

QString path() const;
%Docstring
:rtype: str
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgsdataitem.cpp
Expand Up @@ -229,6 +229,12 @@ QIcon QgsDataItem::icon()
return mIconMap.value( mIconName );
}

void QgsDataItem::setName( const QString &name )
{
mName = name;
emit dataChanged( this );
}

QVector<QgsDataItem *> QgsDataItem::createChildren()
{
return QVector<QgsDataItem *>();
Expand Down
15 changes: 14 additions & 1 deletion src/core/qgsdataitem.h
Expand Up @@ -248,8 +248,21 @@ class CORE_EXPORT QgsDataItem : public QObject
void setParent( QgsDataItem *parent );
QVector<QgsDataItem *> children() const { return mChildren; }
virtual QIcon icon();

/**
* Returns the name of the item (the displayed text for the item).
*
* \see setName()
*/
QString name() const { return mName; }
void setName( const QString &name ) { mName = name; }

/**
* Sets the \a name of the item (the displayed text for the item).
*
* \see name()
*/
void setName( const QString &name );

QString path() const { return mPath; }
void setPath( const QString &path ) { mPath = path; }
//! Create path component replacing path separators
Expand Down

0 comments on commit 12e44b2

Please sign in to comment.