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