-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.h
51 lines (43 loc) · 1.23 KB
/
view.h
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
#ifndef VIEW_H
#define VIEW_H
#include "loader.h"
#include "delegate.h"
#include <QListView>
#include <QStandardItemModel>
#include <QTimer>
#include <QMouseEvent>
class View : public QListView
{
Q_OBJECT
public:
View(QWidget *parent = nullptr);
~View() = default;
void loadFile(const QString &f);
void setCurrentFile(int i);
private:
Loader *loader = nullptr;
Delegate *delegate = nullptr;
QStandardItemModel * itemModel = nullptr;
QTimer *resizeTimer;
QTimer *unloadTimer;
QTimer *scrollTimer;
int toScroll = 0;
QList<QModelIndex> loadedIndexes;
int currentScroll = 0;
int maxScroll = 0;
void onFileListLoaded(const QStringList &fileList);
void onItemLoaded(QStandardItem *item);
void resizeTimeout();
void unloadTimeout();
void setItemPixmap(const QModelIndex &index, const QPixmap &pix);
void scrolled(int value);
signals:
void fileLoaded(const QString &file);
void fileListLoaded(const QStringList &fileList);
void currentFileChanged(const QString ¤tFile);
protected:
void mousePressEvent(QMouseEvent *e) override;
void mouseReleaseEvent(QMouseEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
};
#endif // VIEW_H