* ./vslsisapd/src/configuration:

- New: In Parameter, adds a priority for all the mutators method calls.
        Allows to sets values according to where they came from instead of
        only taking the last change. This is needed because we cannot ensure
        that the last sets value is the truly wanted one. Four priorities
        are avalaibles (in increasing order):
          1. - ApplicationBuiltin (the default).
          2. - ConfigurationFile  (currently: the XML parser).
          3. - CommandLine        (supplied by the command line, see Unicorn).
          4. - Interactive        (changed through ConfigurationWidget).
    - New: In ConfigurationWidget, hideTabs()/showTabs() to explicitly select
        which tabs are displayeds or hidden. Two modes are avalaibles:
        Incremental and Exact. In Exact mode only hidden tabs are hiddens and
        only shown tabs are shown.
    - Change: In ConfigurationWidget/ConfTabWidget/ParameterWidget, no longer
        relies on the Widget parent/child tree to find the ConfigurationWidget
        from a ParameterWidget (consequence of the hide/show capability which
        is implemented by cutting off hidden tabs). Adds an explicit attribute.
This commit is contained in:
Jean-Paul Chaput 2010-11-16 13:51:14 +00:00
parent 7506bae16e
commit a9d0783026
11 changed files with 276 additions and 138 deletions

View File

@ -54,7 +54,7 @@ int main ( int argc, char* argv[] )
options.add_options()
( "help,h" , "Print this help." )
( "disable-gtkstyle", boptions::bool_switch(&disableGtkStyle)->default_value(false)
, "Run the detailed router (Kite).")
, "Do not uses GtkStyle (due to the File/Open native dialog bug).")
( "conf,c" , boptions::value<string>()
, "The path of the configuration file." );
@ -93,9 +93,9 @@ int main ( int argc, char* argv[] )
}
ConfEditorWidget* editor = new ConfEditorWidget ();
//editor->getConfigurationWidget()->selectTab ( "Kite" );
editor->show ();
//QFileDialog::getOpenFileName(NULL, "Choose file", "", "");
//editor->getConfigurationWidget()->selectTab ( "Kite" );
//editor->getConfigurationWidget()->hideTabs ( "Kite;Mauka" );
returnCode = qa->exec ();
}

View File

