ZIMA CAD Parts
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
downloadmodel.h
Go to the documentation of this file.
1 /*
2  ZIMA-CAD-Parts
3  http://www.zima-construction.cz/software/ZIMA-Parts
4 
5  Copyright (C) 2011-2012 Jakub Skokan <aither@havefun.cz>
6 
7  This program is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef DOWNLOADMODEL_H
22 #define DOWNLOADMODEL_H
23 
24 #include <QAbstractItemModel>
25 #include <QItemDelegate>
26 #include <QList>
27 
28 class DataTransfer;
29 class TransferHandler;
30 struct File;
31 
32 class DownloadDelegate : public QItemDelegate
33 {
34 public:
35  DownloadDelegate(QObject* parent=0) : QItemDelegate(parent) {}
36  void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const;
37 };
38 
39 class DownloadModel : public QAbstractItemModel
40 {
41  Q_OBJECT
42 public:
47  };
48 
49  explicit DownloadModel(TransferHandler *handler, QObject *parent = 0);
50 
51  int columnCount(const QModelIndex &parent = QModelIndex()) const;
52  int rowCount(const QModelIndex &parent = QModelIndex()) const;
53  QModelIndex parent(const QModelIndex &index) const;
54  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
55  QVariant data(const QModelIndex &index, int role) const;
56  QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
57  QList<File*> files();
58  bool isEmpty() const;
59  bool isDownloading() const;
60 
61 signals:
62 
63 public slots:
64  void enqueue(File *f);
65  void enqueue(QList<File*> list);
66  void clear();
67  void fileChanged(File *file);
68  void fileDownloaded(File *file);
69  void stop();
70  void resume();
71 
72 private slots:
73 
74 
75 private:
76  QList<File*> queue;
77  bool m_downloading;
78  TransferHandler *m_handler;
79 };
80 
81 #endif // DOWNLOADMODEL_H
void enqueue(File *f)
Definition: downloadmodel.cpp:159
void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
Definition: downloadmodel.cpp:30
void resume()
Definition: downloadmodel.cpp:230
Definition: downloadmodel.h:32
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: downloadmodel.cpp:59
QList< File * > files()
Definition: downloadmodel.cpp:137
Definition: downloadmodel.h:46
bool isDownloading() const
Definition: downloadmodel.cpp:154
Definition: downloadmodel.h:45
void stop()
Definition: downloadmodel.cpp:224
void clear()
Definition: downloadmodel.cpp:191
QVariant data(const QModelIndex &index, int role) const
Definition: downloadmodel.cpp:91
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: downloadmodel.cpp:119
Definition: datatransfer.h:9
Definition: downloadmodel.h:44
Definition: transferhandler.h:4
void fileDownloaded(File *file)
Definition: downloadmodel.cpp:207
Definition: item.h:41
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: downloadmodel.cpp:79
void fileChanged(File *file)
Definition: downloadmodel.cpp:200
QModelIndex parent(const QModelIndex &index) const
Definition: downloadmodel.cpp:73
TransferHandlerType
Definition: downloadmodel.h:43
DownloadDelegate(QObject *parent=0)
Definition: downloadmodel.h:35
Definition: downloadmodel.h:39
DownloadModel(TransferHandler *handler, QObject *parent=0)
Definition: downloadmodel.cpp:52
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: downloadmodel.cpp:65
bool isEmpty() const
Definition: downloadmodel.cpp:149