1 | /* This file is part of the KDE project |
2 | Copyright (C) 2004 Laurent Montel <montel@kde.org> |
3 | |
4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. |
8 | |
9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. |
13 | |
14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
17 | Boston, MA 02110-1301, USA. |
18 | */ |
19 | |
20 | #ifndef KSPLOADINGINFO_H |
21 | #define KSPLOADINGINFO_H |
22 | |
23 | #include "calligra_sheets_limits.h" |
24 | |
25 | #include <QMap> |
26 | #include <QPoint> |
27 | #include <QPointF> |
28 | |
29 | namespace Calligra |
30 | { |
31 | namespace Sheets |
32 | { |
33 | class Sheet; |
34 | |
35 | /// Temporary information used only during loading |
36 | class LoadingInfo |
37 | { |
38 | public: |
39 | enum FileFormat { |
40 | OpenDocument, |
41 | NativeFormat, |
42 | Gnumeric, |
43 | Unknown |
44 | }; |
45 | |
46 | LoadingInfo() |
47 | : m_fileFormat(Unknown) |
48 | , m_initialActiveSheet(0) |
49 | , m_loadTemplate(false) {} |
50 | ~LoadingInfo() {} |
51 | |
52 | FileFormat fileFormat() const { |
53 | return m_fileFormat; |
54 | } |
55 | void setFileFormat(FileFormat format) { |
56 | m_fileFormat = format; |
57 | } |
58 | |
59 | Sheet* initialActiveSheet() const { |
60 | return m_initialActiveSheet; |
61 | } |
62 | void setInitialActiveSheet(Sheet* sheet) { |
63 | m_initialActiveSheet = sheet; |
64 | } |
65 | |
66 | /** |
67 | * @return the cursor positions |
68 | */ |
69 | const QMap<Sheet*, QPoint>& cursorPositions() const { |
70 | return m_cursorPositions; |
71 | } |
72 | |
73 | /** |
74 | * Stores the cursor position @p point for @p sheet . |
75 | */ |
76 | void setCursorPosition(Sheet* sheet, const QPoint& point) { |
77 | Q_ASSERT(1 <= point.x() && point.x() <= KS_colMax); |
78 | Q_ASSERT(1 <= point.y() && point.y() <= KS_rowMax); |
79 | m_cursorPositions.insert(sheet, point); |
80 | } |
81 | |
82 | /** |
83 | * @return scrolling offsets |
84 | */ |
85 | const QMap<Sheet*, QPointF>& scrollingOffsets() const { |
86 | return m_scrollingOffsets; |
87 | } |
88 | |
89 | /** |
90 | * Stores the scrolling offset @p point for @p sheet . |
91 | */ |
92 | void setScrollingOffset(Sheet* sheet, const QPointF& point) { |
93 | m_scrollingOffsets.insert(sheet, point); |
94 | } |
95 | |
96 | void setLoadTemplate(bool _b) { |
97 | m_loadTemplate = _b; |
98 | } |
99 | bool loadTemplate() const { |
100 | return m_loadTemplate; |
101 | } |
102 | |
103 | private: |
104 | FileFormat m_fileFormat; |
105 | Sheet* m_initialActiveSheet; |
106 | QMap<Sheet*, QPoint> m_cursorPositions; |
107 | QMap<Sheet*, QPointF> m_scrollingOffsets; |
108 | bool m_loadTemplate; |
109 | }; |
110 | |
111 | } // namespace Sheets |
112 | } // namespace Calligra |
113 | |
114 | #endif /* KPRLOADINGINFO_H */ |
115 | |
116 | |