Warning, file /office/calligra/braindump/src/RootSection.cpp 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 #include "RootSection.h" 0021 0022 #include <QDebug> 0023 0024 #include <kundo2stack.h> 0025 0026 #include "Section.h" 0027 #include "SectionsIO.h" 0028 0029 #include "ViewManager.h" 0030 0031 RootSection::RootSection() : SectionGroup(0), m_undoStack(new KUndo2Stack(this)), m_viewManager(new ViewManager(this)), m_sectionsSaver(new SectionsIO(this)), m_currentSection(0) 0032 { 0033 connect(m_undoStack, SIGNAL(indexChanged(int)), SIGNAL(commandExecuted())); 0034 connect(m_undoStack, SIGNAL(indexChanged(int)), SLOT(undoIndexChanged(int))); 0035 if(sections().isEmpty()) { 0036 newSection(0); 0037 } 0038 } 0039 0040 RootSection::~RootSection() 0041 { 0042 } 0043 0044 ViewManager* RootSection::viewManager() 0045 { 0046 return m_viewManager; 0047 } 0048 0049 SectionsIO* RootSection::sectionsIO() 0050 { 0051 return m_sectionsSaver; 0052 } 0053 0054 void RootSection::addCommand(Section* _section, KUndo2Command* _command) 0055 { 0056 qDebug() << _command << " is added for section " << _section; 0057 m_commandsMap[_command] = _section; 0058 m_undoStack->push(_command); 0059 } 0060 0061 void RootSection::createActions(KActionCollection* _actionCollection) 0062 { 0063 m_undoStack->createUndoAction(_actionCollection); 0064 m_undoStack->createRedoAction(_actionCollection); 0065 } 0066 0067 KUndo2Stack* RootSection::undoStack() 0068 { 0069 return m_undoStack; 0070 } 0071 0072 void RootSection::undoIndexChanged(int idx) 0073 { 0074 const KUndo2Command* command = m_undoStack->command(idx - 1); 0075 qDebug() << idx << " " << command << " " << m_undoStack->count() << " " << m_undoStack->cleanIndex() << " " << m_undoStack->index(); 0076 Section* section = m_commandsMap[command]; 0077 if(!section && idx == m_undoStack->count()) { 0078 section = m_currentSection; 0079 m_commandsMap[command] = section; 0080 } 0081 m_sectionsSaver->push(section); 0082 qDebug() << "save section: " << section; 0083 } 0084 0085 void RootSection::setCurrentSection(Section* _section) 0086 { 0087 m_currentSection = _section; 0088 }