Relacs Widgets Library
0.9.8
|
#include <optwidget.h>
Public Slots | |
void | accept (bool clearchanged) |
void | accept (void) |
void | acceptGet (void) |
void | acceptNotify (bool clearchanged) |
void | reset (void) |
void | resetDefault (void) |
void | updateValue (const string &name) |
void | updateValues (void) |
void | updateValues (int flag, bool delflags=true) |
void | updateSettings (const string &name) |
void | updateSettings (void) |
void | updateSettings (int flag, bool delflags=true) |
Signals | |
void | valuesChanged (void) |
void | valueChanged (const Parameter &p) |
Public Member Functions | |
OptWidget (QWidget *parent=0, Qt::WindowFlags f=0) | |
OptWidget (Options *o, QMutex *mutex=0, QWidget *parent=0, Qt::WindowFlags f=0) | |
OptWidget (Options *o, int selectmask, int romask, bool contupdate, int style, QMutex *mutex=0, string *tabhotkeys=0, QWidget *parent=0, Qt::WindowFlags f=0) | |
~OptWidget (void) | |
OptWidget & | operator= (Options *o) |
OptWidget & | assign (Options *o, int selectmask=0, int romask=0, bool contupdate=false, int style=0, QMutex *mutex=0, string *tabhotkeys=0) |
bool | tabs (void) const |
int | lines (void) const |
void | setVerticalSpacing (int pixel) |
void | setHorizontalSpacing (int pixel) |
void | setMargins (int pixel) |
void | setMargins (int left, int top, int right, int bottom) |
QWidget * | firstWidget (void) const |
QWidget * | lastWidget (void) const |
int | selectMask (void) const |
int | readOnlyMask (void) const |
bool | continuousUpdate (void) const |
int | style (void) const |
Options * | options (void) const |
void | setMutex (QMutex *mutex) |
void | lockMutex (void) |
bool | tryLockMutex (int timeout=1) |
void | unlockMutex (void) |
Static Public Member Functions | |
static int | changedFlag (void) |
static string | tabLabel (string label, string *tabhotkeys) |
Static Public Attributes | |
static const long | LabelNormal = 0x00000000 |
static const long | LabelSmall = 0x00000001 |
static const long | LabelLarge = 0x00000002 |
static const long | LabelHuge = 0x00000003 |
static const long | LabelBold = 0x00000004 |
static const long | LabelItalic = 0x00000008 |
static const long | LabelBlack = 0x00000000 |
static const long | LabelRed = 0x00000010 |
static const long | LabelGreen = 0x00000020 |
static const long | LabelBlue = 0x00000030 |
static const long | LabelBack = 0x00000000 |
static const long | LabelBackBlack = 0x00000040 |
static const long | LabelBackWhite = 0x00000080 |
static const long | ValueNormal = 0x00000000 |
static const long | ValueSmall = 0x00001000 |
static const long | ValueLarge = 0x00002000 |
static const long | ValueHuge = 0x00003000 |
static const long | ValueBold = 0x00004000 |
static const long | ValueItalic = 0x00008000 |
static const long | ValueBlack = 0x00000000 |
static const long | ValueRed = 0x00010000 |
static const long | ValueGreen = 0x00020000 |
static const long | ValueBlue = 0x00030000 |
static const long | ValueBack = 0x00000000 |
static const long | ValueBackBlack = 0x00040000 |
static const long | ValueBackWhite = 0x00080000 |
static const long | Normal = LabelNormal + ValueNormal |
static const long | Small = LabelSmall + ValueSmall |
static const long | Large = LabelLarge + ValueLarge |
static const long | Huge = LabelHuge + ValueHuge |
static const long | Bold = LabelBold + ValueBold |
static const long | Italic = LabelItalic + ValueItalic |
static const long | Black = LabelBlack + ValueBlack |
static const long | Red = LabelRed + ValueRed |
static const long | Green = LabelGreen + ValueGreen |
static const long | Blue = LabelBlue + ValueBlue |
static const long | Back = LabelBack + ValueBack |
static const long | BackBlack = LabelBackBlack + ValueBackBlack |
static const long | BackWhite = LabelBackWhite + ValueBackWhite |
static const long | SelectText = Parameter::SelectText |
static const int | MultipleSelection = Parameter::MultipleSelection |
static const long | ComboAutoCompletion = 0x04000000 |
static const long | BrowseExisting = 0x08000000 |
static const long | BrowseAny = 0x10000000 |
static const long | BrowseDirectory = 0x20000000 |
static const long | Browse = BrowseExisting + BrowseAny + BrowseDirectory |
static const long | BrowseAbsolute = 0x40000000 |
static const long | ValueLCD = 0x01000000 |
static const long | SpecialInfinite = 0x10000000 |
static const long | SpecialNone = 0x20000000 |
static const long | TabSection = Options::TabSection |
static const long | MathLabel = 0x08000000 |
static const int | BreakLinesStyle = 0x0001 |
static const int | ExtraSpaceStyle = 0x0002 |
static const int | TabSectionStyle = 0x0004 |
static const int | NameFrontStyle = 0x0008 |
static const int | NameBehindStyle = 0x0010 |
static const int | HighlightNameStyle = 0x0020 |
static const int | BoldSectionsStyle = 0x0040 |
static const int | HideStyle = 0x0080 |
Protected Member Functions | |
virtual void | customEvent (QEvent *e) |
Friends | |
class | OptWidgetBase |
class | OptWidgetText |
class | OptWidgetMultiText |
class | OptWidgetNumber |
class | OptWidgetBoolean |
class | OptWidgetDate |
class | OptWidgetTime |
class | OptWidgetSection |
class | OptWidgetMultipleValues |
class | ComboItemDelegate |
A Widget for modifying Options.
This widget is an input form for Options that can be used to interactively edit the values of Options. If you want a dialog-window, use OptDialog, which is based on OptWidget.
The OptWidget supports simple text editing for text-options with a single value, combo-boxes for text-options with multiple values, spin-boxes for number and integer options, check boxes for boolean options, labels, and separators (a horizontal line).
Here is an example:
It was created with the following code:
First you have to create some Options by either defining them explicitely as in the example with the addNumber(), addText(), ... functions, or you load them from a file with the load( istream& ) function. See the documentation for Options for more details. Then you construct the OptWidget. Either the Options are passed directly to OptWidget via the constructor, or they are assigned later on with assign(). Both ways you can specify a select-mask to select a subset of the Options and a readonly-mask to specify which Options are not editable (in the example the "pause" options is not editable).
Normally the new values entered by the user are assigned to the Options by calling the accept() function. If you want the values of the Options to be continuosly updated, set the contupdate argument in the constructor or the assign() function to true
. Each time a new value is entered in the widget the corresponding option gets this value set. You can react to the change by reimplementing the Options::notify() function. The option whose value has changed will have the changedFlag() set. This flag is automatically cleared after notify() was called.
reset() sets the values in the input form to their initial values. resetDefault() sets them to the Options' default values. If the values or properties of the Options are changed, use the update functions updateValue(), updateValues(), updateSettings() to update the input form of the OptWidget.
Options whose values were changed via the OptWidget get the changedFlag() in their flags() set.
The spacing between two input lines can be adjusted with setVerticalSpacing(). The spacing between the widget margins and its content are set with setMargins().
OptWidget | ( | QWidget * | parent = 0 , |
Qt::WindowFlags | f = 0 |
||
) |
Constructs an OptWidget for the Options o. All Options are displayed and are editable.
References OptWidget::assign().
OptWidget | ( | Options * | o, |
int | selectmask, | ||
int | romask, | ||
bool | contupdate, | ||
int | style, | ||
QMutex * | mutex = 0 , |
||
string * | tabhotkeys = 0 , |
||
QWidget * | parent = 0 , |
||
Qt::WindowFlags | f = 0 |
||
) |
Constructs an OptWidget for the Options o. Only Options with their flags() & selectmask > 0 are displayed. If selectmask ist less or equal to zero, all Options o are displayed. Options with their flags() & romask > 0 are not editable. If romask equals zero all Options o are editable. If romask is negative none of the Options o is editable. If contupdate equals true, inputs by the user are immediately applied to the Options o. Otherwise, accept() has to be called in order to apply the changes to the Options o. tabhotkeys can point to a string that contains hotkey-characters that are already in use. This information is used to choose hotkeys for tabs. The new hotkeys are added to the string.
References OptWidget::assign().
Assigns Options o to the widget. All Options are displayed and are editable.
References OptWidget::assign().
OptWidget & assign | ( | Options * | o, |
int | selectmask = 0 , |
||
int | romask = 0 , |
||
bool | contupdate = false , |
||
int | style = 0 , |
||
QMutex * | mutex = 0 , |
||
string * | tabhotkeys = 0 |
||
) |
Assigns Options o to the widget. Only Options with their flags() & selectmask > 0 are displayed. If selectmask ist less or equal to zero, all Options o are displayed. Options with their flags() & romask > 0 are not editable. If romask equals zero all Options o are editable. If romask() is negative none of the Options o is editable. If contupdate equals true, inputs by the user are immediately applied to the Options o. Otherwise, accept() has to be called in order to apply the changes to the Options o. The standard layout style = 0 puts each option into a separate line. If style = 1 then the option's name is in one line and the options value and unit is in the following line. mutex is a mutex that is used by OptWidget to lock access to the options o while they are accessed from OptWidget functions. In particular during calls of the notify() function this mutex will be locked. tabhotkeys can point to a string that contains hotkey-characters that are already in use. This information is used to choose hotkeys for tabs. The new hotkeys are added to the string.
References OptWidget::lockMutex(), OptWidget::style(), OptWidget::tabLabel(), OptWidget::TabSection, OptWidget::TabSectionStyle, and OptWidget::unlockMutex().
Referenced by OptWidget::operator=(), and OptWidget::OptWidget().
bool tabs | ( | void | ) | const |
Returns true
if tabbed widgets are used.
int lines | ( | void | ) | const |
The maximum number of lines in a single tab.
Referenced by ConfigDialog::dialogOptions().
void setVerticalSpacing | ( | int | pixel | ) |
Set the spacing between the lines to pixel pixel.
void setHorizontalSpacing | ( | int | pixel | ) |
Set the horizontal spacing to pixel pixel.
void setMargins | ( | int | pixel | ) |
Set the spacing between the widget margins and its content to pixel pixel.
void setMargins | ( | int | left, |
int | top, | ||
int | right, | ||
int | bottom | ||
) |
Set the spacing between the widget margins and its content to all sides individually.
QWidget * firstWidget | ( | void | ) | const |
A pointer to the first editable widget in OptWidget. Is null, if there isn't any editable widget. Can be used to set the tab order.
QWidget * lastWidget | ( | void | ) | const |
A pointer to the last editable widget in OptWidget. Is null, if there isn't any editable widget. Can be used to set the tab order.
int selectMask | ( | void | ) | const |
The mask that was used to select single options.
int readOnlyMask | ( | void | ) | const |
The mask that was used to decide whether an option should be editable or not.
Referenced by OptWidgetBase::OptWidgetBase().
bool continuousUpdate | ( | void | ) | const |
int style | ( | void | ) | const |
Returns the style flags of the widget.
Referenced by OptWidgetBase::activateOption(), and OptWidget::assign().
|
static |
The flag that is used to mark options whose value were changed by or-ing their flags with this flag. It is preset to a constant value (16384) and cannot be changed by the user.
Referenced by OptWidget::accept(), OptWidget::acceptNotify(), OptDialog::changedFlag(), OptWidgetText::doBrowse(), OptWidgetText::doTextChanged(), OptWidgetMultiText::doTextChanged(), OptWidgetNumber::doValueChanged(), OptWidgetBoolean::doValueChanged(), OptWidgetDate::doValueChanged(), OptWidgetTime::doValueChanged(), OptWidgetText::get(), OptWidgetMultiText::get(), OptWidgetNumber::get(), OptWidgetBoolean::get(), OptWidgetDate::get(), OptWidgetTime::get(), OptWidgetMultipleValues::get(), OptWidgetBase::OptWidgetBase(), OptWidgetText::textChanged(), OptWidgetMultiText::textChanged(), OptWidgetNumber::valueChanged(), OptWidgetBoolean::valueChanged(), OptWidgetDate::valueChanged(), and OptWidgetTime::valueChanged().
void setMutex | ( | QMutex * | mutex | ) |
Provide a mutex that is used by OptWidget to lock access to the options while they are accessed. Passing a '0' disables the mutex.
void lockMutex | ( | void | ) |
Lock the mutex for reading.
Referenced by OptWidget::accept(), OptWidget::acceptGet(), OptWidget::acceptNotify(), OptWidget::assign(), OptWidget::reset(), and OptWidget::resetDefault().
bool tryLockMutex | ( | int | timeout = 1 | ) |
Try to lock the data mutex for reading. Returns true
if the lock was obtained within timeout milliseconds.
Referenced by OptWidget::customEvent().
void unlockMutex | ( | void | ) |
Unlock the data mutex.
Referenced by OptWidget::accept(), OptWidget::acceptGet(), OptWidget::acceptNotify(), OptWidget::assign(), OptWidget::customEvent(), OptWidget::reset(), and OptWidget::resetDefault().
|
static |
References Str::low().
Referenced by OptDialog::addTabOptions(), OptDialog::addTabWidget(), and OptWidget::assign().
|
slot |
Set values of the Options according to the changes entered by the user via the OptWidget. Each options whose value was changed by the user gets the changedFlag() set. Then the Options::notify() function is called and the signal valuesChanged() is emitted. Finally the changedFlag() is cleared if clearchanged is set to true
. If a mutex was provided it is locked within this function and consequently during notify() and valuesChanged(). This function can only be called from the GUI thread. Same as a successive execution of acceptGet() and acceptNotify().
References OptWidget::changedFlag(), OptWidget::lockMutex(), OptWidget::unlockMutex(), and OptWidget::valuesChanged().
|
slot |
Same as accept( bool ) with clearchanged set to true.
|
slot |
Set values of the Options according to the changes entered by the user via the OptWidget. Each options whose value was changed by the user gets the changedFlag() set. If a mutex was provided it is locked within this function and consequently during notify() and valuesChanged(). This function can only be called from the GUI thread. Identical to the first part of the accept() function.
References OptWidget::lockMutex(), and OptWidget::unlockMutex().
|
slot |
Calls the Options::notify() function and emits signal valuesChanged(). Finally the changedFlag() is cleared if clearchanged is set to true
. If a mutex was provided it is locked within this function and consequently during notify() and valuesChanged(). This function can only be called from the GUI thread. Identical to the second part of the accept() function.
References OptWidget::changedFlag(), OptWidget::lockMutex(), OptWidget::unlockMutex(), and OptWidget::valuesChanged().
|
slot |
Reset all input fields to their initial values. If a mutex was provided it is locked within this function. This function can only be called from the GUI thread.
References OptWidget::lockMutex(), and OptWidget::unlockMutex().
|
slot |
Reset all input fields to the Options default values. If a mutex was provided it is locked within this function. This function can only be called from the GUI thread.
References OptWidget::lockMutex(), and OptWidget::unlockMutex().
|
slot |
Read out the value of the option with name name and update the input field accordingly. Can be called from any thread. If a mutex was provided it is locked while the options are accessed. In a multithreaded program this is usually after this function returns.
References OptWidget::customEvent().
|
slot |
Read out the values of all options and update their input fields accordingly. If a mutex was provided it is locked while the options are accessed. In a multithreaded program this is usually after this function returns.
References OptWidget::customEvent().
|
slot |
Read out the values of all options that have flag set and update their input fields accordingly. The flag is automatically removed from all options if delflags is set true
. If a mutex was provided it is locked while the options are accessed. In a multithreaded program this is usually after this function returns.
References OptWidget::customEvent().
|
slot |
Read out the value, range, stepsize, and unit of the option with name name and update the input field accordingly. If a mutex was provided it is locked while the options are accessed. In a multithreaded program this is usually after this function returns.
References OptWidget::customEvent().
|
slot |
Read out the value, range, stepsize, and unit of all options and update their input fields accordingly. If a mutex was provided it is locked while the options are accessed. In a multithreaded program this is usually after this function returns.
References OptWidget::customEvent().
|
slot |
Read out the value, range, stepsize, and unit of all options that have flag set and update their input fields accordingly. The flag is automatically removed from all options if delflags is set true
. If a mutex was provided it is locked while the options are accessed. In a multithreaded program this is usually after this function returns.
References OptWidget::customEvent().
|
signal |
This signal is emitted by accept().
Referenced by OptWidget::accept(), and OptWidget::acceptNotify().
|
signal |
This signal is emitted whenever a widget changes its value. p contains the name of the corresponding Parameter and the new value from the widget.
|
protectedvirtual |
References OptWidget::tryLockMutex(), and OptWidget::unlockMutex().
Referenced by OptWidget::updateSettings(), OptWidget::updateValue(), and OptWidget::updateValues().
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
static |
Use normal sized font for the label.
|
static |
Use small sized font for the label.
|
static |
Use large sized font for the label.
|
static |
Use huge sized font for the label.
|
static |
Use bold font for label.
|
static |
Use italic font for label.
|
static |
Use black color for label.
|
static |
Use red color for label.
|
static |
Use green color for label.
|
static |
Use blue color for label.
|
static |
Use standard background for label.
|
static |
Use black background for label.
|
static |
Use white background for label.
|
static |
Use normal sized font for the value.
|
static |
Use small sized font for the value.
Referenced by OptWidgetNumber::OptWidgetNumber().
|
static |
Use large sized font for the value.
Referenced by OptWidgetNumber::OptWidgetNumber().
|
static |
Use huge sized font for the value.
Referenced by OptWidgetNumber::OptWidgetNumber().
|
static |
Use bold font for value.
|
static |
Use italic font for value.
|
static |
Use black color for value.
|
static |
Use red color for value.
|
static |
Use green color for value.
|
static |
Use blue color for value.
|
static |
Use standard background for value.
|
static |
Use black background for value.
|
static |
Use white background for value.
|
static |
Use normal sized font for the label and the value.
|
static |
Use small sized font for the label and the value.
|
static |
Use large sized font for the label and the value.
|
static |
Use italic font for label and the value.
|
static |
Use black color for label and the value.
|
static |
Use green color for label and the value.
|
static |
Use black background for label and the value.
|
static |
Use white background for label and the value.
|
static |
If set you can only select from text options with multiple values, but not add new values.
Referenced by ComboItemDelegate::createEditor(), OptWidgetMultiText::OptWidgetMultiText(), and OptWidgetText::OptWidgetText().
|
static |
Allow mutliple values to be selected.
|
static |
Enables auto completion mode of editable combo boxes.
Referenced by ComboItemDelegate::createEditor(), and OptWidgetMultiText::OptWidgetMultiText().
|
static |
Browse for existing file.
Referenced by OptWidgetText::browse().
|
static |
Browse for any file.
Referenced by OptWidgetText::browse().
|
static |
Browse for directories.
Referenced by OptWidgetText::browse(), and OptWidgetText::doBrowse().
|
static |
Browse for some file or directory.
Referenced by OptWidgetText::OptWidgetText().
|
static |
Do not strip the current working directory from the path.
Referenced by OptWidgetText::doBrowse().
|
static |
Use LCD numbers to display a number.
Referenced by OptWidgetNumber::OptWidgetNumber(), and OptWidgetNumber::reset().
|
static |
For number options: instead of minimum value display "infinite".
Referenced by NumberItemDelegate::createEditor(), and OptWidgetNumber::OptWidgetNumber().
|
static |
For number options: instead of minimum value display "none".
Referenced by NumberItemDelegate::createEditor(), and OptWidgetNumber::OptWidgetNumber().
|
static |
Section is a new tab.
Referenced by OptWidget::assign().
|
static |
Try to format label as a mathematical equation.
Referenced by OptWidgetSection::OptWidgetSection().
|
static |
Put request string and value in separate lines.
|
static |
Insert extra space between two options.
|
static |
Top level sections are introducing new tabs.
Referenced by OptWidget::assign().
|
static |
Print the options name in front of the request string.
|
static |
Print the options name behind the request string.
Referenced by ConfigDialog::ConfigDialog().
|
static |
Use a different font for the option's name. Only used in combination with NameFrontStyle or NameBehindStyle.
Referenced by ConfigDialog::ConfigDialog().
|
static |
Display all section names using a bold font.
|
static |
Hide inactivated options.
Referenced by OptWidgetBase::activateOption().