forked from mirror/openmw-tes3mp
Merge remote-tracking branch 'graffy76/master'
This commit is contained in:
commit
e43913e7c2
19 changed files with 641 additions and 182 deletions
|
@ -97,6 +97,7 @@ opencs_units (view/settings
|
||||||
listview
|
listview
|
||||||
rangeview
|
rangeview
|
||||||
resizeablestackedwidget
|
resizeablestackedwidget
|
||||||
|
spinbox
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (view/settings
|
opencs_units_noqt (view/settings
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
#include "setting.hpp"
|
#include "setting.hpp"
|
||||||
#include "support.hpp"
|
#include "support.hpp"
|
||||||
|
|
||||||
CSMSettings::Setting::Setting()
|
|
||||||
{
|
|
||||||
buildDefaultSetting();
|
|
||||||
}
|
|
||||||
|
|
||||||
CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
|
CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
|
||||||
const QString &pageName, const QStringList &values)
|
const QString &pageName)
|
||||||
: mIsEditorSetting (false)
|
: mIsEditorSetting (false)
|
||||||
{
|
{
|
||||||
buildDefaultSetting();
|
buildDefaultSetting();
|
||||||
|
@ -19,10 +14,9 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
|
||||||
setProperty (Property_IsMultiValue, QVariant(true).toString());
|
setProperty (Property_IsMultiValue, QVariant(true).toString());
|
||||||
|
|
||||||
//view type is related to setting type by an order of magnitude
|
//view type is related to setting type by an order of magnitude
|
||||||
setProperty (Property_ViewType, QVariant (settingType / 10).toString());
|
setProperty (Property_SettingType, QVariant (settingType).toString());
|
||||||
setProperty (Property_Page, pageName);
|
setProperty (Property_Page, pageName);
|
||||||
setProperty (Property_Name, settingName);
|
setProperty (Property_Name, settingName);
|
||||||
setProperty (Property_DeclaredValues, values);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::buildDefaultSetting()
|
void CSMSettings::Setting::buildDefaultSetting()
|
||||||
|
@ -73,6 +67,11 @@ int CSMSettings::Setting::columnSpan() const
|
||||||
return property (Property_ColumnSpan).at(0).toInt();
|
return property (Property_ColumnSpan).at(0).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setDeclaredValues (QStringList list)
|
||||||
|
{
|
||||||
|
setProperty (Property_DeclaredValues, list);
|
||||||
|
}
|
||||||
|
|
||||||
QStringList CSMSettings::Setting::declaredValues() const
|
QStringList CSMSettings::Setting::declaredValues() const
|
||||||
{
|
{
|
||||||
return property (Property_DeclaredValues);
|
return property (Property_DeclaredValues);
|
||||||
|
@ -96,6 +95,16 @@ QStringList CSMSettings::Setting::property (SettingProperty prop) const
|
||||||
return mProperties.at(prop);
|
return mProperties.at(prop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setDefaultValue (int value)
|
||||||
|
{
|
||||||
|
setDefaultValues (QStringList() << QVariant (value).toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setDefaultValue (double value)
|
||||||
|
{
|
||||||
|
setDefaultValues (QStringList() << QVariant (value).toString());
|
||||||
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::setDefaultValue (const QString &value)
|
void CSMSettings::Setting::setDefaultValue (const QString &value)
|
||||||
{
|
{
|
||||||
setDefaultValues (QStringList() << value);
|
setDefaultValues (QStringList() << value);
|
||||||
|
@ -165,6 +174,16 @@ bool CSMSettings::Setting::serializable() const
|
||||||
return (property (Property_Serializable).at(0) == "true");
|
return (property (Property_Serializable).at(0) == "true");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setSpecialValueText(const QString &text)
|
||||||
|
{
|
||||||
|
setProperty (Property_SpecialValueText, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSMSettings::Setting::specialValueText() const
|
||||||
|
{
|
||||||
|
return property (Property_SpecialValueText).at(0);
|
||||||
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::setName (const QString &value)
|
void CSMSettings::Setting::setName (const QString &value)
|
||||||
{
|
{
|
||||||
setProperty (Property_Name, value);
|
setProperty (Property_Name, value);
|
||||||
|
@ -185,6 +204,16 @@ QString CSMSettings::Setting::page() const
|
||||||
return property (Property_Page).at(0);
|
return property (Property_Page).at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setPrefix (const QString &value)
|
||||||
|
{
|
||||||
|
setProperty (Property_Prefix, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSMSettings::Setting::prefix() const
|
||||||
|
{
|
||||||
|
return property (Property_Prefix).at(0);
|
||||||
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::setRowSpan (const int value)
|
void CSMSettings::Setting::setRowSpan (const int value)
|
||||||
{
|
{
|
||||||
setProperty (Property_RowSpan, value);
|
setProperty (Property_RowSpan, value);
|
||||||
|
@ -195,15 +224,106 @@ int CSMSettings::Setting::rowSpan () const
|
||||||
return property (Property_RowSpan).at(0).toInt();
|
return property (Property_RowSpan).at(0).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::setViewType (int vType)
|
void CSMSettings::Setting::setSingleStep (int value)
|
||||||
{
|
{
|
||||||
setProperty (Property_ViewType, vType);
|
setProperty (Property_SingleStep, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setSingleStep (double value)
|
||||||
|
{
|
||||||
|
setProperty (Property_SingleStep, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSMSettings::Setting::singleStep() const
|
||||||
|
{
|
||||||
|
return property (Property_SingleStep).at(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setSuffix (const QString &value)
|
||||||
|
{
|
||||||
|
setProperty (Property_Suffix, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSMSettings::Setting::suffix() const
|
||||||
|
{
|
||||||
|
return property (Property_Suffix).at(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setTickInterval (int value)
|
||||||
|
{
|
||||||
|
setProperty (Property_TickInterval, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSMSettings::Setting::tickInterval () const
|
||||||
|
{
|
||||||
|
return property (Property_TickInterval).at(0).toInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setTicksAbove (bool state)
|
||||||
|
{
|
||||||
|
setProperty (Property_TicksAbove, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSMSettings::Setting::ticksAbove() const
|
||||||
|
{
|
||||||
|
return (property (Property_TicksAbove).at(0) == "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setTicksBelow (bool state)
|
||||||
|
{
|
||||||
|
setProperty (Property_TicksBelow, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSMSettings::Setting::ticksBelow() const
|
||||||
|
{
|
||||||
|
return (property (Property_TicksBelow).at(0) == "true");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setType (int settingType)
|
||||||
|
{
|
||||||
|
setProperty (Property_SettingType, settingType);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSMSettings::SettingType CSMSettings::Setting::type() const
|
||||||
|
{
|
||||||
|
return static_cast <CSMSettings::SettingType> ( property (
|
||||||
|
Property_SettingType).at(0).toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setMaximum (int value)
|
||||||
|
{
|
||||||
|
setProperty (Property_Maximum, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setMaximum (double value)
|
||||||
|
{
|
||||||
|
setProperty (Property_Maximum, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSMSettings::Setting::maximum() const
|
||||||
|
{
|
||||||
|
return property (Property_Maximum).at(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setMinimum (int value)
|
||||||
|
{
|
||||||
|
setProperty (Property_Minimum, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setMinimum (double value)
|
||||||
|
{
|
||||||
|
setProperty (Property_Minimum, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSMSettings::Setting::minimum() const
|
||||||
|
{
|
||||||
|
return property (Property_Minimum).at(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVSettings::ViewType CSMSettings::Setting::viewType() const
|
CSVSettings::ViewType CSMSettings::Setting::viewType() const
|
||||||
{
|
{
|
||||||
return static_cast <CSVSettings::ViewType>
|
return static_cast <CSVSettings::ViewType> ( property (
|
||||||
(property(Property_ViewType).at(0).toInt());
|
Property_SettingType).at(0).toInt() / 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::setViewColumn (int value)
|
void CSMSettings::Setting::setViewColumn (int value)
|
||||||
|
@ -241,6 +361,17 @@ int CSMSettings::Setting::widgetWidth() const
|
||||||
{
|
{
|
||||||
return property (Property_WidgetWidth).at(0).toInt();
|
return property (Property_WidgetWidth).at(0).toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setWrapping (bool state)
|
||||||
|
{
|
||||||
|
setProperty (Property_Wrapping, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CSMSettings::Setting::wrapping() const
|
||||||
|
{
|
||||||
|
return (property (Property_Wrapping).at(0) == "true");
|
||||||
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::setProperty (SettingProperty prop, bool value)
|
void CSMSettings::Setting::setProperty (SettingProperty prop, bool value)
|
||||||
{
|
{
|
||||||
setProperty (prop, QStringList() << QVariant (value).toString());
|
setProperty (prop, QStringList() << QVariant (value).toString());
|
||||||
|
@ -251,6 +382,11 @@ void CSMSettings::Setting::setProperty (SettingProperty prop, int value)
|
||||||
setProperty (prop, QStringList() << QVariant (value).toString());
|
setProperty (prop, QStringList() << QVariant (value).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSMSettings::Setting::setProperty (SettingProperty prop, double value)
|
||||||
|
{
|
||||||
|
setProperty (prop, QStringList() << QVariant (value).toString());
|
||||||
|
}
|
||||||
|
|
||||||
void CSMSettings::Setting::setProperty (SettingProperty prop,
|
void CSMSettings::Setting::setProperty (SettingProperty prop,
|
||||||
const QString &value)
|
const QString &value)
|
||||||
{
|
{
|
||||||
|
@ -263,18 +399,3 @@ void CSMSettings::Setting::setProperty (SettingProperty prop,
|
||||||
if (prop < mProperties.size())
|
if (prop < mProperties.size())
|
||||||
mProperties.replace (prop, value);
|
mProperties.replace (prop, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDataStream &operator <<(QDataStream &stream, const CSMSettings::Setting& setting)
|
|
||||||
{
|
|
||||||
// stream << setting.properties();
|
|
||||||
|
|
||||||
// stream << setting.proxies();
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
||||||
QDataStream &operator >>(QDataStream& stream, CSMSettings::Setting& setting)
|
|
||||||
{
|
|
||||||
// stream >> setting.properties();
|
|
||||||
// stream >> setting.proxies();
|
|
||||||
return stream;
|
|
||||||
}
|
|
||||||
|
|
|
@ -27,12 +27,8 @@ namespace CSMSettings
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
explicit Setting();
|
|
||||||
|
|
||||||
explicit Setting(SettingType typ, const QString &settingName,
|
explicit Setting(SettingType typ, const QString &settingName,
|
||||||
const QString &pageName,
|
const QString &pageName);
|
||||||
const QStringList &values = QStringList());
|
|
||||||
|
|
||||||
void addProxy (const Setting *setting, const QStringList &vals);
|
void addProxy (const Setting *setting, const QStringList &vals);
|
||||||
void addProxy (const Setting *setting, const QList <QStringList> &list);
|
void addProxy (const Setting *setting, const QList <QStringList> &list);
|
||||||
|
@ -49,6 +45,8 @@ namespace CSMSettings
|
||||||
void setDefinedValues (QStringList list);
|
void setDefinedValues (QStringList list);
|
||||||
QStringList definedValues() const;
|
QStringList definedValues() const;
|
||||||
|
|
||||||
|
void setDefaultValue (int value);
|
||||||
|
void setDefaultValue (double value);
|
||||||
void setDefaultValue (const QString &value);
|
void setDefaultValue (const QString &value);
|
||||||
|
|
||||||
void setDefaultValues (const QStringList &values);
|
void setDefaultValues (const QStringList &values);
|
||||||
|
@ -66,12 +64,26 @@ namespace CSMSettings
|
||||||
void setIsMultiValue (bool state);
|
void setIsMultiValue (bool state);
|
||||||
bool isMultiValue() const;
|
bool isMultiValue() const;
|
||||||
|
|
||||||
|
void setMask (const QString &value);
|
||||||
|
QString mask() const;
|
||||||
|
|
||||||
|
void setMaximum (int value);
|
||||||
|
void setMaximum (double value);
|
||||||
|
QString maximum() const;
|
||||||
|
|
||||||
|
void setMinimum (int value);
|
||||||
|
void setMinimum (double value);
|
||||||
|
QString minimum() const;
|
||||||
|
|
||||||
void setName (const QString &value);
|
void setName (const QString &value);
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
||||||
void setPage (const QString &value);
|
void setPage (const QString &value);
|
||||||
QString page() const;
|
QString page() const;
|
||||||
|
|
||||||
|
void setPrefix (const QString &value);
|
||||||
|
QString prefix() const;
|
||||||
|
|
||||||
void setRowSpan (const int value);
|
void setRowSpan (const int value);
|
||||||
int rowSpan() const;
|
int rowSpan() const;
|
||||||
|
|
||||||
|
@ -80,6 +92,25 @@ namespace CSMSettings
|
||||||
void setSerializable (bool state);
|
void setSerializable (bool state);
|
||||||
bool serializable() const;
|
bool serializable() const;
|
||||||
|
|
||||||
|
void setSpecialValueText (const QString &text);
|
||||||
|
QString specialValueText() const;
|
||||||
|
|
||||||
|
void setSingleStep (int value);
|
||||||
|
void setSingleStep (double value);
|
||||||
|
QString singleStep() const;
|
||||||
|
|
||||||
|
void setSuffix (const QString &value);
|
||||||
|
QString suffix() const;
|
||||||
|
|
||||||
|
void setTickInterval (int value);
|
||||||
|
int tickInterval() const;
|
||||||
|
|
||||||
|
void setTicksAbove (bool state);
|
||||||
|
bool ticksAbove() const;
|
||||||
|
|
||||||
|
void setTicksBelow (bool state);
|
||||||
|
bool ticksBelow() const;
|
||||||
|
|
||||||
void setViewColumn (int value);
|
void setViewColumn (int value);
|
||||||
int viewColumn() const;
|
int viewColumn() const;
|
||||||
|
|
||||||
|
@ -88,9 +119,14 @@ namespace CSMSettings
|
||||||
void setViewRow (int value);
|
void setViewRow (int value);
|
||||||
int viewRow() const;
|
int viewRow() const;
|
||||||
|
|
||||||
void setViewType (int vType);
|
void setType (int settingType);
|
||||||
|
CSMSettings::SettingType type() const;
|
||||||
|
|
||||||
CSVSettings::ViewType viewType() const;
|
CSVSettings::ViewType viewType() const;
|
||||||
|
|
||||||
|
void setWrapping (bool state);
|
||||||
|
bool wrapping() const;
|
||||||
|
|
||||||
void setWidgetWidth (int value);
|
void setWidgetWidth (int value);
|
||||||
int widgetWidth() const;
|
int widgetWidth() const;
|
||||||
|
|
||||||
|
@ -100,6 +136,7 @@ namespace CSMSettings
|
||||||
///boilerplate code to convert setting values of common types
|
///boilerplate code to convert setting values of common types
|
||||||
void setProperty (SettingProperty prop, bool value);
|
void setProperty (SettingProperty prop, bool value);
|
||||||
void setProperty (SettingProperty prop, int value);
|
void setProperty (SettingProperty prop, int value);
|
||||||
|
void setProperty (SettingProperty prop, double value);
|
||||||
void setProperty (SettingProperty prop, const QString &value);
|
void setProperty (SettingProperty prop, const QString &value);
|
||||||
void setProperty (SettingProperty prop, const QStringList &value);
|
void setProperty (SettingProperty prop, const QStringList &value);
|
||||||
|
|
||||||
|
@ -111,9 +148,4 @@ namespace CSMSettings
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(CSMSettings::Setting)
|
|
||||||
|
|
||||||
QDataStream &operator <<(QDataStream &stream, const CSMSettings::Setting& setting);
|
|
||||||
QDataStream &operator >>(QDataStream &stream, CSMSettings::Setting& setting);
|
|
||||||
|
|
||||||
#endif // CSMSETTINGS_SETTING_HPP
|
#endif // CSMSETTINGS_SETTING_HPP
|
||||||
|
|
|
@ -30,8 +30,7 @@ void CSMSettings::SettingManager::dumpModel()
|
||||||
}
|
}
|
||||||
|
|
||||||
CSMSettings::Setting *CSMSettings::SettingManager::createSetting
|
CSMSettings::Setting *CSMSettings::SettingManager::createSetting
|
||||||
(CSMSettings::SettingType typ, const QString &page, const QString &name,
|
(CSMSettings::SettingType typ, const QString &page, const QString &name)
|
||||||
const QStringList &values)
|
|
||||||
{
|
{
|
||||||
//get list of all settings for the current setting name
|
//get list of all settings for the current setting name
|
||||||
if (findSetting (page, name))
|
if (findSetting (page, name))
|
||||||
|
@ -41,7 +40,8 @@ CSMSettings::Setting *CSMSettings::SettingManager::createSetting
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Setting *setting = new Setting (typ, name, page, values);
|
Setting *setting = new Setting (typ, name, page);
|
||||||
|
|
||||||
|
|
||||||
//add declaration to the model
|
//add declaration to the model
|
||||||
mSettings.append (setting);
|
mSettings.append (setting);
|
||||||
|
|
|
@ -46,8 +46,7 @@ namespace CSMSettings
|
||||||
|
|
||||||
///add a new setting to the model and return it
|
///add a new setting to the model and return it
|
||||||
Setting *createSetting (CSMSettings::SettingType typ,
|
Setting *createSetting (CSMSettings::SettingType typ,
|
||||||
const QString &page, const QString &name,
|
const QString &page, const QString &name);
|
||||||
const QStringList &values = QStringList());
|
|
||||||
|
|
||||||
///add definitions to the settings specified in the page map
|
///add definitions to the settings specified in the page map
|
||||||
void addDefinitions (DefinitionPageMap &pageMap);
|
void addDefinitions (DefinitionPageMap &pageMap);
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace CSMSettings
|
||||||
{
|
{
|
||||||
Property_Name = 0,
|
Property_Name = 0,
|
||||||
Property_Page = 1,
|
Property_Page = 1,
|
||||||
Property_ViewType = 2,
|
Property_SettingType = 2,
|
||||||
Property_IsMultiValue = 3,
|
Property_IsMultiValue = 3,
|
||||||
Property_IsMultiLine = 4,
|
Property_IsMultiLine = 4,
|
||||||
Property_WidgetWidth = 5,
|
Property_WidgetWidth = 5,
|
||||||
|
@ -37,12 +37,22 @@ namespace CSMSettings
|
||||||
Property_Serializable = 9,
|
Property_Serializable = 9,
|
||||||
Property_ColumnSpan = 10,
|
Property_ColumnSpan = 10,
|
||||||
Property_RowSpan = 11,
|
Property_RowSpan = 11,
|
||||||
|
Property_Minimum = 12,
|
||||||
|
Property_Maximum = 13,
|
||||||
|
Property_SpecialValueText = 14,
|
||||||
|
Property_Prefix = 15,
|
||||||
|
Property_Suffix = 16,
|
||||||
|
Property_SingleStep = 17,
|
||||||
|
Property_Wrapping = 18,
|
||||||
|
Property_TickInterval = 19,
|
||||||
|
Property_TicksAbove = 20,
|
||||||
|
Property_TicksBelow = 21,
|
||||||
|
|
||||||
//Stringlists should always be the last items
|
//Stringlists should always be the last items
|
||||||
Property_DefaultValues = 12,
|
Property_DefaultValues = 22,
|
||||||
Property_DeclaredValues = 13,
|
Property_DeclaredValues = 23,
|
||||||
Property_DefinedValues = 14,
|
Property_DefinedValues = 24,
|
||||||
Property_Proxies = 15
|
Property_Proxies = 25
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SettingType
|
enum SettingType
|
||||||
|
@ -64,10 +74,12 @@ namespace CSMSettings
|
||||||
Type_ListView = 10,
|
Type_ListView = 10,
|
||||||
Type_ComboBox = 11,
|
Type_ComboBox = 11,
|
||||||
Type_SpinBox = 21,
|
Type_SpinBox = 21,
|
||||||
Type_Slider = 23,
|
Type_DoubleSpinBox = 23,
|
||||||
Type_Dial = 24,
|
Type_Slider = 25,
|
||||||
|
Type_Dial = 27,
|
||||||
Type_TextArea = 30,
|
Type_TextArea = 30,
|
||||||
Type_LineEdit = 31
|
Type_LineEdit = 31,
|
||||||
|
Type_Undefined = 40
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MergeMethod
|
enum MergeMethod
|
||||||
|
@ -97,7 +109,7 @@ namespace CSVSettings
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
namespace CSMSettings
|
namespace CSMSettings
|
||||||
{
|
{
|
||||||
struct PropertyDefaultValues
|
struct PropertyDefaultValues
|
||||||
|
@ -109,9 +121,11 @@ namespace CSMSettings
|
||||||
|
|
||||||
const QString sPropertyNames[] =
|
const QString sPropertyNames[] =
|
||||||
{
|
{
|
||||||
"name", "page", "view_type", "is_multi_value",
|
"name", "page", "setting_type", "is_multi_value",
|
||||||
"is_multi_line", "widget_width", "view_row", "view_column", "delimiter",
|
"is_multi_line", "widget_width", "view_row", "view_column", "delimiter",
|
||||||
"is_serializable","column_span", "row_span",
|
"is_serializable","column_span", "row_span", "minimum", "maximum",
|
||||||
|
"special_value_text", "prefix", "suffix", "single_step", "wrapping",
|
||||||
|
"tick_interval", "ticks_above", "ticks_below",
|
||||||
"defaults", "declarations", "definitions", "proxies"
|
"defaults", "declarations", "definitions", "proxies"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -119,16 +133,26 @@ namespace CSMSettings
|
||||||
{
|
{
|
||||||
"", //name
|
"", //name
|
||||||
"", //page
|
"", //page
|
||||||
"0", //view type
|
"40", //setting type
|
||||||
"false", //multivalue
|
"false", //multivalue
|
||||||
"false", //multiline
|
"false", //multiline
|
||||||
"0", //widget width
|
"7", //widget width
|
||||||
"-1", //view row
|
"-1", //view row
|
||||||
"-1", //view column
|
"-1", //view column
|
||||||
",", //delimiter
|
",", //delimiter
|
||||||
"true", //serialized
|
"true", //serialized
|
||||||
"1", //column span
|
"1", //column span
|
||||||
"1", //row span
|
"1", //row span
|
||||||
|
"0", //value range
|
||||||
|
"0", //value minimum
|
||||||
|
"0", //value maximum
|
||||||
|
"", //special text
|
||||||
|
"", //prefix
|
||||||
|
"", //suffix
|
||||||
|
"false", //wrapping
|
||||||
|
"1", //tick interval
|
||||||
|
"false", //ticks above
|
||||||
|
"true", //ticks below
|
||||||
"", //default values
|
"", //default values
|
||||||
"", //declared values
|
"", //declared values
|
||||||
"", //defined values
|
"", //defined values
|
||||||
|
|
|
@ -51,7 +51,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
Setting *height = createSetting (Type_LineEdit, section, "Height");
|
Setting *height = createSetting (Type_LineEdit, section, "Height");
|
||||||
|
|
||||||
width->setWidgetWidth (5);
|
width->setWidgetWidth (5);
|
||||||
height->setWidgetWidth (5);
|
height->setWidgetWidth (8);
|
||||||
|
|
||||||
width->setDefaultValues (QStringList() << "1024");
|
width->setDefaultValues (QStringList() << "1024");
|
||||||
height->setDefaultValues (QStringList() << "768");
|
height->setDefaultValues (QStringList() << "768");
|
||||||
|
@ -66,13 +66,10 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
*Create the proxy setting for predefined values
|
*Create the proxy setting for predefined values
|
||||||
*/
|
*/
|
||||||
Setting *preDefined = createSetting (Type_ComboBox, section,
|
Setting *preDefined = createSetting (Type_ComboBox, section,
|
||||||
"Pre-Defined",
|
"Pre-Defined");
|
||||||
QStringList()
|
|
||||||
<< "640 x 480"
|
preDefined->setDeclaredValues (QStringList() << "640 x 480"
|
||||||
<< "800 x 600"
|
<< "800 x 600" << "1024 x 768" << "1440 x 900");
|
||||||
<< "1024 x 768"
|
|
||||||
<< "1440 x 900"
|
|
||||||
);
|
|
||||||
|
|
||||||
preDefined->setViewLocation (1, 1);
|
preDefined->setViewLocation (1, 1);
|
||||||
preDefined->setWidgetWidth (10);
|
preDefined->setWidgetWidth (10);
|
||||||
|
@ -95,12 +92,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
<< defaultValue << "Icon Only" << "Text Only";
|
<< defaultValue << "Icon Only" << "Text Only";
|
||||||
|
|
||||||
Setting *rsd = createSetting (Type_RadioButton,
|
Setting *rsd = createSetting (Type_RadioButton,
|
||||||
section, "Record Status Display",
|
section, "Record Status Display");
|
||||||
values);
|
|
||||||
|
|
||||||
Setting *ritd = createSetting (Type_RadioButton,
|
Setting *ritd = createSetting (Type_RadioButton,
|
||||||
section, "Referenceable ID Type Display",
|
section, "Referenceable ID Type Display");
|
||||||
values);
|
|
||||||
|
rsd->setDeclaredValues (values);
|
||||||
|
ritd->setDeclaredValues (values);
|
||||||
|
|
||||||
rsd->setEditorSetting (true);
|
rsd->setEditorSetting (true);
|
||||||
ritd->setEditorSetting (true);
|
ritd->setEditorSetting (true);
|
||||||
|
@ -108,44 +106,67 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
|
|
||||||
section = "Proxy Selection Test";
|
section = "Proxy Selection Test";
|
||||||
{
|
{
|
||||||
//create three setting objects, specifying the basic widget type,
|
/******************************************************************
|
||||||
//the setting view name, the page name, and the default value
|
* There are three types of values:
|
||||||
|
*
|
||||||
|
* Declared values
|
||||||
|
*
|
||||||
|
* Pre-determined values, typically for
|
||||||
|
* combobox drop downs and boolean (radiobutton / checkbox) labels.
|
||||||
|
* These values represent the total possible list of values that
|
||||||
|
* may define a setting. No other values are allowed.
|
||||||
|
*
|
||||||
|
* Defined values
|
||||||
|
*
|
||||||
|
* Values which represent the actual, current value of
|
||||||
|
* a setting. For settings with declared values, this must be one or
|
||||||
|
* several declared values, as appropriate.
|
||||||
|
*
|
||||||
|
* Proxy values - values the proxy master updates the proxy slave when
|
||||||
|
* it's own definition is set / changed. These are definitions for
|
||||||
|
* proxy slave settings, but must match any declared values the proxy
|
||||||
|
* slave has, if any.
|
||||||
|
*******************************************************************/
|
||||||
|
|
||||||
|
//create setting objects, specifying the basic widget type,
|
||||||
|
//the page name, and the view name
|
||||||
|
/*
|
||||||
Setting *masterBoolean = createSetting (Type_RadioButton, section,
|
Setting *masterBoolean = createSetting (Type_RadioButton, section,
|
||||||
"Master Proxy",
|
"Master Proxy");
|
||||||
QStringList()
|
|
||||||
<< "Profile One" << "Profile Two"
|
|
||||||
<< "Profile Three" << "Profile Four"
|
|
||||||
);
|
|
||||||
|
|
||||||
Setting *slaveBoolean = createSetting (Type_CheckBox, section,
|
Setting *slaveBoolean = createSetting (Type_CheckBox, section,
|
||||||
"Proxy Checkboxes",
|
"Proxy Checkboxes");
|
||||||
QStringList() << "One" << "Two"
|
|
||||||
<< "Three" << "Four" << "Five"
|
|
||||||
);
|
|
||||||
|
|
||||||
Setting *slaveSingleText = createSetting (Type_LineEdit, section,
|
Setting *slaveSingleText = createSetting (Type_LineEdit, section,
|
||||||
"Proxy TextBox 1"
|
"Proxy TextBox 1");
|
||||||
);
|
|
||||||
|
|
||||||
Setting *slaveMultiText = createSetting (Type_LineEdit, section,
|
Setting *slaveMultiText = createSetting (Type_LineEdit, section,
|
||||||
"ProxyTextBox 2"
|
"ProxyTextBox 2");
|
||||||
);
|
|
||||||
|
Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, section,
|
||||||
|
"Alpha Spinbox");
|
||||||
|
|
||||||
|
Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, section,
|
||||||
|
"Int Spinbox");
|
||||||
|
|
||||||
|
Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox,
|
||||||
|
section, "Double Spinbox");
|
||||||
|
|
||||||
|
Setting *slaveSlider = createSetting (Type_Slider, section, "Slider");
|
||||||
|
|
||||||
|
Setting *slaveDial = createSetting (Type_Dial, section, "Dial");
|
||||||
|
|
||||||
|
//set declared values for selected views
|
||||||
|
masterBoolean->setDeclaredValues (QStringList()
|
||||||
|
<< "Profile One" << "Profile Two"
|
||||||
|
<< "Profile Three" << "Profile Four");
|
||||||
|
|
||||||
|
slaveBoolean->setDeclaredValues (QStringList()
|
||||||
|
<< "One" << "Two" << "Three" << "Four" << "Five");
|
||||||
|
|
||||||
|
slaveAlphaSpinbox->setDeclaredValues (QStringList()
|
||||||
|
<< "One" << "Two" << "Three" << "Four");
|
||||||
|
|
||||||
// There are three types of values:
|
|
||||||
//
|
|
||||||
// Declared values - Pre-determined values, typically for
|
|
||||||
// combobox drop downs and boolean (radiobutton / checkbox) labels.
|
|
||||||
// These values represent the total possible list of values that may
|
|
||||||
// define a setting. No other values are allowed.
|
|
||||||
//
|
|
||||||
// Defined values - Values which represent the atual, current value of
|
|
||||||
// a setting. For settings with declared values, this must be one or
|
|
||||||
// several declared values, as appropriate.
|
|
||||||
//
|
|
||||||
// Proxy values - values the proxy master updates the proxy slave when
|
|
||||||
// it's own definition is set / changed. These are definitions for
|
|
||||||
// proxy slave settings, but must match any declared values the proxy
|
|
||||||
// slave has, if any.
|
|
||||||
|
|
||||||
masterBoolean->addProxy (slaveBoolean, QList <QStringList>()
|
masterBoolean->addProxy (slaveBoolean, QList <QStringList>()
|
||||||
<< (QStringList() << "One" << "Three")
|
<< (QStringList() << "One" << "Three")
|
||||||
|
@ -168,11 +189,47 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
<< (QStringList() << "Two" << "Four")
|
<< (QStringList() << "Two" << "Four")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
masterBoolean->addProxy (slaveAlphaSpinbox, QList <QStringList>()
|
||||||
|
<< (QStringList() << "Four")
|
||||||
|
<< (QStringList() << "Three")
|
||||||
|
<< (QStringList() << "Two")
|
||||||
|
<< (QStringList() << "One"));
|
||||||
|
|
||||||
|
masterBoolean->addProxy (slaveIntegerSpinbox, QList <QStringList> ()
|
||||||
|
<< (QStringList() << "0")
|
||||||
|
<< (QStringList() << "7")
|
||||||
|
<< (QStringList() << "14")
|
||||||
|
<< (QStringList() << "21"));
|
||||||
|
|
||||||
|
masterBoolean->addProxy (slaveDoubleSpinbox, QList <QStringList> ()
|
||||||
|
<< (QStringList() << "0.17")
|
||||||
|
<< (QStringList() << "0.34")
|
||||||
|
<< (QStringList() << "0.51")
|
||||||
|
<< (QStringList() << "0.68"));
|
||||||
|
|
||||||
|
masterBoolean->addProxy (slaveSlider, QList <QStringList> ()
|
||||||
|
<< (QStringList() << "25")
|
||||||
|
<< (QStringList() << "50")
|
||||||
|
<< (QStringList() << "75")
|
||||||
|
<< (QStringList() << "100")
|
||||||
|
);
|
||||||
|
|
||||||
|
masterBoolean->addProxy (slaveDial, QList <QStringList> ()
|
||||||
|
<< (QStringList() << "25")
|
||||||
|
<< (QStringList() << "50")
|
||||||
|
<< (QStringList() << "75")
|
||||||
|
<< (QStringList() << "100")
|
||||||
|
);
|
||||||
|
|
||||||
//settings with proxies are not serialized by default
|
//settings with proxies are not serialized by default
|
||||||
//other settings non-serialized for demo purposes
|
//other settings non-serialized for demo purposes
|
||||||
slaveBoolean->setSerializable (false);
|
slaveBoolean->setSerializable (false);
|
||||||
slaveSingleText->setSerializable (false);
|
slaveSingleText->setSerializable (false);
|
||||||
slaveMultiText->setSerializable (false);
|
slaveMultiText->setSerializable (false);
|
||||||
|
slaveAlphaSpinbox->setSerializable (false);
|
||||||
|
slaveIntegerSpinbox->setSerializable (false);
|
||||||
|
slaveDoubleSpinbox->setSerializable (false);
|
||||||
|
slaveSlider->setSerializable (false);
|
||||||
|
|
||||||
slaveBoolean->setDefaultValues (QStringList()
|
slaveBoolean->setDefaultValues (QStringList()
|
||||||
<< "One" << "Three" << "Five");
|
<< "One" << "Three" << "Five");
|
||||||
|
@ -184,6 +241,38 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
|
|
||||||
slaveSingleText->setWidgetWidth (24);
|
slaveSingleText->setWidgetWidth (24);
|
||||||
slaveMultiText->setWidgetWidth (24);
|
slaveMultiText->setWidgetWidth (24);
|
||||||
|
|
||||||
|
slaveAlphaSpinbox->setDefaultValue ("Two");
|
||||||
|
slaveAlphaSpinbox->setWidgetWidth (20);
|
||||||
|
//slaveAlphaSpinbox->setPrefix ("No. ");
|
||||||
|
//slaveAlphaSpinbox->setSuffix ("!");
|
||||||
|
slaveAlphaSpinbox->setWrapping (true);
|
||||||
|
|
||||||
|
slaveIntegerSpinbox->setDefaultValue (14);
|
||||||
|
slaveIntegerSpinbox->setMinimum (0);
|
||||||
|
slaveIntegerSpinbox->setMaximum (58);
|
||||||
|
slaveIntegerSpinbox->setPrefix ("$");
|
||||||
|
slaveIntegerSpinbox->setSuffix (".00");
|
||||||
|
slaveIntegerSpinbox->setWidgetWidth (10);
|
||||||
|
slaveIntegerSpinbox->setSpecialValueText ("Nothing!");
|
||||||
|
|
||||||
|
slaveDoubleSpinbox->setDefaultValue (0.51);
|
||||||
|
slaveDoubleSpinbox->setSingleStep(0.17);
|
||||||
|
slaveDoubleSpinbox->setMaximum(4.0);
|
||||||
|
|
||||||
|
slaveSlider->setMinimum (0);
|
||||||
|
slaveSlider->setMaximum (100);
|
||||||
|
slaveSlider->setDefaultValue (75);
|
||||||
|
slaveSlider->setWidgetWidth (100);
|
||||||
|
slaveSlider->setTicksAbove (true);
|
||||||
|
slaveSlider->setTickInterval (25);
|
||||||
|
|
||||||
|
slaveDial->setMinimum (0);
|
||||||
|
slaveDial->setMaximum (100);
|
||||||
|
slaveDial->setSingleStep (5);
|
||||||
|
slaveDial->setDefaultValue (75);
|
||||||
|
slaveDial->setTickInterval (25);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,10 +18,19 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting,
|
||||||
{
|
{
|
||||||
QAbstractButton *button = 0;
|
QAbstractButton *button = 0;
|
||||||
|
|
||||||
if (isMultiValue())
|
switch (setting->type())
|
||||||
|
{
|
||||||
|
case CSMSettings::Type_CheckBox:
|
||||||
button = new QCheckBox (value, this);
|
button = new QCheckBox (value, this);
|
||||||
else
|
break;
|
||||||
|
|
||||||
|
case CSMSettings::Type_RadioButton:
|
||||||
button = new QRadioButton (value, this);
|
button = new QRadioButton (value, this);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
connect (button, SIGNAL (clicked (bool)),
|
connect (button, SIGNAL (clicked (bool)),
|
||||||
this, SLOT (slotToggled (bool)));
|
this, SLOT (slotToggled (bool)));
|
||||||
|
|
|
@ -123,10 +123,8 @@ void CSVSettings::Dialog::show()
|
||||||
{
|
{
|
||||||
if (pages().isEmpty())
|
if (pages().isEmpty())
|
||||||
buildPages();
|
buildPages();
|
||||||
|
|
||||||
QPoint screenCenter = QApplication::desktop()->screenGeometry().center();
|
QPoint screenCenter = QApplication::desktop()->screenGeometry().center();
|
||||||
|
|
||||||
move (screenCenter - geometry().center());
|
move (screenCenter - geometry().center());
|
||||||
|
|
||||||
QWidget::show();
|
QWidget::show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,9 +60,11 @@ void CSVSettings::Frame::showWidgets()
|
||||||
QWidget *widg = static_cast <QWidget *> (obj);
|
QWidget *widg = static_cast <QWidget *> (obj);
|
||||||
|
|
||||||
if (widg->property("sizePolicy").isValid())
|
if (widg->property("sizePolicy").isValid())
|
||||||
|
{
|
||||||
widg->setSizePolicy
|
widg->setSizePolicy
|
||||||
(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
layout()->activate();
|
layout()->activate();
|
||||||
setFixedSize(minimumSizeHint());
|
setFixedSize(minimumSizeHint());
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
#include "../../model/settings/usersettings.hpp"
|
#include "../../model/settings/usersettings.hpp"
|
||||||
#include "../../model/settings/connector.hpp"
|
#include "../../model/settings/connector.hpp"
|
||||||
|
#include "../../model/settings/support.hpp"
|
||||||
|
|
||||||
#include "settingwindow.hpp"
|
#include "settingwindow.hpp"
|
||||||
|
|
||||||
QMap <CSVSettings::ViewType, CSVSettings::IViewFactory *>
|
QMap <CSVSettings::ViewType, CSVSettings::IViewFactory *>
|
||||||
|
|
|
@ -1,88 +1,198 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#include <QCheckBox>
|
|
||||||
#include <QRadioButton>
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
#include <QSpinBox>
|
||||||
#include <QAbstractButton>
|
#include <QDoubleSpinBox>
|
||||||
|
#include <QAbstractSpinBox>
|
||||||
|
#include <QAbstractSlider>
|
||||||
|
#include <QDial>
|
||||||
|
#include <QSlider>
|
||||||
|
|
||||||
#include "rangeview.hpp"
|
#include "rangeview.hpp"
|
||||||
|
#include "spinbox.hpp"
|
||||||
#include "../../model/settings/setting.hpp"
|
#include "../../model/settings/setting.hpp"
|
||||||
|
#include "../../model/settings/support.hpp"
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting,
|
CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting,
|
||||||
Page *parent)
|
Page *parent)
|
||||||
: View (setting, parent)
|
: mRangeWidget (0), mRangeType (setting->type()), View (setting, parent)
|
||||||
{
|
{
|
||||||
foreach (const QString &value, setting->declaredValues())
|
|
||||||
{
|
mRangeWidget = 0;
|
||||||
QAbstractButton *button = 0;
|
|
||||||
|
|
||||||
if (isMultiValue())
|
if (isMultiValue())
|
||||||
button = new QCheckBox (value, this);
|
|
||||||
else
|
|
||||||
button = new QRadioButton (value, this);
|
|
||||||
|
|
||||||
connect (button, SIGNAL (clicked (bool)),
|
|
||||||
this, SLOT (slotToggled (bool)));
|
|
||||||
|
|
||||||
button->setObjectName (value);
|
|
||||||
|
|
||||||
addWidget (button);
|
|
||||||
|
|
||||||
mButtons[value] = button;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVSettings::RangeView::slotToggled (bool state)
|
|
||||||
{
|
|
||||||
//test only for true to avoid multiple selection updates with radiobuttons
|
|
||||||
if (!isMultiValue() && !state)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QStringList values;
|
switch (mRangeType)
|
||||||
|
|
||||||
foreach (QString key, mButtons.keys())
|
|
||||||
{
|
{
|
||||||
if (mButtons.value(key)->isChecked())
|
case CSMSettings::Type_SpinBox:
|
||||||
values.append (key);
|
case CSMSettings::Type_DoubleSpinBox:
|
||||||
|
buildSpinBox (setting);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CSMSettings::Type_Dial:
|
||||||
|
case CSMSettings::Type_Slider:
|
||||||
|
buildSlider (setting);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
setSelectedValues (values, false);
|
|
||||||
|
mRangeWidget->setFixedWidth (widgetWidth (setting->widgetWidth()));
|
||||||
|
mRangeWidget->setObjectName (setting->name());
|
||||||
|
|
||||||
|
addWidget (mRangeWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::RangeView::buildSlider (CSMSettings::Setting *setting)
|
||||||
|
{
|
||||||
|
switch (setting->type())
|
||||||
|
{
|
||||||
|
case CSMSettings::Type_Slider:
|
||||||
|
mRangeWidget = new QSlider (Qt::Horizontal, this);
|
||||||
|
mRangeWidget->setProperty ("tickInterval", setting->tickInterval());
|
||||||
|
|
||||||
|
if (setting->ticksAbove())
|
||||||
|
{
|
||||||
|
if (setting->ticksBelow())
|
||||||
|
mRangeWidget->setProperty ("tickPosition", QSlider::TicksBothSides);
|
||||||
|
else
|
||||||
|
mRangeWidget->setProperty ("tickPosition", QSlider::TicksAbove);
|
||||||
|
}
|
||||||
|
else if (setting->ticksBelow())
|
||||||
|
mRangeWidget->setProperty ("tickPosition", QSlider::TicksBelow);
|
||||||
|
else
|
||||||
|
mRangeWidget->setProperty ("tickPosition", QSlider::NoTicks);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CSMSettings::Type_Dial:
|
||||||
|
mRangeWidget = new QDial (this);
|
||||||
|
mRangeWidget->setProperty ("wrapping", setting->wrapping());
|
||||||
|
mRangeWidget->setProperty ("notchesVisible",
|
||||||
|
(setting->ticksAbove() || setting->ticksBelow()));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
mRangeWidget->setProperty ("minimum", setting->minimum());
|
||||||
|
mRangeWidget->setProperty ("maximum", setting->maximum());
|
||||||
|
mRangeWidget->setProperty ("tracking", false);
|
||||||
|
mRangeWidget->setProperty ("singleStep", setting->singleStep());
|
||||||
|
|
||||||
|
connect (mRangeWidget, SIGNAL (valueChanged (int)),
|
||||||
|
this, SLOT (slotUpdateView (int)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting)
|
||||||
|
{
|
||||||
|
SpinBox *sb = 0;
|
||||||
|
|
||||||
|
switch (setting->type())
|
||||||
|
{
|
||||||
|
case CSMSettings::Type_SpinBox:
|
||||||
|
|
||||||
|
sb = new SpinBox (this);
|
||||||
|
|
||||||
|
if (!setting->declaredValues().isEmpty())
|
||||||
|
sb->setValueList (setting->declaredValues());
|
||||||
|
|
||||||
|
mRangeWidget = sb;
|
||||||
|
|
||||||
|
connect (mRangeWidget, SIGNAL (valueChanged (int)),
|
||||||
|
this, SLOT (slotUpdateView (int)));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CSMSettings::Type_DoubleSpinBox:
|
||||||
|
mRangeWidget = new QDoubleSpinBox (this);
|
||||||
|
|
||||||
|
connect (mRangeWidget, SIGNAL (valueChanged (double)),
|
||||||
|
this, SLOT (slotUpdateView (double)));
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//min / max values are set automatically in AlphaSpinBox
|
||||||
|
if (setting->declaredValues().isEmpty())
|
||||||
|
{
|
||||||
|
mRangeWidget->setProperty ("minimum", setting->minimum());
|
||||||
|
mRangeWidget->setProperty ("maximum", setting->maximum());
|
||||||
|
mRangeWidget->setProperty ("singleStep", setting->singleStep());
|
||||||
|
mRangeWidget->setProperty ("specialValueText",
|
||||||
|
setting->specialValueText());
|
||||||
|
}
|
||||||
|
|
||||||
|
mRangeWidget->setProperty ("prefix", setting->prefix());
|
||||||
|
mRangeWidget->setProperty ("suffix", setting->suffix());
|
||||||
|
mRangeWidget->setProperty ("wrapping", setting->wrapping());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::RangeView::slotUpdateView (int value)
|
||||||
|
{
|
||||||
|
QString textValue = "";
|
||||||
|
QStringList list;
|
||||||
|
|
||||||
|
switch (mRangeType)
|
||||||
|
{
|
||||||
|
case CSMSettings::Type_SpinBox:
|
||||||
|
list = static_cast <SpinBox *> (mRangeWidget)->valueList();
|
||||||
|
if (!list.isEmpty())
|
||||||
|
textValue = list.at(value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (textValue.isEmpty())
|
||||||
|
textValue = QVariant (value).toString();
|
||||||
|
|
||||||
|
setSelectedValue (textValue, false);
|
||||||
|
|
||||||
|
View::updateView();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::RangeView::slotUpdateView (double value)
|
||||||
|
{
|
||||||
|
setSelectedValue (QVariant(value).toString(), false);
|
||||||
|
|
||||||
View::updateView();
|
View::updateView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVSettings::RangeView::updateView (bool signalUpdate) const
|
void CSVSettings::RangeView::updateView (bool signalUpdate) const
|
||||||
{
|
{
|
||||||
|
QString value;
|
||||||
|
|
||||||
QStringList values = selectedValues();
|
if (!selectedValues().isEmpty())
|
||||||
|
value = selectedValues().at(0);
|
||||||
|
|
||||||
foreach (const QString &buttonName, mButtons.keys())
|
switch (mRangeType)
|
||||||
{
|
{
|
||||||
QAbstractButton *button = mButtons[buttonName];
|
case CSMSettings::Type_SpinBox:
|
||||||
|
static_cast <SpinBox *> (mRangeWidget)->setValue (value);
|
||||||
|
break;
|
||||||
|
|
||||||
//if the value is not found in the list, the widget is checked false
|
case CSMSettings::Type_DoubleSpinBox:
|
||||||
bool buttonValue = values.contains(buttonName);
|
static_cast <QDoubleSpinBox *> (mRangeWidget)->setValue (value.toDouble());
|
||||||
|
break;
|
||||||
|
|
||||||
//skip if the butotn value will not change
|
case CSMSettings::Type_Slider:
|
||||||
if (button->isChecked() == buttonValue)
|
case CSMSettings::Type_Dial:
|
||||||
continue;
|
mRangeWidget->setProperty ("value", value.toInt());
|
||||||
|
mRangeWidget->setProperty ("sliderPosition", value.toInt());
|
||||||
|
break;
|
||||||
|
|
||||||
//disable autoexclusive if it's enabled and we're setting
|
default:
|
||||||
//the button value to false
|
break;
|
||||||
bool switchExclusive = (!buttonValue && button->autoExclusive());
|
|
||||||
|
|
||||||
if (switchExclusive)
|
|
||||||
button->setAutoExclusive (false);
|
|
||||||
|
|
||||||
button->setChecked (buttonValue);
|
|
||||||
|
|
||||||
if (switchExclusive)
|
|
||||||
button->setAutoExclusive(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
View::updateView (signalUpdate);
|
View::updateView (signalUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
#ifndef CSVSETTINGS_RANGEVIEW_HPP
|
#ifndef CSVSETTINGS_RANGEVIEW_HPP
|
||||||
#define CSVSETTINGS_RANGEVIEW_HPP
|
#define CSVSETTINGS_RANGEVIEW_HPP
|
||||||
|
|
||||||
#include <QWidget>
|
|
||||||
#include <QAbstractButton>
|
|
||||||
|
|
||||||
#include "view.hpp"
|
#include "view.hpp"
|
||||||
#include "../../model/settings/support.hpp"
|
#include "../../model/settings/support.hpp"
|
||||||
|
|
||||||
class QStringListModel;
|
class QStringListModel;
|
||||||
|
class QAbstractSpinBox;
|
||||||
|
|
||||||
namespace CSVSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
|
@ -15,7 +13,8 @@ namespace CSVSettings
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QMap <QString, QAbstractButton *> mButtons;
|
QWidget *mRangeWidget;
|
||||||
|
CSMSettings::SettingType mRangeType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RangeView (CSMSettings::Setting *setting,
|
explicit RangeView (CSMSettings::Setting *setting,
|
||||||
|
@ -24,8 +23,14 @@ namespace CSVSettings
|
||||||
protected:
|
protected:
|
||||||
void updateView (bool signalUpdate = true) const;
|
void updateView (bool signalUpdate = true) const;
|
||||||
|
|
||||||
|
void buildSlider (CSMSettings::Setting *setting);
|
||||||
|
void buildSpinBox (CSMSettings::Setting *setting);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotToggled (bool state);
|
|
||||||
|
void slotUpdateView (int value);
|
||||||
|
void slotUpdateView (double value);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RangeViewFactory : public QObject, public IViewFactory
|
class RangeViewFactory : public QObject, public IViewFactory
|
||||||
|
|
51
apps/opencs/view/settings/spinbox.cpp
Normal file
51
apps/opencs/view/settings/spinbox.cpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#include "spinbox.hpp"
|
||||||
|
|
||||||
|
#include <QSpinBox>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
|
CSVSettings::SpinBox::SpinBox(QWidget *parent)
|
||||||
|
: mValueList(QStringList()), QSpinBox(parent)
|
||||||
|
{
|
||||||
|
setRange (0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CSVSettings::SpinBox::textFromValue(int val) const
|
||||||
|
{
|
||||||
|
if (mValueList.isEmpty())
|
||||||
|
return QVariant (val).toString();
|
||||||
|
|
||||||
|
QString value = "";
|
||||||
|
|
||||||
|
if (val < mValueList.size())
|
||||||
|
value = mValueList.at (val);
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CSVSettings::SpinBox::valueFromText(const QString &text) const
|
||||||
|
{
|
||||||
|
if (mValueList.isEmpty())
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (mValueList.contains (text))
|
||||||
|
return mValueList.indexOf(text);
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::SpinBox::setValue (const QString &value)
|
||||||
|
{
|
||||||
|
if (!mValueList.isEmpty())
|
||||||
|
{
|
||||||
|
lineEdit()->setText (value);
|
||||||
|
QSpinBox::setValue(valueFromText(value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
QSpinBox::setValue (value.toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSVSettings::SpinBox::setValueList (const QStringList &list)
|
||||||
|
{
|
||||||
|
mValueList = list;
|
||||||
|
setMaximum (list.size() - 1);
|
||||||
|
}
|
31
apps/opencs/view/settings/spinbox.hpp
Normal file
31
apps/opencs/view/settings/spinbox.hpp
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#ifndef CSVSETTINGS_SPINBOX_HPP
|
||||||
|
#define CSVSETTINGS_SPINBOX_HPP
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QSpinBox>
|
||||||
|
|
||||||
|
namespace CSVSettings
|
||||||
|
{
|
||||||
|
class SpinBox : public QSpinBox
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
QStringList mValueList;
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit SpinBox(QWidget *parent = 0);
|
||||||
|
|
||||||
|
void setObjectName (const QString &name);
|
||||||
|
|
||||||
|
void setValue (const QString &value);
|
||||||
|
void setValueList (const QStringList &list);
|
||||||
|
const QStringList &valueList() const { return mValueList; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
QString textFromValue (int val) const;
|
||||||
|
int valueFromText (const QString &text) const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
#endif // CSVSETTINGS_SPINBOX_HPP
|
|
@ -28,11 +28,6 @@ bool CSVSettings::TextView::isEquivalent
|
||||||
return (lhs.trimmed() == rhs.trimmed());
|
return (lhs.trimmed() == rhs.trimmed());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVSettings::TextView::setWidgetText (const QString &value) const
|
|
||||||
{
|
|
||||||
mTextWidget->setProperty ("text", value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSVSettings::TextView::slotTextEdited (QString value)
|
void CSVSettings::TextView::slotTextEdited (QString value)
|
||||||
{
|
{
|
||||||
QStringList values = value.split (mDelimiter, QString::SkipEmptyParts);
|
QStringList values = value.split (mDelimiter, QString::SkipEmptyParts);
|
||||||
|
@ -51,19 +46,14 @@ void CSVSettings::TextView::updateView(bool signalUpdate) const
|
||||||
{
|
{
|
||||||
QString values = selectedValues().join (mDelimiter);
|
QString values = selectedValues().join (mDelimiter);
|
||||||
|
|
||||||
if (isEquivalent (widgetText(), values))
|
if (isEquivalent (mTextWidget->property("text").toString(), values))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setWidgetText (values);
|
mTextWidget->setProperty("text", values);
|
||||||
|
|
||||||
View::updateView (signalUpdate);
|
View::updateView (signalUpdate);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CSVSettings::TextView::widgetText() const
|
|
||||||
{
|
|
||||||
return mTextWidget->property("text").toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
CSVSettings::TextView *CSVSettings::TextViewFactory::createView
|
CSVSettings::TextView *CSVSettings::TextViewFactory::createView
|
||||||
(CSMSettings::Setting *setting,
|
(CSMSettings::Setting *setting,
|
||||||
Page *parent)
|
Page *parent)
|
||||||
|
|
|
@ -32,12 +32,6 @@ namespace CSVSettings
|
||||||
///Comparison function that returns true if the trimmed() strings
|
///Comparison function that returns true if the trimmed() strings
|
||||||
///are equal
|
///are equal
|
||||||
bool isEquivalent (const QString &lhs, const QString &rhs) const;
|
bool isEquivalent (const QString &lhs, const QString &rhs) const;
|
||||||
|
|
||||||
///Convenience function to return the text of the widget
|
|
||||||
QString widgetText() const;
|
|
||||||
|
|
||||||
///Convenience function to set the text of the widget
|
|
||||||
void setWidgetText (const QString &value) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TextViewFactory : public QObject, public IViewFactory
|
class TextViewFactory : public QObject, public IViewFactory
|
||||||
|
|
|
@ -192,6 +192,7 @@ bool CSVSettings::View::stringListsMatch (
|
||||||
QList <QStandardItem *> CSVSettings::View::toStandardItemList
|
QList <QStandardItem *> CSVSettings::View::toStandardItemList
|
||||||
(const QStringList &list) const
|
(const QStringList &list) const
|
||||||
{
|
{
|
||||||
|
|
||||||
QList <QStandardItem *> itemList;
|
QList <QStandardItem *> itemList;
|
||||||
|
|
||||||
foreach (const QString &value, list)
|
foreach (const QString &value, list)
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace CSVSettings
|
||||||
void showEvent ( QShowEvent * event );
|
void showEvent ( QShowEvent * event );
|
||||||
|
|
||||||
///Virtual for updating a specific View subclass
|
///Virtual for updating a specific View subclass
|
||||||
///bool indicates whether a signal is emitted that the view was updated
|
///bool indicates whether viewUpdated() signal is emitted
|
||||||
virtual void updateView (bool signalUpdate = true) const;
|
virtual void updateView (bool signalUpdate = true) const;
|
||||||
|
|
||||||
///Returns the pixel width corresponding to the specified number of
|
///Returns the pixel width corresponding to the specified number of
|
||||||
|
|
Loading…
Reference in a new issue