QGIS API Documentation  2.99.0-Master (f1c3692)
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 
51 class GUI_EXPORT QgsSearchHighlightOptionWidget : public QObject
52 {
53  Q_OBJECT
54  public:
55 
60  explicit QgsSearchHighlightOptionWidget( QWidget *widget = 0 );
61 
65  bool isValid() {return mValid;}
66 
71  bool searchHighlight( const QString &searchText );
72 
76  void reset();
77 
81  QWidget *widget() {return mWidget;}
82 
83  private slots:
84  void widgetDestroyed();
85 
86  private:
87  QWidget *mWidget = nullptr;
88  QString mStyleSheet;
89  bool mValid = true;
90  bool mChangedStyle = false;
91  std::function < QString() > mText;
92 };
93 
94 
113 class GUI_EXPORT QgsOptionsDialogBase : public QDialog
114 {
115  Q_OBJECT
116 
117  public:
118 
126  QgsOptionsDialogBase( const QString &settingsKey, QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = 0, QgsSettings *settings = nullptr );
128 
134  void initOptionsBase( bool restoreUi = true, const QString &title = QString() );
135 
136  // set custom QgsSettings pointer if dialog used outside QGIS (in plugin)
137  void setSettings( QgsSettings *settings );
138 
144  void restoreOptionsBaseUi( const QString &title = QString() );
145 
149  bool iconOnly() {return mIconOnly;}
150 
151  public slots:
152 
158  void searchText( const QString &text );
159 
160  protected slots:
162  virtual void updateOptionsListVerticalTabs();
164  virtual void optionsStackedWidget_CurrentChanged( int index );
166  virtual void optionsStackedWidget_WidgetRemoved( int index );
167 
168  void warnAboutMissingObjects();
169 
170  protected:
171  void showEvent( QShowEvent *e ) override;
172  void paintEvent( QPaintEvent *e ) override;
173 
174  virtual void updateWindowTitle();
175 
181  void registerTextSearchWidgets();
182 
183  QList< QPair< QgsSearchHighlightOptionWidget *, int > > mRegisteredSearchWidgets;
184 
185  QString mOptsKey;
186  bool mInit;
187  QListWidget *mOptListWidget = nullptr;
188  QStackedWidget *mOptStackedWidget = nullptr;
189  QSplitter *mOptSplitter = nullptr;
190  QDialogButtonBox *mOptButtonBox = nullptr;
191  QgsFilterLineEdit *mSearchLineEdit = nullptr;
192  QString mDialogTitle;
193  bool mIconOnly;
194  // pointer to app or custom, external QgsSettings
195  // QPointer in case custom settings obj gets deleted while dialog is open
196  QPointer<QgsSettings> mSettings;
198 };
199 
200 #endif // QGSOPTIONSDIALOGBASE_H
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
This class is a composition of two QSettings instances:
Definition: qgssettings.h:55
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.