QGIS API Documentation  2.99.0-Master (a18066b)
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 "qgisgui.h"
21 #include <functional>
22 
23 #include <QDialog>
24 #include <QPointer>
25 #include <QSettings>
26 #include <QStyledItemDelegate>
27 #include "qgis_gui.h"
28 
29 
30 class QDialogButtonBox;
31 class QListWidget;
32 class QModelIndex;
33 class QPalette;
34 class QPainter;
35 class QStackedWidget;
36 class QStyleOptionViewItem;
37 class QSplitter;
38 
39 class QgsFilterLineEdit;
40 
49 class GUI_EXPORT QgsSearchHighlightOptionWidget : public QObject
50 {
51  Q_OBJECT
52  public:
53 
57  explicit QgsSearchHighlightOptionWidget( QWidget* widget = 0 );
58 
62  bool isValid() {return mValid;}
63 
68  bool searchHighlight( const QString& searchText );
69 
73  void reset();
74 
78  QWidget* widget() {return mWidget;}
79 
80  private slots:
81  void widgetDestroyed();
82 
83  private:
84  QWidget* mWidget = nullptr;
85  QString mStyleSheet;
86  bool mValid;
87  bool mChangedStyle;
88  std::function < QString() > mText;
89 };
90 
91 
109 class GUI_EXPORT QgsOptionsDialogBase : public QDialog
110 {
111  Q_OBJECT
112 
113  public:
114 
121  QgsOptionsDialogBase( const QString& settingsKey, QWidget* parent = nullptr, Qt::WindowFlags fl = 0, QSettings* settings = nullptr );
123 
128  void initOptionsBase( bool restoreUi = true, const QString& title = QString() );
129 
130  // set custom QSettings pointer if dialog used outside QGIS (in plugin)
131  void setSettings( QSettings* settings );
132 
137  void restoreOptionsBaseUi( const QString& title = QString() );
138 
141  bool iconOnly() {return mIconOnly;}
142 
143  public slots:
144 
150  void searchText( const QString& text );
151 
152  protected slots:
153  void updateOptionsListVerticalTabs();
154  void optionsStackedWidget_CurrentChanged( int indx );
155  void optionsStackedWidget_WidgetRemoved( int indx );
156  void warnAboutMissingObjects();
157 
158  protected:
159  void showEvent( QShowEvent* e ) override;
160  void paintEvent( QPaintEvent* e ) override;
161 
162  virtual void updateWindowTitle();
163 
169  void registerTextSearchWidgets();
170 
171  QList< QPair< QgsSearchHighlightOptionWidget*, int > > mRegisteredSearchWidgets;
172 
173  QString mOptsKey;
174  bool mInit;
175  QListWidget* mOptListWidget = nullptr;
176  QStackedWidget* mOptStackedWidget = nullptr;
177  QSplitter* mOptSplitter = nullptr;
178  QDialogButtonBox* mOptButtonBox = nullptr;
179  QgsFilterLineEdit* mSearchLineEdit = nullptr;
180  QString mDialogTitle;
181  bool mIconOnly;
182  // pointer to app or custom, external QSettings
183  // QPointer in case custom settings obj gets deleted while dialog is open
184  QPointer<QSettings> mSettings;
186 };
187 
188 #endif // QGSOPTIONSDIALOGBASE_H
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.
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.
QPointer< QSettings > mSettings