Warning, file /office/calligra/libs/flake/KoConnectionShapeConfigWidget.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net> 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 #include "KoConnectionShapeConfigWidget.h" 0021 #include "commands/KoConnectionShapeTypeCommand.h" 0022 #include <KoIcon.h> 0023 #include <klocalizedstring.h> 0024 0025 KoConnectionShapeConfigWidget::KoConnectionShapeConfigWidget() 0026 { 0027 widget.setupUi(this); 0028 0029 widget.connectionType->clear(); 0030 widget.connectionType->addItem(koIcon("standard-connector"), i18n("Standard")); 0031 widget.connectionType->addItem(koIcon("lines-connector"), i18n("Lines")); 0032 widget.connectionType->addItem(koIcon("straight-connector"), i18n("Straight")); 0033 widget.connectionType->addItem(koIcon("curve-connector"), i18n("Curve")); 0034 0035 connect(widget.connectionType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(propertyChanged())); 0036 connect(widget.connectionType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(connectionTypeChanged(int))); 0037 } 0038 0039 void KoConnectionShapeConfigWidget::setConnectionType(int type) 0040 { 0041 widget.connectionType->blockSignals(true); 0042 widget.connectionType->setCurrentIndex(type); 0043 widget.connectionType->blockSignals(false); 0044 } 0045 0046 void KoConnectionShapeConfigWidget::open(KoShape *shape) 0047 { 0048 m_connection = dynamic_cast<KoConnectionShape*>(shape); 0049 if (! m_connection) 0050 return; 0051 0052 widget.connectionType->blockSignals(true); 0053 widget.connectionType->setCurrentIndex(m_connection->type()); 0054 widget.connectionType->blockSignals(false); 0055 } 0056 0057 void KoConnectionShapeConfigWidget::save() 0058 { 0059 if (!m_connection) { 0060 return; 0061 } 0062 m_connection->setType(static_cast<KoConnectionShape::Type>(widget.connectionType->currentIndex())); 0063 } 0064 0065 KUndo2Command * KoConnectionShapeConfigWidget::createCommand() 0066 { 0067 if (!m_connection) { 0068 return 0; 0069 } else { 0070 KoConnectionShape::Type type = static_cast<KoConnectionShape::Type>(widget.connectionType->currentIndex()); 0071 return new KoConnectionShapeTypeCommand(m_connection, type); 0072 } 0073 }