From c5427574a8f6e74979f439d3ef25b9bb721c400f Mon Sep 17 00:00:00 2001 From: Jean-Paul Chaput Date: Wed, 15 Sep 2010 21:46:42 +0000 Subject: [PATCH] * ./vslsisapd/src/configuration: - New: In Configuration, write methods are ables to completly drive the XML file (values & layout), selectable through flags. - New: In ConfigurationWidget, the Apply button is now outside the tabs. Also adds two modes: Embedded & StandAlone with different sets of buttons. --- .../configuration/src/ConfEditorWidget.cpp | 4 +- .../src/configuration/src/ConfTabWidget.cpp | 33 ++-- .../src/configuration/src/Configuration.cpp | 94 ++++++++-- .../configuration/src/ConfigurationWidget.cpp | 86 ++++++++- .../configuration/src/LayoutDescription.cpp | 164 ++++++++++++++---- .../src/configuration/src/ParameterWidget.cpp | 3 + .../vlsisapd/configuration/ConfTabWidget.h | 3 +- .../vlsisapd/configuration/Configuration.h | 9 +- .../configuration/ConfigurationWidget.h | 56 ++++-- .../configuration/LayoutDescription.h | 40 +++-- 10 files changed, 389 insertions(+), 103 deletions(-) diff --git a/vlsisapd/src/configuration/src/ConfEditorWidget.cpp b/vlsisapd/src/configuration/src/ConfEditorWidget.cpp index 24aa9726..d7e2acf1 100644 --- a/vlsisapd/src/configuration/src/ConfEditorWidget.cpp +++ b/vlsisapd/src/configuration/src/ConfEditorWidget.cpp @@ -39,7 +39,7 @@ namespace Cfg { ConfEditorWidget::ConfEditorWidget ( QWidget* parent ) : QMainWindow (parent) - , _configurationWidget (Configuration::get()->buildWidget()) + , _configurationWidget (Configuration::get()->buildWidget(ConfigurationWidget::StandAlone)) , _fileMenu (NULL) , _saveAction (NULL) , _quitAction (NULL) @@ -90,7 +90,7 @@ namespace Cfg { cout << "Saving configuration file: <" << dotConfigFile << ">."<< endl; - Configuration::get()->writeToStream ( file ); + Configuration::get()->writeToStream ( file, Configuration::DriveValues|Configuration::DriveLayout ); file.close (); } diff --git a/vlsisapd/src/configuration/src/ConfTabWidget.cpp b/vlsisapd/src/configuration/src/ConfTabWidget.cpp index e1a1f419..46b8a71e 100644 --- a/vlsisapd/src/configuration/src/ConfTabWidget.cpp +++ b/vlsisapd/src/configuration/src/ConfTabWidget.cpp @@ -29,7 +29,6 @@ #include #include #include -#include #include #include "vlsisapd/configuration/Configuration.h" @@ -62,22 +61,10 @@ namespace Cfg { setObjectName ( name.c_str() ); QVBoxLayout* vLayout = new QVBoxLayout (); - vLayout->addLayout ( _gridLayout ); - - QHBoxLayout* hLayout = new QHBoxLayout (); - hLayout->addStretch (); - - QPushButton* apply = new QPushButton (); - apply->setText ( tr("Apply") ); - hLayout->addWidget ( apply ); - hLayout->addStretch (); - - vLayout->addLayout ( hLayout ); + vLayout->addLayout ( _gridLayout ); vLayout->addStretch (); setLayout ( vLayout ); - - connect ( apply, SIGNAL(clicked()), this, SIGNAL(updateParameters()) ); } @@ -157,7 +144,11 @@ namespace Cfg { } - ParameterWidget* ConfTabWidget::addParameter ( Parameter* parameter, const std::string& label, int column, int flags ) + ParameterWidget* ConfTabWidget::addParameter ( Parameter* parameter + , const std::string& label + , int column + , int span + , int flags ) { ConfigurationWidget* cw = rparent ( this ); ParameterWidget* pw = cw->find(parameter); @@ -173,15 +164,23 @@ namespace Cfg { if ( column < 0 ) column = 0; else column = _columns-1; } + if ( span < 0 ) span = 1; + if ( (column+span > _columns) ) span = _columns - column; + if ( span > 1 ) _alignMaxRowCount (); + + int qspan = 2*span-1; + //cerr << parameter->getId() << " span:" << span << " " << qspan << endl; pw = new ParameterWidget ( this, parameter, label, flags ); - _gridLayout->addWidget ( pw->getLabelWidget(), row, column*2, Qt::AlignRight ); - _gridLayout->addWidget ( pw->getValueWidget(), row, 1+column*2, Qt::AlignLeft ); + _gridLayout->addWidget ( pw->getLabelWidget(), row, column*2 , Qt::AlignRight ); + _gridLayout->addWidget ( pw->getValueWidget(), row, column*2+1, 1, qspan, Qt::AlignLeft ); connect ( this, SIGNAL(updateParameters()), pw, SLOT(updateValue()) ); _rowsCount[column]++; + if ( span > 1 ) _alignMaxRowCount (); + return pw; } diff --git a/vlsisapd/src/configuration/src/Configuration.cpp b/vlsisapd/src/configuration/src/Configuration.cpp index eafe7f5b..432c902a 100644 --- a/vlsisapd/src/configuration/src/Configuration.cpp +++ b/vlsisapd/src/configuration/src/Configuration.cpp @@ -24,7 +24,9 @@ #include +#include #include +#include #include #include "vlsisapd/configuration/Configuration.h" #include "vlsisapd/configuration/ConfigurationWidget.h" @@ -62,14 +64,14 @@ namespace { }; - XmlParser::XmlParser ( Configuration* conf - , const string& fileName ) - : _configuration (conf) - , _fileName (fileName) - , _reader (NULL) - , _status (1) - , _tool ("") - , _parameter (NULL) + XmlParser::XmlParser ( Configuration* conf + , const string& fileName ) + : _configuration(conf) + , _fileName (fileName) + , _reader (NULL) + , _status (1) + , _tool ("") + , _parameter (NULL) { } @@ -275,6 +277,7 @@ namespace { string attrType = _getAttributeValue("type"); string attrLabel = _getAttributeValue("label"); string attrColumn = _getAttributeValue("column"); + string attrSpan = _getAttributeValue("span"); string attrSpinBox = _getAttributeValue("spinbox"); if ( attrId.empty() and attrType.empty() ) { @@ -287,6 +290,11 @@ namespace { istringstream s ( attrColumn ); s >> column; } + int span = 1; + if ( not attrSpan.empty() ) { + istringstream s ( attrSpan ); s >> span; + } + if ( not attrType.empty() ) { if ( attrType == "title" ) _configuration->getLayout().getBackTab()->addWidget ( WidgetDescription::title (attrLabel) ); if ( attrType == "section" ) _configuration->getLayout().getBackTab()->addWidget ( WidgetDescription::section(attrLabel,column) ); @@ -303,7 +311,7 @@ namespace { int flags = 0; if ( attrSpinBox == "true" ) flags |= ParameterWidget::UseSpinBox; - _configuration->getLayout().getBackTab()->addWidget ( WidgetDescription::parameter(attrId,attrLabel,column,flags) ); + _configuration->getLayout().getBackTab()->addWidget ( WidgetDescription::parameter(attrId,attrLabel,column,span,flags) ); } @@ -328,7 +336,9 @@ namespace Cfg { using std::string; using std::map; using std::ostream; + using std::ofstream; using std::setw; + using std::vector; Configuration* Configuration::_singleton = NULL; @@ -347,8 +357,8 @@ namespace Cfg { { } - ConfigurationWidget* Configuration::buildWidget () - { return _layout.buildWidget(); } + ConfigurationWidget* Configuration::buildWidget ( unsigned int flags ) + { return _layout.buildWidget(flags); } Parameter* Configuration::getParameter ( const string& name, Parameter::Type type ) const @@ -424,7 +434,19 @@ namespace Cfg { } - void Configuration::writeToStream ( ostream& out ) const + bool Configuration::writeToFile ( const std::string& fileName, unsigned int flags ) const + { + ofstream out ( fileName.c_str() ); + if ( out.fail() ) return false; + + writeToStream ( out, flags ); + + out.close (); + return true; + } + + + void Configuration::writeToStream ( ostream& out, unsigned int flags ) const { out << "" << endl; @@ -435,7 +457,6 @@ namespace Cfg { string id = "\"" + p->getId() + "\""; string type = "\"" + Parameter::typeToString(p->getType()) + "\""; - out << " " << endl; + if ( flags & DriveValues ) { + if ( p->getType() == Parameter::Int ) { + if ( p->hasFlags(Parameter::HasMin) ) out << " min=\"" << p->getMinInt() << "\""; + if ( p->hasFlags(Parameter::HasMax) ) out << " max=\"" << p->getMaxInt() << "\""; + } else if ( p->getType() == Parameter::Double ) { + if ( p->hasFlags(Parameter::HasMin) ) out << " min=\"" << p->getMinDouble() << "\""; + if ( p->hasFlags(Parameter::HasMax) ) out << " max=\"" << p->getMaxDouble() << "\""; + } + } + + if ( (flags&DriveValues) and (p->getType() == Parameter::Enumerate) ) { + out << ">" << endl; + + const std::vector& values = p->getValues(); + for ( size_t ivalue=0 ; ivalue" << endl; + } + + out << " " << endl; + } else + out << "/>" << endl; } + if ( flags & DriveValues ) { + for ( iparameter = _parameters.begin(); iparameter != _parameters.end(); ++iparameter ) { + Parameter* p = iparameter->second; + + const vector& slaves = p->getSlaves(); + if ( slaves.empty() ) continue; + + out << " " << endl; + out << " getId() << "\"/>" << endl; + + for ( size_t islave=0 ; islave" << endl; + } + out << " " << endl; + } + } + + if ( flags & DriveLayout ) _layout.writeToStream ( out ); + out << "" << endl; } - void Configuration::readFromFile ( const std::string& fileName ) + bool Configuration::readFromFile ( const std::string& fileName ) { XmlParser parser ( this, fileName ); - parser.parse (); + return parser.parse (); } diff --git a/vlsisapd/src/configuration/src/ConfigurationWidget.cpp b/vlsisapd/src/configuration/src/ConfigurationWidget.cpp index 00340168..3c9f16e6 100644 --- a/vlsisapd/src/configuration/src/ConfigurationWidget.cpp +++ b/vlsisapd/src/configuration/src/ConfigurationWidget.cpp @@ -23,8 +23,14 @@ // x-----------------------------------------------------------------x +#include +#include #include #include +#include +#include +#include +#include #include "vlsisapd/configuration/Configuration.h" #include "vlsisapd/configuration/ParameterWidget.h" @@ -39,19 +45,54 @@ namespace Cfg { using std::endl; using std::string; using std::map; + using std::pair; + using std::make_pair; + using std::vector; // ------------------------------------------------------------------- // Class : "Cfg::ConfigurationWidget". - ConfigurationWidget::ConfigurationWidget ( QWidget* parent ) - : QTabWidget(parent) + ConfigurationWidget::ConfigurationWidget ( unsigned int flags, QWidget* parent ) + : QWidget (parent) + , _flags (flags) , _boldFont (QApplication::font()) + , _tabWidget(new QTabWidget()) + , _apply (new QPushButton()) + , _save (NULL) + , _cancel (NULL) { _boldFont.setBold ( true ); setAttribute ( Qt::WA_QuitOnClose, false ); + + QVBoxLayout* vLayout = new QVBoxLayout (); + vLayout->addWidget ( _tabWidget ); + + QHBoxLayout* hLayout = new QHBoxLayout (); + hLayout->addStretch (); + + _apply->setText ( tr( (_flags&Embedded)?"Apply":"OK") ); + hLayout->addWidget ( _apply ); + hLayout->addStretch (); + + if ( _flags & StandAlone ) { + _save = new QPushButton (); + _save->setText ( tr("Save") ); + hLayout->addWidget ( _save ); + hLayout->addStretch (); + + _cancel = new QPushButton (); + _cancel->setText ( tr("Cancel") ); + hLayout->addWidget ( _cancel ); + hLayout->addStretch (); + } + + vLayout->addLayout ( hLayout ); + vLayout->addStretch (); + + setLayout ( vLayout ); } @@ -84,6 +125,7 @@ namespace Cfg { , Parameter* parameter , const std::string& label , int column + , int span , int flags ) { ParameterWidget* pw = find(parameter); @@ -93,7 +135,7 @@ namespace Cfg { } ConfTabWidget* tab = findOrCreate ( tabName ); - return tab->addParameter ( parameter, label, column, flags ); + return tab->addParameter ( parameter, label, column, span, flags ); } @@ -114,7 +156,9 @@ namespace Cfg { if ( tab != NULL ) return tab; tab = new ConfTabWidget ( tabName ); - addTab ( tab, tabName.c_str() ); + _tabWidget->addTab ( tab, tabName.c_str() ); + + connect ( _apply, SIGNAL(clicked()), tab, SIGNAL(updateParameters()) ); return tab; } @@ -134,6 +178,40 @@ namespace Cfg { pw->enableSlaves ( pw->getParameter()->asBool() ); } } + + + string toXml ( const string& source ) + { + static vector< pair > translations; + + if ( translations.empty() ) { + translations.push_back ( make_pair("&","&") ); + translations.push_back ( make_pair("<","<") ); + translations.push_back ( make_pair(">",">") ); + } + + string translated = source; + + for ( size_t pos=0 ; posgetName() == tabName ) return _tabs[itab]; + } - for ( size_t itab=0 ; itab<_tabs.size() ; ++itab ) { - const vector widgets = _tabs[itab]->getWidgets(); + addTab ( new TabDescription(tabName) ); + return getBackTab(); + } + - for ( size_t iwidget=0 ; iwidgetgetType() ) { - case WidgetDescription::Rule: - cw->addRuler ( _tabs[itab]->getName() ); - break; - case WidgetDescription::Title: - cw->addTitle ( _tabs[itab]->getName() - , widgets[iwidget]->getTitle() ); - break; - case WidgetDescription::Section: - cw->addSection ( _tabs[itab]->getName() - , widgets[iwidget]->getTitle() - , widgets[iwidget]->getColumn() ); - break; - case WidgetDescription::Parameter: - Parameter* parameter = _configuration->getParameter ( widgets[iwidget]->getId() ); - cw->addParameter ( _tabs[itab]->getName() - , parameter - , widgets[iwidget]->getLabel() - , widgets[iwidget]->getColumn() - , widgets[iwidget]->getFlags() ); - break; - } + void LayoutDescription::addRule ( const string& tabName ) + { + TabDescription* tab = getTab ( tabName ); + tab->addWidget ( WidgetDescription::rule() ); + } + + + void LayoutDescription::addTitle ( const string& tabName, const string& title ) + { + TabDescription* tab = getTab ( tabName ); + tab->addWidget ( WidgetDescription::title(title) ); + } + + + void LayoutDescription::addSection ( const string& tabName, const string& section, int column ) + { + TabDescription* tab = getTab ( tabName ); + tab->addWidget ( WidgetDescription::section(section,column) ); + } + + + void LayoutDescription::addParameter ( const string& tabName + , const string& id + , const string& label + , int column + , int span + , unsigned int flags ) + { + TabDescription* tab = getTab ( tabName ); + tab->addWidget ( WidgetDescription::parameter(id,label,column,span,flags) ); + } + + + ConfigurationWidget* LayoutDescription::buildWidget ( unsigned int flags ) + { + ConfigurationWidget* cw = new ConfigurationWidget ( flags ); + + for ( size_t itab=0 ; itab<_tabs.size() ; ++itab ) { + const vector widgets = _tabs[itab]->getWidgets(); + + for ( size_t iwidget=0 ; iwidgetgetType() ) { + case WidgetDescription::Rule: + cw->addRuler ( _tabs[itab]->getName() ); + break; + case WidgetDescription::Title: + cw->addTitle ( _tabs[itab]->getName() + , widgets[iwidget]->getLabel() ); + break; + case WidgetDescription::Section: + cw->addSection ( _tabs[itab]->getName() + , widgets[iwidget]->getLabel() + , widgets[iwidget]->getColumn() ); + break; + case WidgetDescription::Parameter: + Parameter* parameter = _configuration->getParameter ( widgets[iwidget]->getId() ); + cw->addParameter ( _tabs[itab]->getName() + , parameter + , widgets[iwidget]->getLabel() + , widgets[iwidget]->getColumn() + , widgets[iwidget]->getSpan() + , widgets[iwidget]->getFlags() ); + break; } } - - cw->syncSlaves (); - - return cw; } + cw->syncSlaves (); + + return cw; + } + + + void LayoutDescription::writeToStream ( ostream& out ) const + { + out << " " << endl; + + for ( size_t itab=0 ; itab<_tabs.size() ; ++itab ) { + out << " getName() << "\">" << endl; + + const vector& widgets = _tabs[itab]->getWidgets(); + for ( size_t iwidget=0 ; iwidgetgetType() ) { + case WidgetDescription::Rule: + out << "type=\"rule\""; + break; + case WidgetDescription::Title: + out << "type=\"title\" label=\"" << toXml(widget->getLabel()) << "\""; + break; + case WidgetDescription::Section: + out << "type=\"section\"" + << " label=\"" << widget->getLabel() << "\"" + << " column=\"" << widget->getColumn() << "\""; + break; + case WidgetDescription::Parameter: + out << " id=\"" << widget->getId() << "\"" + << " label=\"" << widget->getLabel() << "\"" + << " column=\"" << widget->getColumn() << "\""; + + if ( widget->getSpan() != 1 ) out << " span=\"" << widget->getSpan() << "\""; + if ( widget->getFlags() & ParameterWidget::UseSpinBox ) out << " spinbox=\"true\""; + break; + } + + out << "/>" << endl; + } + + out << " " << endl; + } + + out << " " << endl; + } + } // End of Cfg namespace. diff --git a/vlsisapd/src/configuration/src/ParameterWidget.cpp b/vlsisapd/src/configuration/src/ParameterWidget.cpp index c1fbc836..597231d8 100644 --- a/vlsisapd/src/configuration/src/ParameterWidget.cpp +++ b/vlsisapd/src/configuration/src/ParameterWidget.cpp @@ -63,6 +63,8 @@ namespace Cfg { case Parameter::String: { QLineEdit* lineEdit = new QLineEdit(); + lineEdit->setSizePolicy ( QSizePolicy::Expanding, QSizePolicy::Fixed ); + lineEdit->setMinimumWidth ( 375 ); lineEdit->setText ( QString("%1").arg(_parameter->asString().c_str()) ); _valueWidget = lineEdit; } @@ -151,6 +153,7 @@ namespace Cfg { int currentValue = _parameter->asInt(); int currentIndex = 0; QComboBox* comboBox = new QComboBox(); + //comboBox->setSizePolicy ( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ); const vector& values = _parameter->getValues(); for ( size_t i=0 ; i != values.size() ; ++i ) { comboBox->addItem ( values[i]._label.c_str(), values[i]._value ); diff --git a/vlsisapd/src/configuration/src/vlsisapd/configuration/ConfTabWidget.h b/vlsisapd/src/configuration/src/vlsisapd/configuration/ConfTabWidget.h index a9cb8bef..0b9a2217 100644 --- a/vlsisapd/src/configuration/src/vlsisapd/configuration/ConfTabWidget.h +++ b/vlsisapd/src/configuration/src/vlsisapd/configuration/ConfTabWidget.h @@ -52,7 +52,7 @@ namespace Cfg { 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 flags=0 ); + ParameterWidget* addParameter ( Parameter*, const std::string& label, int column=0, int span=1, int flags=0 ); signals: void updateParameters (); private: @@ -61,6 +61,7 @@ namespace Cfg { private: QGridLayout* _gridLayout; int _columns; + int _span; int* _rowsCount; std::vector _parameters; }; diff --git a/vlsisapd/src/configuration/src/vlsisapd/configuration/Configuration.h b/vlsisapd/src/configuration/src/vlsisapd/configuration/Configuration.h index 1a73b4d3..70d0470b 100644 --- a/vlsisapd/src/configuration/src/vlsisapd/configuration/Configuration.h +++ b/vlsisapd/src/configuration/src/vlsisapd/configuration/Configuration.h @@ -39,11 +39,13 @@ namespace Cfg { class Configuration { + public: + enum Flags { DriveValues=0x1, DriveLayout=0x2 }; public: static Configuration* get (); public: // Methods. - ConfigurationWidget* buildWidget (); + ConfigurationWidget* buildWidget ( unsigned int flags ); inline const std::map& getParameters () const; inline const LayoutDescription& getLayout () const; @@ -54,8 +56,9 @@ namespace Cfg { , Parameter::Type type , const std::string& value ); void print ( std::ostream& ) const; - void readFromFile ( const std::string& ); - void writeToStream ( std::ostream& ) const; + bool readFromFile ( const std::string& ); + bool writeToFile ( const std::string&, unsigned int flags ) const; + void writeToStream ( std::ostream&, unsigned int flags ) const; private: // Attributes. static Configuration* _singleton; diff --git a/vlsisapd/src/configuration/src/vlsisapd/configuration/ConfigurationWidget.h b/vlsisapd/src/configuration/src/vlsisapd/configuration/ConfigurationWidget.h index a8cf37fb..51ae4ce1 100644 --- a/vlsisapd/src/configuration/src/vlsisapd/configuration/ConfigurationWidget.h +++ b/vlsisapd/src/configuration/src/vlsisapd/configuration/ConfigurationWidget.h @@ -27,9 +27,10 @@ #ifndef __CFG_CONFIGURATION_WIDGET__ #define __CFG_CONFIGURATION_WIDGET__ -//#include #include -#include +#include +class QPushButton; +class QTabWidget; namespace Cfg { @@ -44,25 +45,48 @@ namespace Cfg { // Class : "Cfg::ConfigurationWidget". - class ConfigurationWidget : public QTabWidget { + class ConfigurationWidget : public QWidget { Q_OBJECT; public: - ConfigurationWidget ( QWidget* parent=NULL ); + enum Flags { Embedded=0x1, StandAlone=0x2 }; + public: + ConfigurationWidget ( unsigned int flags, QWidget* parent=NULL ); public: - QFont& getBoldFont (); - ParameterWidget* find ( Parameter* ) const; - ParameterWidget* find ( const std::string& id ) const; - ConfTabWidget* findOrCreate ( const std::string& name ); - void addRuler ( const std::string& tabName ); - void addTitle ( const std::string& tabName, const std::string& title ); - void addSection ( const std::string& tabName, const std::string& section, int column=0 ); - ParameterWidget* addParameter ( const std::string& tabName, Parameter*, const std::string& label, int column=0, int flags=0 ); - void syncSlaves (); + QFont& getBoldFont (); + inline QPushButton* getApplyButton (); + inline QPushButton* getSaveButton (); + inline QPushButton* getCancelButton (); + ParameterWidget* find ( Parameter* ) const; + ParameterWidget* find ( const std::string& id ) const; + ConfTabWidget* findOrCreate ( const std::string& name ); + void addRuler ( const std::string& tabName ); + void addTitle ( const std::string& tabName + , const std::string& title ); + void addSection ( const std::string& tabName + , const std::string& section + , int column=0 ); + ParameterWidget* addParameter ( const std::string& tabName + , Parameter* + , const std::string& label + , int column=0 + , int span =1 + , int flags =0 ); + void syncSlaves (); private: - QFont _boldFont; + unsigned int _flags; + QFont _boldFont; + QTabWidget* _tabWidget; + QPushButton* _apply; + QPushButton* _save; + QPushButton* _cancel; }; + inline QPushButton* ConfigurationWidget::getApplyButton () { return _apply; } + inline QPushButton* ConfigurationWidget::getSaveButton () { return _save; } + inline QPushButton* ConfigurationWidget::getCancelButton () { return _cancel; } + + // Functions Templates. template QTypeWidget rparent ( QObject* object ) @@ -79,6 +103,10 @@ namespace Cfg { } +// Misc. Utility. + std::string toXml ( const std::string& ); + + } // End of Cfg namespace. diff --git a/vlsisapd/src/configuration/src/vlsisapd/configuration/LayoutDescription.h b/vlsisapd/src/configuration/src/vlsisapd/configuration/LayoutDescription.h index 93f1f3df..b519e562 100644 --- a/vlsisapd/src/configuration/src/vlsisapd/configuration/LayoutDescription.h +++ b/vlsisapd/src/configuration/src/vlsisapd/configuration/LayoutDescription.h @@ -29,6 +29,7 @@ #include #include +#include namespace Cfg { @@ -51,26 +52,29 @@ namespace Cfg { inline static WidgetDescription* parameter ( const std::string& id , const std::string& label , int column + , int span , int flags ); inline Type getType () const; inline const std::string& getId () const; inline const std::string& getLabel () const; - inline const std::string& getTitle () const; inline int getColumn () const; + inline int getSpan () const; inline int getFlags () const; private: Type _type; - std::string _id; // Alternate id, title or section. + std::string _id; // Note: title, section & rule have no id. std::string _label; int _column; + int _span; int _flags; private: inline WidgetDescription ( Type type , const std::string& id ="" , const std::string& label ="" , int column=0 - , int flags=0 + , int span =1 + , int flags =0 ); }; @@ -80,31 +84,33 @@ namespace Cfg { , const std::string& id , const std::string& label , int column + , int span , int flags ) - : _type(type), _id(id), _label(label), _column(column), _flags(flags) + : _type(type), _id(id), _label(label), _column(column), _span(span), _flags(flags) { } inline WidgetDescription* WidgetDescription::rule () { return new WidgetDescription(Rule); } inline WidgetDescription* WidgetDescription::title ( const std::string& title ) - { return new WidgetDescription(Title,title); } + { return new WidgetDescription(Title,"",title); } - inline WidgetDescription* WidgetDescription::section ( const std::string& title, int column ) - { return new WidgetDescription(Section,title,"",column); } + inline WidgetDescription* WidgetDescription::section ( const std::string& section, int column ) + { return new WidgetDescription(Section,"",section,column); } inline WidgetDescription* WidgetDescription::parameter ( const std::string& id , const std::string& label , int column + , int span , int flags ) - { return new WidgetDescription(Parameter,id,label,column,flags); } + { return new WidgetDescription(Parameter,id,label,column,span,flags); } inline WidgetDescription::Type WidgetDescription::getType () const { return _type; } inline const std::string& WidgetDescription::getId () const { return _id; } inline const std::string& WidgetDescription::getLabel () const { return _label; } - inline const std::string& WidgetDescription::getTitle () const { return _id; } inline int WidgetDescription::getColumn () const { return _column; } + inline int WidgetDescription::getSpan () const { return _span; } inline int WidgetDescription::getFlags () const { return _flags; } @@ -148,8 +154,22 @@ namespace Cfg { inline LayoutDescription ( Configuration* ); inline void addTab ( TabDescription* ); inline TabDescription* getBackTab (); + TabDescription* getTab ( const std::string& tabName ); inline const std::vector& getTabs () const; - ConfigurationWidget* buildWidget (); + void addRule ( const std::string& tabName ); + void addTitle ( const std::string& tabName + , const std::string& title ); + void addSection ( const std::string& tabName + , const std::string& section + , int column=0 ); + void addParameter ( const std::string& tabName + , const std::string& id + , const std::string& label + , int column=0 + , int span =1 + , unsigned int flags =0 ); + ConfigurationWidget* buildWidget ( unsigned int flags ); + void writeToStream ( std::ostream& ) const; private: Configuration* _configuration; std::vector _tabs;