QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
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
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
18#include "qgssettingstree.h"
19
20#include <QAction>
21#include <QTreeView>
22#include <QHBoxLayout>
23#include <QVBoxLayout>
24
25
27 : QWidget( parent )
29{
30 setObjectName( QStringLiteral( "mSettingsTreeWidget" ) );
31
32 QVBoxLayout *mainLayout = new QVBoxLayout( this );
33 mainLayout->setContentsMargins( 0, 0, 0, 0 );
34
36
37 mTreeView = new QTreeView( this );
38 mTreeView->setModel( mTreeModel );
39 mTreeView->setItemDelegate( new QgsSettingsTreeItemDelegate( qobject_cast<QgsSettingsTreeModel *>( mTreeModel->sourceModel() ), parent ) );
40 mTreeView->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
41 mTreeView->setMinimumWidth( 400 );
42 mTreeView->resizeColumnToContents( 0 );
43
44 mainLayout->addWidget( mTreeView );
45}
46
48{
49 mTreeModel->applyChanges();
50}
51
52
53bool QgsSettingsTreeWidget::searchText( const QString &text )
54{
55 mTreeModel->setFilterText( text );
56 return mTreeModel->rowCount() > 0;
57}
58
59bool QgsSettingsTreeWidget::highlightText( const QString &text )
60{
61 Q_UNUSED( text );
62 return true;
63}
64
66{
67 mTreeModel->setFilterText( QString() );
68}
Container for a widget to be used to search text in the option dialog If the widget type is handled,...
QgsSettingsTreeProxyModel 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.