LibEngsas
esettingsmodel.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  MA 02110-1301 USA.
18 */
19 
20 #ifndef ESETTINGSMODEL_H
21 #define ESETTINGSMODEL_H
22 
23 #include "eglobal.h"
24 #include "eabstractitemmodel.h"
25 
26 class ESettingsModelItem;
27 
35 {
36  Q_OBJECT
37  public:
38  ESettingsModel(QObject *parent = 0);
39  ~ESettingsModel();
40 
41  bool addItem(ESettingsModelItem *item);
42  ESettingsModelItem *itemFromIndex(QModelIndex index) const;
43  bool save(QString &error);
44 
45  // standard api
46  QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
47  int columnCount(const QModelIndex& parent = QModelIndex()) const;
48  int rowCount(const QModelIndex& parent = QModelIndex()) const;
49  QModelIndex parent(const QModelIndex& child) const;
50  QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const;
51  QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
52 
53  public slots:
54  inline void reloadSettings(){ emit doReloadSettings(); };
55 
56  private slots:
57  inline void reloadSettingsRequestByPass(){ reloadRequested = true; };
58 
59  private:
60  ESettingsModelItem* root;
65 
66  signals:
67  void reloadSettingsRequest();
68  void doReloadSettings();
69 };
70 
71 #endif // ESETTINGSMODEL_H