File indexing completed on 2024-04-28 16:21:24
0001 /* This file is part of the KDE project 0002 Copyright (C) 2004 Laurent Montel <montel@kde.org> 0003 0004 This library is free software; you can redistribute it and/or 0005 modify it under the terms of the GNU Library General Public 0006 License as published by the Free Software Foundation; either 0007 version 2 of the License, or (at your option) any later version. 0008 0009 This library is distributed in the hope that it will be useful, 0010 but WITHOUT ANY WARRANTY; without even the implied warranty of 0011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0012 Library General Public License for more details. 0013 0014 You should have received a copy of the GNU Library General Public License 0015 along with this library; see the file COPYING.LIB. If not, write to 0016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0017 Boston, MA 02110-1301, USA. 0018 */ 0019 0020 #ifndef KSPLOADINGINFO_H 0021 #define KSPLOADINGINFO_H 0022 0023 #include "calligra_sheets_limits.h" 0024 0025 #include <QMap> 0026 #include <QPoint> 0027 #include <QPointF> 0028 0029 namespace Calligra 0030 { 0031 namespace Sheets 0032 { 0033 class Sheet; 0034 0035 /// Temporary information used only during loading 0036 class LoadingInfo 0037 { 0038 public: 0039 enum FileFormat { 0040 OpenDocument, 0041 NativeFormat, 0042 Gnumeric, 0043 Unknown 0044 }; 0045 0046 LoadingInfo() 0047 : m_fileFormat(Unknown) 0048 , m_initialActiveSheet(0) 0049 , m_loadTemplate(false) {} 0050 ~LoadingInfo() {} 0051 0052 FileFormat fileFormat() const { 0053 return m_fileFormat; 0054 } 0055 void setFileFormat(FileFormat format) { 0056 m_fileFormat = format; 0057 } 0058 0059 Sheet* initialActiveSheet() const { 0060 return m_initialActiveSheet; 0061 } 0062 void setInitialActiveSheet(Sheet* sheet) { 0063 m_initialActiveSheet = sheet; 0064 } 0065 0066 /** 0067 * @return the cursor positions 0068 */ 0069 const QMap<Sheet*, QPoint>& cursorPositions() const { 0070 return m_cursorPositions; 0071 } 0072 0073 /** 0074 * Stores the cursor position @p point for @p sheet . 0075 */ 0076 void setCursorPosition(Sheet* sheet, const QPoint& point) { 0077 Q_ASSERT(1 <= point.x() && point.x() <= KS_colMax); 0078 Q_ASSERT(1 <= point.y() && point.y() <= KS_rowMax); 0079 m_cursorPositions.insert(sheet, point); 0080 } 0081 0082 /** 0083 * @return scrolling offsets 0084 */ 0085 const QMap<Sheet*, QPointF>& scrollingOffsets() const { 0086 return m_scrollingOffsets; 0087 } 0088 0089 /** 0090 * Stores the scrolling offset @p point for @p sheet . 0091 */ 0092 void setScrollingOffset(Sheet* sheet, const QPointF& point) { 0093 m_scrollingOffsets.insert(sheet, point); 0094 } 0095 0096 void setLoadTemplate(bool _b) { 0097 m_loadTemplate = _b; 0098 } 0099 bool loadTemplate() const { 0100 return m_loadTemplate; 0101 } 0102 0103 private: 0104 FileFormat m_fileFormat; 0105 Sheet* m_initialActiveSheet; 0106 QMap<Sheet*, QPoint> m_cursorPositions; 0107 QMap<Sheet*, QPointF> m_scrollingOffsets; 0108 bool m_loadTemplate; 0109 }; 0110 0111 } // namespace Sheets 0112 } // namespace Calligra 0113 0114 #endif /* KPRLOADINGINFO_H */ 0115