OSDN Git Service

Model/View構造への変更。一旦コミット。
[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 \r
9 class FileTableModel : public QAbstractTableModel\r
10 {\r
11     Q_OBJECT\r
12 public:\r
13     explicit FileTableModel(QObject *parent = 0);\r
14 \r
15     bool setPath(const QString &path);\r
16 \r
17     QDir::Filters filter() const { return m_dir.filter(); }\r
18     void setFilter(QDir::Filters filters) { m_dir.setFilter(filters); }\r
19 \r
20     QDir::SortFlags sorting() const { return m_dir.sorting(); }\r
21     void setSorting(QDir::SortFlags sort) { m_dir.setSorting(sort); }\r
22 \r
23     Qt::CheckState checkState(const QModelIndex &index) const;\r
24     void setCheckState(const QModelIndex &index, Qt::CheckState state);\r
25     void setCheckStateAll(Qt::CheckState state);\r
26 \r
27     bool isDir(const QModelIndex &index) const;\r
28     const QString absolutePath() const { return m_dir.absolutePath(); }\r
29     const QString absoluteFilePath(const QModelIndex &index) const;\r
30     QFileInfoList checkedItems() const;\r
31     QFileInfo fileInfo(const QModelIndex &index) const;\r
32 \r
33 signals:\r
34     void rootChanged(const QString &root);\r
35     void stateChanged(int checkedFoldrs, int checkedFiles, quint64 totalSize);\r
36 \r
37 public slots:\r
38     void refresh() { setPath(m_dir.absolutePath()); }\r
39 \r
40 private:\r
41     QDir m_dir;\r
42     QFileInfoList m_fileInfoList;\r
43     QVector<Qt::CheckState> m_checkStates;\r
44     QFileIconProvider m_IconFactory;\r
45     QFileSystemWatcher *m_fsWatcher;\r
46 \r
47     void stateChanged();\r
48 \r
49     // QAbstractItemModel interface\r
50 public:\r
51     int rowCount(const QModelIndex &parent = QModelIndex()) const;\r
52     int columnCount(const QModelIndex &parent = QModelIndex()) const;\r
53     QVariant data(const QModelIndex &index, int role) const;\r
54     QVariant headerData(int section, Qt::Orientation orientation, int role) const;\r
55     Qt::ItemFlags flags(const QModelIndex &index) const;\r
56     bool setData(const QModelIndex &index, const QVariant &value, int role);\r
57 };\r
58 \r
59 #endif // FILETABLEMODEL_H\r