4 * This file is part of CameraPlus.
6 * Copyright (C) 2012 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;
91 class PostCaptureModelItem : public QObject {
94 Q_PROPERTY(QString type READ type NOTIFY typeChanged);
95 Q_PROPERTY(QUrl url READ url NOTIFY urlChanged);
96 Q_PROPERTY(QString created READ created NOTIFY createdChanged);
97 Q_PROPERTY(QString title READ title NOTIFY titleChanged);
98 Q_PROPERTY(QString fileName READ fileName NOTIFY fileNameChanged);
99 Q_PROPERTY(QString mimeType READ mimeType NOTIFY mimeTypeChanged);
100 Q_PROPERTY(bool available READ available NOTIFY availableChanged);
101 Q_PROPERTY(QString lastModified READ lastModified NOTIFY lastModifiedChanged);
102 Q_PROPERTY(unsigned trackerId READ trackerId CONSTANT);
103 Q_PROPERTY(bool favorite READ favorite NOTIFY favoriteChanged);
106 PostCaptureModelItem(const QSparqlResultRow& row, QObject *parent = 0);
108 ~PostCaptureModelItem() {
112 void update(PostCaptureModelItem *other);
114 QString type() const;
116 QString created() const;
117 QString title() const;
118 QString fileName() const;
119 QString mimeType() const;
120 bool available() const;
121 QString lastModified() const;
122 unsigned trackerId() const;
123 bool favorite() const;
128 void createdChanged();
130 void fileNameChanged();
131 void mimeTypeChanged();
132 void availableChanged();
133 void lastModifiedChanged();
134 void favoriteChanged();
137 QString formatDateTime(const QDateTime& dt) const;
138 QVariant value(const QString& id, const QVariant& def = QVariant()) const;
143 #endif /* POST_CAPTURE_MODEL_H */