QGIS API Documentation  3.21.0-Master (5b68dc587e)
Public Slots | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
QgsOptionsDialogBase Class Reference

A base dialog for options and properties dialogs that offers vertical tabs. More...

#include <qgsoptionsdialogbase.h>

Inheritance diagram for QgsOptionsDialogBase:
Inheritance graph
[legend]

Public Slots

void searchText (const QString &text)
 searchText searches for a text in all the pages of the stacked widget and highlight the results More...
 

Public Member Functions

 QgsOptionsDialogBase (const QString &settingsKey, QWidget *parent=nullptr, Qt::WindowFlags fl=Qt::WindowFlags(), QgsSettings *settings=nullptr)
 Constructor. More...
 
 ~QgsOptionsDialogBase () override
 
void addPage (const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget, const QStringList &path=QStringList())
 Adds a new page to the dialog pages. More...
 
bool iconOnly ()
 Determine if the options list is in icon only mode. More...
 
void initOptionsBase (bool restoreUi=true, const QString &title=QString())
 Set up the base ui connections for vertical tabs. More...
 
void insertPage (const QString &title, const QString &tooltip, const QIcon &icon, QWidget *widget, const QString &before, const QStringList &path=QStringList())
 Inserts a new page into the dialog pages. More...
 
void resizeAlltabs (int index)
 Resizes all tabs when the dialog is resized. More...
 
void restoreLastPage ()
 Refocus the active tab from the last time the dialog was shown. More...
 
void restoreOptionsBaseUi (const QString &title=QString())
 Restore the base ui. More...
 
void setCurrentPage (const QString &page)
 Sets the dialog page (by object name) to show. More...
 
void setSettings (QgsSettings *settings)
 

Protected Slots

virtual void optionsStackedWidget_CurrentChanged (int index)
 Select relevant tab on current page change. More...
 
virtual void optionsStackedWidget_WidgetRemoved (int index)
 Remove tab and unregister widgets on page remove. More...
 
virtual void updateOptionsListVerticalTabs ()
 Update tabs on the splitter move. More...
 
void warnAboutMissingObjects ()
 

Protected Member Functions

QStandardItem * createItem (const QString &name, const QString &tooltip, const QString &icon)
 Creates a new QStandardItem with the specified name, tooltip and icon. More...
 
void paintEvent (QPaintEvent *e) override
 
void registerTextSearchWidgets ()
 register widgets in the dialog to search for text in it it is automatically called if a line edit has "mSearchLineEdit" as object name. More...
 
void showEvent (QShowEvent *e) override
 
virtual void updateWindowTitle ()
 

Protected Attributes

bool mDelSettings = false
 
QString mDialogTitle
 
bool mIconOnly = false
 
bool mInit = false
 
QDialogButtonBox * mOptButtonBox = nullptr
 
QListWidget * mOptListWidget = nullptr
 
QString mOptsKey
 
QSplitter * mOptSplitter = nullptr
 
QStackedWidget * mOptStackedWidget = nullptr
 
QStandardItemModel * mOptTreeModel = nullptr
 
QTreeView * mOptTreeView = nullptr
 
QList< QPair< QgsOptionsDialogHighlightWidget *, int > > mRegisteredSearchWidgets
 
QgsFilterLineEditmSearchLineEdit = nullptr
 
QPointer< QgsSettings > mSettings
 
QgsOptionsProxyModel * mTreeProxyModel = nullptr
 

Detailed Description

A base dialog for options and properties dialogs that offers vertical tabs.

It handles saving/restoring of geometry, splitter and current tab states, switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left), and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots

To use:

Start with copy of qgsoptionsdialog_template.ui and build options/properties dialog.

In source file for dialog, inherit this class instead of QDialog, then in constructor:

... setupUi( this ); // set up .ui file objects initOptionsBase( false ); // set up this class to use .ui objects, optionally restoring base ui ... restoreOptionsBaseUi(); // restore the base ui with initOptionsBase or use this later on

Definition at line 86 of file qgsoptionsdialogbase.h.

Constructor & Destructor Documentation

◆ QgsOptionsDialogBase()

QgsOptionsDialogBase::QgsOptionsDialogBase ( const QString &  settingsKey,
QWidget *  parent = nullptr,
Qt::WindowFlags  fl = Qt::WindowFlags(),
QgsSettings *  settings = nullptr 
)

Constructor.

Parameters
settingsKeyQgsSettings subgroup key for saving/restore ui states, e.g. "ProjectProperties".
parentparent object (owner)
flwidget flags
settingscustom QgsSettings pointer

