1 /*
2  * This file is part of the KDE project
3  * Copyright (C) 2013 Arjen Hiemstra <ahiemstra@heimr.nl>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef VIEWMODESWITCHEVENT_H
21 #define VIEWMODESWITCHEVENT_H
22 
23 #include <QEvent>
24 #include <QPointF>
25 #include <KoZoomMode.h>
26 
27 class KoShape;
28 class KoGridData;
29 struct ViewModeSynchronisationObject {
ViewModeSynchronisationObjectViewModeSynchronisationObject30     ViewModeSynchronisationObject()
31         : initialized(false)
32         , currentIndex(-1)
33         , scrollBarValue(QPoint())
34         , zoomLevel(0)
35         , gridData(0)
36         { }
37 
38     bool initialized;
39 
40     int currentIndex;
41     QPoint scrollBarValue;
42     float zoomLevel;
43 
44     QString activeToolId;
45 
46     KoGridData* gridData;
47     QList< KoShape* > shapes;
48 };
49 
50 class ViewModeSwitchEvent : public QEvent
51 {
52 public:
53     enum ViewModeEventType {
54         AboutToSwitchViewModeEvent = QEvent::User + 1,
55         SwitchedToDesktopModeEvent,
56         SwitchedToTouchModeEvent,
57     };
58 
ViewModeSwitchEvent(ViewModeEventType type,QObject * fromView,QObject * toView,ViewModeSynchronisationObject * syncObject)59     inline ViewModeSwitchEvent(ViewModeEventType type, QObject* fromView, QObject* toView, ViewModeSynchronisationObject* syncObject)
60             : QEvent(static_cast<QEvent::Type>(type))
61             , m_fromView(fromView)
62             , m_toView(toView)
63             , m_syncObject(syncObject) {
64 
65     }
66 
fromView()67     inline QObject* fromView() const {
68         return m_fromView;
69     }
toView()70     inline QObject* toView() const {
71         return m_toView;
72     }
73 
synchronisationObject()74     inline ViewModeSynchronisationObject* synchronisationObject() const {
75         return m_syncObject;
76     }
77 
78 private:
79     QObject* m_fromView;
80     QObject* m_toView;
81     ViewModeSynchronisationObject* m_syncObject;
82 };
83 
84 #endif // VIEWMODESWITCHEVENT_H
85