-
Notifications
You must be signed in to change notification settings - Fork 0
/
ThumbnailView.hpp
60 lines (47 loc) · 1.34 KB
/
ThumbnailView.hpp
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
#ifndef THUMBNAILVIEW_HPP
#define THUMBNAILVIEW_HPP
#include <QListView>
#include <QtConcurrent/QtConcurrentRun>
#include <cstddef>
#include <iostream>
#include "Archive.hpp"
class ThumbnailModel : public QAbstractListModel {
Q_OBJECT
public:
ThumbnailModel(QList<QString> pathNameList, QWidget *parent = Q_NULLPTR) : QAbstractListModel(parent), pathNameList_(pathNameList) {
}
int rowCount(const QModelIndex &parent = QModelIndex()) const {
(void)parent;
return pathNameList_.size();
}
QVariant data(const QModelIndex &index , int role = Qt::DisplayRole) const;
void addImage(int index, QImage img);
virtual ~ThumbnailModel() {
std::cerr << "ThumbnailModel Destructor!!" << std::endl;
}
private:
QList<QString> pathNameList_;
QMap<int, QImage> imgMap_;
};
class ThumbnailView : public QListView {
Q_OBJECT
public:
ThumbnailView(QWidget *parent = Q_NULLPTR);
virtual ~ThumbnailView();
bool open(const QString &arcName);
virtual bool event(QEvent* event);
void setOffsetY(int y);
void clear();
private:
void run(Archive* archive, QList<QString> pathNameList);
QAtomicInteger<bool> thread_;
QAtomicInteger<bool> show_;
QFuture<void> future_;
Archive archive_;
QList<QString> pathNameList_;
private slots:
void addImage(int index, QImage img);
signals:
void loadedImg(int index, QImage img);
};
#endif