split off settings page label from internal section name

loadfix
Marc Zinnschlag 10 years ago
parent 720ba2c0d8
commit c94c1adaf3

@ -50,7 +50,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
{ {
QString section; QString section;
declareSection ("Objects"); declareSection ("Objects", "Objects");
{ {
Setting *numLights = createSetting (Type_SpinBox, "num_lights", "num_lights"); Setting *numLights = createSetting (Type_SpinBox, "num_lights", "num_lights");
numLights->setDefaultValue(8); numLights->setDefaultValue(8);
@ -58,10 +58,9 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
Setting *shaders = createSetting (Type_CheckBox, "shaders", "Enable Shaders"); Setting *shaders = createSetting (Type_CheckBox, "shaders", "Enable Shaders");
shaders->setDefaultValue("true"); shaders->setDefaultValue("true");
// shaders->setSpecialValueText("Enable Shaders");
} }
declareSection ("Scene"); declareSection ("Scene", "Scene");
{ {
Setting *fastFactor = createSetting (Type_SpinBox, "fast factor", "fast factor"); Setting *fastFactor = createSetting (Type_SpinBox, "fast factor", "fast factor");
fastFactor->setDefaultValue(4); fastFactor->setDefaultValue(4);
@ -76,7 +75,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
timerStart->setRange (1, 100); timerStart->setRange (1, 100);
} }
declareSection ("SubView"); declareSection ("SubView", "SubView");
{ {
Setting *maxSubView = createSetting (Type_SpinBox, "max subviews", "max subviews"); Setting *maxSubView = createSetting (Type_SpinBox, "max subviews", "max subviews");
maxSubView->setDefaultValue(256); maxSubView->setDefaultValue(256);
@ -91,7 +90,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
// reuse->setSpecialValueText("Reuse SubView"); // reuse->setSpecialValueText("Reuse SubView");
} }
declareSection ("Window Size"); declareSection ("Window Size", "Window Size");
{ {
Setting *width = createSetting (Type_LineEdit, "Width", "Width"); Setting *width = createSetting (Type_LineEdit, "Width", "Width");
Setting *height = createSetting (Type_LineEdit, "Height", "Height"); Setting *height = createSetting (Type_LineEdit, "Height", "Height");
@ -124,7 +123,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
); );
} }
declareSection ("Display Format"); declareSection ("Display Format", "Display Format");
{ {
QString defaultValue = "Icon and Text"; QString defaultValue = "Icon and Text";
@ -139,7 +138,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
ritd->setDeclaredValues (values); ritd->setDeclaredValues (values);
} }
declareSection ("Video"); declareSection ("Video", "Video");
{ {
QString defaultValue = "None"; QString defaultValue = "None";
QStringList values = QStringList() QStringList values = QStringList()
@ -480,7 +479,23 @@ CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const
SettingPageMap pageMap; SettingPageMap pageMap;
foreach (Setting *setting, mSettings) foreach (Setting *setting, mSettings)
pageMap[setting->page()].append (setting); {
SettingPageMap::iterator iter = pageMap.find (setting->page());
if (iter==pageMap.end())
{
QPair<QString, QList <Setting *> > value;
std::map<QString, QString>::const_iterator iter2 =
mSectionLabels.find (setting->page());
value.first = iter2!=mSectionLabels.end() ? iter2->second : "";
iter = pageMap.insert (setting->page(), value);
}
iter->second.append (setting);
}
return pageMap; return pageMap;
} }
@ -532,9 +547,10 @@ CSMSettings::Setting *CSMSettings::UserSettings::createSetting
return setting; return setting;
} }
void CSMSettings::UserSettings::declareSection (const QString& page) void CSMSettings::UserSettings::declareSection (const QString& page, const QString& label)
{ {
mSection = page; mSection = page;
mSectionLabels[page] = label;
} }
QStringList CSMSettings::UserSettings::definitions (const QString &viewKey) const QStringList CSMSettings::UserSettings::definitions (const QString &viewKey) const