@ -49,11 +49,12 @@ namespace Cfg {
// Class : "Cfg::ConfTabWidget".
ConfTabWidget::ConfTabWidget ( const string& name, QWidget* parent )
ConfTabWidget::ConfTabWidget ( ConfigurationWidget* parent, const string& name )
: QWidget (parent)
, _gridLayout(new QGridLayout())
, _columns (2)
, _rowsCount (new int[_columns])
, _confWidget(parent)
, _parameters()
{
for ( int i=0 ; i<_columns ; ++i ) _rowsCount[i] = 0;
@ -108,10 +109,13 @@ namespace Cfg {
}
ConfigurationWidget* ConfTabWidget::getConfigurationWidget ()
{ return _confWidget; }
QFont& ConfTabWidget::getParentBoldFont ()
{
ConfigurationWidget* cw = rparent<ConfigurationWidget*> ( this );
return cw->getBoldFont();
return _confWidget->getBoldFont();
}
@ -150,8 +154,7 @@ namespace Cfg {
, int span
, int flags )
{
ConfigurationWidget* cw = rparent<ConfigurationWidget*> ( this );
ParameterWidget* pw = cw->find(parameter);
ParameterWidget* pw = _confWidget->find(parameter);
if ( pw != NULL ) {
cerr << "[ERROR] Parameter <" << parameter->getId() << "> already added." << endl;

View File

@ -162,6 +162,7 @@ namespace {
_parameter = _configuration->addParameter ( attrId
, type
, _getAttributeValue("value")
, Parameter::ConfigurationFile
);
} else {
_parameter->setString ( _getAttributeValue("value")
@ -427,7 +428,8 @@ namespace Cfg {
Parameter* Configuration::addParameter ( const string& id
, Parameter::Type type
, const string& value )
, const string& value
, int priority )
{
Parameter* p = getParameter ( id );
if ( p != NULL ) {
@ -435,7 +437,7 @@ namespace Cfg {
return p;
}
p = new Parameter ( id, type, value );
p = new Parameter ( id, type, value, priority );
_parameters.insert ( make_pair(id,p) );
return p;

View File

@ -58,14 +58,15 @@ namespace Cfg {
ConfigurationWidget::ConfigurationWidget ( unsigned int flags, QWidget* parent )
: QWidget (parent)
, _flags (flags)
, _boldFont (QApplication::font())
, _tabWidget(new QTabWidget())
, _apply (new QPushButton())
, _save (NULL)
, _cancel (NULL)
, _log (NULL)
: QWidget (parent)
, _flags (flags)
, _boldFont (QApplication::font())
, _tabWidget (new QTabWidget())
, _apply (new QPushButton())
, _save (NULL)
, _cancel (NULL)
, _tabWidgets()
, _log (NULL)
{
_boldFont.setBold ( true );
@ -111,21 +112,21 @@ namespace Cfg {
void ConfigurationWidget::addRuler ( const string& tabName )
{
ConfTabWidget* tab = findOrCreate ( tabName );
ConfTabWidget* tab = findOrCreateTab ( tabName );
tab->addRuler ();
}
void ConfigurationWidget::addTitle ( const string& tabName, const string& title )
{
ConfTabWidget* tab = findOrCreate ( tabName );
ConfTabWidget* tab = findOrCreateTab ( tabName );
tab->addTitle ( title );
}
void ConfigurationWidget::addSection ( const string& tabName, const string& section, int column )
{
ConfTabWidget* tab = findOrCreate ( tabName );
ConfTabWidget* tab = findOrCreateTab ( tabName );
tab->addSection ( section, column );
}
@ -143,7 +144,7 @@ namespace Cfg {
return pw;
}
ConfTabWidget* tab = findOrCreate ( tabName );
ConfTabWidget* tab = findOrCreateTab ( tabName );
return tab->addParameter ( parameter, label, column, span, flags );
}
@ -159,13 +160,16 @@ namespace Cfg {
{ return findChild<ParameterWidget*>(id.c_str()); }
ConfTabWidget* ConfigurationWidget::findOrCreate ( const string& tabName )
ConfTabWidget* ConfigurationWidget::findOrCreateTab ( const string& tabName )
{
ConfTabWidget* tab = findChild<ConfTabWidget*>(tabName.c_str());
//ConfTabWidget* tab = findChild<ConfTabWidget*>(tabName.c_str());
ConfTabWidget* tab = findTab(tabName,AllTabs);
if ( tab != NULL ) return tab;
tab = new ConfTabWidget ( tabName );
tab = new ConfTabWidget ( this, tabName );
_tabWidget->addTab ( tab, tabName.c_str() );
_tabWidgets.push_back ( tab );
connect ( this, SIGNAL(updateParameters()), tab, SIGNAL(updateParameters()) );
if (_save)
@ -219,15 +223,79 @@ namespace Cfg {
}
void ConfigurationWidget::selectTab ( const std::string& tabName )
ConfTabWidget* ConfigurationWidget::findTab ( const std::string& tabName, int mode )
{
QString qtabName ( tabName.c_str() );
for ( int itab=0 ; itab<_tabWidget->count() ; ++itab ) {
if ( _tabWidget->tabText(itab) == qtabName ) {
_tabWidget->setCurrentIndex ( itab );
return;
if ( mode & ShownTabs ) {
for ( int itab=0 ; itab<_tabWidgets.size() ; ++itab ) {
if ( _tabWidgets[itab]->objectName() == qtabName ) return _tabWidgets[itab];
}
} else {
// AllTabs.
for ( int itab=0 ; itab<_tabWidget->count() ; ++itab ) {
if ( _tabWidget->tabText(itab) == qtabName ) {
return qobject_cast<ConfTabWidget*>(_tabWidget->widget(itab));
}
}
}
return NULL;
}
void ConfigurationWidget::selectTab ( const std::string& tabName )
{
ConfTabWidget* tab = findTab ( tabName, ShownTabs );
if ( tab ) _tabWidget->setCurrentWidget ( tab );
}
void ConfigurationWidget::showTabs ( const std::string& tabNames, int mode )
{
_tabWidget->setUpdatesEnabled ( false );
QString qtabNames ( tabNames.c_str() );
QStringList qtabList = qtabNames.split ( ";" );
if ( mode & ExactSet ) _tabWidget->clear ();
int insertIndex = 0;
for ( int itab=0 ; itab<_tabWidgets.size() ; ++itab ) {
ConfTabWidget* tab = _tabWidgets[itab];
int tabIndex = _tabWidget->indexOf ( tab );
if ( (tabIndex < 0) and qtabList.contains(tab->objectName()) ) {
tabIndex = _tabWidget->insertTab ( insertIndex, tab, tab->objectName() );
}
if ( tabIndex >= 0 ) insertIndex = tabIndex+1;
}
_tabWidget->setUpdatesEnabled ( true );
}
void ConfigurationWidget::hideTabs ( const std::string& tabNames, int mode )
{
_tabWidget->setUpdatesEnabled ( false );
QString qtabNames ( tabNames.c_str() );
QStringList qtabList = qtabNames.split ( ";" );
if ( mode & ExactSet ) _tabWidget->clear ();
for ( int itab=0 ; itab<_tabWidgets.size() ; ++itab ) {
ConfTabWidget* tab = _tabWidgets[itab];
int tabIndex = _tabWidget->indexOf ( tab );
if ( (tabIndex >= 0) and qtabList.contains(tab->objectName()) )
_tabWidget->removeTab ( tabIndex );
if ( (mode & ExactSet) and not qtabList.contains(tab->objectName()) )
_tabWidget->addTab ( tab, tab->objectName() );
}
_tabWidget->setUpdatesEnabled ( true );
}

View File

@ -58,15 +58,21 @@ namespace Cfg {
Parameter::Parameter ( const std::string& id
, Type type
, const std::string& value )
, const std::string& value
, int priority
)
: _id (id)
, _type (type)
, _value (value)
, _values ()
, _priority (priority)
, _flags (0)
, _minInt (0)
, _maxInt (0)
, _minDouble(0.0)
, _maxDouble(0.0)
, _slaves ()
, _callbacks()
{
if ( type == Percentage ) {
setPercentage ( asDouble() );
@ -134,8 +140,11 @@ namespace Cfg {
}
bool Parameter::setString ( const std::string& s, unsigned int flags )
bool Parameter::setString ( const std::string& s, unsigned int flags, int priority )
{
if ( priority < _priority ) return false;
_priority = priority;
if ( (flags & TypeCheck) and (_type != String) )
cerr << "[ERROR] Parameter::setString(): Setting " << Parameter::typeToString(_type)
<< " parameter <" << _id
@ -145,8 +154,11 @@ namespace Cfg {
}
bool Parameter::setBool ( bool b )
bool Parameter::setBool ( bool b, int priority )
{
if ( priority < _priority ) return false;
_priority = priority;
if ( _type != Bool )
cerr << "[ERROR] Parameter::setBool(): Setting " << Parameter::typeToString(_type)
<< " parameter <" << _id
@ -156,8 +168,11 @@ namespace Cfg {
}
bool Parameter::setInt ( int i )
bool Parameter::setInt ( int i, int priority )
{
if ( priority < _priority ) return false;
_priority = priority;
if ( (_type != Int) and (_type != Enumerate) )
cerr << "[ERROR] Parameter::setInt(): Setting " << Parameter::typeToString(_type)
<< " parameter <" << _id
@ -167,8 +182,11 @@ namespace Cfg {
}
bool Parameter::setDouble ( double d )
bool Parameter::setDouble ( double d, int priority )
{
if ( priority < _priority ) return false;
_priority = priority;
if ( (_type != Double) and (_type != Percentage) )
cerr << "[ERROR] Parameter::setDouble(): Setting " << Parameter::typeToString(_type)
<< " parameter <" << _id
@ -178,7 +196,7 @@ namespace Cfg {
}
bool Parameter::setPercentage ( double d )
bool Parameter::setPercentage ( double d, int priority )
{
if ( (_type != Double) and (_type != Percentage) )
cerr << "[ERROR] Parameter::setPercentage(): Setting " << Parameter::typeToString(_type)

View File

@ -34,6 +34,7 @@
#include "vlsisapd/configuration/Parameter.h"
#include "vlsisapd/configuration/FilePathEdit.h"
#include "vlsisapd/configuration/ParameterWidget.h"
#include "vlsisapd/configuration/ConfTabWidget.h"
#include "vlsisapd/configuration/ConfigurationWidget.h"
@ -47,12 +48,13 @@ namespace Cfg {
using std::ostringstream;
ParameterWidget::ParameterWidget ( QObject* parent, Parameter* parameter, const std::string& label, int flags )
: QObject (parent)
, _parameter (parameter)
, _labelWidget(new QLabel())
, _valueWidget(NULL)
, _flags (flags)
ParameterWidget::ParameterWidget ( ConfTabWidget* parent, Parameter* parameter, const std::string& label, int flags )
: QObject (parent)
, _confTabWidget(parent)
, _parameter (parameter)
, _labelWidget (new QLabel())
, _valueWidget (NULL)
, _flags (flags)
{
setObjectName ( _parameter->getId().c_str() );
@ -182,12 +184,12 @@ namespace Cfg {
if ( _parameter->getType() == Parameter::String )
{
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(_valueWidget);
_parameter->setString ( lineEdit->displayText().toStdString() );
_parameter->setString ( lineEdit->displayText().toStdString(), Parameter::Interactive );
}
else if ( _parameter->getType() == Parameter::Bool )
{
QCheckBox* checkBox = qobject_cast<QCheckBox*>(_valueWidget);
_parameter->setBool ( checkBox->isChecked() );
_parameter->setBool ( checkBox->isChecked(), Parameter::Interactive );
}
else if ( _parameter->getType() == Parameter::Int )
{
@ -195,14 +197,14 @@ namespace Cfg {
QSpinBox* spinBox = qobject_cast<QSpinBox*>(_valueWidget);
int value = spinBox->value();
if ( not _parameter->setInt(value) )
if ( not _parameter->setInt(value,Parameter::Interactive) )
spinBox->setValue ( _parameter->asInt() );
} else {
bool success;
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(_valueWidget);
int value = lineEdit->displayText().toInt ( &success );
if ( not success or not _parameter->setInt(value) )
if ( not success or not _parameter->setInt(value,Parameter::Interactive) )
lineEdit->setText ( _parameter->asString().c_str() );
}
}
@ -212,7 +214,7 @@ namespace Cfg {
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(_valueWidget);
double value = lineEdit->displayText().toFloat ( &success );
if ( not success or not _parameter->setDouble(value) )
if ( not success or not _parameter->setDouble(value,Parameter::Interactive) )
lineEdit->setText ( _parameter->asString().c_str() );
}
else if ( _parameter->getType() == Parameter::Percentage )
@ -221,7 +223,7 @@ namespace Cfg {
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(_valueWidget);
double value = lineEdit->displayText().toFloat ( &success );
if ( not success or not _parameter->setPercentage(value) ) {
if ( not success or not _parameter->setPercentage(value,Parameter::Interactive) ) {
lineEdit->setText ( _parameter->asPercentageString().c_str() );
}
}
@ -230,7 +232,7 @@ namespace Cfg {
QComboBox* comboBox = qobject_cast<QComboBox*>(_valueWidget);
const vector<Parameter::EnumValue>& values = _parameter->getValues();
_parameter->setInt ( values[comboBox->currentIndex()]._value );
_parameter->setInt ( values[comboBox->currentIndex()]._value, Parameter::Interactive );
}
}
@ -349,17 +351,11 @@ namespace Cfg {
void ParameterWidget::enableSlaves ( int state )
{
ConfigurationWidget* cw = rparent<ConfigurationWidget*> ( this );
if ( cw == NULL ) {
cerr << "[ERROR] ParameterWidget::enableSlaves(): Cannot find parent ConfigurationWidget." << endl;
return;
}
bool enabled = ( state != Qt::Unchecked );
const vector<string>& slaveIds = _parameter->getSlaves();
for ( size_t islave=0 ; islave<slaveIds.size() ; ++islave ) {
ParameterWidget* slave = cw->find(slaveIds[islave]);
ParameterWidget* slave = getConfigurationWidget()->find(slaveIds[islave]);
if ( slave == NULL ) continue;
slave->getLabelWidget()->setEnabled ( enabled );
@ -368,4 +364,8 @@ namespace Cfg {
}
ConfigurationWidget* ParameterWidget::getConfigurationWidget ()
{ return (_confTabWidget) ? _confTabWidget->getConfigurationWidget() : NULL; }
} // End of Cfg namespace.

View File

@ -45,24 +45,26 @@ namespace Cfg {
class ConfTabWidget : public QWidget {
Q_OBJECT;
public:
ConfTabWidget ( const std::string& name="<noname>", QWidget* parent=NULL );
virtual ~ConfTabWidget ();
public:
QFont& getParentBoldFont ();
void addRuler ();
void addTitle ( const std::string& title );
void addSection ( const std::string& section, int column=0 );
ParameterWidget* addParameter ( Parameter*, const std::string& label, int column=0, int span=1, int flags=0 );
signals:
void updateParameters ();
private:
int _getMaxRowCount ();
int _alignMaxRowCount ();
ConfTabWidget ( ConfigurationWidget* parent, const std::string& name="<noname>" );
virtual ~ConfTabWidget ();
public:
ConfigurationWidget* getConfigurationWidget ();
QFont& getParentBoldFont ();
void addRuler ();
void addTitle ( const std::string& title );
void addSection ( const std::string& section, int column=0 );
ParameterWidget* addParameter ( Parameter*, const std::string& label, int column=0, int span=1, int flags=0 );
signals:
void updateParameters ();
private:
int _getMaxRowCount ();
int _alignMaxRowCount ();
private:
QGridLayout* _gridLayout;
int _columns;
int _span;
int* _rowsCount;
ConfigurationWidget* _confWidget;
std::vector<ParameterWidget*> _parameters;
};

View File

@ -72,7 +72,8 @@ namespace Cfg {
, Parameter::Type type=Parameter::Unknown ) const;
Parameter* addParameter ( const std::string& id
, Parameter::Type type
, const std::string& value );
, const std::string& value
, int priority=0 );
inline void setFlags ( unsigned int mask );
inline bool hasLogs ( unsigned int mask ) const;
void addLog ( unsigned int mask, const std::string& id );

View File

@ -29,6 +29,7 @@
#include <QFont>
#include <QWidget>
#include <QVector>
class QPushButton;
class QTabWidget;
@ -49,7 +50,13 @@ namespace Cfg {
class ConfigurationWidget : public QWidget {
Q_OBJECT;
public:
enum Flags { Embedded=0x1, StandAlone=0x2 };
enum Flags { Embedded = 0x1
, StandAlone = 0x2
, AllTabs = 0x1
, ShownTabs = 0x2
, ExactSet = 0x4
, IncrementalSet = 0x8
};
public:
ConfigurationWidget ( unsigned int flags, QWidget* parent=NULL );
public:
@ -59,7 +66,8 @@ namespace Cfg {
inline QPushButton* getCancelButton ();
ParameterWidget* find ( Parameter* ) const;
ParameterWidget* find ( const std::string& id ) const;
ConfTabWidget* findOrCreate ( const std::string& name );
ConfTabWidget* findTab ( const std::string& name, int mode );
ConfTabWidget* findOrCreateTab ( const std::string& name );
void addRuler ( const std::string& tabName );
void addTitle ( const std::string& tabName
, const std::string& title );
@ -74,6 +82,8 @@ namespace Cfg {
, int flags =0 );
void syncSlaves ();
void selectTab ( const std::string& );
void showTabs ( const std::string&, int mode=IncrementalSet );
void hideTabs ( const std::string&, int mode=IncrementalSet );
public slots:
void applyClicked ();
signals:
@ -81,13 +91,14 @@ namespace Cfg {
void confOk ();
void needRestart ();
private:
unsigned int _flags;
QFont _boldFont;
QTabWidget* _tabWidget;
QPushButton* _apply;
QPushButton* _save;
QPushButton* _cancel;
LogWidget* _log;
unsigned int _flags;
QFont _boldFont;
QTabWidget* _tabWidget;
QPushButton* _apply;
QPushButton* _save;
QPushButton* _cancel;
QVector<ConfTabWidget*> _tabWidgets;
LogWidget* _log;
};

View File

@ -38,24 +38,29 @@ namespace Cfg {
class Parameter {
public:
enum Type { Unknown = 0
, String = 1
, Bool = 2
, Int = 3
, Enumerate = 4
, Double = 5
, Percentage = 6
};
enum Flags { HasMin = 0x01
, HasMax = 0x02
, IsFile = 0x04
, IsPath = 0x08
, NeedRestart = 0x10
, MustExist = 0x20
, TypeCheck = 0x40
, FromString = 0x80
, AllRequirements = HasMin|HasMax|IsFile|IsPath|NeedRestart|MustExist|TypeCheck
};
enum Type { Unknown = 0
, String = 1
, Bool = 2
, Int = 3
, Enumerate = 4
, Double = 5
, Percentage = 6
};
enum Flags { HasMin = 0x01
, HasMax = 0x02
, IsFile = 0x04
, IsPath = 0x08
, NeedRestart = 0x10
, MustExist = 0x20
, TypeCheck = 0x40
, FromString = 0x80
, AllRequirements = HasMin|HasMax|IsFile|IsPath|NeedRestart|MustExist|TypeCheck
};
enum Priority { ApplicationBuiltin = 1
, ConfigurationFile = 2
, CommandLine = 3
, Interactive = 4
};
typedef boost::function< void(Parameter*) > ParameterChangedCb_t;
public:
class EnumValue {
@ -70,7 +75,8 @@ namespace Cfg {
public:
Parameter ( const std::string& id
, Type type
, const std::string& value );
, const std::string& value
, int priority=0 );
inline bool isFile () const;
inline bool isPath () const;
inline bool hasMin () const;
@ -99,17 +105,21 @@ namespace Cfg {
double asPercentage () const;
inline void addValue ( const std::string&, int );
inline void addSlave ( const std::string& );
inline void setPriority ( int );
inline void setFlags ( int mask );
inline void unsetFlags ( int mask );
bool setString ( const std::string&, unsigned int flags=AllRequirements );
bool setBool ( bool );
bool setInt ( int );
bool setDouble ( double );
bool setPercentage ( double );
inline void setMin ( int );
inline void setMax ( int );
inline void setMin ( double );
inline void setMax ( double );
bool setString ( const std::string&
, unsigned int flags=AllRequirements
, int priority=ApplicationBuiltin
);
bool setBool ( bool , int priority=ApplicationBuiltin );
bool setInt ( int , int priority=ApplicationBuiltin );
bool setDouble ( double, int priority=ApplicationBuiltin );
bool setPercentage ( double, int priority=ApplicationBuiltin );
inline void setMin ( int , int priority=ApplicationBuiltin );
inline void setMax ( int , int priority=ApplicationBuiltin );
inline void setMin ( double, int priority=ApplicationBuiltin );
inline void setMax ( double, int priority=ApplicationBuiltin );
inline void registerCb ( ParameterChangedCb_t );
private:
inline void _onValueChanged ();
@ -120,6 +130,7 @@ namespace Cfg {
Type _type;
std::string _value;
std::vector<EnumValue> _values;
int _priority;
int _flags;
int _minInt;
int _maxInt;
@ -146,6 +157,9 @@ namespace Cfg {
inline double Parameter::getMinDouble () const { return _minDouble; }
inline double Parameter::getMaxDouble () const { return _maxDouble; }
inline const std::string& Parameter::asString () const { return _value; }
inline void Parameter::setFlags ( int mask ) { _flags |= mask; }
inline void Parameter::unsetFlags ( int mask ) { _flags &= ~mask; }
inline void Parameter::setPriority ( int priority ) { _priority = priority; }
inline bool Parameter::checkValue ( int value ) const {
bool ok = not ( ( (_flags&HasMin) and (value < _minInt) )
@ -178,16 +192,29 @@ namespace Cfg {
_values.push_back ( EnumValue(label,value) );
}
inline void Parameter::setFlags ( int mask ) { _flags |= mask; }
inline void Parameter::unsetFlags ( int mask ) { _flags &= ~mask; }
inline void Parameter::setMin ( int min ) { _minInt = min; setFlags(HasMin); }
inline void Parameter::setMax ( int max ) { _maxInt = max; setFlags(HasMax); }
inline void Parameter::setMin ( int min, int priority )
{ if (priority >= _priority) { _priority=priority; _minInt = min; setFlags(HasMin); } }
inline void Parameter::setMax ( int max, int priority )
{ if (priority >= _priority) { _priority=priority; _maxInt = max; setFlags(HasMax); } }
inline void Parameter::setMin ( double min )
{ _minDouble = min; setFlags(HasMin); if (_type==Percentage) _minDouble/=100.0; }
inline void Parameter::setMin ( double min, int priority )
{ if (priority >= _priority) {
_priority = priority;
_minDouble = min;
setFlags ( HasMin );
if (_type==Percentage) _minDouble/=100.0;
}
}
inline void Parameter::setMax ( double max )
{ _maxDouble = max; setFlags(HasMax); if (_type==Percentage) _maxDouble/=100.0; }
inline void Parameter::setMax ( double max, int priority )
{ if (priority >= _priority) {
_priority = priority;
_maxDouble = max;
setFlags ( HasMax );
if (_type==Percentage) _maxDouble/=100.0;
}
}
inline Parameter::EnumValue::EnumValue ( const std::string& label, int value )
: _label(label), _value(value) { }

View File

@ -35,6 +35,8 @@ class QLabel;
namespace Cfg {
class Parameter;
class ConfTabWidget;
class ConfigurationWidget;
// -------------------------------------------------------------------
@ -46,34 +48,38 @@ namespace Cfg {
public:
enum Flags { UseSpinBox=0x1, IsFileName=0x2, IsPathName=0x4 };
public:
ParameterWidget ( QObject* parent, Parameter*, const std::string& label, int flags );
inline Parameter* getParameter ();
inline QLabel* getLabelWidget ();
inline QWidget* getValueWidget ();
inline int getFlags () const;
inline bool hasFlags ( int mask ) const;
inline void setFlags ( int mask );
inline void unsetFlags ( int mask );
void onUpdateValueCb ( Parameter* );
public slots:
void updateValue ();
void enableSlaves ( int );
ParameterWidget ( ConfTabWidget* parent, Parameter*, const std::string& label, int flags );
inline Parameter* getParameter ();
inline QLabel* getLabelWidget ();
inline QWidget* getValueWidget ();
inline ConfTabWidget* getConfTabWidget ();
ConfigurationWidget* getConfigurationWidget ();
inline int getFlags () const;
inline bool hasFlags ( int mask ) const;
inline void setFlags ( int mask );
inline void unsetFlags ( int mask );
void onUpdateValueCb ( Parameter* );
public slots:
void updateValue ();
void enableSlaves ( int );
public:
Parameter* _parameter;
QLabel* _labelWidget;
QWidget* _valueWidget;
int _flags;
ConfTabWidget* _confTabWidget;
Parameter* _parameter;
QLabel* _labelWidget;
QWidget* _valueWidget;
int _flags;
};
// Inline Methods.
inline Parameter* ParameterWidget::getParameter () { return _parameter; }
inline QLabel* ParameterWidget::getLabelWidget () { return _labelWidget; }
inline QWidget* ParameterWidget::getValueWidget () { return _valueWidget; }
inline int ParameterWidget::getFlags () const { return _flags; }
inline bool ParameterWidget::hasFlags ( int mask ) const { return (_flags & mask); }
inline void ParameterWidget::setFlags ( int mask ) { _flags |= mask; }
inline void ParameterWidget::unsetFlags ( int mask ) { _flags &= ~mask; }
inline Parameter* ParameterWidget::getParameter () { return _parameter; }
inline QLabel* ParameterWidget::getLabelWidget () { return _labelWidget; }
inline QWidget* ParameterWidget::getValueWidget () { return _valueWidget; }
inline ConfTabWidget* ParameterWidget::getConfTabWidget () { return _confTabWidget; }
inline int ParameterWidget::getFlags () const { return _flags; }
inline bool ParameterWidget::hasFlags ( int mask ) const { return (_flags & mask); }
inline void ParameterWidget::setFlags ( int mask ) { _flags |= mask; }
inline void ParameterWidget::unsetFlags ( int mask ) { _flags &= ~mask; }
} // End of Cfg namespace.