MythTV  master
iconview.h
Go to the documentation of this file.
1 /* ============================================================
2  * File : iconview.h
3  * Description :
4  *
5 
6  * This program is free software; you can redistribute it
7  * and/or modify it under the terms of the GNU General
8  * Public License as published bythe Free Software Foundation;
9  * either version 2, or (at your option)
10  * any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * ============================================================ */
18 
19 #ifndef ICONVIEW_H
20 #define ICONVIEW_H
21 
22 #include <vector>
23 
24 // Qt headers
25 #include <QStringList>
26 #include <QList>
27 #include <QHash>
28 
29 // MythTV headers
30 #include <mythscreentype.h>
31 #include <mythuitext.h>
32 #include <mythuibuttonlist.h>
33 #include <mythuiimage.h>
34 #include <mythdialogbox.h>
35 #include <mythmedia.h>
36 #include <mthread.h>
37 
38 // MythGallery headers
39 #include "galleryfilter.h"
40 #include "galleryfilterdlg.h"
41 #include "thumbview.h"
42 
43 using namespace std;
44 
45 class ThumbGenerator;
46 class MediaMonitor;
47 class ChildCountThread;
48 
50 
51 class IconView : public MythScreenType
52 {
53  Q_OBJECT
54 
55  public:
56  IconView(MythScreenStack *parent, const char *name,
57  const QString &galleryDir, MythMediaDevice *initialDevice);
58  ~IconView();
59 
60  bool Create(void) override; // MythScreenType
61  bool keyPressEvent(QKeyEvent *) override; // MythScreenType
62  void customEvent(QEvent*) override; // MythUIType
63  void HandleRandomShow(void);
64  void HandleSeasonalShow(void);
65 
66  QString GetError(void) { return m_errorStr; }
67 
68  private:
69  void SetupMediaMonitor(void);
70 
71  void LoadDirectory(const QString &dir);
72 
73  bool HandleEscape(void);
74  bool HandleMediaEscape(MediaMonitor*);
75  bool HandleSubDirEscape(const QString &parent);
76 
77  bool HandleMediaDeviceSelect(ThumbItem *item);
78  bool HandleImageSelect(const QString &action);
79 
80  void HandleMainMenu(void);
81  MythMenu* CreateMetadataMenu(void);
82  MythMenu* CreateMarkingMenu(void);
83  void HandleSubMenuFilter(void);
84  MythMenu* CreateFileMenu(void);
85 
86  private slots:
87  void HandleRotateCW(void);
88  void HandleRotateCCW(void);
89  void HandleDeleteCurrent(void);
90  void HandleSlideShow(void);
91  void HandleSettings(void);
92  void ReloadSettings(void);
93  void HandleEject(void);
94  void HandleImport(void);
95  void HandleShowDevices(void);
96  void HandleCopyHere(void);
97  void HandleMoveHere(void);
98  void HandleDelete(void);
99  void HandleDeleteMarked(void);
100  void HandleClearMarked(void);
101  void HandleClearOneMarked(void);
102  void HandleSelectAll(void);
103  void HandleSelectOne(void);
104  void HandleMkDir(void);
105  void HandleRename(void);
106 
107  void DoMkDir(const QString& folderName);
108  void DoDeleteMarked(bool doDelete);
109  void DoRename(const QString& folderName);
110  void DoDeleteCurrent(bool doDelete);
111 
112  private:
113  void LoadThumbnail(ThumbItem *item);
114  void ImportFromDir(const QString &fromDir, const QString &toDir);
115  void CopyMarkedFiles(bool move = false);
116  ThumbItem *GetCurrentThumb(void);
117  int GetChildCount(ThumbItem *thumbitem);
118 
119  QList<ThumbItem*> m_itemList;
120  QHash<QString, ThumbItem*> m_itemHash;
121  QStringList m_itemMarked;
122  QString m_galleryDir;
123  vector<int> m_history;
124  GalleryFilter *m_galleryFilter {nullptr};
125 
126  MythUIButtonList *m_imageList {nullptr};
127  MythUIText *m_captionText {nullptr};
128  MythUIText *m_crumbsText {nullptr};
129  MythUIText *m_positionText {nullptr};
130  MythUIText *m_noImagesText {nullptr};
131  MythUIImage *m_selectedImage {nullptr};
132  MythDialogBox *m_menuPopup {nullptr};
133  MythScreenStack *m_popupStack {nullptr};
134 
135  bool m_isGallery {false};
136  bool m_showDevices {false};
137  QString m_currDir;
138  MythMediaDevice *m_currDevice {nullptr};
139 
140  ThumbGenerator *m_thumbGen {nullptr};
141  ChildCountThread *m_childCountThread {nullptr};
142 
143  bool m_showcaption {false};
144  int m_sortorder {0};
145  bool m_useOpenGL {false};
146  bool m_recurse {false};
147  QStringList m_paths;
148 
149  QString m_errorStr;
150 
151  bool m_allowImportScripts {false};
152 
153  protected slots:
154  void reloadData();
155 
156  public slots:
157  void mediaStatusChanged(MythMediaStatus oldStatus, MythMediaDevice *pMedia);
158  void HandleItemSelect(MythUIButtonListItem *);
159  void UpdateText(MythUIButtonListItem *);
160  void UpdateImage(MythUIButtonListItem *);
161 
162  friend class FileCopyThread;
163 };
164 
165 typedef struct
166 {
167  QString fileName;
168  int count;
170 
171 class ChildCountEvent : public QEvent
172 {
173  public:
175  QEvent(kEventType), childCountData(ccd) {}
176  ~ChildCountEvent() = default;
177 
178  ChildCountData *childCountData {nullptr};
179 
180  static Type kEventType;
181 };
182 
183 class ChildCountThread : public MThread
184 {
185 public:
186 
187  explicit ChildCountThread(QObject *parent) :
188  MThread("ChildCountThread"), m_parent(parent) {}
189  ~ChildCountThread();
190 
191  void addFile(const QString &filePath);
192  void cancel();
193 
194 protected:
195  void run() override; // MThread
196 
197 private:
198 
199  bool moreWork();
200  int getChildCount(const QString &filepath);
201 
202  QObject *m_parent {nullptr};
203  QStringList m_fileList;
204  QMutex m_mutex;
205 };
206 
207 class ImportThread: public MThread
208 {
209  public:
210  explicit ImportThread(const QString &cmd)
211  : MThread("import"), m_command(cmd) {}
212  void run() override; // MThread
213  private:
214  QString m_command;
215 };
216 
217 #endif /* ICONVIEW_H */
QString GetError(void)
Definition: iconview.h:66
QMutex m_mutex
Definition: iconview.h:204
This is a wrapper around QThread that does several additional things.
Definition: mthread.h:46
Q_DECLARE_METATYPE(ThumbItem *)
unsigned int slots[4]
Definition: element.c:38
QString m_errorStr
Definition: iconview.h:149
All purpose text widget, displays a text string.
Definition: mythuitext.h:28
vector< int > m_history
Definition: iconview.h:123
Image widget, displays a single image or multiple images in sequence.
Definition: mythuiimage.h:97
Basic menu dialog, message and a list of options.
QString m_galleryDir
Definition: iconview.h:122
static int run(MythMediaDevice *dev=nullptr, bool startRandomShow=false)
const char * name
Definition: ParseText.cpp:328
List widget, displays list items in a variety of themeable arrangements and can trigger signals when ...
ImportThread(const QString &cmd)
Definition: iconview.h:210
QHash< QString, ThumbItem * > m_itemHash
Definition: iconview.h:120
QString m_currDir
Definition: iconview.h:137
QStringList m_itemMarked
Definition: iconview.h:121
QStringList m_paths
Definition: iconview.h:147
ChildCountThread(QObject *parent)
Definition: iconview.h:187
QString m_command
Definition: iconview.h:214
MythMediaStatus
Definition: mythmedia.h:12
Screen in which all other widgets are contained and rendered.
static Type kEventType
Definition: iconview.h:180
QStringList m_fileList
Definition: iconview.h:203
QList< ThumbItem * > m_itemList
Definition: iconview.h:119
QString fileName
Definition: iconview.h:167
ChildCountEvent(ChildCountData *ccd)
Definition: iconview.h:174