QSettingsDialog
1.0.0
A Qt library to easily create a settings dialog for user configurable settings
|
A general class to modifiy the appereance of elements of a settings dialog. More...
#include <qsettingslayout.h>
Public Types | |
enum | LayoutType { DialogLayout, CategoryLayout, SectionLayout, GroupLayout, EntryLayout } |
Defines the different elements a layout can be created for. More... | |
Public Member Functions | |
QSettingsLayout (QSettingsDialog *settingsDialog, bool fromCurrentContainer=false) | |
Creates a new layout for the given dialogs root element or current container. More... | |
QSettingsLayout (QSettingsDialog *settingsDialog, const QString &containerPath, int entryId=-1) | |
Creates a new layout for the given container in the dialog or an entry within that container. More... | |
QSettingsLayout (QSettingsContainer *container) | |
Creates a new layout from the given container. | |
QString | id () const |
Returns the container id of the current container. More... | |
LayoutType | layoutType () const |
Returns the element type this layout represents. More... | |
bool | isNull () const |
Returns whether this layout is a null-layout (does not represent anything) More... | |
QSettingsDialog * | dialog () const |
Returns the dialog this layout belongs to. More... | |
QString | containerPath () const |
Returns the full container path of the element. More... | |
QSettingsLayout | parentContainer () const |
Returns the parent container element, if available. More... | |
int | displayId () const |
Gets the elements display id. More... | |
void | setDisplayId (int displayId) |
Sets the elements display id. More... | |
QString | name () const |
Gets the elements name. More... | |
void | setName (const QString &name) |
Sets the elements name. More... | |
QIcon | icon () const |
Gets the elements icon. More... | |
void | setIcon (const QIcon &icon) |
Sets the elements icon. More... | |
QString | tooltip () const |
Gets the elements tooltip. More... | |
void | setTooltip (const QString &tooltip) |
Sets the elements tooltip. More... | |
bool | isOptional () const |
Gets whether the element is optional or not. More... | |
void | setOptional (bool optional) |
Sets whether the element is optional or not. More... | |
QSettingsLayout | defaultElement (bool allowCreateNew=false) const |
Returns the elements default child element. More... | |
bool | removeDefaultElement () |
Removes the default element, if it exists. More... | |
int | elementCount () const |
Returns the number of children this element has. More... | |
QSettingsLayout | elementAt (int index) const |
Gets the child element at the given position. More... | |
int | indexOfElement (const QSettingsLayout &element) const |
Gets the child index of the given element within this element. More... | |
int | indexOfElement (const QString &elementName) const |
Gets the child index of the given element by name within this element. More... | |
QSettingsLayout | createElement (int index, const QString &id, const QString &name=QString(), const QIcon &icon=QIcon(), const QString &tooltip=QString()) |
Creates a new child element at the given index. More... | |
QSettingsLayout | createGroupElement (int index, const QString &id, int displayId=0, const QString &name=QString(), bool optional=false, const QString &tooltip=QString()) |
Creates a new optional child element at the given index. More... | |
void | removeElement (int index) |
Removes the child element at the given index. More... | |
void | moveElement (int indexFrom, int indexTo) |
Moves the child from one index to a new one. More... | |
void | transferElement (int indexFrom, QSettingsLayout targetLayout, int indexTo) |
Transfers a child from this layout to the given target. More... | |
Friends | |
class | SettingsEntryLayout |
class | SettingsGroupLayout |
class | SettingsSectionLayout |
class | SettingsCategoryLayout |
class | SettingsRootLayout |
A general class to modifiy the appereance of elements of a settings dialog.
Layouts can be created for any element within the dialog (see QSettingsLayout::LayoutType). The layout itself is a generalized class that provides a bunch of functions to modify those elements, focused on their appereance and the organization of their child elements.
The layouts themselves are value-classes that can be copied without hesitation, because they are mere wrappers around the internal data structures. This makes the use of them easy and simple. Even if you have multiple copies of one layout, if one is changed, all will see this change, because all of them are internally using the same data
Defines the different elements a layout can be created for.
|
explicit |
Creates a new layout for the given dialogs root element or current container.
settingsDialog | The dialog to create the layout for |
fromCurrentContainer | true , to use the current container, false to create a root layout |
If fromCurrentContainer is false
(the default), a LayoutType::DialogLayout will be created from the dialog itself. If it is true
, the dialogs current container path (QSettingsDialog::containerPath) will be used.
|
explicit |
Creates a new layout for the given container in the dialog or an entry within that container.
settingsDialog | The dialog to create the layout for |
containerPath | The path to create the layout for |
entryId | The id of the entry within the container, or -1, if the path container should be used |
If entryId is < 0, a container for the given path will be created. An empty path will create a LayoutType::DialogLayout. If the path has 1 element, it will be QSettingsLayout::CategoryLayout, a QSettingsLayout::SectionLayout for 2 and a QSettingsLayout::GroupLayout for 3. If you have a section or group path, and id is 0 or greater, the entry with the given id inside the specified path will be used.
QSettingsLayout::containerPath | ( | ) | const |
Returns the full container path of the element.
For categories, this is just the id. For sections and groups, this will be a 2 or three element path.
./Baum/#42
. Please note that this is not a valid container path, just a representation of container and id.Supported Layout Types |
---|
Supported for all layout types |
QSettingsLayout::createElement | ( | int | index, |
const QString & | id, | ||
const QString & | name = QString() , |
||
const QIcon & | icon = QIcon() , |
||
const QString & | tooltip = QString() |
||
) |
Creates a new child element at the given index.
index | The index to insert the item at |
id | The id the new element should have |
name | The display name the element should have |
icon | The display icon for the element |
tooltip | The tooltip for the new element |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
If an element with that id does already exist, it will be deleted and overwritten. To avoid this, check for children beforehand. If name is left as a null string, the id will be used as name. If index is not a valid index, the function will assert.
For group elements, use QSettingsLayout::createGroupElement.
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::createGroupElement | ( | int | index, |
const QString & | id, | ||
int | displayId = 0 , |
||
const QString & | name = QString() , |
||
bool | optional = false , |
||
const QString & | tooltip = QString() |
||
) |
Creates a new optional child element at the given index.
index | The index to insert the item at |
id | The id the new element should have |
displayId | The displayId the new element should have |
name | The display name the element should have |
optional | Specifies whether the element should be optional or not |
tooltip | The tooltip for the new element |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
If an element with that id does already exist, it will be deleted and overwritten. To avoid this, check for children beforehand. If name is left as a null string, the id will be used as name. If index is not a valid index, the function will assert.
For other elements, use QSettingsLayout::createElement.
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::defaultElement | ( | bool | allowCreateNew = false | ) | const |
Returns the elements default child element.
allowCreateNew | Specifies whether it's allowed to create the default element if it does not exist |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
If the default element does not yet exist, allowCreateNew can be used to create it. If it is not created, a null layout will be returned (See QSettingsLayout::isNull)
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::dialog | ( | ) | const |
Returns the dialog this layout belongs to.
If the dialog was destroyed while this layout is still alive, this function will return nullptr
. It is save to destroy a layout even after the dialog was deleted.
Supported Layout Types |
---|
Supported for all layout types |
QSettingsLayout::displayId | ( | ) | const |
Gets the elements display id.
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::elementAt | ( | int | index | ) | const |
Gets the child element at the given position.
index | The index of the desired child element |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
If index is not a valid index, the function will assert.
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::elementCount | ( | ) | const |
Returns the number of children this element has.
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::icon | ( | ) | const |
Gets the elements icon.
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::id | ( | ) | const |
Returns the container id of the current container.
Will return the container id of the element this layout represents. For LayoutType::DialogLayout this will always be an emtpy string, and for LayoutType::EntryLayout, the entry id (an integer) prepended by #
will be returned. E.g. #42
for an entry with the id 42
Supported Layout Types |
---|
Supported for all layout types |
QSettingsLayout::indexOfElement | ( | const QSettingsLayout & | element | ) | const |
Gets the child index of the given element within this element.
element | The element to be found within this layout |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::indexOfElement | ( | const QString & | elementName | ) | const |
Gets the child index of the given element by name within this element.
elementName | The name of the element to be found within this layout |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::isNull | ( | ) | const |
Returns whether this layout is a null-layout (does not represent anything)
true
, if this element is a null element, false
if notNull layouts can happen if you try to create a layout for a container path that does not exist
Supported Layout Types |
---|
Supported for all layout types |
QSettingsLayout::isOptional | ( | ) | const |
Gets whether the element is optional or not.
true
, if the element is optional, false
if not LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::layoutType | ( | ) | const |
Returns the element type this layout represents.
Supported Layout Types |
---|
Supported for all layout types |
QSettingsLayout::moveElement | ( | int | indexFrom, |
int | indexTo | ||
) |
Moves the child from one index to a new one.
indexFrom | The index of the child element to be moved |
indexTo | The index to move the element to |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
If one of the indexes is not a valid index, the function will assert.
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::name | ( | ) | const |
Gets the elements name.
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::parentContainer | ( | ) | const |
Returns the parent container element, if available.
The parent container will only be available, if this layout was originally created from a parent layout. In other words, a layout created from a constructor it will always return a null layout. If you created it from a parent, for example by using QSettingsLayout::elementAt, it will return the element it was created from.
Supported Layout Types |
---|
Supported for all layout types |
QSettingsLayout::removeDefaultElement | ( | ) |
Removes the default element, if it exists.
true
, if the default group was removed, false
if none exists LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
If the default element does exist, it will be removed. If does not currently exist, nothing happens
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::removeElement | ( | int | index | ) |
Removes the child element at the given index.
index | The index of the child element to be removed |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
If index is not a valid index, the function will assert.
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::setDisplayId | ( | int | displayId | ) |
Sets the elements display id.
displayId | The id to be set as new display id |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::setIcon | ( | const QIcon & | icon | ) |
Sets the elements icon.
icon | The icon to be set as new icon |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::setName | ( | const QString & | name | ) |
Sets the elements name.
name | The name to be set as new name |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::setOptional | ( | bool | optional | ) |
Sets whether the element is optional or not.
optional | The value that optional should be set to |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::setTooltip | ( | const QString & | tooltip | ) |
Sets the elements tooltip.
tooltip | The tooltip to be set as new tooltip |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::tooltip | ( | ) | const |
Gets the elements tooltip.
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |
QSettingsLayout::transferElement | ( | int | indexFrom, |
QSettingsLayout | targetLayout, | ||
int | indexTo | ||
) |
Transfers a child from this layout to the given target.
indexFrom | The index of the child element to be moved |
targetLayout | The layout to move the element to |
indexTo | The index to move the element to |
LayoutPropertyNotDefinedException | Will be thrown if called on a layout with an unsupported type |
InvalidTargetLayoutException | Will the thrown if the target layout is of a different layout type |
If one of the indexes is not a valid index, the function will assert. To move entries from layouts to groups and the other way around, please use QSettingsContainer classes.
Supported Layout Types | |
---|---|
QSettingsLayout::DialogLayout | |
QSettingsLayout::CategoryLayout | |
QSettingsLayout::SectionLayout | |
QSettingsLayout::GroupLayout | |
QSettingsLayout::EntryLayout |