OSDN Git Service

Ver0.05
[gefu/Gefu.git] / filetablemodel.h
1 #ifndef FILETABLEMODEL_H\r
2 #define FILETABLEMODEL_H\r
3 \r
4 #include <QAbstractTableModel>\r
5 #include <QDir>\r
6 #include <QFileIconProvider>\r
7 #include <QFileSystemWatcher>\r
8 #include <QBrush>\r
9 #include <QFont>\r
10 \r
11 class FileTableModel : public QAbstractTableModel\r
12 {\r
13     Q_OBJECT\r
14 public:\r
15     explicit FileTableModel(QObject *parent = 0);\r
16 \r
17     bool setPath(const QString &path);\r
18 \r
19     QDir::Filters filter() const { return m_dir.filter(); }\r
20     void setFilter(QDir::Filters filters) { m_dir.setFilter(filters); }\r
21 \r
22     QDir::SortFlags sorting() const { return m_dir.sorting(); }\r
23     void setSorting(QDir::SortFlags sort) { m_dir.setSorting(sort); }\r
24 \r
25     Qt::CheckState checkState(const QModelIndex &index) const;\r
26     void setCheckState(const QModelIndex &index, Qt::CheckState state);\r
27     void setCheckStateAll(Qt::CheckState state);\r
28 \r
29     bool isDir(const QModelIndex &index) const;\r
30     const QString absolutePath() const { return m_dir.absolutePath(); }\r
31     const QString absoluteFilePath(const QModelIndex &index) const;\r
32     QFileInfoList checkedItems() const;\r
33     QFileInfo fileInfo(const QModelIndex &index) const;\r
34 \r
35     void updateAppearance();\r
36 \r
37 signals:\r
38     void rootChanged(const QString &root);\r
39     void stateChanged(int checkedFoldrs, int checkedFiles, quint64 totalSize);\r
40     void listUpdated();\r
41     void filesDropped(const QFileInfoList &list);\r
42 \r
43 public slots:\r
44 //    void refresh();\r
45 \r
46 private:\r
47     QDir m_dir;\r
48     QFileInfoList m_fileInfoList;\r
49     QVector<Qt::CheckState> m_checkStates;\r
50     QFileIconProvider m_IconFactory;\r
51     QFileSystemWatcher *m_fsWatcher;\r
52     QFont m_font;\r
53     QBrush m_NormalBrush;\r
54     QBrush m_NormalTextBrush;\r
55     QBrush m_MarkBrush;\r
56     QBrush m_MarkTextBrush;\r
57     QBrush m_SystemBrush;\r
58     QBrush m_HiddenBrush;\r
59     QBrush m_ReadonlyBrush;\r
60 \r
61     void stateChanged();\r
62 \r
63     // QAbstractItemModel interface\r
64 public:\r
65     int rowCount(const QModelIndex &parent = QModelIndex()) const;\r
66     int columnCount(const QModelIndex &parent = QModelIndex()) const;\r
67     QVariant data(const QModelIndex &index, int role) const;\r
68     QVariant headerData(int section, Qt::Orientation orientation, int role) const;\r
69     Qt::ItemFlags flags(const QModelIndex &index) const;\r
70     bool setData(const QModelIndex &index, const QVariant &value, int role);\r
71     Qt::DropActions supportedDropActions() const;\r
72     QStringList mimeTypes() const;\r
73     bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);\r
74 };\r
75 \r
76 \r
77 \r
78 #endif // FILETABLEMODEL_H\r