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