16#ifndef QGSSETTINGSTREEMODEL_H
17#define QGSSETTINGSTREEMODEL_H
23#include <QAbstractItemModel>
24#include <QSortFilterProxyModel>
25#include <QItemDelegate>
45class GUI_EXPORT QgsSettingsTreeModelNodeData :
public QObject
60 static QgsSettingsTreeModelNodeData *createRootNodeData(
const QgsSettingsTreeNode *rootNode, QObject *parent );
66 bool isRoot()
const {
return !mParent; }
69 QStringList namedParentNodes()
const {
return mNamedParentNodes; }
72 QList<QgsSettingsTreeModelNodeData *> children()
const {
return mChildren; }
75 QgsSettingsTreeModelNodeData *parent()
const {
return mParent; }
78 Type type()
const {
return mType; }
81 QString name()
const {
return mName; }
84 QVariant value()
const {
return mValue; }
87 QVariant originalValue()
const {
return mOriginalValue; }
90 bool setValue(
const QVariant &value );
93 bool exists()
const {
return mExists; }
96 bool isEdited()
const {
return mIsEdited; }
106 QgsSettingsTreeModelNodeData( QObject *parent )
107 : 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;
189 QgsSettingsTreeModelNodeData *index2node(
const QModelIndex &index )
const SIP_SKIP;
192 QModelIndex node2index( QgsSettingsTreeModelNodeData *node )
const SIP_SKIP;
195 QModelIndex index(
int row,
int column,
const QModelIndex &parent )
const override;
196 QModelIndex parent(
const QModelIndex &child )
const override;
197 int rowCount(
const QModelIndex &parent )
const override;
198 int columnCount(
const QModelIndex &parent )
const override;
199 QVariant data(
const QModelIndex &index,
int role )
const override;
200 QVariant headerData(
int section, Qt::Orientation orientation,
int role )
const override;
201 Qt::ItemFlags flags(
const QModelIndex &index )
const override;
202 bool setData(
const QModelIndex &index,
const QVariant &value,
int role )
override;
205 QModelIndex indexOfParentSettingsTreeNode( QgsSettingsTreeModelNodeData *parentNode )
const;
207 QgsSettingsTreeModelNodeData *mRootNode =
nullptr;
209 QColor mEditedColorBack;
210 QColor mEditedColorFore;
233 void setFilterText(
const QString &filterText = QString() );
237 bool filterAcceptsRow(
int source_row,
const QModelIndex &source_parent )
const override;
242 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.