Go to the documentation of this file.
4 #include <QCoreApplication>
6 #include <QImageReader>
47 if (!qurl.fragment().isEmpty())
90 return QFileInfo::fileName();
97 return QFileInfo::filePath();
104 return QFileInfo::isDir();
111 return QFileInfo::isFile();
118 return (QFileInfo::fileName() ==
"..");
125 return QFileInfo::isExecutable();
132 return QFileInfo::absoluteFilePath();
139 return QFileInfo::size();
152 const QString &startPath)
154 m_previewTimer(new QTimer(this))
167 if (startPath.startsWith(
"myth://"))
171 QUrl qurl(startPath);
173 if (!qurl.path().isEmpty())
219 LOG(VB_GENERAL, LOG_ERR,
"MythUIFileBrowser: Your theme is missing"
220 " some UI elements! Bailing out.");
245 const QString &resultid)
267 if (finfo.isParentDir())
320 if (finfo.isParentDir())
326 if (finfo.isRemote())
343 if (extension.isEmpty())
346 extension = extension.toLower();
348 QList<QByteArray>
formats = QImageReader::supportedImageFormats();
350 return formats.contains(extension.toLatin1());
442 QStringList sgdirlist;
453 LOG(VB_GENERAL, LOG_ERR,
"GetRemoteFileList failed to get "
454 "Storage Group dirs");
458 if ((sgdirlist.size() == 1) &&
459 (sgdirlist[0].startsWith(
"sgdir::")))
461 QStringList tokens = sgdirlist[0].split(
"::");
468 LOG(VB_GENERAL, LOG_ERR,
469 QString(
"GetRemoteFileList failed for '%1' in '%2' SG dir")
483 displayName = tr(
"Parent");
509 QVariant::fromValue(finfo));
511 item->SetText(QString(
"0"),
"filesize");
513 item->DisplayState(
type,
"nodetype");
524 for (
const auto & line : std::as_const(slist))
526 QStringList tokens = line.split(
"::");
528 if (tokens.size() < 2)
530 LOG(VB_GENERAL, LOG_ERR, QString(
"failed to parse '%1'.").arg(line));
534 displayName = tokens[1];
536 if (tokens[0] ==
"sgdir")
544 dataName = QString(
"%1%2/%3")
550 if ((tokens[0] ==
"dir") &&
558 else if ((tokens[0] ==
"sgdir") &&
566 else if ((tokens[0] ==
"file") &&
570 finfo.
setSize(tokens[2].toInt());
584 QVariant::fromValue(finfo));
590 item->SetImage(dataName);
592 item->SetText(dataName,
"fullpath");
593 item->DisplayState(
type,
"nodetype");
604 d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase);
608 LOG(VB_GENERAL, LOG_ERR,
609 "MythUIFileBrowser: current directory does not exist!");
615 QFileInfoList list =
d.entryInfoList();
616 bool showBackButton =
false;
621 tr(
"Parent Directory"));
622 item->DisplayState(
"upfolder",
"nodetype");
626 for (
const auto & fi : std::as_const(list))
633 QString displayName = finfo.
fileName();
636 if (displayName ==
"..")
641 displayName = tr(
"Parent");
643 showBackButton =
true;
645 else if (finfo.
isDir())
659 QVariant::fromValue(finfo));
669 item->DisplayState(
type,
"nodetype");
681 QString filesize(
"%L1 %2");
684 filesize = filesize.arg((
double)size / 1000.0, 0,
'f', 0).arg(
"KB");
685 else if (size < 1000000000)
686 filesize = filesize.arg((
double)size / 1000000.0, 0,
'f', 1).arg(
"MB");
688 filesize = filesize.arg((
double)size / 1000000000.0, 0,
'f', 1).arg(
"GB");
694 const QString &sgDir,
698 QString storageGroup = qurl.userName();
702 if (storageGroup.isEmpty())
703 storageGroup =
"Default";
705 list <<
"QUERY_SG_GETFILELIST";
707 list << storageGroup;
709 QString path = sgDir + qurl.path();
711 if (!qurl.fragment().isEmpty())
712 path +=
"#" + qurl.fragment();
719 if ((list.size() == 1) && (list[0] ==
"EMPTY LIST"))
MythUIFileBrowser(MythScreenStack *parent, const QString &startPath)
Browse a local filesystem or remote Storage Group Returns the selected file. Includes previews of ima...
QString absoluteFilePath(void) const
Image widget, displays a single image or multiple images in sequence.
void Reset(void) override
Reset the widget to it's original state, should not reset changes made by the theme.
void updateFileList(void)
bool SendReceiveStringList(QStringList &strlist, bool quickTimeout=false, bool block=true)
Send a message to the backend and wait for a response.
MythUIType * GetChild(const QString &name) const
Get a named child of this UIType.
MythUIImage * m_previewImage
bool Load(bool allowLoadInBackground=true, bool forceStat=false)
Load the image(s), wraps ImageLoader::LoadImage()
MythUIButton * m_homeButton
MythUITextEdit * m_locationEdit
MythUIButton * m_cancelButton
void init(const QString &fileName="", QString sgDir="", bool isDir=false, qint64 size=0)
A text entry and edit widget.
void setIsDir(bool isDir)
static QString FormatSize(int64_t size)
void SetReturnEvent(QObject *retobject, const QString &resultid)
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Screen in which all other widgets are contained and rendered.
MFileInfo & operator=(const MFileInfo &other)
void PathSelected(MythUIButtonListItem *item)
MythUIText * m_fullpathText
MythUIButton * m_okButton
QString GetText(void) const
bool Create(void) override
void Reset(void) override
Reset the image back to the default defined in the theme.
MythUIText * m_filenameText
QString fileName(void) const
void SetText(const QString &text, bool moveCursor=true)
MythUIButton * m_backButton
void PathClicked(MythUIButtonListItem *item)
static QString GenMythURL(const QString &host=QString(), int port=0, QString path=QString(), const QString &storageGroup=QString())
bool isExecutable(void) const
void setSize(qint64 size)
void setSGDir(QString sgDir)
QString m_storageGroupDir
void BuildFocusList(void)
const std::array< const std::string, 8 > formats
MythUIButtonList * m_fileList
static bool CopyWindowFromBase(const QString &windowname, MythScreenType *win)
void updateRemoteFileList(void)
void SetEnabled(bool enable)
QString filePath(void) const
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
void updateLocalFileList(void)
static bool IsImage(QString extension)
QString storageGroupDir(void) const
All purpose text widget, displays a text string.
bool isParentDir(void) const
Event dispatched from MythUI modal dialogs to a listening class containing a result of some form.
virtual void SetText(const QString &text)
QString m_storageGroupDir
static bool GetRemoteFileList(const QString &url, const QString &sgDir, QStringList &list)
void SetPath(const QString &startPath)
static const iso6937table * d
void SetFilename(const QString &filename)
Must be followed by a call to Load() to load the image.
QDir::Filters m_typeFilter
MFileInfo(const QString &fileName="", QString sgDir="", bool isDir=false, qint64 size=0)