MythTV  master
fileselector.h
Go to the documentation of this file.
1 #ifndef FILESELECTOR_H_
2 #define FILESELECTOR_H_
3 
4 #include <iostream>
5 #include <utility>
6 
7 // qt
8 #include <QKeyEvent>
9 #include <QString>
10 #include <QStringList>
11 
12 // myth
13 #include <mythscreentype.h>
14 
15 // mytharchive
16 #include "archiveutil.h"
17 
18 struct FileData
19 {
20  bool directory { false };
21  bool selected { false };
22  QString filename;
23  int64_t size { 0 };
24 };
25 
26 enum FSTYPE
27 {
31 };
32 
33 class MythUIText;
34 class MythUITextEdit;
35 class MythUIButton;
36 class MythUIButtonList;
38 
40 {
41  Q_OBJECT
42 
43  public:
44  FileSelector(MythScreenStack *parent, QList<ArchiveItem *> *archiveList,
45  FSTYPE type, QString startDir, QString filemask)
46  : MythScreenType(parent, "FileSelector"),
48  m_filemask(std::move(filemask)),
49  m_curDirectory(std::move(startDir)),
50  m_archiveList(archiveList) {}
51  ~FileSelector() override;
52 
53  bool Create(void) override; // MythScreenType
54  bool keyPressEvent(QKeyEvent *e) override; // MythScreenType
55 
56  QString getSelected(void);
57 
58  signals:
59  void haveResult(bool ok); // used in FSTYPE_FILELIST mode
60  void haveResult(QString filename); // used in FSTYPE_FILE or FSTYPE_DIRECTORY mode
61 
62  protected slots:
63  void OKPressed(void);
64  void cancelPressed(void);
65  void backPressed(void);
66  void homePressed(void);
68  void locationEditLostFocus(void);
69 
70  protected:
71  void updateFileList(void);
72  void updateSelectedList(void);
73  void updateWidgets(void);
74  void wireUpTheme(void);
75  void updateScrollArrows(void);
76 
78  QString m_filemask;
79  QString m_curDirectory;
80  QList<FileData *> m_fileData;
81  QStringList m_selectedList;
82  QList<ArchiveItem *> *m_archiveList;
83  //
84  // GUI stuff
85  //
86  MythUIText *m_titleText {nullptr};
93 };
94 
96 
97 #endif
QList< FileData * > m_fileData
Definition: fileselector.h:80
~FileSelector() override
MythUIText * m_titleText
Definition: fileselector.h:86
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
void cancelPressed(void)
void updateWidgets(void)
MythUIButton * m_okButton
Definition: fileselector.h:89
FSTYPE
Definition: fileselector.h:26
bool selected
Definition: fileselector.h:21
unsigned int slots[4]
Definition: element.cpp:38
void backPressed(void)
void updateFileList(void)
Q_DECLARE_METATYPE(GrabberScript *)
QString m_curDirectory
Definition: fileselector.h:79
bool Create(void) override
MythUIButton * m_homeButton
Definition: fileselector.h:92
FileSelector(MythScreenStack *parent, QList< ArchiveItem * > *archiveList, FSTYPE type, QString startDir, QString filemask)
Definition: fileselector.h:44
void updateSelectedList(void)
MythUIButton * m_cancelButton
Definition: fileselector.h:90
MythUIButtonList * m_fileButtonList
Definition: fileselector.h:87
A text entry and edit widget.
FSTYPE m_selectorType
Definition: fileselector.h:77
int64_t size
Definition: fileselector.h:23
void updateScrollArrows(void)
void homePressed(void)
bool directory
Definition: fileselector.h:20
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
A single button widget.
Definition: mythuibutton.h:21
QString filename
Definition: fileselector.h:22
QStringList m_selectedList
Definition: fileselector.h:81
bool keyPressEvent(QKeyEvent *e) override
Key event handler.
QList< ArchiveItem * > * m_archiveList
Definition: fileselector.h:82
MythUIButton * m_backButton
Definition: fileselector.h:91
void wireUpTheme(void)
void OKPressed(void)
QString getSelected(void)
Screen in which all other widgets are contained and rendered.
void itemClicked(MythUIButtonListItem *item)
void haveResult(bool ok)
void locationEditLostFocus(void)
QString m_filemask
Definition: fileselector.h:78
MythUITextEdit * m_locationEdit
Definition: fileselector.h:88