@ -1,10 +1,13 @@
#ifndef USERSETTINGS_HPP #ifndef USERSETTINGS_HPP
#define USERSETTINGS_HPP #define USERSETTINGS_HPP
#include <map>
#include <QList> #include <QList>
#include <QStringList> #include <QStringList>
#include <QString> #include <QString>
#include <QMap> #include <QMap>
#include <QPair>
#include <boost/filesystem/path.hpp> #include <boost/filesystem/path.hpp>
#include "support.hpp" #include "support.hpp"
@ -22,7 +25,7 @@ class QSettings;
namespace CSMSettings { namespace CSMSettings {
class Setting; class Setting;
typedef QMap <QString, QList <Setting *> > SettingPageMap; typedef QMap <QString, QPair<QString, QList <Setting *> > > SettingPageMap;
class UserSettings: public QObject class UserSettings: public QObject
{ {
@ -36,7 +39,7 @@ namespace CSMSettings {
QSettings *mSettingCfgDefinitions; QSettings *mSettingCfgDefinitions;
QList <Setting *> mSettings; QList <Setting *> mSettings;
QString mSection; QString mSection;
std::map<QString, QString> mSectionLabels;
public: public:
@ -91,7 +94,7 @@ namespace CSMSettings {
/// Set the section for createSetting calls. /// Set the section for createSetting calls.
/// ///
/// Sections can be declared multiple times. /// Sections can be declared multiple times.
void declareSection (const QString& page); void declareSection (const QString& page, const QString& label);
signals: signals:

@ -67,11 +67,9 @@ void CSVSettings::Dialog::buildPages()
foreach (Page *page, SettingWindow::pages()) foreach (Page *page, SettingWindow::pages())
{ {
QString pageName = page->objectName(); maxWidth = std::max (maxWidth, fm.width(page->getLabel()));
maxWidth = std::max (maxWidth, fm.width(pageName)); new QListWidgetItem (page->getLabel(), mPageListWidget);
new QListWidgetItem (pageName, mPageListWidget);
mStackedWidget->addWidget (page); mStackedWidget->addWidget (page);
} }

@ -17,10 +17,9 @@
QMap <CSVSettings::ViewType, CSVSettings::IViewFactory *> QMap <CSVSettings::ViewType, CSVSettings::IViewFactory *>
CSVSettings::Page::mViewFactories; CSVSettings::Page::mViewFactories;
CSVSettings::Page::Page(const QString &pageName, CSVSettings::Page::Page (const QString &pageName, QList <CSMSettings::Setting *> settingList,
QList <CSMSettings::Setting *> settingList, SettingWindow *parent, const QString& label)
SettingWindow *parent) : : mParent(parent), mIsEditorPage (false), Frame(false, "", parent), mLabel (label)
mParent(parent), mIsEditorPage (false), Frame(false, "", parent)
{ {
setObjectName (pageName); setObjectName (pageName);
@ -104,3 +103,8 @@ void CSVSettings::Page::buildFactories()
mViewFactories[ViewType_List] = new ListViewFactory (this); mViewFactories[ViewType_List] = new ListViewFactory (this);
mViewFactories[ViewType_Range] = new RangeViewFactory (this); mViewFactories[ViewType_Range] = new RangeViewFactory (this);
} }
QString CSVSettings::Page::getLabel() const
{
return mLabel;
}

@ -25,11 +25,11 @@ namespace CSVSettings
SettingWindow *mParent; SettingWindow *mParent;
static QMap <ViewType, IViewFactory *> mViewFactories; static QMap <ViewType, IViewFactory *> mViewFactories;
bool mIsEditorPage; bool mIsEditorPage;
QString mLabel;
public: public:
explicit Page(const QString &pageName, Page (const QString &pageName, QList <CSMSettings::Setting *> settingList,
QList <CSMSettings::Setting *> settingList, SettingWindow *parent, const QString& label);
SettingWindow *parent);
///Creates a new view based on the passed setting and adds it to ///Creates a new view based on the passed setting and adds it to
///the page. ///the page.
@ -42,6 +42,8 @@ namespace CSVSettings
///returns the list of views associated with the page ///returns the list of views associated with the page
const QList <View *> &views () const { return mViews; } const QList <View *> &views () const { return mViews; }
QString getLabel() const;
private: private:
///Creates views based on the passed setting list ///Creates views based on the passed setting list

@ -20,9 +20,9 @@ void CSVSettings::SettingWindow::createPages()
foreach (const QString &pageName, pageMap.keys()) foreach (const QString &pageName, pageMap.keys())
{ {
QList <CSMSettings::Setting *> pageSettings = pageMap.value (pageName); QList <CSMSettings::Setting *> pageSettings = pageMap.value (pageName).second;
mPages.append (new Page (pageName, pageSettings, this)); mPages.append (new Page (pageName, pageSettings, this, pageMap.value (pageName).first));
for (int i = 0; i < pageSettings.size(); i++) for (int i = 0; i < pageSettings.size(); i++)
{ {

Loading…
Cancel
Save