00001
00002 #ifndef MYTHUIFILEBROWSER_H_
00003 #define MYTHUIFILEBROWSER_H_
00004
00005 #include <QDir>
00006 #include <QEvent>
00007 #include <QFileInfo>
00008
00009 #include "mythscreentype.h"
00010 #include "mythuitextedit.h"
00011
00012 class QString;
00013 class QStringList;
00014 class QTimer;
00015
00016 class MythUIButtonListItem;
00017 class MythUIButtonList;
00018 class MythUIButton;
00019 class MythUITextEdit;
00020 class MythUIImage;
00021 class MythUIStateType;
00022
00023 class MUI_PUBLIC MFileInfo : public QFileInfo
00024 {
00025 public:
00026 MFileInfo(QString fileName = "", QString sgDir = "", bool isDir = false,
00027 qint64 size = 0);
00028 ~MFileInfo();
00029
00030 MFileInfo &operator=(const MFileInfo &fileinfo);
00031
00032 void init(QString fileName = "", QString sgDir = "", bool isDir = false,
00033 qint64 size = 0);
00034
00035 QString fileName(void) const;
00036 QString filePath(void) const;
00037 bool isRemote(void) { return m_isRemote; }
00038 bool isDir(void) const;
00039 bool isFile(void) const;
00040 bool isParentDir(void) const;
00041 bool isExecutable(void) const;
00042 QString absoluteFilePath(void) const;
00043 qint64 size(void) const;
00044
00045 void setFile(const QString &file) { init(file); }
00046 void setSize(qint64 size) { m_size = size; }
00047 void setIsDir(bool isDir) { m_isDir = isDir; m_isFile = !isDir; }
00048 void setIsFile(bool isFile) { m_isFile = isFile; m_isDir = !isFile; }
00049 void setIsParentDir(bool isParentDir) { m_isParentDir = isParentDir; }
00050 void setSGDir(QString sgDir) { m_storageGroupDir = sgDir; }
00051
00052 QString hostName(void) const { return m_hostName; }
00053 QString storageGroup(void) const { return m_storageGroup; }
00054 QString storageGroupDir(void) const { return m_storageGroupDir; }
00055 QString subDir(void) const { return m_subDir; }
00056
00057 private:
00058
00059 bool m_isRemote;
00060 bool m_isDir;
00061 bool m_isFile;
00062 bool m_isParentDir;
00063
00064 QString m_hostName;
00065 QString m_storageGroup;
00066 QString m_storageGroupDir;
00067 QString m_fileName;
00068 QString m_subDir;
00069
00070 qint64 m_size;
00071 };
00072
00073 Q_DECLARE_METATYPE(MFileInfo);
00074
00075 class MUI_PUBLIC MythUIFileBrowser : public MythScreenType
00076 {
00077 Q_OBJECT
00078
00079 public:
00080 MythUIFileBrowser(MythScreenStack *parent, const QString &startPath);
00081 ~MythUIFileBrowser();
00082
00083 void Init(const QString &startPath);
00084 bool Create(void);
00085
00086 void SetReturnEvent(QObject *retobject, const QString &resultid);
00087
00088 void SetTypeFilter(QDir::Filters filter) { m_typeFilter = filter; }
00089 void SetNameFilter(QStringList filter) { m_nameFilter = filter; }
00090
00091 private slots:
00092 void OKPressed(void);
00093 void cancelPressed(void);
00094 void backPressed(void);
00095 void homePressed(void);
00096 void editLostFocus(void);
00097 void PathSelected(MythUIButtonListItem *item);
00098 void PathClicked(MythUIButtonListItem *item);
00099 void LoadPreview(void);
00100
00101 private:
00102 bool GetRemoteFileList(const QString &url, const QString &sgDir,
00103 QStringList &list);
00104 void updateFileList(void);
00105 void updateRemoteFileList(void);
00106 void updateLocalFileList(void);
00107 void updateSelectedList(void);
00108 void updateWidgets(void);
00109
00110 bool IsImage(QString extension);
00111 QString FormatSize(int size);
00112
00113 bool m_isRemote;
00114
00115 QTimer *m_previewTimer;
00116
00117 QString m_baseDirectory;
00118 QString m_subDirectory;
00119 QString m_storageGroupDir;
00120 QString m_parentDir;
00121 QString m_parentSGDir;
00122
00123 QDir::Filters m_typeFilter;
00124 QStringList m_nameFilter;
00125
00126 MythUIButtonList *m_fileList;
00127 MythUITextEdit *m_locationEdit;
00128 MythUIButton *m_okButton;
00129 MythUIButton *m_cancelButton;
00130 MythUIButton *m_backButton;
00131 MythUIButton *m_homeButton;
00132 MythUIImage *m_previewImage;
00133 MythUIText *m_infoText;
00134 MythUIText *m_filenameText;
00135 MythUIText *m_fullpathText;
00136
00137 QObject *m_retObject;
00138 QString m_id;
00139 };
00140
00141 #endif
00142