1 #ifndef _QTUIPLUS_OPTIONS_HPP_
2 #define _QTUIPLUS_OPTIONS_HPP_
8 #include <QAbstractItemModel>
9 #include <QSharedPointer>
20 Option(QString const& name, QVariant const& value)
24 QString const& name() const {
28 QVariant const& value() const {
39 typedef QVector<size_t> options_t;
40 typedef QHash<QString, size_t> index_t;
44 typedef SettingsModel* model_ptr;
46 OptionsGroup(QString const& name, model_ptr)
49 void addOption(QString const& name, QVariant const& value) {
50 if (idx_.find() != idx_.end()) {
54 size_t pos = model_->addOption(this, name, value);
55 options_.push_back(pos);
60 QString name() const {
64 size_t optionsCount() const {
65 return options_.size();
68 size_t getOptionPos(size_t pos) const {
69 return ( (0 <= pos && pos < options_.size())
81 class SettingsModel : public QAbstractItemModel
87 SettingsModel(QObject *parent = 0);
89 typedef QSharedPointer<OptionsGroup> group_ptr;
91 QModelIndex index(int row, int col, const QModelIndex &parent = QModelIndex() ) const;
92 QModelIndex parent(const QModelIndex &child) const;
93 int rowCount(const QModelIndex &parent = QModelIndex() ) const;
94 int columnCount(const QModelIndex &parent = QModelIndex() ) const;
95 QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
97 bool addGroup(QString const& name, SettingsModel*);
98 bool addOption(OptionsGroup *group, QString const& name, QVariant const& value);
102 typedef QVector<group_ptr> groups_t;
103 typedef QHash<QString, group_ptr> groups_index_t;
104 typedef QSharedPointer<Option> option_ptr;
105 typedef QVector<option_ptr> options_t;
113 } // namespace qtplus
115 #endif // _QTPLUS_OPTIONS_HPP_