~ubuntu-branches/ubuntu/precise/gwenview/precise-proposed

« back to all changes in this revision

Viewing changes to lib/documentview/documentview.h

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2011-12-15 14:17:54 UTC
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20111215141754-z043hyx69dulbggf
Tags: upstream-4.7.90
Import upstream version 4.7.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// vim: set tabstop=4 shiftwidth=4 noexpandtab:
 
1
// vim: set tabstop=4 shiftwidth=4 expandtab:
2
2
/*
3
3
Gwenview: an image viewer
4
4
Copyright 2008 Aurélien Gâteau <agateau@kde.org>
24
24
#include <lib/gwenviewlib_export.h>
25
25
 
26
26
// Qt
27
 
#include <QWidget>
 
27
#include <QGraphicsWidget>
28
28
 
29
29
// KDE
30
30
#include <kactioncollection.h>
34
34
 
35
35
class KUrl;
36
36
 
37
 
namespace Gwenview {
 
37
namespace Gwenview
 
38
{
38
39
 
39
 
class AbstractDocumentViewAdapter;
 
40
class AbstractRasterImageViewTool;
 
41
class RasterImageView;
40
42
class SlideShow;
41
43
class ZoomWidget;
42
44
 
46
48
 * This widget can display various documents, using an instance of
47
49
 * AbstractDocumentViewAdapter
48
50
 */
49
 
class GWENVIEWLIB_EXPORT DocumentView : public QWidget {
50
 
        Q_OBJECT
51
 
        Q_PROPERTY(qreal zoom READ zoom WRITE setZoom NOTIFY zoomChanged)
52
 
        Q_PROPERTY(bool zoomToFit READ zoomToFit WRITE setZoomToFit NOTIFY zoomToFitChanged)
53
 
        Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
 
51
class GWENVIEWLIB_EXPORT DocumentView : public QGraphicsWidget
 
52
{
 
53
    Q_OBJECT
 
54
    Q_PROPERTY(qreal zoom READ zoom WRITE setZoom NOTIFY zoomChanged)
 
55
    Q_PROPERTY(bool zoomToFit READ zoomToFit WRITE setZoomToFit NOTIFY zoomToFitChanged)
 
56
    Q_PROPERTY(QPoint position READ position WRITE setPosition NOTIFY positionChanged)
54
57
public:
55
 
        enum {
56
 
                MaximumZoom = 16
57
 
        };
58
 
        DocumentView(QWidget* parent, KActionCollection*);
59
 
        ~DocumentView();
60
 
 
61
 
        AbstractDocumentViewAdapter* adapter() const;
62
 
 
63
 
        Document::Ptr document() const;
64
 
 
65
 
        KUrl url() const;
66
 
 
67
 
        void openUrl(const KUrl&);
68
 
 
69
 
        void reset();
70
 
 
71
 
        bool isEmpty() const;
72
 
 
73
 
        qreal minimumZoom() const;
74
 
 
75
 
        qreal zoom() const;
76
 
 
77
 
        bool isCurrent() const;
78
 
 
79
 
        void setCurrent(bool);
80
 
 
81
 
        void setCompareMode(bool);
82
 
 
83
 
        bool zoomToFit() const;
84
 
 
85
 
        QPoint position() const;
 
58
    enum {
 
59
        MaximumZoom = 16
 
60
    };
 
61
 
 
62
    /**
 
63
     * Create a new view attached to scene. We need the scene to be able to
 
64
     * install scene event filters.
 
65
     */
 
66
    DocumentView(QGraphicsScene* scene);
 
67
    ~DocumentView();
 
68
 
 
69
    Document::Ptr document() const;
 
70
 
 
71
    KUrl url() const;
 
72
 
 
73
    void openUrl(const KUrl&);
 
74
 
 
75
    /**
 
76
     * Tells the current adapter to load its config. Used when the user changed
 
77
     * the config while the view was visible.
 
78
     */
 
79
    void loadAdapterConfig();
 
80
 
 
81
    /**
 
82
     * Returns true if an adapter is loaded (note: adapters are also used to
 
83
     * display error messages!)
 
84
     */
 
85
    bool isEmpty() const;
 
86
 
 
87
    bool canZoom() const;
 
88
 
 
89
    qreal minimumZoom() const;
 
90
 
 
91
    qreal zoom() const;
 
92
 
 
93
    bool isCurrent() const;
 
94
 
 
95
    void setCurrent(bool);
 
96
 
 
97
    void setCompareMode(bool);
 
98
 
 
99
    bool zoomToFit() const;
 
100
 
 
101
    QPoint position() const;
 
102
 
 
103
    /**
 
104
     * Returns the RasterImageView of the current adapter, if it has one
 
105
     */
 
106
    RasterImageView* imageView() const;
 
107
 
 
108
    AbstractRasterImageViewTool* currentTool() const;
 
109
 
 
110
    void moveTo(const QRect&);
 
111
    void moveToAnimated(const QRect&);
 
112
    void fadeIn();
 
113
    void fadeOut();
 
114
 
 
115
    void setGeometry(const QRectF& rect); // reimp
86
116
 
87
117
public Q_SLOTS:
88
 
        void setZoom(qreal);
89
 
 
90
 
        void setZoomToFit(bool);
91
 
 
92
 
        void setPosition(const QPoint&);
 
118
    void setZoom(qreal);
 
119
 
 
120
    void setZoomToFit(bool);
 
121
 
 
122
    void setPosition(const QPoint&);
93
123
 
94
124
Q_SIGNALS:
95
 
        /**
96
 
         * Emitted when the part has finished loading
97
 
         */
98
 
        void completed();
99
 
 
100
 
        void previousImageRequested();
101
 
 
102
 
        void nextImageRequested();
103
 
 
104
 
        void captionUpdateRequested(const QString&);
105
 
 
106
 
        void toggleFullScreenRequested();
107
 
 
108
 
        void videoFinished();
109
 
 
110
 
        void minimumZoomChanged(qreal);
111
 
 
112
 
        void zoomChanged(qreal);
113
 
 
114
 
        void adapterChanged();
115
 
 
116
 
        void focused(DocumentView*);
117
 
 
118
 
        void zoomToFitChanged(bool);
119
 
 
120
 
        void positionChanged();
 
125
    /**
 
126
     * Emitted when the part has finished loading
 
127
     */
 
128
    void completed();
 
129
 
 
130
    void previousImageRequested();
 
131
 
 
132
    void nextImageRequested();
 
133
 
 
134
    void captionUpdateRequested(const QString&);
 
135
 
 
136
    void toggleFullScreenRequested();
 
137
 
 
138
    void videoFinished();
 
139
 
 
140
    void minimumZoomChanged(qreal);
 
141
 
 
142
    void zoomChanged(qreal);
 
143
 
 
144
    void adapterChanged();
 
145
 
 
146
    void focused(DocumentView*);
 
147
 
 
148
    void zoomToFitChanged(bool);
 
149
 
 
150
    void positionChanged();
 
151
 
 
152
    void hudTrashClicked(DocumentView*);
 
153
    void hudDeselectClicked(DocumentView*);
 
154
 
 
155
    void animationFinished(DocumentView*);
 
156
 
 
157
    void contextMenuRequested();
 
158
 
 
159
    void currentToolChanged(AbstractRasterImageViewTool*);
121
160
 
122
161
protected:
123
 
        virtual bool eventFilter(QObject*, QEvent* event);
 
162
    void paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget = 0);
124
163
 
125
 
