-
Notifications
You must be signed in to change notification settings - Fork 0
/
filemodel.h
65 lines (47 loc) · 1.67 KB
/
filemodel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/**
* Copyright (C) 2012 by Kunal Parmar <[email protected]>
*
**/
#ifndef FILEMODEL_H
#define FILEMODEL_H
#include <QObject>
#include <QAbstractItemModel>
#include <QStringList>
class FileModel : public QAbstractItemModel
{
Q_OBJECT
Q_PROPERTY(bool canGoUp READ canGoUp NOTIFY directoryChanged )
Q_PROPERTY(QString directory READ directory NOTIFY directoryChanged )
public:
enum { IconRole = Qt::UserRole + 1 };
FileModel ( QObject* parent=0);
~FileModel ();
QVariant data (const QModelIndex &index, int role) const;
Qt::ItemFlags flags (const QModelIndex &index) const;
QVariant headerData (int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
QModelIndex index (int row, int column,
const QModelIndex &parent = QModelIndex()) const;
QModelIndex parent (const QModelIndex &index) const;
bool hasChildren (const QModelIndex& parent = QModelIndex ()) const;
int rowCount (const QModelIndex &parent = QModelIndex()) const;
int columnCount (const QModelIndex &parent = QModelIndex()) const;
Q_INVOKABLE void openDirectory( int index);
Q_INVOKABLE void updateFiles ();
Q_INVOKABLE QString currentDirectory () const { return mCurrentDirectory; }
Q_INVOKABLE void setCurrentDirectory (const QString& dir);
Q_INVOKABLE QString directory() const;
Q_INVOKABLE bool isDir( int path) const;
Q_INVOKABLE void goUp ();
bool canGoUp ();
Q_SIGNALS:
void showEmptyDir(bool show);
void directoryChanged ();
private Q_SLOTS:
void openCurrentDirectory();
private:
bool mFilesRetrieved;
QStringList mFiles;
QString mCurrentDirectory;
};
#endif