forked from sanshao27/apktool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
myfiledialog.h
41 lines (35 loc) · 1.27 KB
/
myfiledialog.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
#ifndef MYFILEDIALOG_H
#define MYFILEDIALOG_H
#include <QObject>
#include <QDir>
class MyFileDialog : public QObject
{
Q_OBJECT
Q_PROPERTY(QList<QObject*> fileModel READ fileModel NOTIFY fileModelChanged)
Q_PROPERTY(QString filter READ filter WRITE setFilter)
Q_PROPERTY(QString currentPath READ currentPath CONSTANT)
public:
explicit MyFileDialog(QObject *parent = 0);
QList<QObject*> fileModel(){ return fList; }
QString filter(){ return _filter; }
QString currentPath(){ return MyFileDialog::_currentPath; }
signals:
void fileModelChanged();
void clickFile();
public:
Q_INVOKABLE void singlePress(QString fname);
Q_INVOKABLE void setFilter(QString filter){ _filter = filter; refresh();}
Q_INVOKABLE void setcurrentPath(QString path){if(MyFileDialog::_currentPath.isEmpty()) MyFileDialog::_currentPath = path; }
private:
inline QDir::Filters currentFilter(){
if(QDir(_currentPath).isRoot())
return QDir::NoDotAndDotDot|QDir::AllEntries|QDir::Hidden|QDir::AllDirs;
else
return QDir::NoDot|QDir::AllEntries|QDir::Hidden|QDir::AllDirs;
}
QList <QObject*> fList;
QString _filter;
static QString _currentPath;
void refresh();
};
#endif // MYFILEDIALOG_H