digiKam
previewlayout.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 : Layout for an item on image preview
8  *
9  * Copyright (C) 2010-2011 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  *
11  * This program is free software; you can redistribute it
12  * and/or modify it under the terms of the GNU General
13  * Public License as published by the Free Software Foundation;
14  * either version 2, or (at your option)
15  * any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * ============================================================ */
23 
24 #ifndef DIGIKAM_PREVIEW_LAYOUT_H
25 #define DIGIKAM_PREVIEW_LAYOUT_H
26 
27 // Qt includes
28 
29 #include <QFlags>
30 #include <QObject>
31 #include <QPointF>
32 
33 // Local includes
34 
35 #include "digikam_export.h"
36 
37 namespace Digikam
38 {
39 
40 class GraphicsDImgItem;
41 class GraphicsDImgView;
42 
43 class DIGIKAM_EXPORT SinglePhotoPreviewLayout : public QObject
44 {
45  Q_OBJECT
46 
47 public:
48 
50  {
51  JustSetFactor = 0,
52  CenterView = 1 << 0,
53  SnapZoomFactor = 1 << 1
54  };
55  Q_DECLARE_FLAGS(SetZoomFlags, SetZoomFlag)
56 
57 public:
58 
59  explicit SinglePhotoPreviewLayout(QObject* const parent);
60  ~SinglePhotoPreviewLayout() override;
61 
65  void setGraphicsView(GraphicsDImgView* const view);
66 
71  void addItem(GraphicsDImgItem* const item);
72 
73  bool isFitToWindow() const;
74  double zoomFactor() const;
75  double realZoomFactor() const;
76 
80  double maxZoomFactor() const;
81  double minZoomFactor() const;
82  void setMaxZoomFactor(double z);
83  void setMinZoomFactor(double z);
84  bool atMaxZoom() const;
85  bool atMinZoom() const;
86 
87 Q_SIGNALS:
88 
89  void fitToWindowToggled(bool fitToWindow);
90  void zoomFactorChanged(double);
91 
92 public Q_SLOTS:
93 
94  void increaseZoom(const QPoint& viewportAnchor = QPoint());
95  void decreaseZoom(const QPoint& viewportAnchor = QPoint());
96  void setZoomFactor(double z, const QPoint& viewportAnchor = QPoint(), SetZoomFlags flags = JustSetFactor);
97  void setZoomFactor(double z, SetZoomFlags flags);
98  void setZoomFactorSnapped(double z);
99  void fitToWindow();
100 
102  void toggleFitToWindow();
103 
105  void toggleFitToWindowOr100();
106 
108  void updateZoomAndSize();
109 
110 protected:
111 
112  void updateLayout();
113 
114 private:
115 
116  SinglePhotoPreviewLayout(); // Disable default constructor.
117 
118  class Private;
119  Private* const d;
120 };
121 
122 Q_DECLARE_OPERATORS_FOR_FLAGS(SinglePhotoPreviewLayout::SetZoomFlags)
123 
124 } // namespace Digikam
125 
126 #endif // DIGIKAM_PREVIEW_LAYOUT_H
Definition: dimgitems_p.h:75
Definition: graphicsdimgview.h:44
Definition: previewlayout.h:44
void fitToWindowToggled(bool fitToWindow)
SetZoomFlag
Definition: previewlayout.h:50
Definition: datefolderview.cpp:43