        virtual void paintEvent(QPaintEvent*);
 
164
    void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
 
165
    void wheelEvent(QGraphicsSceneWheelEvent* event);
 
166
    void contextMenuEvent(QGraphicsSceneContextMenuEvent* event);
 
167
    bool sceneEventFilter(QGraphicsItem*, QEvent*);
126
168
 
127
169
private Q_SLOTS:
128
 
        void finishOpenUrl();
129
 
        void slotLoaded();
130
 
        void slotLoadingFailed();
131
 
 
132
 
        void zoomActualSize();
133
 
 
134
 
        void zoomIn(const QPoint& center = QPoint(-1,-1));
135
 
        void zoomOut(const QPoint& center = QPoint(-1,-1));
136
 
 
137
 
        void slotZoomChanged(qreal);
138
 
 
139
 
        void slotBusyChanged(const KUrl&, bool);
140
 
 
141
 
        void slotKeyPressed(Qt::Key key, bool pressed);
 
170
    void finishOpenUrl();
 
171
    void slotLoaded();
 
172
    void slotLoadingFailed();
 
173
 
 
174
    void zoomActualSize();
 
175
 
 
176
    void zoomIn(const QPointF& center = QPointF(-1, -1));
 
177
    void zoomOut(const QPointF& center = QPointF(-1, -1));
 
178
 
 
179
    void slotZoomChanged(qreal);
 
180
 
 
181
    void slotBusyChanged(const KUrl&, bool);
 
182
 
 
183
    void emitHudTrashClicked();
 
184
    void emitHudDeselectClicked();
 
185
    void emitFocused();
 
186
 
 
187
    void slotAnimationFinished();
142
188
 
143
189
private:
144
 
        friend struct DocumentViewPrivate;
145
 
        DocumentViewPrivate* const d;
 
190
    friend struct DocumentViewPrivate;
 
191
    DocumentViewPrivate* const d;
146
192
 
147
 
        void createAdapterForDocument();
 
193
    void createAdapterForDocument();
148
194
};
149
195
 
150
 
 
151
196
} // namespace
152
197
 
153
198
#endif /* DOCUMENTVIEW_H */