refactoring qad widgets part 1

c++ cast, nullptr, forward declaration, agregate ui, connect to member functions, order and clear includes
This commit is contained in:
2022-12-11 16:27:04 +03:00
parent 5d9381dd37
commit 728c132f2b
22 changed files with 561 additions and 404 deletions

View File

@@ -20,9 +20,11 @@
#ifndef IMAGE_VIEW_H
#define IMAGE_VIEW_H
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include "qad_widgets_export.h"
#include <QGraphicsView>
class QGraphicsPixmapItem;
class QAD_WIDGETS_EXPORT ImageView: public QGraphicsView
@@ -31,31 +33,16 @@ class QAD_WIDGETS_EXPORT ImageView: public QGraphicsView
Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap)
Q_PROPERTY(bool viewInteractive READ viewInteractive WRITE setViewInteractive)
public:
ImageView(QWidget * parent = 0);
~ImageView();
ImageView(QWidget * parent = nullptr);
~ImageView() override;
void setImage(const QImage & i, bool save = true);
void setImage(const QByteArray & i);
QByteArray image() const {return im_data;}
QPixmap pixmap() const;
bool viewInteractive() const {return interactive_;}
void clear();
private:
void mouseDoubleClickEvent(QMouseEvent * e);
void mousePressEvent(QMouseEvent * e);
void wheelEvent(QWheelEvent * e);
bool eventFilter(QObject * o, QEvent * e);
void adjustView();
QGraphicsPixmapItem item;
QByteArray im_data;
QPoint prev_pos;
bool autofit_, interactive_;
QPixmap map;
public slots:
void autofit();
void setPixmap(QPixmap pixmap);
@@ -64,6 +51,18 @@ public slots:
signals:
void clicked(QPointF, Qt::MouseButtons);
private:
void mouseDoubleClickEvent(QMouseEvent * e) override;
void mousePressEvent(QMouseEvent * e) override;
void wheelEvent(QWheelEvent * e) override;
bool eventFilter(QObject * o, QEvent * e) override;
void adjustView();
QGraphicsPixmapItem * item;
QByteArray im_data;
QPoint prev_pos;
bool autofit_, interactive_;
QPixmap map;
};
#endif // IMAGE_VIEW_H