Definition at line 43 of file qgsoptionsdialogbase.cpp.

◆ ~QgsOptionsDialogBase()

QgsOptionsDialogBase::~QgsOptionsDialogBase ( )
override

Definition at line 50 of file qgsoptionsdialogbase.cpp.

Member Function Documentation

◆ addPage()

void QgsOptionsDialogBase::addPage ( const QString &  title,
const QString &  tooltip,
const QIcon &  icon,
QWidget *  widget,
const QStringList &  path = QStringList() 
)

Adds a new page to the dialog pages.

The title, tooltip and icon arguments dictate the page list item title, tooltip and icon respectively.

The page content is specified via the widget argument. Ownership of widget is transferred to the dialog.

Since QGIS 3.22, the optional path argument can be used to set the path of the item's entry in the tree view (for dialogs which show a tree view of options pages only).

See also
insertPage()
Since
QGIS 3.14

Definition at line 327 of file qgsoptionsdialogbase.cpp.

◆ createItem()

QStandardItem * QgsOptionsDialogBase::createItem ( const QString &  name,
const QString &  tooltip,
const QString &  icon 
)
protected

Creates a new QStandardItem with the specified name, tooltip and icon.

Since
QGIS 3.22

Definition at line 681 of file qgsoptionsdialogbase.cpp.

◆ iconOnly()

bool QgsOptionsDialogBase::iconOnly ( )
inline

Determine if the options list is in icon only mode.

Definition at line 136 of file qgsoptionsdialogbase.h.

◆ initOptionsBase()

void QgsOptionsDialogBase::initOptionsBase ( bool  restoreUi = true,
const QString &  title = QString() 
)

Set up the base ui connections for vertical tabs.

Parameters
restoreUiWhether to restore the base ui at this time.
titlethe window title

Definition at line 67 of file qgsoptionsdialogbase.cpp.

◆ insertPage()

void QgsOptionsDialogBase::insertPage ( const QString &  title,
const QString &  tooltip,
const QIcon &  icon,
QWidget *  widget,
const QString &  before,
const QStringList &  path = QStringList() 
)

Inserts a new page into the dialog pages.

The title, tooltip and icon arguments dictate the page list item title, tooltip and icon respectively.

The page content is specified via the widget argument. Ownership of widget is transferred to the dialog.

The before argument specifies the object name of an existing page. The new page will be inserted directly before the matching page.

Since QGIS 3.22, the optional path argument can be used to set the path of the item's entry in the tree view (for dialogs which show a tree view of options pages only).

See also
addPage()
Since
QGIS 3.14

Definition at line 401 of file qgsoptionsdialogbase.cpp.

◆ optionsStackedWidget_CurrentChanged

void QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged ( int  index)
protectedvirtualslot

Select relevant tab on current page change.

Definition at line 783 of file qgsoptionsdialogbase.cpp.

◆ optionsStackedWidget_WidgetRemoved

void QgsOptionsDialogBase::optionsStackedWidget_WidgetRemoved ( int  index)
protectedvirtualslot

Remove tab and unregister widgets on page remove.

Definition at line 801 of file qgsoptionsdialogbase.cpp.

◆ paintEvent()

void QgsOptionsDialogBase::paintEvent ( QPaintEvent *  e)
overrideprotected

Definition at line 715 of file qgsoptionsdialogbase.cpp.

◆ registerTextSearchWidgets()

void QgsOptionsDialogBase::registerTextSearchWidgets ( )
protected

register widgets in the dialog to search for text in it it is automatically called if a line edit has "mSearchLineEdit" as object name.

Since
QGIS 3.0

Definition at line 640 of file qgsoptionsdialogbase.cpp.

◆ resizeAlltabs()

void QgsOptionsDialogBase::resizeAlltabs ( int  index)

Resizes all tabs when the dialog is resized.

Parameters
indexcurrent tab index
Since
QGIS 3.10

Definition at line 288 of file qgsoptionsdialogbase.cpp.

◆ restoreLastPage()

void QgsOptionsDialogBase::restoreLastPage ( )

Refocus the active tab from the last time the dialog was shown.

Since
QGIS 3.14

Definition at line 250 of file qgsoptionsdialogbase.cpp.

◆ restoreOptionsBaseUi()

void QgsOptionsDialogBase::restoreOptionsBaseUi ( const QString &  title = QString())

Restore the base ui.

Sometimes useful to do at end of subclass's constructor.

