1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
/***************************************************************************
* fqterm, a terminal emulator for both BBS and *nix. *
* Copyright (C) 2008 fqterm development group. *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. *
***************************************************************************/
#ifndef IMAGE_VIERWER_H
#define IMAGE_VIERWER_H
#include <QDesktopWidget>
#include <QDirModel>
#include <QLabel>
#include <QPainter>
#include <QPixmapCache>
#include <QScrollArea>
#include <QStatusBar>
#include <QToolButton>
#include <QToolBar>
#include <QLayout>
#include <QItemDelegate>
#include <QItemSelection>
class QString;
class QPushButton;
class QVBoxLayout;
class QHBoxLayout;
class QMenuBar;
class QTreeView;
class QComboBox;
#include "pictureflow.h"
namespace FQTerm {
#define DISP_MARGIN (10.0) // show a margin
#define PIXMAP_CACHESIZE (5120) // in KBytes
#define ZOOMIN_FACTOR (1.15)
#define ZOOMOUT_FACTOR (0.85)
#define ROTLEFT_DEG (-90.0)
#define ROTRIGHT_DEG (90.0)
#define IMG_CHUNK (16384) // in bytes
#define IMAGE_BROWSER_NAME "FQLora [Image Companion for FQTerm]"
#define ICON_SOURCE "pic/ViewerButtons/"
#define POOL_SOURCE "pool/"
#define SHADOW_SOURCE "shadow-cache/"
#define TRASH_SOURCE ".Trash/"
#define EMBLEM_LIKE "emblem-like.png"
#define EMBLEM_NEW "emblem-new.png"
#define EMBLEM_RECOVER "emblem-recover.png"
#define EMBLEM_TRASH "emblem-trash.png"
#define EMBLEM_TITLE "emblem-title.png"
class FQTermConfig;
class FQTermFileDialog;
class FQTermImage : public QWidget {
Q_OBJECT;
public:
FQTermImage(QWidget * parent, Qt::WindowFlags f);
virtual void adjustItemSize() = 0;
virtual void scrollTo(const QString &) = 0;
virtual void updateImage(const QString &) = 0;
};
class ImageFlow;
class ImageMenu;
class ImageFlowItem;
class FQTermImageFlow: public FQTermImage {
Q_OBJECT;
public:
FQTermImageFlow(FQTermConfig *, QWidget *, Qt::WindowFlags);
~FQTermImageFlow();
/* don't modify the funcs below */
/* they are for API compatibiliy */
void adjustItemSize();
void scrollTo(const QString &);
void updateImage(const QString &);
/*********************************/
public slots:
void saveImages(void);
void clearImages(void);
void trashAllImages(void);
void recoverImages(void);
void showStatusMessage(const QString &message);
private:
ImageFlow *imageFlow_;
ImageMenu *imageMenu_;
QStatusBar *statusBar_;
FQTermConfig *config_;
QFileInfoList sortedList(const QString &path);
const QString& poolSource(void) const;
const QString& trashSource(void) const;
private slots:
void loadImages(const int status);
void reshuffleImages(const int status);
void checkTrashState(void);
signals:
void statusMessage(const QString &message);
void isTrashEmpty(void);
void trashStatus(const bool fullOrNot);
void saveStatus(const bool hasOrNot);
void clearStatus(const bool hasOrNot);
protected:
void showEvent(QShowEvent *event);
void closeEvent(QCloseEvent *event);
};
class ImageMenu: public QLabel {
Q_OBJECT;
public:
ImageMenu(QWidget *parent = 0);
~ImageMenu();
public slots:
void updateEmblems(const int status);
void updateDustbin(const bool fullOrNot);
void updateSave(const bool hasOrNot);
void updateClear(const bool hasOrNot);
signals:
void toggleFlowStatus(const int status);
void recoverImages(void);
void saveImages(void);
void clearImages(void);
private:
class Private;
Private *fh;
protected:
void paintEvent(QPaintEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
};
class ImageFlow: public PictureFlow {
Q_OBJECT;
Q_PROPERTY(QList<QByteArray> itemsTitles READ itemsTitles);
public:
ImageFlow(QWidget *parent);
~ImageFlow();
const ImageFlowItem& operator[](int index) const;
ImageFlowItem& operator[](int index);
const ImageFlowItem& at(int index) const;
QList<QByteArray>& itemsTitles(void) const;
QFileInfoList& digest(const int status);
void strip(const int status);
QList<qint64> sort(const int status);
bool reorder(const QList<qint64>& itemsKey);
public slots:
void add(const ImageFlowItem &item);
void clear(void);
int count(void) const;
int size(void) const;
void rehash(void);
void toggleStatus(const int status);
void setCurrentImage(const int index);
private:
class Private;
Private *m;
signals:
void statusMessage(const QString &message);
void emblemStatus(const int status);
void saveStatus(const bool hasOrNot);
void clearStatus(const bool hasOrNot);
void titlesChanged(QList<QByteArray> &titles);
protected:
void paintEvent(QPaintEvent *event);
};
class ImageFlowItem: public QObject {
Q_OBJECT;
Q_PROPERTY(qint64 key READ key);
Q_PROPERTY(int status READ status WRITE setStatus);
Q_PROPERTY(QImage image READ image WRITE setImage);
Q_PROPERTY(QFileInfo info READ info WRITE setInfo);
Q_PROPERTY(QString comment READ comment WRITE setComment);
public:
ImageFlowItem(QObject *parent = 0);
ImageFlowItem(const ImageFlowItem &item);
ImageFlowItem(const QImage &image, QObject *parent = 0);
ImageFlowItem(const QImage &image, const QFileInfo &info, QObject *parent = 0);
ImageFlowItem(const QImage &image, const QFileInfo &info, const int state, QObject *parent = 0);
ImageFlowItem(const QImage &image, const QFileInfo &info, const QString &comment, QObject *parent = 0);
ImageFlowItem(const QImage &image, const QFileInfo &info, const QString& comment, const int status, QObject *parent = 0);
~ImageFlowItem();
const QFileInfo& info(void) const;
const QString& comment(void) const;
const QImage& image(void) const;
int status(void) const;
qint64 key(void) const;
ImageFlowItem& operator=(const ImageFlowItem &item);
bool operator==(const ImageFlowItem &item) const;
bool operator!=(const ImageFlowItem &item) const;
public slots:
void setStatus(const int status);
void setInfo(const QFileInfo &info);
void setComment(const QString &comment);
void setImage(const QImage &image);
void setImage(const QString &filePath, int size);
private slots:
void loadImage(void);
private:
QImage resizeImage(const QImage &image, int size);
class Private;
Private *m;
};
///////////////////////////////////////////////////////
//////// the origin image viewer //////////////////////
///////////////////////////////////////////////////////
class FQTermCanvas;
class ExifExtractor;
class ItemDelegate : public QItemDelegate {
public:
ItemDelegate() {
size_ = QSize(250,200);
}
QSize sizeHint (const QStyleOptionViewItem & option, const QModelIndex & index) const {
//if (index.column() == 0) return QSize(1, 1);
return size_;
}
void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
static QSize size_;
};
class ExifTable : public QLabel {
Q_OBJECT;
public:
ExifTable(QWidget *parent);
signals:
void showExifDetails();
protected:
void mouseReleaseEvent(QMouseEvent *pEvent);
};
class ImageViewerDirModel : public QDirModel {
public:
ImageViewerDirModel(QObject *parent = 0);
int columnCount(const QModelIndex & = QModelIndex()) const;
QVariant headerData ( int section, Qt::Orientation orientation, int role) const;
QVariant data(const QModelIndex &index, int role) const;
};
class FQTermImageOrigin: public FQTermImage {
Q_OBJECT;
public:
FQTermImageOrigin(FQTermConfig * config, QWidget *parent, Qt::WindowFlags wflag);
~FQTermImageOrigin();
void scrollTo(const QString& filename);
void updateImage(const QString& filename);
public slots:
void onChange(const QModelIndex & index);
void next();
void previous();
void adjustItemSize();
void selectionChanged(const QItemSelection & selected, const QItemSelection & deselected);
void sortFileList(int index);
void showFullExifInfo();
void adjustLayout(bool withExifTable);
void updateExifInfo();
protected:
void closeEvent(QCloseEvent *clse);
private:
FQTermCanvas* canvas_;
QTreeView* tree_;
ImageViewerDirModel* model_;
QMenuBar* menuBar_;
QComboBox* comboBox_;
FQTermConfig* config_;
ExifExtractor* exifExtractor_;
ExifTable* exifTable_;
QGridLayout* layout_;
bool isExifTableShown_;
};
} // namespace FQTerm
#endif // IMAGE_VIERWER_H
|