2
* Copyright (C) 2016 Canonical, Ltd.
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; version 3.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Arthur Mello <arthur.mello@canonical.com>
19
#ifndef PASTEDATAMODEL_H
20
#define PASTEDATAMODEL_H
22
#include <QAbstractListModel>
24
class PasteDataProvider;
26
class PasteDataModel : public QAbstractListModel
30
Q_PROPERTY(int count READ rowCount NOTIFY rowCountChanged)
31
Q_PROPERTY(QString surfaceId READ surfaceId WRITE setSurfaceId NOTIFY surfaceIdChanged)
32
Q_PROPERTY(int appState READ appState WRITE setAppState NOTIFY appStateChanged)
33
Q_PROPERTY(bool anyEntrySelected READ anyEntrySelected NOTIFY anyEntrySelectedChanged)
34
Q_PROPERTY(bool allEntriesSelected READ allEntriesSelected NOTIFY allEntriesSelectedChanged)
37
Q_ENUMS(PasteDataType)
38
Q_ENUMS(PasteOutputType)
41
PasteDataModel(QObject* parent=0);
45
Id = Qt::UserRole + 1,
62
enum PasteOutputType {
67
// reimplemented from QAbstractListModel
68
QHash<int, QByteArray> roleNames() const;
69
int rowCount(const QModelIndex& parent=QModelIndex()) const;
70
QVariant data(const QModelIndex& index, int role) const;
72
QString surfaceId() const;
73
void setSurfaceId(QString surfaceId);
76
void setAppState(int state);
78
bool anyEntrySelected() const;
79
bool allEntriesSelected() const;
81
Q_INVOKABLE void selectAll(bool selected);
82
Q_INVOKABLE void selectByIndex(int index, bool selected);
83
Q_INVOKABLE void markSelectedForDeletion();
84
Q_INVOKABLE void markForDeletionByIndex(int index, bool deleted);
85
Q_INVOKABLE void cancelDeletion();
86
Q_INVOKABLE void deleteEntries();
87
Q_INVOKABLE void deleteByIndex(int index);
88
Q_INVOKABLE void setOutputTypeByIndex(int index, PasteOutputType outputType);
94
PasteDataType dataType;
100
PasteOutputType outputType;
102
QList<PasteEntry> m_entries;
106
void rowCountChanged();
107
void surfaceIdChanged();
108
void appStateChanged();
109
void anyEntrySelectedChanged();
110
void allEntriesSelectedChanged();
113
void onPasteboardChanged();
116
void addToModelByPasteId(const QString& pasteId);
117
void addToModel(PasteEntry& entry);
118
void removeFromModel(int index);
121
PasteDataProvider* m_provider;
124
int m_selectedEntries;
125
bool m_shouldUpdateModel;
128
#endif // PASTEDATAMODEL_H