Parameters
titlethe window title (it does not need to be defined if previously given to initOptionsBase();

Definition at line 206 of file qgsoptionsdialogbase.cpp.

◆ searchText

void QgsOptionsDialogBase::searchText ( const QString &  text)
slot

searchText searches for a text in all the pages of the stacked widget and highlight the results

Parameters
textthe text to search
Since
QGIS 3.0

Definition at line 496 of file qgsoptionsdialogbase.cpp.

◆ setCurrentPage()

void QgsOptionsDialogBase::setCurrentPage ( const QString &  page)

Sets the dialog page (by object name) to show.

Since
QGIS 3.14

Definition at line 312 of file qgsoptionsdialogbase.cpp.

◆ setSettings()

void QgsOptionsDialogBase::setSettings ( QgsSettings *  settings)

Definition at line 195 of file qgsoptionsdialogbase.cpp.

◆ showEvent()

void QgsOptionsDialogBase::showEvent ( QShowEvent *  e)
overrideprotected

Definition at line 688 of file qgsoptionsdialogbase.cpp.

◆ updateOptionsListVerticalTabs

void QgsOptionsDialogBase::updateOptionsListVerticalTabs ( )
protectedvirtualslot

Update tabs on the splitter move.

Definition at line 740 of file qgsoptionsdialogbase.cpp.

◆ updateWindowTitle()

void QgsOptionsDialogBase::updateWindowTitle ( )
protectedvirtual

Definition at line 723 of file qgsoptionsdialogbase.cpp.

◆ warnAboutMissingObjects

void QgsOptionsDialogBase::warnAboutMissingObjects ( )
protectedslot

Definition at line 823 of file qgsoptionsdialogbase.cpp.

Member Data Documentation

◆ mDelSettings

bool QgsOptionsDialogBase::mDelSettings = false
protected

Definition at line 235 of file qgsoptionsdialogbase.h.

◆ mDialogTitle

QString QgsOptionsDialogBase::mDialogTitle
protected

Definition at line 230 of file qgsoptionsdialogbase.h.

◆ mIconOnly

bool QgsOptionsDialogBase::mIconOnly = false
protected

Definition at line 231 of file qgsoptionsdialogbase.h.

◆ mInit

bool QgsOptionsDialogBase::mInit = false
protected

Definition at line 220 of file qgsoptionsdialogbase.h.

◆ mOptButtonBox

QDialogButtonBox* QgsOptionsDialogBase::mOptButtonBox = nullptr
protected

Definition at line 228 of file qgsoptionsdialogbase.h.

◆ mOptListWidget

QListWidget* QgsOptionsDialogBase::mOptListWidget = nullptr
protected

Definition at line 221 of file qgsoptionsdialogbase.h.

◆ mOptsKey

QString QgsOptionsDialogBase::mOptsKey
protected

Definition at line 219 of file qgsoptionsdialogbase.h.

◆ mOptSplitter

QSplitter* QgsOptionsDialogBase::mOptSplitter = nullptr
protected

Definition at line 227 of file qgsoptionsdialogbase.h.

◆ mOptStackedWidget

QStackedWidget* QgsOptionsDialogBase::mOptStackedWidget = nullptr
protected

Definition at line 226 of file qgsoptionsdialogbase.h.

◆ mOptTreeModel

QStandardItemModel* QgsOptionsDialogBase::mOptTreeModel = nullptr
protected

Definition at line 223 of file qgsoptionsdialogbase.h.

◆ mOptTreeView

QTreeView* QgsOptionsDialogBase::mOptTreeView = nullptr
protected

Definition at line 222 of file qgsoptionsdialogbase.h.

◆ mRegisteredSearchWidgets

QList< QPair< QgsOptionsDialogHighlightWidget *, int > > QgsOptionsDialogBase::mRegisteredSearchWidgets
protected

Definition at line 217 of file qgsoptionsdialogbase.h.

◆ mSearchLineEdit

QgsFilterLineEdit* QgsOptionsDialogBase::mSearchLineEdit = nullptr
protected

Definition at line 229 of file qgsoptionsdialogbase.h.

◆ mSettings

QPointer<QgsSettings> QgsOptionsDialogBase::mSettings
protected

Definition at line 234 of file qgsoptionsdialogbase.h.

◆ mTreeProxyModel

QgsOptionsProxyModel* QgsOptionsDialogBase::mTreeProxyModel = nullptr
protected

Definition at line 224 of file qgsoptionsdialogbase.h.


The documentation for this class was generated from the following files: