MythTV  master
mythuifilebrowser.h
Go to the documentation of this file.
1 
2 #ifndef MYTHUIFILEBROWSER_H_
3 #define MYTHUIFILEBROWSER_H_
4 
5 #include <QDir>
6 #include <QEvent>
7 #include <QFileInfo>
8 
9 #include "mythscreentype.h"
10 #include "mythuitextedit.h"
11 
12 class QString;
13 class QStringList;
14 class QTimer;
15 
17 class MythUIButtonList;
18 class MythUIButton;
19 class MythUITextEdit;
20 class MythUIImage;
21 class MythUIStateType;
22 
23 class MUI_PUBLIC MFileInfo : public QFileInfo
24 {
25  public:
26  MFileInfo(QString fileName = "", QString sgDir = "", bool isDir = false,
27  qint64 size = 0);
28  ~MFileInfo() = default;
29 
30  MFileInfo &operator=(const MFileInfo &other);
31 
32  void init(const QString& fileName = "", QString sgDir = "", bool isDir = false,
33  qint64 size = 0);
34 
35  QString fileName(void) const;
36  QString filePath(void) const;
37  bool isRemote(void) { return m_isRemote; }
38  bool isDir(void) const;
39  bool isFile(void) const;
40  bool isParentDir(void) const;
41  bool isExecutable(void) const;
42  QString absoluteFilePath(void) const;
43  qint64 size(void) const;
44 
45  void setFile(const QString &file) { init(file); }
46  void setSize(qint64 size) { m_size = size; }
47  void setIsDir(bool isDir) { m_isDir = isDir; m_isFile = !isDir; }
48  void setIsFile(bool isFile) { m_isFile = isFile; m_isDir = !isFile; }
49  void setIsParentDir(bool isParentDir) { m_isParentDir = isParentDir; }
50  void setSGDir(QString sgDir) { m_storageGroupDir = sgDir; }
51 
52  QString hostName(void) const { return m_hostName; }
53  QString storageGroup(void) const { return m_storageGroup; }
54  QString storageGroupDir(void) const { return m_storageGroupDir; }
55  QString subDir(void) const { return m_subDir; }
56 
57  private:
58 
59  bool m_isRemote {false};
60  bool m_isDir {false};
61  bool m_isFile {true};
62  bool m_isParentDir {false};
63 
64  QString m_hostName;
65  QString m_storageGroup;
67  QString m_fileName;
68  QString m_subDir;
69 
70  qint64 m_size {0};
71 };
72 
74 
76 {
77  Q_OBJECT
78 
79  public:
80  MythUIFileBrowser(MythScreenStack *parent, const QString &startPath);
81  ~MythUIFileBrowser() = default;
82 
83  bool Create(void) override; // MythScreenType
84 
85  void SetReturnEvent(QObject *retobject, const QString &resultid);
86 
87  void SetTypeFilter(QDir::Filters filter) { m_typeFilter = filter; }
88  void SetNameFilter(QStringList filter) { m_nameFilter = filter; }
89 
90  private slots:
91  void OKPressed(void);
92  void cancelPressed(void);
93  void backPressed(void);
94  void homePressed(void);
95  void editLostFocus(void);
96  void PathSelected(MythUIButtonListItem *item);
97  void PathClicked(MythUIButtonListItem *item);
98  void LoadPreview(void);
99 
100  private:
101  void SetPath(const QString &startPath);
102  bool GetRemoteFileList(const QString &url, const QString &sgDir,
103  QStringList &list);
104  void updateFileList(void);
105  void updateRemoteFileList(void);
106  void updateLocalFileList(void);
107  void updateSelectedList(void);
108  void updateWidgets(void);
109 
110  bool IsImage(QString extension);
111  QString FormatSize(int size);
112 
113  bool m_isRemote {false};
114 
115  QTimer *m_previewTimer {nullptr};
116 
118  QString m_subDirectory;
120  QString m_parentDir;
121  QString m_parentSGDir;
122 
123  QDir::Filters m_typeFilter {QDir::AllDirs | QDir::Drives |
124  QDir::Files | QDir::Readable |
125  QDir::Writable | QDir::Executable};
126  QStringList m_nameFilter;
127 
128  MythUIButtonList *m_fileList {nullptr};
129  MythUITextEdit *m_locationEdit {nullptr};
130  MythUIButton *m_okButton {nullptr};
131  MythUIButton *m_cancelButton {nullptr};
132  MythUIButton *m_backButton {nullptr};
133  MythUIButton *m_homeButton {nullptr};
134  MythUIImage *m_previewImage {nullptr};
135  MythUIText *m_infoText {nullptr};
136  MythUIText *m_filenameText {nullptr};
137  MythUIText *m_fullpathText {nullptr};
138 
139  QObject *m_retObject {nullptr};
140  QString m_id;
141 };
142 
143 #endif
144 /* vim: set expandtab tabstop=4 shiftwidth=4: */
This widget is used for grouping other widgets for display when a particular named state is called.
void setSGDir(QString sgDir)
QString m_storageGroupDir
unsigned int slots[4]
Definition: element.c:38
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
void setIsFile(bool isFile)
QString storageGroup(void) const
QString m_hostName
void setIsParentDir(bool isParentDir)
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
QStringList m_nameFilter
QString hostName(void) const
virtual bool Create(void)
Q_DECLARE_METATYPE(MFileInfo)
QString m_fileName
bool isRemote(void)
void SetNameFilter(QStringList filter)
QString storageGroupDir(void) const
QString m_subDir
void setFile(const QString &file)
QString m_storageGroup
A text entry and edit widget.
void setSize(qint64 size)
void SetTypeFilter(QDir::Filters filter)
void setIsDir(bool isDir)
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 subDir(void) const
#define MUI_PUBLIC
Definition: mythuiexp.h:9
static void init(VideoFrame *vf, VideoFrameType _codec, unsigned char *_buf, int _width, int _height, int _size, const int *p=nullptr, const int *o=nullptr, float _aspect=-1.0F, double _rate=-1.0F, int _aligned=64)
Definition: mythframe.h:115
Screen in which all other widgets are contained and rendered.