From 532ea00ea6ec0e20898ef009e432ea1f55dc8db1 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Tue, 6 Sep 2022 01:13:42 -0400 Subject: Transitioning to using ListView to show images. The old widgets are not yet removed. A LOT of old sh*t needs rewriting for removing them. (Note to self) Other TODOs: - Convert all keyevents to qactions. - Convert main window to an actual main window. - Move file loading logic out of main.cpp (or not, doesn't even matter). - Move subsliced signatures into library. --- mingui/imageitem.hpp | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 mingui/imageitem.hpp (limited to 'mingui/imageitem.hpp') diff --git a/mingui/imageitem.hpp b/mingui/imageitem.hpp new file mode 100644 index 0000000..8c9397e --- /dev/null +++ b/mingui/imageitem.hpp @@ -0,0 +1,39 @@ +#ifndef IMAGEITEM_HPP +#define IMAGEITEM_HPP + +#include +#include +#include +#include + +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; +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); +Q_SIGNALS: + void sizeHintChanged(const QModelIndex &index); +}; + +#endif -- cgit v1.2.3