diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 558845902..f60da9472 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -73,29 +73,33 @@ opencs_units_noqt (view/tools ) opencs_units (view/settings - customblock - proxyblock - groupbox abstractblock - settingwidget - itemblock - groupblock - toggleblock + proxyblock + abstractwidget usersettingsdialog + editorpage + ) + +opencs_units_noqt (view/settings abstractpage - abstractwidget blankpage - editorpage + groupblock + customblock + groupbox + itemblock + settingwidget + toggleblock + support ) opencs_units (model/settings settingcontainer - settingsitem ) opencs_units_noqt (model/settings support usersettings + settingsitem ) set (OPENCS_US diff --git a/apps/opencs/model/settings/settingcontainer.cpp b/apps/opencs/model/settings/settingcontainer.cpp index 700c70fa4..a75a84ec5 100644 --- a/apps/opencs/model/settings/settingcontainer.cpp +++ b/apps/opencs/model/settings/settingcontainer.cpp @@ -2,17 +2,17 @@ #include -CsSettings::SettingContainer::SettingContainer(QObject *parent) : +CSMSettings::SettingContainer::SettingContainer(QObject *parent) : QObject(parent), mValue (0), mValues (0) { } -CsSettings::SettingContainer::SettingContainer(const QString &value, QObject *parent) : +CSMSettings::SettingContainer::SettingContainer(const QString &value, QObject *parent) : QObject(parent), mValue (new QString (value)), mValues (0) { } -void CsSettings::SettingContainer::insert (const QString &value) +void CSMSettings::SettingContainer::insert (const QString &value) { if (mValue) { @@ -31,7 +31,7 @@ void CsSettings::SettingContainer::insert (const QString &value) } -void CsSettings::SettingContainer::update (const QString &value, int index) +void CSMSettings::SettingContainer::update (const QString &value, int index) { if (isEmpty()) mValue = new QString(value); @@ -43,7 +43,7 @@ void CsSettings::SettingContainer::update (const QString &value, int index) mValues->replace(index, value); } -QString CsSettings::SettingContainer::getValue (int index) const +QString CSMSettings::SettingContainer::getValue (int index) const { QString retVal(""); @@ -66,7 +66,7 @@ QString CsSettings::SettingContainer::getValue (int index) const return retVal; } -int CsSettings::SettingContainer::count () const +int CSMSettings::SettingContainer::count () const { int retVal = 0; diff --git a/apps/opencs/model/settings/settingcontainer.hpp b/apps/opencs/model/settings/settingcontainer.hpp index 929c6a25d..eb264248d 100644 --- a/apps/opencs/model/settings/settingcontainer.hpp +++ b/apps/opencs/model/settings/settingcontainer.hpp @@ -5,7 +5,7 @@ class QStringList; -namespace CsSettings +namespace CSMSettings { class SettingContainer : public QObject { diff --git a/apps/opencs/model/settings/settingsitem.cpp b/apps/opencs/model/settings/settingsitem.cpp index b2a8b509b..fef9d3e2f 100644 --- a/apps/opencs/model/settings/settingsitem.cpp +++ b/apps/opencs/model/settings/settingsitem.cpp @@ -1,6 +1,6 @@ #include "settingsitem.hpp" -bool CsSettings::SettingsItem::updateItem (const QStringList *values) +bool CSMSettings::SettingsItem::updateItem (const QStringList *values) { QStringList::ConstIterator it = values->begin(); @@ -30,7 +30,7 @@ bool CsSettings::SettingsItem::updateItem (const QStringList *values) return isValid; } -bool CsSettings::SettingsItem::updateItem (const QString &value) +bool CSMSettings::SettingsItem::updateItem (const QString &value) { //takes a value or a SettingsContainer and updates itself accordingly //after validating the data against it's own definition @@ -52,7 +52,7 @@ bool CsSettings::SettingsItem::updateItem (const QString &value) return success; } -bool CsSettings::SettingsItem::updateItem(int valueListIndex) +bool CSMSettings::SettingsItem::updateItem(int valueListIndex) { bool success = false; @@ -64,7 +64,7 @@ bool CsSettings::SettingsItem::updateItem(int valueListIndex) return success; } -bool CsSettings::SettingsItem::validate (const QString &value) +bool CSMSettings::SettingsItem::validate (const QString &value) { bool isValid = true; @@ -90,13 +90,13 @@ bool CsSettings::SettingsItem::validate (const QString &value) return isValid; } -void CsSettings::SettingsItem::setDefaultValue (const QString &value) +void CSMSettings::SettingsItem::setDefaultValue (const QString &value) { mDefaultValue = value; update (value); } -QString CsSettings::SettingsItem::getDefaultValue() const +QString CSMSettings::SettingsItem::getDefaultValue() const { return mDefaultValue; } diff --git a/apps/opencs/model/settings/settingsitem.hpp b/apps/opencs/model/settings/settingsitem.hpp index 8168edee5..8be05a4c7 100644 --- a/apps/opencs/model/settings/settingsitem.hpp +++ b/apps/opencs/model/settings/settingsitem.hpp @@ -5,7 +5,7 @@ #include "support.hpp" #include "settingcontainer.hpp" -namespace CsSettings +namespace CSMSettings { class SettingsItem : public SettingContainer { diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index 6953cbb61..1155d2a29 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -1,5 +1,5 @@ -#ifndef SUPPORT_HPP -#define SUPPORT_HPP +#ifndef MODEL_SUPPORT_HPP +#define MODEL_SUPPORT_HPP #include #include @@ -8,48 +8,13 @@ class QLayout; class QWidget; class QListWidgetItem; -namespace CsSettings +namespace CSMSettings { - class SettingContainer; - struct WidgetDef; - class ItemBlock; - class GroupBlock; - struct GroupBlockDef; - typedef QList GroupBlockDefList; - typedef QList GroupBlockList; - typedef QList ItemBlockList; - typedef QList SettingList; - typedef QMap SettingMap; + typedef QList SettingList; + typedef QMap SettingMap; typedef QMap SectionMap; - typedef QList ProxyList; - typedef QList WidgetList; - typedef QMap ItemBlockMap; - - enum OcsWidgetOrientation - { - OCS_HORIZONTAL, - OCS_VERTICAL - }; - - enum OcsWidgetType - { - OCS_CHECK_WIDGET, - OCS_COMBO_WIDGET, - OCS_TEXT_WIDGET, - OCS_LIST_WIDGET, - OCS_RADIO_WIDGET, - OCS_SPIN_WIDGET, - OCS_UNDEFINED_WIDGET - }; - - enum OcsAlignment - { - OCS_LEFT = Qt::AlignLeft, - OCS_CENTER = Qt::AlignHCenter, - OCS_RIGHT = Qt::AlignRight - }; struct QStringPair { @@ -67,104 +32,8 @@ namespace CsSettings QString left; QString right; - bool isEmpty() + bool isEmpty() const { return (left.isEmpty() && right.isEmpty()); } }; - - //template for defining the widget of a property. - struct WidgetDef - { - OcsWidgetType type; //type of widget providing input - int labelWidth; //width of caption label - int widgetWidth; //width of input widget - OcsWidgetOrientation orientation; //label / widget orientation (horizontal / vertical) - QString inputMask; //input mask (line edit) - QString caption; //label caption. Leave empty for multiple items. See BlockDef::captionList - QString value; //widget value. Leave empty for multiple items. See BlockDef::valueList - QStringPair *minMax; //Min/Max QString value pair. If empty, assigned to property item value pair. - QStringList *valueList; //value list for list widgets. If left empty, is assigned to property item value list during block build(). - bool isDefault; //isDefault - determined at runtime. - OcsAlignment valueAlignment; //left / center / right-justify text in widget - OcsAlignment widgetAlignment; //left / center / right-justify widget in group box - - - WidgetDef() : labelWidth (-1), widgetWidth (-1), - orientation (OCS_HORIZONTAL), - isDefault (true), valueAlignment (OCS_CENTER), - widgetAlignment (OCS_RIGHT), - inputMask (""), value (""), - caption (""), valueList (0) - {} - - WidgetDef (OcsWidgetType widgType) - : type (widgType), orientation (OCS_HORIZONTAL), - caption (""), value (""), valueAlignment (OCS_CENTER), - widgetAlignment (OCS_RIGHT), - labelWidth (-1), widgetWidth (-1), - valueList (0), isDefault (true) - {} - - }; - - //Defines the attributes of the property as it is represented in the config file - //as well as the UI elements (group box and widget) that serve it. - //Only one widget may serve as the input widget for the property. - struct SettingsItemDef - { - QString name; //property name - QStringList *valueList; //list of valid values for the property. - //Used to populate option widget captions or list widget item lists (see WidgetDef::caption / value) - QString defaultValue; - bool hasMultipleValues; - QStringPair minMax; //minimum / maximum value pair - WidgetDef widget; //definition of the input widget for this setting - OcsWidgetOrientation orientation; //general orientation of the widget / label for this property - ProxyList *proxyList; //list of property and corresponding default values for proxy widget - - SettingsItemDef() : name (""), defaultValue (""), orientation (OCS_VERTICAL), hasMultipleValues (false) - {} - - SettingsItemDef (QString propName, QString propDefault, OcsWidgetOrientation propOrient = OCS_VERTICAL) - : name (propName), defaultValue (propDefault), orientation (propOrient), - hasMultipleValues(false), valueList (new QStringList), proxyList ( new ProxyList) - {} - }; - - - //Hierarchically, this is a "sub-section" of properties within a section, solely for UI organization. - //Does not correlate to config file structure. - struct GroupBlockDef - { - QString title; //title of the block containing the property or properties of this sub-section - QStringList captions; //list of captions for widgets at the block level (not associated with any particular property) - WidgetList widgets; //list of widgets at the block level (not associated with any particular property) - QList properties; //list of the property(ies) which are subordinate to the property block. - OcsWidgetOrientation widgetOrientation; //general orientation of widgets in group block - bool isVisible; //determines whether or not box border/title are visible - bool isProxy; //indicates whether or not this block defines a proxy block - QString defaultValue; //generic default value attribute - - GroupBlockDef (): title(""), widgetOrientation (OCS_VERTICAL), isVisible (true), isProxy (false), defaultValue ("") - {} - - GroupBlockDef (QString blockTitle) - : title (blockTitle), widgetOrientation (OCS_VERTICAL), isProxy (false), isVisible (true), defaultValue ("") - {} - }; - - struct CustomBlockDef - { - QString title; - QString defaultValue; //default value for widgets unique to the custom block - GroupBlockDefList blockDefList; //list of settings groups that comprise the settings within the custom block - OcsWidgetOrientation blockOrientation; - - CustomBlockDef (): title (""), defaultValue (""), blockOrientation (OCS_HORIZONTAL) - {} - - CustomBlockDef (const QString &blockTitle) - : title (blockTitle), defaultValue (""), blockOrientation (OCS_HORIZONTAL) - {} - }; } -#endif // SUPPORT_HPP +#endif // MODEL_SUPPORT_HPP diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 2ddef938b..b33b39203 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -30,16 +30,16 @@ namespace boost #endif /* (BOOST_VERSION <= 104600) */ -CsSettings::UserSettings::UserSettings(Files::ConfigurationManager &cfg) +CSMSettings::UserSettings::UserSettings(Files::ConfigurationManager &cfg) : mCfgMgr(cfg) { } -CsSettings::UserSettings::~UserSettings() +CSMSettings::UserSettings::~UserSettings() { } -QFile *CsSettings::UserSettings::openFile (const QString &filename) +QFile *CSMSettings::UserSettings::openFile (const QString &filename) { QFile *file = new QFile(filename); @@ -63,7 +63,7 @@ QFile *CsSettings::UserSettings::openFile (const QString &filename) return file; } -bool CsSettings::UserSettings::writeFile(QFile *file, QMap &settings) +bool CSMSettings::UserSettings::writeFile(QFile *file, QMap &settings) { if (!file) return false; @@ -88,7 +88,7 @@ bool CsSettings::UserSettings::writeFile(QFile *file, QMap PathContainer; class QFile; -namespace CsSettings { +namespace CSMSettings { class UserSettings { diff --git a/apps/opencs/view/doc/view.cpp b/apps/opencs/view/doc/view.cpp index 665ca2b3a..4d1ab78bd 100644 --- a/apps/opencs/view/doc/view.cpp +++ b/apps/opencs/view/doc/view.cpp @@ -257,7 +257,7 @@ QDockWidget *CSVDoc::View::getOperations() const void CSVDoc::View::showUserSettings() { - CsSettings::UserSettingsDialog *settingsDialog = new CsSettings::UserSettingsDialog(this); + CSVSettings::UserSettingsDialog *settingsDialog = new CSVSettings::UserSettingsDialog(this); connect (settingsDialog, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)), this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)) ); @@ -271,11 +271,7 @@ void CSVDoc::View::slotUpdateEditorSetting(const QString &settingName, const QSt if (lastValue != settingValue) { - if (settingName == "Undo Stack Size"); - - if (settingName == "Top-Level Window Count"); - - if (settingName == "Reuse Subwindows"); + //evaluate settingName against tokens to determine which function to call to update Editor application. lastValue = settingValue; } diff --git a/apps/opencs/view/settings/abstractblock.cpp b/apps/opencs/view/settings/abstractblock.cpp index 8fab5819c..b2041ccbe 100644 --- a/apps/opencs/view/settings/abstractblock.cpp +++ b/apps/opencs/view/settings/abstractblock.cpp @@ -1,14 +1,15 @@ #include "abstractblock.hpp" -CsSettings::AbstractBlock::AbstractBlock(QWidget* parent) +CSVSettings::AbstractBlock::AbstractBlock(QWidget* parent) : QObject (parent), mBox ( new GroupBox (parent) ), mWidgetParent (parent) {} -CsSettings::AbstractBlock::AbstractBlock(bool isVisible, QWidget* parent) +CSVSettings::AbstractBlock::AbstractBlock(bool isVisible, QWidget* parent) : QObject (parent), mBox ( new GroupBox (isVisible, parent)), mWidgetParent (parent) {} -QLayout *CsSettings::AbstractBlock::createLayout (OcsWidgetOrientation direction, bool isZeroMargin, QWidget* parent) +QLayout *CSVSettings::AbstractBlock::createLayout (OcsWidgetOrientation direction, + bool isZeroMargin, QWidget* parent) { QLayout *layout = 0; @@ -23,13 +24,13 @@ QLayout *CsSettings::AbstractBlock::createLayout (OcsWidgetOrientation direction return layout; } -QGroupBox *CsSettings::AbstractBlock::getGroupBox() +QGroupBox *CSVSettings::AbstractBlock::getGroupBox() { return mBox; } -CsSettings::AbstractWidget *CsSettings::AbstractBlock::buildWidget (const QString& widgetName, WidgetDef &def, - QLayout *layout, bool isConnected) const +CSVSettings::AbstractWidget *CSVSettings::AbstractBlock::buildWidget (const QString& widgetName, WidgetDef &def, + QLayout *layout, bool isConnected) const { AbstractWidget *widg = 0; @@ -76,32 +77,32 @@ CsSettings::AbstractWidget *CsSettings::AbstractBlock::buildWidget (const QStrin return widg; } -void CsSettings::AbstractBlock::setVisible (bool isVisible) +void CSVSettings::AbstractBlock::setVisible (bool isVisible) { mBox->setBorderVisibility (isVisible); } -bool CsSettings::AbstractBlock::isVisible () const +bool CSVSettings::AbstractBlock::isVisible () const { return mBox->borderVisibile(); } -QWidget *CsSettings::AbstractBlock::getParent() const +QWidget *CSVSettings::AbstractBlock::getParent() const { return mWidgetParent; } -void CsSettings::AbstractBlock::slotUpdate (const QString &value) +void CSVSettings::AbstractBlock::slotUpdate (const QString &value) { slotUpdateSetting (objectName(), value); } -void CsSettings::AbstractBlock::slotSetEnabled(bool value) +void CSVSettings::AbstractBlock::slotSetEnabled(bool value) { mBox->setEnabled(value); } -void CsSettings::AbstractBlock::slotUpdateSetting (const QString &settingName, const QString &settingValue) +void CSVSettings::AbstractBlock::slotUpdateSetting (const QString &settingName, const QString &settingValue) { bool doEmit = true; updateBySignal (settingName, settingValue, doEmit); diff --git a/apps/opencs/view/settings/abstractblock.hpp b/apps/opencs/view/settings/abstractblock.hpp index 31c093283..278e351ef 100644 --- a/apps/opencs/view/settings/abstractblock.hpp +++ b/apps/opencs/view/settings/abstractblock.hpp @@ -8,7 +8,7 @@ #include "../../model/settings/settingsitem.hpp" #include "groupbox.hpp" -namespace CsSettings +namespace CSVSettings { class AbstractBlock : public QObject @@ -17,7 +17,7 @@ namespace CsSettings protected: - typedef QMap SettingsItemMap; + typedef QMap SettingsItemMap; GroupBox *mBox; QWidget *mWidgetParent; @@ -30,8 +30,8 @@ namespace CsSettings void setVisible (bool isVisible); bool isVisible() const; - virtual SettingList *getSettings() = 0; - virtual bool updateSettings (const SettingMap &settings) = 0; + virtual CSMSettings::SettingList *getSettings() = 0; + virtual bool updateSettings (const CSMSettings::SettingMap &settings) = 0; virtual bool updateBySignal (const QString &name, const QString &value, bool &doEmit) { return false; } diff --git a/apps/opencs/view/settings/abstractpage.cpp b/apps/opencs/view/settings/abstractpage.cpp index 1fd60fbf0..512b5abbd 100644 --- a/apps/opencs/view/settings/abstractpage.cpp +++ b/apps/opencs/view/settings/abstractpage.cpp @@ -10,28 +10,28 @@ #include #include -CsSettings::AbstractPage::AbstractPage(QWidget *parent): +CSVSettings::AbstractPage::AbstractPage(QWidget *parent): QWidget(parent) { } -CsSettings::AbstractPage::AbstractPage(const QString &pageName, QWidget *parent): +CSVSettings::AbstractPage::AbstractPage(const QString &pageName, QWidget *parent): QWidget(parent) { QWidget::setObjectName (pageName); } -CsSettings::AbstractPage::~AbstractPage() +CSVSettings::AbstractPage::~AbstractPage() { } -CsSettings::SettingList *CsSettings::AbstractPage::getSettings() +CSMSettings::SettingList *CSVSettings::AbstractPage::getSettings() { - SettingList *settings = new SettingList(); + CSMSettings::SettingList *settings = new CSMSettings::SettingList(); foreach (AbstractBlock *block, mAbstractBlocks) { - SettingList *groupSettings = block->getSettings(); + CSMSettings::SettingList *groupSettings = block->getSettings(); settings->append (*groupSettings); } diff --git a/apps/opencs/view/settings/abstractpage.hpp b/apps/opencs/view/settings/abstractpage.hpp index b5ee86f57..15ac82a62 100644 --- a/apps/opencs/view/settings/abstractpage.hpp +++ b/apps/opencs/view/settings/abstractpage.hpp @@ -10,15 +10,13 @@ class SettingMap; class SettingList; -namespace CsSettings { +namespace CSVSettings { typedef QList AbstractBlockList; class AbstractPage: public QWidget { - Q_OBJECT - protected: AbstractBlockList mAbstractBlocks; @@ -32,9 +30,9 @@ namespace CsSettings { virtual void setupUi()=0; - virtual void initializeWidgets (const SettingMap &settings) = 0; + virtual void initializeWidgets (const CSMSettings::SettingMap &settings) = 0; - SettingList *getSettings(); + CSMSettings::SettingList *getSettings(); void setObjectName(); diff --git a/apps/opencs/view/settings/abstractwidget.cpp b/apps/opencs/view/settings/abstractwidget.cpp index a23c3ee1b..6f6d45316 100644 --- a/apps/opencs/view/settings/abstractwidget.cpp +++ b/apps/opencs/view/settings/abstractwidget.cpp @@ -3,7 +3,7 @@ #include #include -void CsSettings::AbstractWidget::build(QWidget *widget, WidgetDef &def, bool noLabel) +void CSVSettings::AbstractWidget::build(QWidget *widget, WidgetDef &def, bool noLabel) { if (!mLayout) createLayout(def.orientation, true); @@ -12,7 +12,7 @@ void CsSettings::AbstractWidget::build(QWidget *widget, WidgetDef &def, bool noL } -void CsSettings::AbstractWidget::buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel) +void CSVSettings::AbstractWidget::buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel) { if (def.widgetWidth > -1) widget->setFixedWidth (def.widgetWidth); @@ -31,7 +31,7 @@ void CsSettings::AbstractWidget::buildLabelAndWidget (QWidget *widget, WidgetDef mLayout->setAlignment (widget, getAlignment (def.widgetAlignment)); } -void CsSettings::AbstractWidget::createLayout +void CSVSettings::AbstractWidget::createLayout (OcsWidgetOrientation direction, bool isZeroMargin) { if (direction == OCS_VERTICAL) @@ -43,36 +43,36 @@ void CsSettings::AbstractWidget::createLayout mLayout->setContentsMargins(0, 0, 0, 0); } -QFlags CsSettings::AbstractWidget::getAlignment (CsSettings::OcsAlignment flag) +QFlags CSVSettings::AbstractWidget::getAlignment (CSVSettings::OcsAlignment flag) { return QFlags(static_cast(flag)); } -QLayout *CsSettings::AbstractWidget::getLayout() +QLayout *CSVSettings::AbstractWidget::getLayout() { return mLayout; } -void CsSettings::AbstractWidget::slotUpdateWidget (const QString &value) +void CSVSettings::AbstractWidget::slotUpdateWidget (const QString &value) { updateWidget (value); } -void CsSettings::AbstractWidget::slotUpdateItem(const QString &value) +void CSVSettings::AbstractWidget::slotUpdateItem(const QString &value) { emit signalUpdateItem (value); } -void CsSettings::AbstractWidget::slotUpdateItem(bool value) +void CSVSettings::AbstractWidget::slotUpdateItem(bool value) { if (value) emit signalUpdateItem (widget()->objectName()); } -void CsSettings::AbstractWidget::slotUpdateItem(int value) +void CSVSettings::AbstractWidget::slotUpdateItem(int value) { emit signalUpdateItem (QString::number(value)); } -void CsSettings::AbstractWidget::slotUpdateItem (QListWidgetItem* current, QListWidgetItem* previous) +void CSVSettings::AbstractWidget::slotUpdateItem (QListWidgetItem* current, QListWidgetItem* previous) {} diff --git a/apps/opencs/view/settings/abstractwidget.hpp b/apps/opencs/view/settings/abstractwidget.hpp index b5c646754..98653e465 100644 --- a/apps/opencs/view/settings/abstractwidget.hpp +++ b/apps/opencs/view/settings/abstractwidget.hpp @@ -2,11 +2,11 @@ #define ABSTRACTWIDGET_HPP #include -#include "../../model/settings/support.hpp" +#include "support.hpp" class QLayout; -namespace CsSettings +namespace CSVSettings { class AbstractWidget : public QObject { @@ -35,12 +35,12 @@ namespace CsSettings virtual void updateWidget (const QString &value) = 0; //converts user-defined enum to Qt equivalents - QFlags getAlignment (CsSettings::OcsAlignment flag); + QFlags getAlignment (OcsAlignment flag); private: //widget initialization utilities - void createLayout (CsSettings::OcsWidgetOrientation direction, bool isZeroMargin); + void createLayout (OcsWidgetOrientation direction, bool isZeroMargin); void buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel); diff --git a/apps/opencs/view/settings/blankpage.cpp b/apps/opencs/view/settings/blankpage.cpp index deb77e057..57d5c7caa 100644 --- a/apps/opencs/view/settings/blankpage.cpp +++ b/apps/opencs/view/settings/blankpage.cpp @@ -17,19 +17,19 @@ #include "groupblock.hpp" #include "toggleblock.hpp" -CsSettings::BlankPage::BlankPage(QWidget *parent): +CSVSettings::BlankPage::BlankPage(QWidget *parent): AbstractPage("Blank", parent) { initPage(); } -CsSettings::BlankPage::BlankPage(const QString &title, QWidget *parent): +CSVSettings::BlankPage::BlankPage(const QString &title, QWidget *parent): AbstractPage(title, parent) { initPage(); } -void CsSettings::BlankPage::initPage() +void CSVSettings::BlankPage::initPage() { // Hacks to get the stylesheet look properly #ifdef Q_OS_MAC @@ -40,7 +40,7 @@ void CsSettings::BlankPage::initPage() setupUi(); } -void CsSettings::BlankPage::setupUi() +void CSVSettings::BlankPage::setupUi() { QGroupBox *pageBox = new QGroupBox(this); QLayout* pageLayout = new QVBoxLayout(); @@ -49,7 +49,7 @@ void CsSettings::BlankPage::setupUi() pageLayout->addWidget(pageBox); } -void CsSettings::BlankPage::initializeWidgets (const SettingMap &settings) +void CSVSettings::BlankPage::initializeWidgets (const CSMSettings::SettingMap &settings) { //iterate each item in each blocks in this section //validate the corresponding setting against the defined valuelist if any. diff --git a/apps/opencs/view/settings/blankpage.hpp b/apps/opencs/view/settings/blankpage.hpp index 9dd6c5e56..648d373f3 100644 --- a/apps/opencs/view/settings/blankpage.hpp +++ b/apps/opencs/view/settings/blankpage.hpp @@ -5,14 +5,13 @@ class QGroupBox; -namespace CsSettings { +namespace CSVSettings { class UserSettings; class AbstractBlock; class BlankPage : public AbstractPage { - Q_OBJECT public: @@ -20,7 +19,7 @@ namespace CsSettings { BlankPage (const QString &title, QWidget *parent); void setupUi(); - void initializeWidgets (const SettingMap &settings); + void initializeWidgets (const CSMSettings::SettingMap &settings); private: void initPage(); diff --git a/apps/opencs/view/settings/customblock.cpp b/apps/opencs/view/settings/customblock.cpp index f70db47a0..03b838501 100644 --- a/apps/opencs/view/settings/customblock.cpp +++ b/apps/opencs/view/settings/customblock.cpp @@ -3,11 +3,11 @@ #include "itemblock.hpp" #include "proxyblock.hpp" -CsSettings::CustomBlock::CustomBlock (QWidget *parent) : AbstractBlock (parent) +CSVSettings::CustomBlock::CustomBlock (QWidget *parent) : AbstractBlock (parent) { } -int CsSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefList::iterator *it) +int CSVSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefList::iterator *it) { int retVal = 0; @@ -37,7 +37,7 @@ int CsSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefList return retVal; } -CsSettings::GroupBox *CsSettings::CustomBlock::buildGroupBox (CsSettings::OcsWidgetOrientation orientation) +CSVSettings::GroupBox *CSVSettings::CustomBlock::buildGroupBox (OcsWidgetOrientation orientation) { GroupBox *box = new GroupBox (false, mBox); QLayout *layout = createLayout (orientation, true, box); @@ -45,7 +45,7 @@ CsSettings::GroupBox *CsSettings::CustomBlock::buildGroupBox (CsSettings::OcsWid return box; } -int CsSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def) +int CSVSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def) { GroupBlock *block = new GroupBlock (getParent()); @@ -57,7 +57,7 @@ int CsSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def) return block->build(def); } -int CsSettings::CustomBlock::buildProxyBlock(GroupBlockDef& def, ProxyBlock *block) +int CSVSettings::CustomBlock::buildProxyBlock(GroupBlockDef& def, ProxyBlock *block) { if (def.properties.size() != 1) return -1; @@ -91,13 +91,13 @@ int CsSettings::CustomBlock::buildProxyBlock(GroupBlockDef& def, ProxyBlock *blo return 0; } -CsSettings::SettingList *CsSettings::CustomBlock::getSettings() +CSMSettings::SettingList *CSVSettings::CustomBlock::getSettings() { - SettingList *settings = new SettingList(); + CSMSettings::SettingList *settings = new CSMSettings::SettingList(); foreach (GroupBlock *block, mGroupList) { - SettingList *groupSettings = block->getSettings(); + CSMSettings::SettingList *groupSettings = block->getSettings(); if (groupSettings) settings->append(*groupSettings); @@ -106,7 +106,7 @@ CsSettings::SettingList *CsSettings::CustomBlock::getSettings() return settings; } -bool CsSettings::CustomBlock::updateSettings (const SettingMap &settings) +bool CSVSettings::CustomBlock::updateSettings (const CSMSettings::SettingMap &settings) { bool success = true; diff --git a/apps/opencs/view/settings/customblock.hpp b/apps/opencs/view/settings/customblock.hpp index ba83464da..4bcc85c5c 100644 --- a/apps/opencs/view/settings/customblock.hpp +++ b/apps/opencs/view/settings/customblock.hpp @@ -3,7 +3,7 @@ #include "abstractblock.hpp" -namespace CsSettings +namespace CSVSettings { class ProxyBlock; @@ -19,8 +19,8 @@ namespace CsSettings explicit CustomBlock (QWidget *parent = 0); - bool updateSettings (const SettingMap &settings); - SettingList *getSettings(); + bool updateSettings (const CSMSettings::SettingMap &settings); + CSMSettings::SettingList *getSettings(); int build (GroupBlockDefList &defList, GroupBlockDefList::Iterator *it = 0); protected: diff --git a/apps/opencs/view/settings/editorpage.cpp b/apps/opencs/view/settings/editorpage.cpp index 2a9bf0aab..83f29438d 100644 --- a/apps/opencs/view/settings/editorpage.cpp +++ b/apps/opencs/view/settings/editorpage.cpp @@ -17,7 +17,7 @@ #include "groupblock.hpp" #include "toggleblock.hpp" -CsSettings::EditorPage::EditorPage(QWidget *parent): +CSVSettings::EditorPage::EditorPage(QWidget *parent): AbstractPage("Editor", parent) { // Hacks to get the stylesheet look properly @@ -29,7 +29,7 @@ CsSettings::EditorPage::EditorPage(QWidget *parent): setupUi(); } -void CsSettings::EditorPage::setupUi() +void CSVSettings::EditorPage::setupUi() { GroupBlockDef undoStack (QString("Undo Stack Size")); GroupBlockDef topLevelWindowCount (QString("Maximum Top-Level Window Count")); @@ -153,7 +153,7 @@ void CsSettings::EditorPage::setupUi() } } -void CsSettings::EditorPage::initializeWidgets (const SettingMap &settings) +void CSVSettings::EditorPage::initializeWidgets (const CSMSettings::SettingMap &settings) { //iterate each item in each blocks in this section //validate the corresponding setting against the defined valuelist if any. diff --git a/apps/opencs/view/settings/editorpage.hpp b/apps/opencs/view/settings/editorpage.hpp index 87ae7da83..0c1e80e89 100644 --- a/apps/opencs/view/settings/editorpage.hpp +++ b/apps/opencs/view/settings/editorpage.hpp @@ -5,7 +5,7 @@ class QGroupBox; -namespace CsSettings { +namespace CSVSettings { class UserSettings; class AbstractBlock; @@ -19,7 +19,7 @@ namespace CsSettings { EditorPage(QWidget *parent = 0); void setupUi(); - void initializeWidgets (const SettingMap &settings); + void initializeWidgets (const CSMSettings::SettingMap &settings); signals: void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue); diff --git a/apps/opencs/view/settings/groupblock.cpp b/apps/opencs/view/settings/groupblock.cpp index b5917ec38..b18f629ba 100644 --- a/apps/opencs/view/settings/groupblock.cpp +++ b/apps/opencs/view/settings/groupblock.cpp @@ -1,15 +1,15 @@ #include "groupblock.hpp" #include "itemblock.hpp" -CsSettings::GroupBlock::GroupBlock (QWidget* parent) +CSVSettings::GroupBlock::GroupBlock (QWidget* parent) : AbstractBlock (parent) {} -CsSettings::GroupBlock::GroupBlock (bool isVisible, QWidget *parent) +CSVSettings::GroupBlock::GroupBlock (bool isVisible, QWidget *parent) : AbstractBlock (isVisible, parent) {} -int CsSettings::GroupBlock::build (GroupBlockDef &def) +int CSVSettings::GroupBlock::build (GroupBlockDef &def) { if (def.properties.size() == 0) @@ -44,14 +44,14 @@ int CsSettings::GroupBlock::build (GroupBlockDef &def) return retVal; } -CsSettings::SettingList *CsSettings::GroupBlock::getSettings() +CSMSettings::SettingList *CSVSettings::GroupBlock::getSettings() { - SettingList *settings = 0; + CSMSettings::SettingList *settings = 0; foreach (ItemBlock *block, mItemBlockList) { if (!settings) - settings = new SettingList(); + settings = new CSMSettings::SettingList(); settings->append(*(block->getSettings ())); } @@ -59,7 +59,7 @@ CsSettings::SettingList *CsSettings::GroupBlock::getSettings() return settings; } -CsSettings::ItemBlock *CsSettings::GroupBlock::getItemBlock (const QString &name, ItemBlockList *blockList) +CSVSettings::ItemBlock *CSVSettings::GroupBlock::getItemBlock (const QString &name, ItemBlockList *blockList) { ItemBlock *retBlock = 0; @@ -78,7 +78,7 @@ CsSettings::ItemBlock *CsSettings::GroupBlock::getItemBlock (const QString &name return retBlock; } -CsSettings::ItemBlock *CsSettings::GroupBlock::getItemBlock (int index) +CSVSettings::ItemBlock *CSVSettings::GroupBlock::getItemBlock (int index) { ItemBlock *retBlock = 0; @@ -88,14 +88,14 @@ CsSettings::ItemBlock *CsSettings::GroupBlock::getItemBlock (int index) return retBlock; } -bool CsSettings::GroupBlock::updateSettings (const SettingMap &settings) +bool CSVSettings::GroupBlock::updateSettings (const CSMSettings::SettingMap &settings) { bool success = true; //update all non-proxy settings foreach (ItemBlock *block, mItemBlockList) { - SettingContainer *setting = settings[block->objectName()]; + CSMSettings::SettingContainer *setting = settings[block->objectName()]; if (setting) { diff --git a/apps/opencs/view/settings/groupblock.hpp b/apps/opencs/view/settings/groupblock.hpp index f3b0c4bae..a8fd4e3b4 100644 --- a/apps/opencs/view/settings/groupblock.hpp +++ b/apps/opencs/view/settings/groupblock.hpp @@ -4,7 +4,7 @@ #include #include "abstractblock.hpp" -namespace CsSettings +namespace CSVSettings { class ItemBlock; @@ -18,9 +18,9 @@ namespace CsSettings int build (GroupBlockDef &def); - bool updateSettings (const SettingMap &settings); + bool updateSettings (const CSMSettings::SettingMap &settings); - SettingList *getSettings(); + CSMSettings::SettingList *getSettings(); ItemBlock *getItemBlock (const QString &name, ItemBlockList *blockList = 0); ItemBlock *getItemBlock (int index); diff --git a/apps/opencs/view/settings/groupbox.cpp b/apps/opencs/view/settings/groupbox.cpp index c996a22aa..da2cc2571 100644 --- a/apps/opencs/view/settings/groupbox.cpp +++ b/apps/opencs/view/settings/groupbox.cpp @@ -1,21 +1,21 @@ #include "groupbox.hpp" -const QString CsSettings::GroupBox::INVISIBLE_BOX_STYLE = +const QString CSVSettings::GroupBox::INVISIBLE_BOX_STYLE = QString::fromUtf8("QGroupBox { border: 0px; padding 0px; margin: 0px;}"); -CsSettings::GroupBox::GroupBox(QWidget *parent) : +CSVSettings::GroupBox::GroupBox(QWidget *parent) : QGroupBox (parent) { initBox(); } -CsSettings::GroupBox::GroupBox (bool isVisible, QWidget *parent) : +CSVSettings::GroupBox::GroupBox (bool isVisible, QWidget *parent) : QGroupBox (parent) { initBox(isVisible); } -void CsSettings::GroupBox::initBox(bool isVisible) +void CSVSettings::GroupBox::initBox(bool isVisible) { setFlat (true); VISIBLE_BOX_STYLE = styleSheet(); @@ -24,12 +24,12 @@ void CsSettings::GroupBox::initBox(bool isVisible) setStyleSheet (INVISIBLE_BOX_STYLE); } -bool CsSettings::GroupBox::borderVisibile() const +bool CSVSettings::GroupBox::borderVisibile() const { return (styleSheet() != INVISIBLE_BOX_STYLE); } -void CsSettings::GroupBox::setTitle (const QString &title) +void CSVSettings::GroupBox::setTitle (const QString &title) { if (borderVisibile() ) { @@ -38,7 +38,7 @@ void CsSettings::GroupBox::setTitle (const QString &title) } } -void CsSettings::GroupBox::setBorderVisibility (bool value) +void CSVSettings::GroupBox::setBorderVisibility (bool value) { if (value) setStyleSheet(VISIBLE_BOX_STYLE); @@ -46,7 +46,7 @@ void CsSettings::GroupBox::setBorderVisibility (bool value) setStyleSheet(INVISIBLE_BOX_STYLE); } -void CsSettings::GroupBox::setMinimumWidth() +void CSVSettings::GroupBox::setMinimumWidth() { //set minimum width to accommodate title, if needed //1.5 multiplier to account for bold title. diff --git a/apps/opencs/view/settings/groupbox.hpp b/apps/opencs/view/settings/groupbox.hpp index d229dbc8e..43cb2e0c3 100644 --- a/apps/opencs/view/settings/groupbox.hpp +++ b/apps/opencs/view/settings/groupbox.hpp @@ -3,12 +3,10 @@ #include -namespace CsSettings +namespace CSVSettings { class GroupBox : public QGroupBox { - Q_OBJECT - static const QString INVISIBLE_BOX_STYLE; QString VISIBLE_BOX_STYLE; //not a const... diff --git a/apps/opencs/view/settings/itemblock.cpp b/apps/opencs/view/settings/itemblock.cpp index 261319d8d..0280a6afd 100644 --- a/apps/opencs/view/settings/itemblock.cpp +++ b/apps/opencs/view/settings/itemblock.cpp @@ -2,12 +2,12 @@ #include -CsSettings::ItemBlock::ItemBlock (QWidget* parent) +CSVSettings::ItemBlock::ItemBlock (QWidget* parent) : mSetting (0), AbstractBlock (false, parent) { } -int CsSettings::ItemBlock::build(SettingsItemDef &iDef) +int CSVSettings::ItemBlock::build(SettingsItemDef &iDef) { buildItemBlock (iDef); buildItemBlockWidgets (iDef); @@ -15,7 +15,7 @@ int CsSettings::ItemBlock::build(SettingsItemDef &iDef) return 0; } -void CsSettings::ItemBlock::buildItemBlockWidgets (SettingsItemDef &iDef) +void CSVSettings::ItemBlock::buildItemBlockWidgets (SettingsItemDef &iDef) { WidgetDef wDef = iDef.widget; QLayout *blockLayout = 0; @@ -56,13 +56,13 @@ void CsSettings::ItemBlock::buildItemBlockWidgets (SettingsItemDef &iDef) } } -void CsSettings::ItemBlock::buildItemBlock (SettingsItemDef &iDef) +void CSVSettings::ItemBlock::buildItemBlock (SettingsItemDef &iDef) { QString defaultValue = iDef.defaultValue; setObjectName(iDef.name); - mSetting = new SettingsItem (objectName(), + mSetting = new CSMSettings::SettingsItem (objectName(), iDef.hasMultipleValues, iDef.defaultValue, parent()); @@ -74,7 +74,7 @@ void CsSettings::ItemBlock::buildItemBlock (SettingsItemDef &iDef) } -bool CsSettings::ItemBlock::update (const QString &value) +bool CSVSettings::ItemBlock::update (const QString &value) { bool success = updateItem (value); @@ -85,13 +85,13 @@ bool CsSettings::ItemBlock::update (const QString &value) } -bool CsSettings::ItemBlock::updateItem (const QString &value) +bool CSVSettings::ItemBlock::updateItem (const QString &value) { return mSetting->updateItem(value); } -bool CsSettings::ItemBlock::updateBySignal(const QString &name, const QString &value, bool &doEmit) +bool CSVSettings::ItemBlock::updateBySignal(const QString &name, const QString &value, bool &doEmit) { bool success = (mSetting->getValue() != value); @@ -101,15 +101,15 @@ bool CsSettings::ItemBlock::updateBySignal(const QString &name, const QString &v return success; } -CsSettings::SettingList *CsSettings::ItemBlock::getSettings () +CSMSettings::SettingList *CSVSettings::ItemBlock::getSettings () { - SettingList *list = new SettingList(); + CSMSettings::SettingList *list = new CSMSettings::SettingList(); list->push_back(mSetting); return list; } -QString CsSettings::ItemBlock::getValue() const +QString CSVSettings::ItemBlock::getValue() const { return mSetting->getValue(); } diff --git a/apps/opencs/view/settings/itemblock.hpp b/apps/opencs/view/settings/itemblock.hpp index 8aab65745..c7714ac64 100644 --- a/apps/opencs/view/settings/itemblock.hpp +++ b/apps/opencs/view/settings/itemblock.hpp @@ -3,21 +3,21 @@ #include "abstractblock.hpp" -namespace CsSettings +namespace CSVSettings { class ItemBlock : public AbstractBlock { - SettingsItem *mSetting; + CSMSettings::SettingsItem *mSetting; WidgetList mWidgetList; public: ItemBlock (QWidget* parent = 0); - bool updateSettings (const SettingMap &settings) { return false; } + bool updateSettings (const CSMSettings::SettingMap &settings) { return false; } - SettingList *getSettings (); + CSMSettings::SettingList *getSettings (); QString getValue () const; int getSettingCount(); diff --git a/apps/opencs/view/settings/proxyblock.cpp b/apps/opencs/view/settings/proxyblock.cpp index 46e404a12..71a307084 100644 --- a/apps/opencs/view/settings/proxyblock.cpp +++ b/apps/opencs/view/settings/proxyblock.cpp @@ -1,11 +1,11 @@ #include "proxyblock.hpp" #include "itemblock.hpp" -CsSettings::ProxyBlock::ProxyBlock (QWidget *parent) +CSVSettings::ProxyBlock::ProxyBlock (QWidget *parent) : GroupBlock (parent) { } -int CsSettings::ProxyBlock::build (GroupBlockDef &proxyDef) +int CSVSettings::ProxyBlock::build (GroupBlockDef &proxyDef) { //get the list of pre-defined values for the proxy mValueList = proxyDef.properties.at(0)->valueList; @@ -19,7 +19,7 @@ int CsSettings::ProxyBlock::build (GroupBlockDef &proxyDef) return success; } -void CsSettings::ProxyBlock::addSetting (ItemBlock *settingBlock, QStringList *proxyList) +void CSVSettings::ProxyBlock::addSetting (ItemBlock *settingBlock, QStringList *proxyList) { //connect the item block of the proxied seting to the generic update slot connect (settingBlock, SIGNAL (signalUpdateSetting(const QString &, const QString &)), @@ -29,23 +29,23 @@ void CsSettings::ProxyBlock::addSetting (ItemBlock *settingBlock, QStringList *p mProxyList << proxyList; } -bool CsSettings::ProxyBlock::updateSettings (const SettingMap &settings) +bool CSVSettings::ProxyBlock::updateSettings (const CSMSettings::SettingMap &settings) { return updateByProxiedSettings(&settings); } -bool CsSettings::ProxyBlock::updateBySignal(const QString &name, const QString &value, bool &doEmit) +bool CSVSettings::ProxyBlock::updateBySignal(const QString &name, const QString &value, bool &doEmit) { doEmit = false; return updateProxiedSettings(); } -void CsSettings::ProxyBlock::slotUpdateProxySetting (const QString &name, const QString &value) +void CSVSettings::ProxyBlock::slotUpdateProxySetting (const QString &name, const QString &value) { updateByProxiedSettings(); } -bool CsSettings::ProxyBlock::updateProxiedSettings() +bool CSVSettings::ProxyBlock::updateProxiedSettings() { foreach (ItemBlock *block, mProxiedItemBlockList) { @@ -74,7 +74,7 @@ bool CsSettings::ProxyBlock::updateProxiedSettings() return true; } -bool CsSettings::ProxyBlock::updateByProxiedSettings(const SettingMap *settings) +bool CSVSettings::ProxyBlock::updateByProxiedSettings(const CSMSettings::SettingMap *settings) { bool success = false; int commonIndex = -1; @@ -143,7 +143,7 @@ bool CsSettings::ProxyBlock::updateByProxiedSettings(const SettingMap *settings) return success; } -CsSettings::ItemBlock *CsSettings::ProxyBlock::getProxiedItemBlock (const QString &name) +CSVSettings::ItemBlock *CSVSettings::ProxyBlock::getProxiedItemBlock (const QString &name) { return getItemBlock (name, &mProxiedItemBlockList); } diff --git a/apps/opencs/view/settings/proxyblock.hpp b/apps/opencs/view/settings/proxyblock.hpp index d35d7da69..f757842ea 100644 --- a/apps/opencs/view/settings/proxyblock.hpp +++ b/apps/opencs/view/settings/proxyblock.hpp @@ -3,7 +3,7 @@ #include "groupblock.hpp" -namespace CsSettings +namespace CSVSettings { class ProxyBlock : public GroupBlock { @@ -23,14 +23,14 @@ namespace CsSettings void addSetting (ItemBlock* settingBlock, QStringList *proxyList); int build (GroupBlockDef &def); - SettingList *getSettings() { return 0; } - bool updateSettings (const SettingMap &settings); + CSMSettings::SettingList *getSettings() { return 0; } + bool updateSettings (const CSMSettings::SettingMap &settings); bool updateBySignal (const QString &name, const QString &value, bool &doEmit); private: ItemBlock *getProxiedItemBlock (const QString &name); - bool updateByProxiedSettings(const SettingMap *settings = 0); + bool updateByProxiedSettings(const CSMSettings::SettingMap *settings = 0); bool updateProxiedSettings(); private slots: diff --git a/apps/opencs/view/settings/settingwidget.hpp b/apps/opencs/view/settings/settingwidget.hpp index 4e4bad132..b29523a3a 100644 --- a/apps/opencs/view/settings/settingwidget.hpp +++ b/apps/opencs/view/settings/settingwidget.hpp @@ -14,7 +14,7 @@ #include "abstractwidget.hpp" -namespace CsSettings +namespace CSVSettings { //VALID FOR RADIOBUTTON / CHECKBOX (or other toggle widget with it's own label) template @@ -25,7 +25,7 @@ namespace CsSettings public: - explicit SettingWidget(WidgetDef &def, QLayout *layout, QWidget* parent = 0) + explicit SettingWidget (WidgetDef &def, QLayout *layout, QWidget* parent = 0) : AbstractWidget (layout, parent), mWidget (new T1 (parent)) { mWidget->setText(def.caption); @@ -55,7 +55,7 @@ namespace CsSettings public: - SettingWidget(WidgetDef &def, QLayout *layout, QWidget *parent = 0) + SettingWidget (WidgetDef &def, QLayout *layout, QWidget *parent = 0) : AbstractWidget (layout, parent), mWidget (new QSpinBox (parent)) { def.caption += tr(" (%1 to %2)").arg(def.minMax->left).arg(def.minMax->right); @@ -91,7 +91,7 @@ namespace CsSettings }; template <> - class SettingWidget : public CsSettings::AbstractWidget + class SettingWidget : public CSVSettings::AbstractWidget { QComboBox *mWidget; @@ -143,7 +143,7 @@ namespace CsSettings }; template <> - class SettingWidget : public CsSettings::AbstractWidget + class SettingWidget : public CSVSettings::AbstractWidget { QLineEdit *mWidget; @@ -176,7 +176,7 @@ namespace CsSettings }; template <> - class SettingWidget : public CsSettings::AbstractWidget + class SettingWidget : public CSVSettings::AbstractWidget { QListWidget *mWidget; diff --git a/apps/opencs/view/settings/support.cpp b/apps/opencs/view/settings/support.cpp new file mode 100644 index 000000000..d79edfdb3 --- /dev/null +++ b/apps/opencs/view/settings/support.cpp @@ -0,0 +1 @@ +#include "support.hpp" diff --git a/apps/opencs/view/settings/support.hpp b/apps/opencs/view/settings/support.hpp new file mode 100644 index 000000000..1bd5f841a --- /dev/null +++ b/apps/opencs/view/settings/support.hpp @@ -0,0 +1,144 @@ +#ifndef VIEW_SUPPORT_HPP +#define VIEW_SUPPORT_HPP + +#include +#include + +#include "../../model/settings/support.hpp" + +namespace CSVSettings +{ + struct WidgetDef; + class ItemBlock; + class GroupBlock; + struct GroupBlockDef; + + typedef QList GroupBlockDefList; + typedef QList GroupBlockList; + typedef QList ItemBlockList; + typedef QList ProxyList; + typedef QList WidgetList; + typedef QMap ItemBlockMap; + + enum OcsWidgetOrientation + { + OCS_HORIZONTAL, + OCS_VERTICAL + }; + + enum OcsWidgetType + { + OCS_CHECK_WIDGET, + OCS_COMBO_WIDGET, + OCS_TEXT_WIDGET, + OCS_LIST_WIDGET, + OCS_RADIO_WIDGET, + OCS_SPIN_WIDGET, + OCS_UNDEFINED_WIDGET + }; + + enum OcsAlignment + { + OCS_LEFT = Qt::AlignLeft, + OCS_CENTER = Qt::AlignHCenter, + OCS_RIGHT = Qt::AlignRight + }; + + //template for defining the widget of a property. + struct WidgetDef + { + OcsWidgetType type; //type of widget providing input + int labelWidth; //width of caption label + int widgetWidth; //width of input widget + OcsWidgetOrientation orientation; //label / widget orientation (horizontal / vertical) + QString inputMask; //input mask (line edit) + QString caption; //label caption. Leave empty for multiple items. See BlockDef::captionList + QString value; //widget value. Leave empty for multiple items. See BlockDef::valueList + CSMSettings::QStringPair *minMax; //Min/Max QString value pair. If empty, assigned to property item value pair. + QStringList *valueList; //value list for list widgets. If left empty, is assigned to property item value list during block build(). + bool isDefault; //isDefault - determined at runtime. + OcsAlignment valueAlignment; //left / center / right-justify text in widget + OcsAlignment widgetAlignment; //left / center / right-justify widget in group box + + + WidgetDef() : labelWidth (-1), widgetWidth (-1), + orientation (OCS_HORIZONTAL), + isDefault (true), valueAlignment (OCS_CENTER), + widgetAlignment (OCS_RIGHT), + inputMask (""), value (""), + caption (""), valueList (0) + {} + + WidgetDef (OcsWidgetType widgType) + : type (widgType), orientation (OCS_HORIZONTAL), + caption (""), value (""), valueAlignment (OCS_CENTER), + widgetAlignment (OCS_RIGHT), + labelWidth (-1), widgetWidth (-1), + valueList (0), isDefault (true) + {} + + }; + + //Defines the attributes of the property as it is represented in the config file + //as well as the UI elements (group box and widget) that serve it. + //Only one widget may serve as the input widget for the property. + struct SettingsItemDef + { + QString name; //property name + QStringList *valueList; //list of valid values for the property. + //Used to populate option widget captions or list widget item lists (see WidgetDef::caption / value) + QString defaultValue; + bool hasMultipleValues; + CSMSettings::QStringPair minMax; //minimum / maximum value pair + WidgetDef widget; //definition of the input widget for this setting + OcsWidgetOrientation orientation; //general orientation of the widget / label for this property + ProxyList *proxyList; //list of property and corresponding default values for proxy widget + + SettingsItemDef() : name (""), defaultValue (""), orientation (OCS_VERTICAL), hasMultipleValues (false) + {} + + SettingsItemDef (QString propName, QString propDefault, OcsWidgetOrientation propOrient = OCS_VERTICAL) + : name (propName), defaultValue (propDefault), orientation (propOrient), + hasMultipleValues(false), valueList (new QStringList), proxyList ( new ProxyList) + {} + }; + + + //Hierarchically, this is a "sub-section" of properties within a section, solely for UI organization. + //Does not correlate to config file structure. + struct GroupBlockDef + { + QString title; //title of the block containing the property or properties of this sub-section + QStringList captions; //list of captions for widgets at the block level (not associated with any particular property) + WidgetList widgets; //list of widgets at the block level (not associated with any particular property) + QList properties; //list of the property(ies) which are subordinate to the property block. + OcsWidgetOrientation widgetOrientation; //general orientation of widgets in group block + bool isVisible; //determines whether or not box border/title are visible + bool isProxy; //indicates whether or not this block defines a proxy block + QString defaultValue; //generic default value attribute + + GroupBlockDef (): title(""), widgetOrientation (OCS_VERTICAL), isVisible (true), isProxy (false), defaultValue ("") + {} + + GroupBlockDef (QString blockTitle) + : title (blockTitle), widgetOrientation (OCS_VERTICAL), isProxy (false), isVisible (true), defaultValue ("") + {} + }; + + struct CustomBlockDef + { + QString title; + QString defaultValue; //default value for widgets unique to the custom block + GroupBlockDefList blockDefList; //list of settings groups that comprise the settings within the custom block + OcsWidgetOrientation blockOrientation; + + CustomBlockDef (): title (""), defaultValue (""), blockOrientation (OCS_HORIZONTAL) + {} + + CustomBlockDef (const QString &blockTitle) + : title (blockTitle), defaultValue (""), blockOrientation (OCS_HORIZONTAL) + {} + }; +} + +#endif // VIEW_SUPPORT_HPP diff --git a/apps/opencs/view/settings/toggleblock.cpp b/apps/opencs/view/settings/toggleblock.cpp index f30ffceb0..7c484ac97 100644 --- a/apps/opencs/view/settings/toggleblock.cpp +++ b/apps/opencs/view/settings/toggleblock.cpp @@ -3,11 +3,11 @@ #include "groupbox.hpp" #include "itemblock.hpp" -CsSettings::ToggleBlock::ToggleBlock(QWidget *parent) : +CSVSettings::ToggleBlock::ToggleBlock(QWidget *parent) : CustomBlock(parent) {} -int CsSettings::ToggleBlock::build(CustomBlockDef &def) +int CSVSettings::ToggleBlock::build(CustomBlockDef &def) { if (def.blockDefList.size()==0) return -1; @@ -49,7 +49,7 @@ int CsSettings::ToggleBlock::build(CustomBlockDef &def) return 0; } -CsSettings::GroupBox *CsSettings::ToggleBlock::buildToggleWidgets (GroupBlockDef &def, QString &defaultToggle) +CSVSettings::GroupBox *CSVSettings::ToggleBlock::buildToggleWidgets (GroupBlockDef &def, QString &defaultToggle) { GroupBox *box = new GroupBox (false, getParent()); diff --git a/apps/opencs/view/settings/toggleblock.hpp b/apps/opencs/view/settings/toggleblock.hpp index 990dc0826..8afe701b8 100644 --- a/apps/opencs/view/settings/toggleblock.hpp +++ b/apps/opencs/view/settings/toggleblock.hpp @@ -5,7 +5,7 @@ #include "customblock.hpp" -namespace CsSettings +namespace CSVSettings { class GroupBlock; class GroupBox; diff --git a/apps/opencs/view/settings/usersettingsdialog.cpp b/apps/opencs/view/settings/usersettingsdialog.cpp index 19c81fde9..9e3c01eda 100644 --- a/apps/opencs/view/settings/usersettingsdialog.cpp +++ b/apps/opencs/view/settings/usersettingsdialog.cpp @@ -17,7 +17,7 @@ #include "settingwidget.hpp" #include -CsSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) : +CSVSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) : QMainWindow (parent), mUserSettings (mCfgMgr), mStackedWidget (0) { setWindowTitle(QString::fromUtf8 ("User Settings")); @@ -31,22 +31,22 @@ CsSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) : SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*))); } -CsSettings::UserSettingsDialog::~UserSettingsDialog() +CSVSettings::UserSettingsDialog::~UserSettingsDialog() { } -void CsSettings::UserSettingsDialog::closeEvent (QCloseEvent *event) +void CSVSettings::UserSettingsDialog::closeEvent (QCloseEvent *event) { writeSettings(); } -void CsSettings::UserSettingsDialog::setWidgetStates (SectionMap settingsMap) +void CSVSettings::UserSettingsDialog::setWidgetStates (CSMSettings::SectionMap settingsMap) { //iterate the tabWidget's pages (sections) for (int i = 0; i < mStackedWidget->count(); i++) { //get the settings defined for the entire section - CsSettings::SettingMap *settings = settingsMap [mStackedWidget->widget(i)->objectName()]; + CSMSettings::SettingMap *settings = settingsMap [mStackedWidget->widget(i)->objectName()]; //if found, initialize the page's widgets if (settings) @@ -57,7 +57,7 @@ void CsSettings::UserSettingsDialog::setWidgetStates (SectionMap settingsMap) } } -void CsSettings::UserSettingsDialog::buildPages() +void CSVSettings::UserSettingsDialog::buildPages() { //craete central widget with it's layout and immediate children QWidget *centralWidget = new QWidget (this); @@ -75,17 +75,17 @@ void CsSettings::UserSettingsDialog::buildPages() setCentralWidget (centralWidget); setDockOptions (QMainWindow::AllowNestedDocks); //uncomment to test with sample editor page. - //createSamplePage(); + createSamplePage(); createPage("Page1"); createPage("Page2"); createPage("Page3"); } -void CsSettings::UserSettingsDialog::createSamplePage() +void CSVSettings::UserSettingsDialog::createSamplePage() { //add pages to stackedwidget and items to listwidget - CsSettings::AbstractPage *page - = new CsSettings::EditorPage(this); + CSVSettings::AbstractPage *page + = new CSVSettings::EditorPage(this); mStackedWidget->addWidget (page); @@ -95,7 +95,7 @@ void CsSettings::UserSettingsDialog::createSamplePage() this, SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &))); } -void CsSettings::UserSettingsDialog::positionWindow () +void CSVSettings::UserSettingsDialog::positionWindow () { QRect scr = QApplication::desktop()->screenGeometry(); @@ -103,14 +103,14 @@ void CsSettings::UserSettingsDialog::positionWindow () } -CsSettings::SectionMap CsSettings::UserSettingsDialog::loadSettings () +CSMSettings::SectionMap CSVSettings::UserSettingsDialog::loadSettings () { QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string()); mPaths.append(QString("opencs.cfg")); mPaths.append(userPath + QString("opencs.cfg")); - SectionMap settingsMap; + CSMSettings::SectionMap settingsMap; foreach (const QString &path, mPaths) { @@ -144,9 +144,9 @@ CsSettings::SectionMap CsSettings::UserSettingsDialog::loadSettings () return settingsMap; } -void CsSettings::UserSettingsDialog::writeSettings() +void CSVSettings::UserSettingsDialog::writeSettings() { - QMap settings; + QMap settings; for (int i = 0; i < mStackedWidget->count(); ++i) { @@ -158,12 +158,12 @@ void CsSettings::UserSettingsDialog::writeSettings() } -CsSettings::AbstractPage *CsSettings::UserSettingsDialog::getAbstractPage (int index) +CSVSettings::AbstractPage *CSVSettings::UserSettingsDialog::getAbstractPage (int index) { return dynamic_cast(mStackedWidget->widget(index)); } -void CsSettings::UserSettingsDialog::slotChangePage(QListWidgetItem *current, QListWidgetItem *previous) +void CSVSettings::UserSettingsDialog::slotChangePage(QListWidgetItem *current, QListWidgetItem *previous) { if (!current) current = previous; diff --git a/apps/opencs/view/settings/usersettingsdialog.hpp b/apps/opencs/view/settings/usersettingsdialog.hpp index 9836fa5d9..be36d49c2 100644 --- a/apps/opencs/view/settings/usersettingsdialog.hpp +++ b/apps/opencs/view/settings/usersettingsdialog.hpp @@ -13,7 +13,7 @@ class AbstractWidget; class QStackedWidget; class QListWidget; -namespace CsSettings { +namespace CSVSettings { class AbstractPage; class UserSettingsDialog : public QMainWindow @@ -23,7 +23,7 @@ namespace CsSettings { QStringList mPaths; QListWidget *mListWidget; QStackedWidget *mStackedWidget; - UserSettings mUserSettings; + CSMSettings::UserSettings mUserSettings; Files::ConfigurationManager mCfgMgr; public: @@ -34,10 +34,10 @@ namespace CsSettings { void closeEvent (QCloseEvent *event); AbstractPage *getAbstractPage (int index); - void setWidgetStates (SectionMap settingsMap); + void setWidgetStates (CSMSettings::SectionMap settingsMap); void buildPages(); void positionWindow (); - SectionMap loadSettings(); + CSMSettings::SectionMap loadSettings(); void writeSettings(); void createSamplePage();