Warning, file /office/calligra/libs/text/InsertVariableAction.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 Thomas Zander <zander@kde.org> 0003 * Copyright (C) 2008 Thorsten Zachmann <zachmann@kde.org> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #include "InsertVariableAction_p.h" 0022 #include "KoVariable.h" 0023 #include "KoInlineObjectFactoryBase.h" 0024 #include "KoText.h" 0025 0026 #include <KoCanvasBase.h> 0027 #include <KoShapeController.h> 0028 #include <KoInlineTextObjectManager.h> 0029 0030 #include <kpagedialog.h> 0031 0032 #include <klocalizedstring.h> 0033 #include <QLayout> 0034 0035 InsertVariableAction::InsertVariableAction(KoCanvasBase *base, KoInlineObjectFactoryBase *factory, const KoInlineObjectTemplate &templ) 0036 : InsertInlineObjectActionBase(base, templ.name) 0037 , m_factory(factory) 0038 , m_templateId(templ.id) 0039 , m_properties(templ.properties) 0040 , m_templateName(templ.name) 0041 { 0042 } 0043 0044 KoInlineObject *InsertVariableAction::createInlineObject() 0045 { 0046 KoInlineObject *io = m_factory->createInlineObject(m_properties); 0047 KoVariable *variable = dynamic_cast<KoVariable*>(io); 0048 Q_ASSERT(variable); 0049 KoInlineTextObjectManager *objManager = m_canvas->shapeController()->resourceManager()->resource(KoText::InlineTextObjectManager).value<KoInlineTextObjectManager*>(); 0050 Q_ASSERT(objManager); 0051 variable->setManager(objManager); 0052 QWidget *widget = variable->createOptionsWidget(); 0053 if (widget) { 0054 if (widget->layout()) { 0055 widget->layout()->setMargin(0); 0056 } 0057 KPageDialog *dialog = new KPageDialog(m_canvas->canvasWidget()); 0058 dialog->setWindowTitle(i18n("%1 Options", m_templateName)); 0059 dialog->addPage(widget, QString()); 0060 if (dialog->exec() != KPageDialog::Accepted) { 0061 delete variable; 0062 variable = 0; 0063 } 0064 delete dialog; 0065 } 0066 return variable; 0067 }