16#ifndef QGSSETTINGSTREEMODEL_H
17#define QGSSETTINGSTREEMODEL_H
23#include <QAbstractItemModel>
24#include <QSortFilterProxyModel>
25#include <QItemDelegate>
45class GUI_EXPORT QgsSettingsTreeModelNodeData :
public QObject
61 static QgsSettingsTreeModelNodeData *createRootNodeData(
const QgsSettingsTreeNode *rootNode, QObject *parent );
67 bool isRoot()
const {
return !mParent; }
70 QStringList namedParentNodes()
const {
return mNamedParentNodes; }
73 QList<QgsSettingsTreeModelNodeData *> children()
const {
return mChildren;}
76 QgsSettingsTreeModelNodeData *parent()
const {
return mParent;}
79 Type type()
const {
return mType;}
82 QString name()
const {
return mName;}
85 QVariant value()
const {
return mValue;}
88 QVariant originalValue()
const {
return mOriginalValue;}
91 bool setValue(
const QVariant &value );
94 bool exists()
const {
return mExists;}
97 bool isEdited()
const {
return mIsEdited;}
107 QgsSettingsTreeModelNodeData( QObject *parent ) : QObject( parent ) {}
113 Type mType = Type::TreeNode;
116 QVariant mOriginalValue;
117 QStringList mNamedParentNodes;
118 bool mExists =
false;
119 bool mIsEdited =
false;
121 QList<QgsSettingsTreeModelNodeData *> mChildren;
122 QgsSettingsTreeModelNodeData *mParent =
nullptr;
138class GUI_EXPORT QgsSettingsTreeItemDelegate :
public QItemDelegate
146 QWidget *createEditor( QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index )
const override;
147 void setEditorData( QWidget *editor,
const QModelIndex &index )
const override;
148 void setModelData( QWidget *editor, QAbstractItemModel *model,
const QModelIndex &index )
const override;
190 QgsSettingsTreeModelNodeData *index2node(
const QModelIndex &index )
const SIP_SKIP;
193 QModelIndex node2index( QgsSettingsTreeModelNodeData *node )
const SIP_SKIP;
196 QModelIndex index(
int row,
int column,
const QModelIndex &parent )
const override;
197 QModelIndex parent(
const QModelIndex &child )
const override;
198 int rowCount(
const QModelIndex &parent )
const override;
199 int columnCount(
const QModelIndex &parent )
const override;
200 QVariant data(
const QModelIndex &index,
int role )
const override;
201 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
202 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
203 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
206 QModelIndex indexOfParentSettingsTreeNode( QgsSettingsTreeModelNodeData *parentNode )
const;
208 QgsSettingsTreeModelNodeData *mRootNode =
nullptr;
210 QColor mEditedColorBack;
211 QColor mEditedColorFore;
235 void setFilterText(
const QString &filterText = QString() );
239 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
244 bool nodeShown( QgsSettingsTreeModelNodeData *node )
const;
Represent settings entry and provides methods for reading and writing settings values.
QgsSettingsTreeModel is a tree model for the settings tree.
QgsSettingsTreeNamedListNode is a named list tree node for the settings tree to help organizing and i...
QgsSettingsTreeNode is a tree node for the settings tree to help organizing and introspecting the tre...
QgsSettingsTreeProxyModel allows filtering the settings tree.
void applyChanges()
Apply pending changes in the model to the corresponding settings.