aboutsummaryrefslogtreecommitdiff
path: root/qdeduper/imageitem.hpp
blob: 43fb0c892d402ba049d41437e863fcd3cd834ef0 (plain) (blame)
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
#ifndef IMAGEITEM_HPP
#define IMAGEITEM_HPP

#include <QStandardItem>
#include <QAbstractItemDelegate>
#include <QStyleOptionViewItem>
#include <QModelIndex>

class ImageItem : public QStandardItem
{
public:
    enum ImageItemRoles
    {
        path_role = Qt::ItemDataRole::UserRole + 0x1000,
        dimension_role,
        file_size_role,
        hotkey_role
    };
    ImageItem(QString fn, QString dispn, QKeySequence hotkey, double pxratio = 1.0);
};

class ImageItemDelegate : public QAbstractItemDelegate
{
    Q_OBJECT
private:
    const static int MARGIN = 3;
    const static int BORDER = 3;
    const static int HKPADD = 4;
    const static int LINESP = 4;
    const static int HKSHDS = 2;
    int vw = -1;
    int hh = -1;
public:
    void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void resize(const QModelIndex &index);
    void setScrollbarMargins(int vw, int hh);
Q_SIGNALS:
    void sizeHintChanged(const QModelIndex &index);
};

#endif