libs/flake
KoConnectionShapeConfigWidget.cpp
Go to the documentation of this file.00001 /* This file is part of the KDE project 00002 * Copyright (C) 2007 Jan Hambrecht <jaham@gmx.net> 00003 * 00004 * This library is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU Library General Public 00006 * License as published by the Free Software Foundation; either 00007 * version 2 of the License, or (at your option) any later version. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #include "KoConnectionShapeConfigWidget.h" 00021 #include "commands/KoConnectionShapeTypeCommand.h" 00022 #include <klocale.h> 00023 00024 KoConnectionShapeConfigWidget::KoConnectionShapeConfigWidget() 00025 { 00026 widget.setupUi(this); 00027 00028 widget.connectionType->clear(); 00029 widget.connectionType->addItem(i18n("Standard")); 00030 widget.connectionType->addItem(i18n("Lines")); 00031 widget.connectionType->addItem(i18n("Straight")); 00032 widget.connectionType->addItem(i18n("Curve")); 00033 00034 connect(widget.connectionType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(propertyChanged())); 00035 } 00036 00037 void KoConnectionShapeConfigWidget::open(KoShape *shape) 00038 { 00039 m_connection = dynamic_cast<KoConnectionShape*>(shape); 00040 if (! m_connection) 00041 return; 00042 00043 widget.connectionType->blockSignals(true); 00044 00045 widget.connectionType->setCurrentIndex(m_connection->connectionType()); 00046 00047 widget.connectionType->blockSignals(false); 00048 } 00049 00050 void KoConnectionShapeConfigWidget::save() 00051 { 00052 if (! m_connection) 00053 return; 00054 00055 m_connection->setConnectionType(static_cast<KoConnectionShape::Type>(widget.connectionType->currentIndex())); 00056 } 00057 00058 QUndoCommand * KoConnectionShapeConfigWidget::createCommand() 00059 { 00060 if (! m_connection) 00061 return 0; 00062 else { 00063 KoConnectionShape::Type type = static_cast<KoConnectionShape::Type>(widget.connectionType->currentIndex()); 00064 return new KoConnectionShapeTypeCommand(m_connection, type); 00065 } 00066 } 00067 00068 #include "KoConnectionShapeConfigWidget.moc"
