digiKam
graphicsdimgview.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2010-04-30
7  * Description : Graphics View for DImg preview
8  *
9  * Copyright (C) 2010-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2011-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_GRAPHICS_DIMG_VIEW_H
26 #define DIGIKAM_GRAPHICS_DIMG_VIEW_H
27 
28 // Qt includes
29 
30 #include <QGraphicsView>
31 
32 // Local includes
33 
34 #include "digikam_export.h"
35 
36 namespace Digikam
37 {
38 
39 class GraphicsDImgItem;
40 class DImgPreviewItem;
41 class SinglePhotoPreviewLayout;
42 
43 class DIGIKAM_EXPORT GraphicsDImgView : public QGraphicsView
44 {
45  Q_OBJECT
46 
47 public:
48 
49  explicit GraphicsDImgView(QWidget* const parent = nullptr);
50  ~GraphicsDImgView() override;
51 
57  void setItem(GraphicsDImgItem* const item);
58 
62  GraphicsDImgItem* item() const;
63 
68  DImgPreviewItem* previewItem() const;
69 
70  SinglePhotoPreviewLayout* layout() const;
71 
78  void scrollPointOnPoint(const QPointF& scenePos, const QPoint& viewportPos);
79 
80  // Change from protected to public to be used by ImageRegionWidget and ImageRegionItem
81  void drawText(QPainter* p, const QRectF& rect, const QString& text);
82 
83  int contentsX() const;
84  int contentsY() const;
85  QRect visibleArea() const;
86  void setContentsPos(int x, int y);
87  void fitToWindow();
88  void toggleFullScreen(bool set);
89 
90 Q_SIGNALS:
91 
92  void contentsMoving(int, int);
96  void activated();
97  void toNextImage();
99  void contentsMoved(bool panningFinished);
100  void resized();
101 /*
102  void contentTakeFocus();
103 */
104  void viewportRectChanged(const QRectF& viewportRect);
105 
106 protected:
107 
108  void drawForeground(QPainter* painter, const QRectF& rect) override;
109 
110  void installPanIcon();
111 
112  void mouseDoubleClickEvent(QMouseEvent*) override;
113  void mousePressEvent(QMouseEvent*) override;
114  void mouseMoveEvent(QMouseEvent*) override;
115  void mouseReleaseEvent(QMouseEvent*) override;
116  void wheelEvent(QWheelEvent*) override;
117  void resizeEvent(QResizeEvent*) override;
118 
119  void startPanning(const QPoint& pos);
120  void continuePanning(const QPoint& pos);
121  void finishPanning();
122 
123  void setShowText(bool value);
124 
125  virtual bool acceptsMouseClick(QMouseEvent* e);
126  void scrollContentsBy(int dx, int dy) override;
127 
128 protected Q_SLOTS:
129 
130  void slotContentsMoved();
131  void slotCornerButtonPressed();
132  void slotPanIconHidden();
133 
134  virtual void slotPanIconSelectionMoved(const QRect&, bool);
135 
136 private:
137 
138  class Private;
139  Private* const d;
140 };
141 
142 } // namespace Digikam
143 
144 #endif // DIGIKAM_GRAPHICS_DIMG_VIEW_H
Definition: dimgitems_p.h:97
Definition: dimgitems_p.h:75
Definition: graphicsdimgview.h:44
void contentsMoving(int, int)
void viewportRectChanged(const QRectF &viewportRect)
void contentsMoved(bool panningFinished)
Definition: previewlayout.h:44
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: datefolderview.cpp:43