diff options
author | Chris Xiong <chirs241097@gmail.com> | 2022-09-18 11:08:01 -0400 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2022-09-18 11:08:01 -0400 |
commit | 4b8d314f575d9e893d8dda7431194f8b470fc888 (patch) | |
tree | 4d42ebc06d2522c9141c42ff91be214e521e5fcb /qdeduper/imageitem.hpp | |
parent | 0570b0f172631ba8f3c6180d2c850635c3cd6037 (diff) | |
download | deduper-4b8d314f575d9e893d8dda7431194f8b470fc888.tar.xz |
First step to adopt mingui as part of the project -- break it!
Diffstat (limited to 'qdeduper/imageitem.hpp')
-rw-r--r-- | qdeduper/imageitem.hpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/qdeduper/imageitem.hpp b/qdeduper/imageitem.hpp new file mode 100644 index 0000000..43fb0c8 --- /dev/null +++ b/qdeduper/imageitem.hpp @@ -0,0 +1,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 |