4 * This file is part of CameraPlus.
6 * Copyright (C) 2012-2013 Mohammed Sameer <msameer@foolab.org>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef POST_CAPTURE_MODEL_H
24 #define POST_CAPTURE_MODEL_H
26 #include <QAbstractListModel>
27 #include <QDeclarativeParserStatus>
30 class QSparqlConnection;
31 class PostCaptureModelItem;
35 class QSparqlResultRow;
37 class PostCaptureModel : public QAbstractListModel, public QDeclarativeParserStatus {
39 Q_INTERFACES(QDeclarativeParserStatus);
41 Q_PROPERTY(QString manufacturer READ manufacturer WRITE setManufacturer NOTIFY manufacturerChanged);
42 Q_PROPERTY(QString model READ model WRITE setModel NOTIFY modelChanged);
45 Item = Qt::UserRole + 1
49 PostCaptureModel(QObject *parent = 0);
52 virtual void classBegin();
53 virtual void componentComplete();
55 virtual int rowCount(const QModelIndex& parent = QModelIndex()) const;
56 virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
58 QString manufacturer() const;
59 void setManufacturer(const QString& manufacturer);
61 QString model() const;
62 void setModel(const QString& model);
65 void error(const QString& msg);
67 void manufacturerChanged();
72 void remove(QObject *item);
75 void dataReady(int totalCount);
76 void graphUpdated(const QString& className, const QList<Quad>& deleted,
77 const QList<Quad>& inserted);
80 void addRow(PostCaptureModelItem *item);
81 void exec(QSparqlQuery& query);
83 QSparqlConnection *m_connection;
84 QString m_manufacturer;
87 QList<PostCaptureModelItem *> m_items;
88 QHash<int, PostCaptureModelItem *> m_hash;
93 class PostCaptureModelItem : public QObject {
96 Q_PROPERTY(QString type READ type NOTIFY typeChanged);
97 Q_PROPERTY(QUrl url READ url NOTIFY urlChanged);
98 Q_PROPERTY(QString created READ created NOTIFY createdChanged);
99 Q_PROPERTY(QString title READ title NOTIFY titleChanged);
100 Q_PROPERTY(QString fileName READ fileName NOTIFY fileNameChanged);
101 Q_PROPERTY(QString mimeType READ mimeType NOTIFY mimeTypeChanged);
102 Q_PROPERTY(bool available READ available NOTIFY availableChanged);
103 Q_PROPERTY(QString lastModified READ lastModified NOTIFY lastModifiedChanged);
104 Q_PROPERTY(unsigned trackerId READ trackerId CONSTANT);
105 Q_PROPERTY(bool favorite READ favorite WRITE setFavorite NOTIFY favoriteChanged);
108 PostCaptureModelItem(const QSparqlResultRow& row, QObject *parent = 0);
110 ~PostCaptureModelItem() {
114 void update(PostCaptureModelItem *other);
116 QString type() const;
118 QString created() const;
119 QString title() const;
120 QString fileName() const;
121 QString mimeType() const;
122 bool available() const;
123 QString lastModified() const;
124 unsigned trackerId() const;
126 void setFavorite(bool add);
127 bool favorite() const;
132 void createdChanged();
134 void fileNameChanged();
135 void mimeTypeChanged();
136 void availableChanged();
137 void lastModifiedChanged();
138 void favoriteChanged();
141 QString formatDateTime(const QDateTime& dt) const;
142 QVariant value(const QString& id, const QVariant& def = QVariant()) const;
147 #endif /* POST_CAPTURE_MODEL_H */