Changeset View
Changeset View
Standalone View
Standalone View
applets/kicker/plugin/placeholdermodel.h
- This file was added.
1 | /*************************************************************************** | ||||
---|---|---|---|---|---|
2 | * Copyright (C) 2015 by Eike Hein <hein@kde.org> * | ||||
3 | * * | ||||
4 | * This program is free software; you can redistribute it and/or modify * | ||||
5 | * it under the terms of the GNU General Public License as published by * | ||||
6 | * the Free Software Foundation; either version 2 of the License, or * | ||||
7 | * (at your option) any later version. * | ||||
8 | * * | ||||
9 | * This program 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 * | ||||
12 | * GNU General Public License for more details. * | ||||
13 | * * | ||||
14 | * You should have received a copy of the GNU General Public License * | ||||
15 | * along with this program; if not, write to the * | ||||
16 | * Free Software Foundation, Inc., * | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||||
18 | ***************************************************************************/ | ||||
19 | | ||||
20 | #ifndef PLACEHOLDERMODEL_H | ||||
21 | #define PLACEHOLDERMODEL_H | ||||
22 | | ||||
23 | #include "abstractmodel.h" | ||||
24 | | ||||
25 | #include <QPointer> | ||||
26 | | ||||
27 | class PlaceholderModel : public AbstractModel | ||||
28 | { | ||||
29 | Q_OBJECT | ||||
30 | | ||||
31 | Q_PROPERTY(QAbstractItemModel* sourceModel READ sourceModel WRITE setSourceModel NOTIFY sourceModelChanged); | ||||
32 | Q_PROPERTY(int dropPlaceholderIndex READ dropPlaceholderIndex WRITE setDropPlaceholderIndex NOTIFY dropPlaceholderIndexChanged) | ||||
33 | | ||||
34 | public: | ||||
35 | explicit PlaceholderModel(QObject *parent = 0); | ||||
36 | ~PlaceholderModel(); | ||||
37 | | ||||
38 | QString description() const; | ||||
39 | | ||||
40 | QAbstractItemModel *sourceModel() const; | ||||
41 | virtual void setSourceModel(QAbstractItemModel *sourceModel); | ||||
42 | | ||||
43 | bool canFetchMore(const QModelIndex &parent) const; | ||||
44 | void fetchMore(const QModelIndex &parent); | ||||
45 | | ||||
46 | QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; | ||||
47 | QModelIndex parent(const QModelIndex &index) const; | ||||
48 | | ||||
49 | virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; | ||||
50 | | ||||
51 | int rowCount(const QModelIndex &parent = QModelIndex()) const; | ||||
52 | | ||||
53 | Q_INVOKABLE bool trigger(int row, const QString &actionId, const QVariant &argument); | ||||
54 | | ||||
55 | Q_INVOKABLE QString labelForRow(int row); | ||||
56 | | ||||
57 | Q_INVOKABLE AbstractModel *modelForRow(int row); | ||||
58 | | ||||
59 | AbstractModel* favoritesModel(); | ||||
60 | | ||||
61 | int separatorCount() const; | ||||
62 | | ||||
63 | int dropPlaceholderIndex() const; | ||||
64 | void setDropPlaceholderIndex(int index); | ||||
65 | | ||||
66 | public Q_SLOTS: | ||||
67 | void reset(); | ||||
68 | | ||||
69 | Q_SIGNALS: | ||||
70 | void sourceModelChanged() const; | ||||
71 | void dropPlaceholderIndexChanged(); | ||||
72 | | ||||
73 | protected: | ||||
74 | QModelIndex indexToSourceIndex(const QModelIndex &index) const; | ||||
75 | QModelIndex sourceIndexToIndex(const QModelIndex &index) const; | ||||
76 | int sourceRowToRow(int sourceRow) const; | ||||
77 | int rowToSourceRow(int row) const; | ||||
78 | | ||||
79 | virtual QVariant internalData(const QModelIndex &index, int role) const; | ||||
80 | | ||||
81 | void connectSignals(); | ||||
82 | void disconnectSignals(); | ||||
83 | | ||||
84 | QPointer<QAbstractItemModel> m_sourceModel; | ||||
85 | | ||||
86 | int m_dropPlaceholderIndex; | ||||
87 | }; | ||||
88 | | ||||
89 | #endif |