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#include "mythuibuttonlist.h"
16
17class MythUIButton;
18class MythUITextEdit;
19class MythUIImage;
20class MythUIStateType;
21
22class MUI_PUBLIC MFileInfo : public QFileInfo
23{
24 public:
25 explicit MFileInfo(const QString& fileName = "", QString sgDir = "", bool isDir = false,
26 qint64 size = 0);
27 ~MFileInfo() = default;
28
29 MFileInfo(const MFileInfo &other);
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) const { 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 = std::move(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;
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() override = 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 = std::move(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 static bool GetRemoteFileList(const QString &url, const QString &sgDir,
103 QStringList &list);
104 void updateFileList(void);
105 void updateRemoteFileList(void);
106 void updateLocalFileList(void);
108 void updateWidgets(void);
109
110 static bool IsImage(QString extension);
111 static QString FormatSize(int64_t size);
112
113 bool m_isRemote {false};
114
115 QTimer *m_previewTimer {nullptr};
116
120 QString m_parentDir;
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: */
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)