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
FSTYPE_FILE
@ FSTYPE_FILE
Definition: fileselector.h:29
FileData::selected
bool selected
Definition: fileselector.h:21
e
QDomElement e
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:1420
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(GrabberScript *)
FileSelector::backPressed
void backPressed(void)
Definition: fileselector.cpp:184
FileData
Definition: fileselector.h:19
FileSelector::itemClicked
void itemClicked(MythUIButtonListItem *item)
Definition: fileselector.cpp:121
FileSelector::Create
bool Create(void) override
Definition: fileselector.cpp:33
FileSelector::updateScrollArrows
void updateScrollArrows(void)
FileSelector::updateFileList
void updateFileList(void)
Definition: fileselector.cpp:358
FileSelector::homePressed
void homePressed(void)
Definition: fileselector.cpp:196
MythScreenStack
Definition: mythscreenstack.h:16
FileSelector::keyPressEvent
bool keyPressEvent(QKeyEvent *e) override
Key event handler.
Definition: fileselector.cpp:94
FileSelector::m_fileData
QList< FileData * > m_fileData
Definition: fileselector.h:80
MythUITextEdit
A text entry and edit widget.
Definition: mythuitextedit.h:33
MythScreenType
Screen in which all other widgets are contained and rendered.
Definition: mythscreentype.h:45
FileSelector::m_backButton
MythUIButton * m_backButton
Definition: fileselector.h:91
FileSelector::m_titleText
MythUIText * m_titleText
Definition: fileselector.h:86
FileSelector::getSelected
QString getSelected(void)
Definition: fileselector.cpp:173
FSTYPE_DIRECTORY
@ FSTYPE_DIRECTORY
Definition: fileselector.h:30
FileSelector::cancelPressed
void cancelPressed(void)
Definition: fileselector.cpp:327
FileData::directory
bool directory
Definition: fileselector.h:20
MythUIButtonListItem
Definition: mythuibuttonlist.h:28
FileSelector
Definition: fileselector.h:40
archiveutil.h
FileSelector::m_selectedList
QStringList m_selectedList
Definition: fileselector.h:81
FileSelector::m_filemask
QString m_filemask
Definition: fileselector.h:78
MythUIButton
A single button widget.
Definition: mythuibutton.h:22
filename
QString filename
Definition: mythplugins/mytharchive/mytharchivehelper/main.cpp:637
FileSelector::m_archiveList
QList< ArchiveItem * > * m_archiveList
Definition: fileselector.h:82
FileSelector::locationEditLostFocus
void locationEditLostFocus(void)
Definition: fileselector.cpp:178
FileSelector::wireUpTheme
void wireUpTheme(void)
FileSelector::haveResult
void haveResult(QString filename)
FileSelector::m_locationEdit
MythUITextEdit * m_locationEdit
Definition: fileselector.h:88
FileSelector::updateSelectedList
void updateSelectedList(void)
Definition: fileselector.cpp:336
FileSelector::m_okButton
MythUIButton * m_okButton
Definition: fileselector.h:89
FileSelector::OKPressed
void OKPressed(void)
Definition: fileselector.cpp:204
FileSelector::~FileSelector
~FileSelector() override
Definition: fileselector.cpp:27
FileData::filename
QString filename
Definition: fileselector.h:22
FileSelector::m_selectorType
FSTYPE m_selectorType
Definition: fileselector.h:77
MythUIText
All purpose text widget, displays a text string.
Definition: mythuitext.h:29
FileSelector::haveResult
void haveResult(bool ok)
FileData::size
int64_t size
Definition: fileselector.h:23
FileSelector::FileSelector
FileSelector(MythScreenStack *parent, QList< ArchiveItem * > *archiveList, FSTYPE type, QString startDir, QString filemask)
Definition: fileselector.h:44
FileSelector::m_curDirectory
QString m_curDirectory
Definition: fileselector.h:79
FSTYPE
FSTYPE
Definition: fileselector.h:27
FSTYPE_FILELIST
@ FSTYPE_FILELIST
Definition: fileselector.h:28
FileSelector::m_homeButton
MythUIButton * m_homeButton
Definition: fileselector.h:92
MythUIButtonList
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
Definition: mythuibuttonlist.h:144
FileSelector::m_fileButtonList
MythUIButtonList * m_fileButtonList
Definition: fileselector.h:87
mythscreentype.h
FileSelector::m_cancelButton
MythUIButton * m_cancelButton
Definition: fileselector.h:90
FileSelector::updateWidgets
void updateWidgets(void)