ZIMA CAD Parts
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
filemodel.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 FILEMODEL_H
22 #define FILEMODEL_H
23 
24 #include <QAbstractItemModel>
25 #include <QStringList>
26 
27 class Item;
28 struct File;
29 
30 class FileModel : public QAbstractItemModel
31 {
32  Q_OBJECT
33 public:
34  explicit FileModel(QObject *parent = 0);
35 
36  //---
37  int columnCount(const QModelIndex &parent = QModelIndex()) const;
38  int rowCount(const QModelIndex &parent = QModelIndex()) const;
39  QModelIndex parent(const QModelIndex &index) const;
40  QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
41  QVariant data(const QModelIndex &index, int role) const;
42  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
43  QVariant headerData (int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
44  bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole);
45  QModelIndex mapToSource(const QModelIndex &proxyIndex) const;
46  QModelIndex mapFromSource(const QModelIndex &sourceIndex) const;
47  Qt::ItemFlags flags(const QModelIndex &index) const;
48  //---
49 
50  Item* getRootItem();
51  void setPreviewWidth(int size);
52 
53 public slots:
54  void setRootIndex(const QModelIndex &index);
55  void setRootIndex(Item *item);
56  void setThumbWidth(int size);
57  void initMetadata(Item *i);
58  void prepareForUpdate();
59 
60 protected:
63 
64 private:
65  int thumbWidth;
66  int previewWidth;
67  QStringList colLabels;
68 
69 private slots:
70  void thumbnailDownloaded(File *file);
71  void itemLoaded(Item *item);
72  void metadataRetranslated();
73 
74 signals:
75  void requestColumnResize();
76 };
77 
78 #endif // FILEMODEL_H
bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role=Qt::EditRole)
Definition: filemodel.cpp:179
void setThumbWidth(int size)
Definition: filemodel.cpp:266
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: filemodel.cpp:40
Item * getRootItem()
Definition: filemodel.cpp:261
Qt::ItemFlags flags(const QModelIndex &index) const
Definition: filemodel.cpp:188
Definition: filemodel.h:30
QVariant data(const QModelIndex &index, int role) const
Definition: filemodel.cpp:74
Definition: item.h:130
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Definition: filemodel.cpp:145
void requestColumnResize()
QModelIndex mapFromSource(const QModelIndex &sourceIndex) const
void prepareForUpdate()
Definition: filemodel.cpp:306
FileModel(QObject *parent=0)
Definition: filemodel.cpp:28
Definition: item.h:41
QVariant headerData(int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const
Definition: filemodel.cpp:158
void setPreviewWidth(int size)
Definition: filemodel.cpp:274
Item * rootItem
Definition: filemodel.h:61
QModelIndex mapToSource(const QModelIndex &proxyIndex) const
void setRootIndex(const QModelIndex &index)
Definition: filemodel.cpp:195
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const
Definition: filemodel.cpp:59
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: filemodel.cpp:33
Item * formalRootItem
Definition: filemodel.h:62
void initMetadata(Item *i)
Definition: filemodel.cpp:243
QModelIndex parent(const QModelIndex &index) const
Definition: filemodel.cpp:52