Warning, file /office/calligra/libs/rdf/InsertSemanticObjectCreateAction.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) 2010 KO GmbH <ben.martin@kogmbh.com>
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 "InsertSemanticObjectCreateAction.h"
0021 #include "KoDocumentRdf.h"
0022 
0023 #include "KoCanvasBase.h"
0024 #include "KoToolProxy.h"
0025 #include "KoTextEditor.h"
0026 
0027 #include <kdebug.h>
0028 #include <klocalizedstring.h>
0029 #include <kpagedialog.h>
0030 
0031 #include <QVBoxLayout>
0032 
0033 InsertSemanticObjectCreateAction::InsertSemanticObjectCreateAction(
0034     KoCanvasBase *canvas,
0035     KoDocumentRdf *rdf,
0036     const QString &name)
0037         : InsertSemanticObjectActionBase(canvas, rdf, name),
0038         m_semanticClass(name)
0039 {
0040 }
0041 
0042 InsertSemanticObjectCreateAction::~InsertSemanticObjectCreateAction()
0043 {
0044 }
0045 
0046 void InsertSemanticObjectCreateAction::activated()
0047 {
0048     kDebug(30015) << "create semantic action...";
0049     QWidget *widget = new QWidget();
0050     QVBoxLayout *lay = new QVBoxLayout(widget);
0051     widget->setLayout(lay);
0052     lay->setMargin(0);
0053     kDebug(30015) << "semanticClass:" << m_semanticClass;
0054     hKoRdfSemanticItem semItem(static_cast<KoRdfSemanticItem *>(
0055     m_rdf->createSemanticItem(m_semanticClass, m_rdf).data()));
0056     QWidget *w = semItem->createEditor(widget);
0057     lay->addWidget(w);
0058     KPageDialog dialog(m_canvas->canvasWidget());
0059     dialog.setWindowTitle(i18n("%1 Options", text().remove('&'))); // TODO add comment using i18nc
0060     dialog.addPage(widget, QString());
0061     if (dialog.exec() == KPageDialog::Accepted) {
0062         kDebug(30015) << "activated...";
0063         semItem->updateFromEditorData();
0064         semItem->insert(m_canvas);
0065     }
0066 }