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