QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
161 void addPage( const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget SIP_TRANSFER, const QStringList &path = QStringList(), const QString &key = QString() );
162
182 void insertPage( const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget SIP_TRANSFER, const QString &before, const QStringList &path = QStringList(), const QString &key = QString() );
183
184 public slots:
185
190 void searchText( const QString &text );
191
192 protected slots:
194 virtual void updateOptionsListVerticalTabs();
196 virtual void optionsStackedWidget_CurrentChanged( int index );
198 virtual void optionsStackedWidget_WidgetRemoved( int index );
199
200 void warnAboutMissingObjects();
201
202 protected:
203 void showEvent( QShowEvent *e ) override;
204 void paintEvent( QPaintEvent *e ) override;
205
206 virtual void updateWindowTitle();
207
212 void registerTextSearchWidgets();
213
219 QStandardItem *createItem( const QString &name, const QString &tooltip, const QString &icon ) SIP_SKIP;
220
221 QList< QPair< QgsOptionsDialogHighlightWidget *, int > > mRegisteredSearchWidgets;
222
223 QString mOptsKey;
224 bool mInit = false;
225 QListWidget *mOptListWidget = nullptr;
226 QTreeView *mOptTreeView = nullptr;
227 QStandardItemModel *mOptTreeModel = nullptr;
228 QgsOptionsProxyModel *mTreeProxyModel = nullptr;
229
230 QStackedWidget *mOptStackedWidget = nullptr;
231 QSplitter *mOptSplitter = nullptr;
232 QDialogButtonBox *mOptButtonBox = nullptr;
233 QgsFilterLineEdit *mSearchLineEdit = nullptr;
235 bool mIconOnly = false;
236 // pointer to app or custom, external QgsSettings
237 // QPointer in case custom settings obj gets deleted while dialog is open
238 QPointer<QgsSettings> mSettings;
239 bool mDelSettings = false;
240
241 private:
242
243 void setListToItemAtIndex( int index );
244
245};
246
247#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:64
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_TRANSFER
Definition: qgis_sip.h:36