QGIS API Documentation 3.43.0-Master (b60ef06885e)
qgssettingstreewidget.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgssettingstreewidget.h
3 --------------------------------------
4 Date : April 2023
5 Copyright : (C) 2023 by Denis Rouzaud
6 Email : denis@opengis.ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17#include "moc_qgssettingstreewidget.cpp"
19#include "qgssettingstree.h"
20
21#include <QAction>
22#include <QTreeView>
23#include <QHBoxLayout>
24#include <QVBoxLayout>
25
26
28 : QWidget( parent )
30{
31 setObjectName( QStringLiteral( "mSettingsTreeWidget" ) );
32
33 QVBoxLayout *mainLayout = new QVBoxLayout( this );
34 mainLayout->setContentsMargins( 0, 0, 0, 0 );
35
37
38 mTreeView = new QTreeView( this );
39 mTreeView->setModel( mTreeModel );
40 mTreeView->setItemDelegate( new QgsSettingsTreeItemDelegate( qobject_cast<QgsSettingsTreeModel *>( mTreeModel->sourceModel() ), parent ) );
41 mTreeView->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
42 mTreeView->setMinimumWidth( 400 );
43 mTreeView->resizeColumnToContents( 0 );
44
45 mainLayout->addWidget( mTreeView );
46}
47
49{
50 mTreeModel->applyChanges();
51}
52
53
54bool QgsSettingsTreeWidget::searchText( const QString &text )
55{
56 mTreeModel->setFilterText( text );
57 return mTreeModel->rowCount() > 0;
58}
59
60bool QgsSettingsTreeWidget::highlightText( const QString &text )
61{
62 Q_UNUSED( text );
63 return true;
64}
65
67{
68 mTreeModel->setFilterText( QString() );
69}
Container for a widget to be used to search text in the option dialog.
A proxy model which allows filtering the settings tree.
void applyChanges()
Apply pending changes in the model to the corresponding settings.
void setFilterText(const QString &filterText=QString())
Sets the filter text.
void applyChanges() const
Apply changes to settings value.
bool searchText(const QString &text) override
Search for the text in the widget and return true if it was found.
void reset() override
reset the style of the widgets to its original state
QgsSettingsTreeWidget(QWidget *parent=nullptr)
Constructor.
bool highlightText(const QString &text) override
Highlight the text in the widget.
static QgsSettingsTreeNode * treeRoot()
Returns the tree root node for the settings tree.