QGIS API Documentation  2.99.0-Master (13a3f2f)
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 
30 
31 class QDialogButtonBox;
32 class QListWidget;
33 class QModelIndex;
34 class QPalette;
35 class QPainter;
36 class QStackedWidget;
37 class QStyleOptionViewItem;
38 class QSplitter;
39 
40 class QgsFilterLineEdit;
41 
50 class GUI_EXPORT QgsSearchHighlightOptionWidget : public QObject
51 {
52  Q_OBJECT
53  public:
54 
58  explicit QgsSearchHighlightOptionWidget( QWidget *widget = 0 );
59 
63  bool isValid() {return mValid;}
64 
69  bool searchHighlight( const QString &searchText );
70 
74  void reset();
75 
79  QWidget *widget() {return mWidget;}
80 
81  private slots:
82  void widgetDestroyed();
83 
84  private:
85  QWidget *mWidget = nullptr;
86  QString mStyleSheet;
87  bool mValid;
88  bool mChangedStyle;
89  std::function < QString() > mText;
90 };
91 
92 
110 class GUI_EXPORT QgsOptionsDialogBase : public QDialog
111 {
112  Q_OBJECT
113 
114  public:
115 
122  QgsOptionsDialogBase( const QString &settingsKey, QWidget *parent = nullptr, Qt::WindowFlags fl = 0, QgsSettings *settings = nullptr );
124 
129  void initOptionsBase( bool restoreUi = true, const QString &title = QString() );
130 
131  // set custom QgsSettings pointer if dialog used outside QGIS (in plugin)
132  void setSettings( QgsSettings *settings );
133 
138  void restoreOptionsBaseUi( const QString &title = QString() );
139 
142  bool iconOnly() {return mIconOnly;}
143 
144  public slots:
145 
151  void searchText( const QString &text );
152 
153  protected slots:
154  void updateOptionsListVerticalTabs();
155  void optionsStackedWidget_CurrentChanged( int indx );
156  void optionsStackedWidget_WidgetRemoved( int indx );
157  void warnAboutMissingObjects();
158 
159  protected:
160  void showEvent( QShowEvent *e ) override;
161  void paintEvent( QPaintEvent *e ) override;
162 
163  virtual void updateWindowTitle();
164 
170  void registerTextSearchWidgets();
171 
172  QList< QPair< QgsSearchHighlightOptionWidget *, int > > mRegisteredSearchWidgets;
173 
174  QString mOptsKey;
175  bool mInit;
176  QListWidget *mOptListWidget = nullptr;
177  QStackedWidget *mOptStackedWidget = nullptr;
178  QSplitter *mOptSplitter = nullptr;
179  QDialogButtonBox *mOptButtonBox = nullptr;
180  QgsFilterLineEdit *mSearchLineEdit = nullptr;
181  QString mDialogTitle;
182  bool mIconOnly;
183  // pointer to app or custom, external QgsSettings
184  // QPointer in case custom settings obj gets deleted while dialog is open
185  QPointer<QgsSettings> mSettings;
187 };
188 
189 #endif // QGSOPTIONSDIALOGBASE_H
This class is a composition of two QSettings instances:
Definition: qgssettings.h:54
bool isValid()
Returns if it valid: if the widget type is handled and if the widget is not still available...
QList< QPair< QgsSearchHighlightOptionWidget *, int > > mRegisteredSearchWidgets
QLineEdit subclass with built in support for clearing the widget&#39;s value and handling custom null val...
QWidget * widget()
return the widget
A base dialog for options and properties dialogs that offers vertical tabs.
QPointer< QgsSettings > mSettings
Container for a widget to be used to search text in the option dialog If the widget type is handled...
bool iconOnly()
Determine if the options list is in icon only mode.