Warning, file /office/calligra/braindump/src/SectionPropertiesDock.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 "SectionPropertiesDock.h" 0021 #include "LayoutFactoryRegistry.h" 0022 #include "Section.h" 0023 #include "Layout.h" 0024 #include "commands/ChangeLayoutCommand.h" 0025 #include "RootSection.h" 0026 0027 SectionPropertiesDock::SectionPropertiesDock() : 0028 m_currentSection(0), m_rootSection(0) 0029 { 0030 QWidget* mainWidget = new QWidget(this); 0031 setWidget(mainWidget); 0032 setWindowTitle(i18n("Dump properties")); 0033 0034 m_wdgSectionProperties.setupUi(mainWidget); 0035 0036 typedef QPair<QString, QString> PairType; 0037 foreach(const PairType & pair, LayoutFactoryRegistry::instance()->factories()) { 0038 m_wdgSectionProperties.comboBoxLayout->addItem(pair.second, pair.first); 0039 } 0040 connect(m_wdgSectionProperties.comboBoxLayout, SIGNAL(currentIndexChanged(int)), SLOT(layoutChanged(int))); 0041 } 0042 0043 SectionPropertiesDock::~SectionPropertiesDock() 0044 { 0045 } 0046 0047 void SectionPropertiesDock::setRootSection(RootSection* _rootSection) 0048 { 0049 Q_ASSERT(m_rootSection == 0); 0050 m_rootSection = _rootSection; 0051 connect(m_rootSection, SIGNAL(commandExecuted()), SLOT(reload())); 0052 } 0053 0054 void SectionPropertiesDock::setSection(Section* _section) 0055 { 0056 m_currentSection = _section; 0057 m_wdgSectionProperties.comboBoxLayout->setEnabled(m_currentSection); 0058 reload(); 0059 } 0060 0061 void SectionPropertiesDock::reload() 0062 { 0063 if(m_currentSection) { 0064 for(int i = 0; i < m_wdgSectionProperties.comboBoxLayout->count(); ++i) { 0065 if(m_wdgSectionProperties.comboBoxLayout->itemData(i) == m_currentSection->layout()->id()) { 0066 bool v = m_wdgSectionProperties.comboBoxLayout->blockSignals(true); 0067 m_wdgSectionProperties.comboBoxLayout->setCurrentIndex(i); 0068 m_wdgSectionProperties.comboBoxLayout->blockSignals(v); 0069 break; 0070 } 0071 } 0072 } 0073 } 0074 0075 void SectionPropertiesDock::layoutChanged(int index) 0076 { 0077 Q_ASSERT(m_currentSection); 0078 Q_ASSERT(m_rootSection); 0079 0080 m_rootSection->addCommand(m_currentSection, 0081 new ChangeLayoutCommand(m_currentSection, 0082 m_wdgSectionProperties.comboBoxLayout->itemData(index).toString())); 0083 }