Notify model of changes when renaming data items

This commit is contained in:
Nyall Dawson 2017-12-14 15:40:31 +10:00
parent 8df67111cd
commit 12e44b2016
3 changed files with 31 additions and 1 deletions

View File

@ -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

View File

@ -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 *>();

View File

@ -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