QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsoptionsdialogbase.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsoptionsdialogbase.h - base vertical tabs option dialog
3
4 ---------------------
5 begin : March 24, 2013
6 copyright : (C) 2013 by Larry Shaffer
7 email : larrys at dakcarto dot com
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
17#ifndef QGSOPTIONSDIALOGBASE_H
18#define QGSOPTIONSDIALOGBASE_H
19
20#include "qgsguiutils.h"
21#include "qgssettings.h"
22#include "qgis_gui.h"
23
24#include <functional>
25
26#include <QDialog>
27#include <QPointer>
28#include <QStyledItemDelegate>
29#include <QSortFilterProxyModel>
30
31class QDialogButtonBox;
32class QListWidget;
33class QModelIndex;
34class QPalette;
35class QPainter;
36class QStackedWidget;
37class QStyleOptionViewItem;
38class QSplitter;
39class QStandardItem;
40class QTreeView;
41class QStandardItemModel;
42
45
46#ifndef SIP_RUN
48class GUI_EXPORT QgsOptionsProxyModel : public QSortFilterProxyModel
49{
50 Q_OBJECT
51 public:
52
53 QgsOptionsProxyModel( QObject *parent );
54
55 void setPageHidden( int page, bool hidden );
56 QModelIndex pageNumberToSourceIndex( int page ) const;
57 int sourceIndexToPageNumber( const QModelIndex &index ) const;
58 bool filterAcceptsRow( int source_row, const QModelIndex &source_parent ) const override;
59
60 private:
61 QMap< int, bool > mHiddenPages;
62};
64#endif
65
66
86class GUI_EXPORT QgsOptionsDialogBase : public QDialog
87{
88 Q_OBJECT
89
90 public:
91
99 QgsOptionsDialogBase( const QString &settingsKey, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = Qt::WindowFlags(), QgsSettings *settings = nullptr );
100 ~QgsOptionsDialogBase() override;
101
107 void initOptionsBase( bool restoreUi = true, const QString &title = QString() );
108
109 // set custom QgsSettings pointer if dialog used outside QGIS (in plugin)
110 void setSettings( QgsSettings *settings );
111
117 void restoreOptionsBaseUi( const QString &title = QString() );
118
124 void restoreLastPage();
125
131 void resizeAlltabs( int index );
132
136 bool iconOnly() {return mIconOnly;}
137
143 void setCurrentPage( const QString &page );
144
158 void addPage( const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget SIP_TRANSFER, const QStringList &path = QStringList() );
159
176 void insertPage( const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget SIP_TRANSFER, const QString &before, const QStringList &path = QStringList() );
177
178 public slots:
179
185 void searchText( const QString &text );
186
187 protected slots:
189 virtual void updateOptionsListVerticalTabs();
191 virtual void optionsStackedWidget_CurrentChanged( int index );
193 virtual void optionsStackedWidget_WidgetRemoved( int index );
194
195 void warnAboutMissingObjects();
196
197 protected:
198 void showEvent( QShowEvent *e ) override;
199 void paintEvent( QPaintEvent *e ) override;
200
201 virtual void updateWindowTitle();
202
208 void registerTextSearchWidgets();
209
215 QStandardItem *createItem( const QString &name, const QString &tooltip, const QString &icon ) SIP_SKIP;
216
217 QList< QPair< QgsOptionsDialogHighlightWidget *, int > > mRegisteredSearchWidgets;
218
219 QString mOptsKey;
220 bool mInit = false;
221 QListWidget *mOptListWidget = nullptr;
222 QTreeView *mOptTreeView = nullptr;
223 QStandardItemModel *mOptTreeModel = nullptr;
224 QgsOptionsProxyModel *mTreeProxyModel = nullptr;
225
226 QStackedWidget *mOptStackedWidget = nullptr;
227 QSplitter *mOptSplitter = nullptr;
228 QDialogButtonBox *mOptButtonBox = nullptr;
229 QgsFilterLineEdit *mSearchLineEdit = nullptr;
231 bool mIconOnly = false;
232 // pointer to app or custom, external QgsSettings
233 // QPointer in case custom settings obj gets deleted while dialog is open
234 QPointer<QgsSettings> mSettings;
235 bool mDelSettings = false;
236
237 private:
238
239 void setListToItemAtIndex( int index );
240
241};
242
243#endif // QGSOPTIONSDIALOGBASE_H
QLineEdit subclass with built in support for clearing the widget's value and handling custom null val...
A base dialog for options and properties dialogs that offers vertical tabs.
QPointer< QgsSettings > mSettings
QList< QPair< QgsOptionsDialogHighlightWidget *, int > > mRegisteredSearchWidgets
bool iconOnly()
Determine if the options list is in icon only mode.
Container for a widget to be used to search text in the option dialog If the widget type is handled,...
This class is a composition of two QSettings instances:
Definition: qgssettings.h:62
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36