QSettingsDialog  1.0.0
A Qt library to easily create a settings dialog for user configurable settings
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
QSettingsGroupWidgetBase Class Referenceabstract

The base class for group widgets in the settings dialog. More...

#include <qsettingsgroupwidget.h>

+ Inheritance diagram for QSettingsGroupWidgetBase:

Public Member Functions

virtual ~QSettingsGroupWidgetBase ()
 Virtual destructor.
 
virtual QWidgetasWidget ()=0
 Must return this as QWidget (a cast) More...
 
virtual void initialize (const UiPropertyMap &uiPropertyMap)=0
 Will be called to initialize the widgets properties with the given ones.
 
virtual void setName (const QString &name)=0
 Will be called to set the name (title) of the group.
 
virtual void setTooltip (const QString &tooltip)=0
 Will be called to set the tooltip of the group.
 
virtual void setOptional (bool optional)=0
 Will be called to set the group optional or required. More...
 
virtual bool isChecked () const =0
 Returns whether the group is checked or not.
 
virtual void setChecked (bool checked)=0
 Sets the groups checked state.
 
virtual void addWidgetRaw (QSharedPointer< QSettingsEntry > entry, QWidget *content, bool hasError)
 Adds a widget to the dialog in a raw way.
 
virtual void setEntryChecked (QSharedPointer< QSettingsEntry > entry, bool checked)
 Sets an entry within the dialog to be checked.
 
virtual void setEntryLabelEnabled (QSharedPointer< QSettingsEntry > entry, bool enabled)
 Enables or disables an entry (and it's label) in the group.
 
virtual bool isEntryChecked (QSharedPointer< QSettingsEntry > entry) const
 Will be called to find out whether one entry within the group is checked.
 
virtual bool searchExpression (const QRegularExpression &regex, const QString &searchStyleSheet)
 Called to search for the expression within the group and it's children.
 

Protected Types

typedef QPair< QWidget *, QSettingsWidgetBase * > GroupElement
 Defines one "element" within the group - label and edit widget.
 

Protected Member Functions

virtual void addWidgetWithLabel (QWidget *label, QWidget *content)=0
 Simple way to add widgets with a label to the group. More...
 

Protected Attributes

QHash< QSharedPointer< QSettingsEntry >, GroupElemententryMap
 A map that contains all elements withing this group, by their entry.
 

Detailed Description

The base class for group widgets in the settings dialog.

Implementations must inherit from QWidget!

Custom groups can be used to provide a customized way to organize entries in a group. Because of the way the dialog is build up, the raw mechanics and organization within the dialog can get very complicated. To make it possible to create custom groups in a simple way, there are two approaches on creating a custom group

Simple implementation

All you have to do is to provide a widget that can somehow contain children. All you have to do is implement the QSettingsGroupWidgetBase::addWidgetWithLabel method. (And the other pure virtual functions). This way the group will handle all the complex stuff on it's own. However, this requires you to provide a group that can handle a label and a widget. For groups that are more complex, the second method must be used.

Raw implementation

Instead of using the simple implementation, override all the management functions:

This requies you to do all the complex checking and searching logic on your own, but you can create fully customized groups.

Note
You should not use this class directly. It simply serves as base for the generic interface. You should only implement the QSettingsGroupWidget interface!

Member Function Documentation

QSettingsGroupWidgetBase::addWidgetWithLabel ( QWidget label,
QWidget content 
)
protectedpure virtual

Simple way to add widgets with a label to the group.

Parameters
labelThe widget that operates as a label. Will be a QLabel or a QCheckBox
contentThe edit widget, a QSettingsWidgetBase implementation (here simply as QWidget)

This function should simply add the two given widget into the groups display layout. All the logic connecting them and other managemant stuff is done by the group itself. In most cases the implementations of this function will simply add those two widget into a QLayout.

QSettingsGroupWidgetBase::asWidget ( )
pure virtual

Must return this as QWidget (a cast)

Returns
(QWidget*)this;
Warning
This function MUST return itself. It's basically a shortcut for (QWidget*)element, and is there to ensure all widgets that implement this interface do inherit QWidget.

Implemented in QSettingsGroupWidget< TWidget >.

QSettingsGroupWidgetBase::setOptional ( bool  optional)
pure virtual

Will be called to set the group optional or required.

Parameters
optionalIf true, the group should be optional, if false required.

Optional groups are a way to make it possible for the user to batch-enable settings. If a group is optional and checked, or required, it should let the user use the contents normally. If it optional and unchecked, the contents should be disabled, preventing the user from accessing them. If the settings get saved, all children within an unchecked group will be resetted. Otherwise the normal operation for them will be used.


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