00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef ICONVIEW_H
00020 #define ICONVIEW_H
00021
00022 #include <vector>
00023
00024
00025 #include <QStringList>
00026 #include <QList>
00027 #include <QHash>
00028
00029
00030 #include <mythscreentype.h>
00031 #include <mythuitext.h>
00032 #include <mythuibuttonlist.h>
00033 #include <mythuiimage.h>
00034 #include <mythdialogbox.h>
00035 #include <mythmedia.h>
00036 #include <mthread.h>
00037
00038
00039 #include "galleryfilter.h"
00040 #include "galleryfilterdlg.h"
00041 #include "thumbview.h"
00042
00043 using namespace std;
00044
00045 class ThumbGenerator;
00046 class MediaMonitor;
00047 class ChildCountThread;
00048
00049 Q_DECLARE_METATYPE(ThumbItem*)
00050
00051 class IconView : public MythScreenType
00052 {
00053 Q_OBJECT
00054
00055 public:
00056 IconView(MythScreenStack *parent, const char *name,
00057 const QString &galleryDir, MythMediaDevice *initialDevice);
00058 ~IconView();
00059
00060 bool Create(void);
00061 bool keyPressEvent(QKeyEvent *);
00062 void customEvent(QEvent*);
00063 void HandleRandomShow(void);
00064
00065 QString GetError(void) { return m_errorStr; }
00066
00067 private:
00068 void SetupMediaMonitor(void);
00069
00070 void LoadDirectory(const QString &dir);
00071
00072 bool HandleEscape(void);
00073 bool HandleMediaEscape(MediaMonitor*);
00074 bool HandleSubDirEscape(const QString &parent);
00075
00076 bool HandleMediaDeviceSelect(ThumbItem *item);
00077 bool HandleImageSelect(const QString &action);
00078
00079 void HandleMainMenu(void);
00080 MythMenu* CreateMetadataMenu(void);
00081 MythMenu* CreateMarkingMenu(void);
00082 void HandleSubMenuFilter(void);
00083 MythMenu* CreateFileMenu(void);
00084
00085 private slots:
00086 void HandleRotateCW(void);
00087 void HandleRotateCCW(void);
00088 void HandleDeleteCurrent(void);
00089 void HandleSlideShow(void);
00090 void HandleSettings(void);
00091 void HandleEject(void);
00092 void HandleImport(void);
00093 void HandleShowDevices(void);
00094 void HandleCopyHere(void);
00095 void HandleMoveHere(void);
00096 void HandleDelete(void);
00097 void HandleDeleteMarked(void);
00098 void HandleClearMarked(void);
00099 void HandleClearOneMarked(void);
00100 void HandleSelectAll(void);
00101 void HandleSelectOne(void);
00102 void HandleMkDir(void);
00103 void HandleRename(void);
00104
00105 void DoMkDir(QString folderName);
00106 void DoDeleteMarked(bool doDelete);
00107 void DoRename(QString folderName);
00108 void DoDeleteCurrent(bool doDelete);
00109
00110 private:
00111 void LoadThumbnail(ThumbItem *item);
00112 void ImportFromDir(const QString &fromDir, const QString &toDir);
00113 void CopyMarkedFiles(bool move = false);
00114 ThumbItem *GetCurrentThumb(void);
00115 int GetChildCount(ThumbItem *thumbitem);
00116
00117 QList<ThumbItem*> m_itemList;
00118 QHash<QString, ThumbItem*> m_itemHash;
00119 QStringList m_itemMarked;
00120 QString m_galleryDir;
00121 vector<int> m_history;
00122 GalleryFilter *m_galleryFilter;
00123
00124 MythUIButtonList *m_imageList;
00125 MythUIText *m_captionText;
00126 MythUIText *m_crumbsText;
00127 MythUIText *m_positionText;
00128 MythUIText *m_noImagesText;
00129 MythUIImage *m_selectedImage;
00130 MythDialogBox *m_menuPopup;
00131 MythScreenStack *m_popupStack;
00132
00133 bool m_isGallery;
00134 bool m_showDevices;
00135 QString m_currDir;
00136 MythMediaDevice *m_currDevice;
00137
00138 ThumbGenerator *m_thumbGen;
00139 ChildCountThread *m_childCountThread;
00140
00141 int m_showcaption;
00142 int m_sortorder;
00143 bool m_useOpenGL;
00144 bool m_recurse;
00145 QStringList m_paths;
00146
00147 QString m_errorStr;
00148
00149 protected slots:
00150 void reloadData();
00151
00152 public slots:
00153 void mediaStatusChanged(MythMediaStatus oldStatus, MythMediaDevice *pMedia);
00154 void HandleItemSelect(MythUIButtonListItem *);
00155 void UpdateText(MythUIButtonListItem *);
00156 void UpdateImage(MythUIButtonListItem *);
00157
00158 friend class FileCopyThread;
00159 };
00160
00161 typedef struct
00162 {
00163 QString fileName;
00164 int count;
00165 } ChildCountData;
00166
00167 class ChildCountEvent : public QEvent
00168 {
00169 public:
00170 ChildCountEvent(ChildCountData *ccd) :
00171 QEvent(kEventType), childCountData(ccd) {}
00172 ~ChildCountEvent() {}
00173
00174 ChildCountData *childCountData;
00175
00176 static Type kEventType;
00177 };
00178
00179 class ChildCountThread : public MThread
00180 {
00181 public:
00182
00183 ChildCountThread(QObject *parent);
00184 ~ChildCountThread();
00185
00186 void addFile(const QString &fileName);
00187 void cancel();
00188
00189 protected:
00190 void run();
00191
00192 private:
00193
00194 bool moreWork();
00195 int getChildCount(const QString &fileName);
00196
00197 QObject *m_parent;
00198 QStringList m_fileList;
00199 QMutex m_mutex;
00200 };
00201
00202 #endif