1 | /* This file is part of the KDE project |
2 | Copyright 2009 Stefan Nikolaus <stefan.nikolaus@kdemail.net> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 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 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef CALLIGRA_SHEETS_MAP_MODEL |
21 | #define CALLIGRA_SHEETS_MAP_MODEL |
22 | |
23 | #include <QAbstractListModel> |
24 | |
25 | class KUndo2Command; |
26 | |
27 | namespace Calligra |
28 | { |
29 | namespace Sheets |
30 | { |
31 | class Map; |
32 | class Sheet; |
33 | |
34 | /** |
35 | * A model for the 'embedded document'. |
36 | * Actually, a model for a sheet list. |
37 | * \ingroup Model |
38 | */ |
39 | class MapModel : public QAbstractListModel |
40 | { |
41 | Q_OBJECT |
42 | public: |
43 | explicit MapModel(Map *map); |
44 | virtual ~MapModel(); |
45 | |
46 | // QAbstractItemModel interface |
47 | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; |
48 | virtual Qt::ItemFlags flags(const QModelIndex &index) const; |
49 | virtual QVariant (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; |
50 | virtual QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; |
51 | virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; |
52 | virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); |
53 | |
54 | public Q_SLOTS: |
55 | /** |
56 | * Hides \p sheet, if \p hidden is \c true and \p sheet is visible. |
57 | * Shows \p sheet, if \p hidden is \c false and \p sheet is hidden. |
58 | * \return \c true on success; \c false on failure |
59 | */ |
60 | bool setHidden(Sheet* sheet, bool hidden = true); |
61 | |
62 | Q_SIGNALS: |
63 | void addCommandRequested(KUndo2Command* command); |
64 | |
65 | protected: |
66 | Map* map() const; |
67 | |
68 | protected Q_SLOTS: |
69 | virtual void addSheet(Sheet *sheet); |
70 | virtual void removeSheet(Sheet *sheet); |
71 | |
72 | private: |
73 | class Private; |
74 | Private * const d; |
75 | }; |
76 | |
77 | } // namespace Sheets |
78 | } // namespace Calligra |
79 | |
80 | #endif // CALLIGRA_SHEETS_MAP_MODEL |
81 | |