/
fileselector.h
96 lines (79 loc) · 2.29 KB
/
fileselector.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#ifndef FILESELECTOR_H_
#define FILESELECTOR_H_
#include <iostream>
// qt
#include <QString>
#include <QStringList>
#include <QKeyEvent>
// myth
#include <mythscreentype.h>
// mytharchive
#include "archiveutil.h"
struct FileData
{
bool directory;
bool selected;
QString filename;
int64_t size;
};
enum FSTYPE
{
FSTYPE_FILELIST = 0,
FSTYPE_FILE = 1,
FSTYPE_DIRECTORY = 2
};
class MythUIText;
class MythUITextEdit;
class MythUIButton;
class MythUIButtonList;
class MythUIButtonListItem;
class FileSelector : public MythScreenType
{
Q_OBJECT
public:
FileSelector(MythScreenStack *parent, QList<ArchiveItem *> *archiveList,
FSTYPE type, const QString &startDir, const QString &filemask)
: MythScreenType(parent, "FileSelector"),
m_selectorType(type),
m_filemask(filemask),
m_curDirectory(startDir),
m_archiveList(archiveList) {}
~FileSelector();
bool Create(void) override; // MythScreenType
bool keyPressEvent(QKeyEvent *e) override; // MythScreenType
QString getSelected(void);
signals:
void haveResult(bool ok); // used in FSTYPE_FILELIST mode
void haveResult(QString filename); // used in FSTYPE_FILE or FSTYPE_DIRECTORY mode
protected slots:
void OKPressed(void);
void cancelPressed(void);
void backPressed(void);
void homePressed(void);
void itemClicked(MythUIButtonListItem *item);
void locationEditLostFocus(void);
protected:
void updateFileList(void);
void updateSelectedList(void);
void updateWidgets(void);
void wireUpTheme(void);
void updateScrollArrows(void);
FSTYPE m_selectorType;
QString m_filemask;
QString m_curDirectory;
QList<FileData *> m_fileData;
QStringList m_selectedList;
QList<ArchiveItem *> *m_archiveList;
//
// GUI stuff
//
MythUIText *m_titleText {nullptr};
MythUIButtonList *m_fileButtonList {nullptr};
MythUITextEdit *m_locationEdit {nullptr};
MythUIButton *m_okButton {nullptr};
MythUIButton *m_cancelButton {nullptr};
MythUIButton *m_backButton {nullptr};
MythUIButton *m_homeButton {nullptr};
};
Q_DECLARE_METATYPE(FileData *)
#endif