2013-05-08 01:33:42 +00:00
|
|
|
#ifndef SETTINGCONTAINER_HPP
|
|
|
|
#define SETTINGCONTAINER_HPP
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
class QStringList;
|
|
|
|
|
2013-05-11 10:55:46 +00:00
|
|
|
namespace CSMSettings
|
2013-05-08 01:33:42 +00:00
|
|
|
{
|
|
|
|
class SettingContainer : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
QString *mValue;
|
|
|
|
QStringList *mValues;
|
|
|
|
|
|
|
|
public:
|
2013-06-20 23:06:25 +00:00
|
|
|
|
2013-05-08 01:33:42 +00:00
|
|
|
explicit SettingContainer (QObject *parent = 0);
|
|
|
|
explicit SettingContainer (const QString &value, QObject *parent = 0);
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// add a value to the container
|
|
|
|
/// multiple values supported
|
2013-05-08 01:33:42 +00:00
|
|
|
void insert (const QString &value);
|
2013-06-20 23:06:25 +00:00
|
|
|
|
|
|
|
/// update an existing value
|
|
|
|
/// index specifies multiple values
|
2013-05-08 01:33:42 +00:00
|
|
|
void update (const QString &value, int index = 0);
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// return value at specified index
|
2013-05-08 01:33:42 +00:00
|
|
|
QString getValue (int index = -1) const;
|
2013-06-20 23:06:25 +00:00
|
|
|
|
|
|
|
/// retrieve list of all values
|
2013-05-08 01:33:42 +00:00
|
|
|
inline QStringList *getValues() const { return mValues; }
|
2013-06-20 23:06:25 +00:00
|
|
|
|
|
|
|
/// return size of list
|
2013-05-08 01:33:42 +00:00
|
|
|
int count() const;
|
|
|
|
|
2013-06-20 23:06:25 +00:00
|
|
|
/// test for empty container
|
|
|
|
/// useful for default-constructed containers returned by QMap when invalid key is passed
|
2013-05-08 01:33:42 +00:00
|
|
|
inline bool isEmpty() const { return (!mValue && !mValues); }
|
2013-06-20 23:06:25 +00:00
|
|
|
|
2013-05-08 01:33:42 +00:00
|
|
|
inline bool isMultiValue() const { return (mValues); }
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SETTINGCONTAINER_HPP
|