Warning, file /office/calligra/braindump/src/SectionsIO.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 * Copyright (c) 2009 Cyrille Berger <cberger@cberger.net> 0003 * 0004 * This library is free software; you can redistribute it and/or 0005 * modify it under the terms of the GNU Lesser General Public 0006 * License as published by the Free Software Foundation; 0007 * either version 2, or (at your option) any later version of the License. 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 * Lesser General Public License for more details. 0013 * 0014 * You should have received a copy of the GNU Lesser General Public License 0015 * along with this library; see the file COPYING. 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 _SECTIONSIO_H_ 0021 #define _SECTIONSIO_H_ 0022 0023 #include <QObject> 0024 #include <QMap> 0025 0026 class QDomDocument; 0027 class QDomElement; 0028 class QTimer; 0029 class RootSection; 0030 class Section; 0031 class SectionGroup; 0032 0033 class SectionsIO : public QObject 0034 { 0035 Q_OBJECT 0036 public: 0037 explicit SectionsIO(RootSection* rootSection); 0038 ~SectionsIO(); 0039 public: 0040 enum PushMode { 0041 SinglePush, 0042 RecursivePush 0043 }; 0044 /** 0045 * push a section to save 0046 */ 0047 void push(Section* _section, PushMode _pushMode = SinglePush); 0048 public Q_SLOTS: 0049 void save(); 0050 private: 0051 void load(); 0052 private: 0053 RootSection* m_rootSection; 0054 QTimer* m_timer; 0055 struct SaveContext; 0056 QMap<Section*, SaveContext*> m_contextes; 0057 QString m_directory; ///< directory where the sections are saved 0058 private: 0059 /** 0060 * Save the structure and update the m_contextes map 0061 * @param contextToRemove contains a list of used context, that need to be removed 0062 * from that list, otherwise doSave will remove the 0063 * associated files 0064 */ 0065 void saveTheStructure(QDomDocument& doc, QDomElement& elt, SectionGroup* root, QList<SaveContext*>& contextToRemove); 0066 void loadTheStructure(QDomElement& elt, SectionGroup* root, RootSection* _rootSection); 0067 QString generateFileName(); 0068 bool usedFileName(const QString&); 0069 QString structureFileName(); 0070 int m_nextNumber; 0071 QList<Section* > m_sectionsToSave; 0072 }; 0073 0074 #endif