Warning, file /office/calligra/libs/rdf/InsertSemanticObjectReferenceAction.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 "InsertSemanticObjectReferenceAction.h" 0021 0022 #include "KoDocumentRdf.h" 0023 0024 #include <KoCanvasBase.h> 0025 #include <KoToolProxy.h> 0026 #include <KoTextEditor.h> 0027 #include "KoRdfSemanticTreeWidgetItem.h" 0028 0029 #include <kdebug.h> 0030 #include <klocalizedstring.h> 0031 #include <kpagedialog.h> 0032 0033 #include <QVBoxLayout> 0034 #include <QLabel> 0035 0036 InsertSemanticObjectReferenceAction::InsertSemanticObjectReferenceAction( 0037 KoCanvasBase *canvas, 0038 KoDocumentRdf *rdf, 0039 const QString &name) 0040 : InsertSemanticObjectActionBase(canvas, rdf, name) 0041 { 0042 } 0043 0044 InsertSemanticObjectReferenceAction::~InsertSemanticObjectReferenceAction() 0045 { 0046 } 0047 0048 void InsertSemanticObjectReferenceAction::activated() 0049 { 0050 kDebug(30015) << "create semantic item reference..."; 0051 QWidget *widget = new QWidget(); 0052 QVBoxLayout *lay = new QVBoxLayout(widget); 0053 widget->setLayout(lay); 0054 lay->setMargin(0); 0055 0056 QLabel *label = new QLabel(i18n("Select the object you want to reference"), widget); 0057 lay->addWidget(label); 0058 QTreeWidget *tree = new QTreeWidget(widget); 0059 KoRdfSemanticTree td = KoRdfSemanticTree::createTree(tree); 0060 td.update(const_cast<KoDocumentRdf*>(m_rdf)); 0061 lay->addWidget(tree); 0062 0063 KPageDialog dialog(m_canvas->canvasWidget()); 0064 dialog.setWindowTitle(i18n("%1 Options", text())); // TODO add comment (i18nc) 0065 dialog.addPage(widget, QString()); 0066 0067 if (dialog.exec() == KPageDialog::Accepted && tree->currentItem()) { 0068 QTreeWidgetItem *item = tree->currentItem(); 0069 if (KoRdfSemanticTreeWidgetItem *ditem = dynamic_cast<KoRdfSemanticTreeWidgetItem*>(item)) { 0070 kDebug(30015) << "InsertSemanticObjectReferenceAction::activated... item:" << item; 0071 ditem->insert(m_canvas); 0072 } 0073 } 0074 }