OSDN Git Service

テキストビューアを試し実装
[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     QStringList nameFilters() const { return m_dir.nameFilters(); }\r
23     void setNameFilters(const QStringList &nameFiltes) {\r
24         m_dir.setNameFilters(nameFiltes);\r
25     }\r
26 \r
27     QDir::SortFlags sorting() const { return m_dir.sorting(); }\r
28     void setSorting(QDir::SortFlags sort) { m_dir.setSorting(sort); }\r
29 \r
30     Qt::CheckState checkState(const QModelIndex &index) const;\r
31     void setCheckState(const QModelIndex &index, Qt::CheckState state);\r
32     void setCheckStateAll(Qt::CheckState state);\r
33     const QString absolutePath() const { return m_dir.absolutePath(); }\r
34 #if 0\r
35     bool isDir(const QModelIndex &index) const;\r
36     const QString absoluteFilePath(const QModelIndex &index) const;\r
37     const QString fileName(const QModelIndex &index) const;\r
38 #endif\r
39     QFileInfoList checkedItems() const;\r
40     QFileInfo fileInfo(const QModelIndex &index) const;\r
41 \r
42     void updateAppearance();\r
43 \r
44 signals:\r
45     void rootChanged(const QString &root);\r
46     void stateChanged(int checkedFoldrs, int checkedFiles, quint64 totalSize);\r
47     void listUpdated();\r
48 \r
49 public slots:\r
50 \r
51 private:\r
52     QDir m_dir;\r
53     QFileInfoList m_fileInfoList;\r
54     QVector<Qt::CheckState> m_checkStates;\r
55     QFileIconProvider m_IconFactory;\r
56     QFileSystemWatcher *m_fsWatcher;\r
57     QFont m_font;\r
58     QBrush m_NormalBrush;\r
59     QBrush m_NormalTextBrush;\r
60     QBrush m_MarkBrush;\r
61     QBrush m_MarkTextBrush;\r
62     QBrush m_SystemBrush;\r
63     QBrush m_HiddenBrush;\r
64     QBrush m_ReadonlyBrush;\r
65 \r
66     void stateChanged();\r
67 \r
68     // QAbstractItemModel interface\r
69 public:\r
70     int rowCount(const QModelIndex &parent = QModelIndex()) const;\r
71     int columnCount(const QModelIndex &parent = QModelIndex()) const;\r
72     QVariant data(const QModelIndex &index, int role) const;\r
73     QVariant headerData(int section, Qt::Orientation orientation, int role) const;\r
74     Qt::ItemFlags flags(const QModelIndex &index) const;\r
75     bool setData(const QModelIndex &index, const QVariant &value, int role);\r
76     Qt::DropActions supportedDropActions() const;\r
77     QStringList mimeTypes() const;\r
78 };\r
79 \r
80 #endif // FILETABLEMODEL_H\r