Commit 8e6d913f authored by Boudewijn Rempt's avatar Boudewijn Rempt

Split out the rdf code into its own library

parent 42f48a1a
......@@ -540,9 +540,12 @@ set(KOMAIN_INCLUDES ${KDE4_INCLUDES}
${MARBLE_INCLUDE_DIR}
${CMAKE_SOURCE_DIR}/libs/widgets
${CMAKE_SOURCE_DIR}/libs/main
${CMAKE_SOURCE_DIR}/libs/main/rdf
${CMAKE_SOURCE_DIR}/libs/main/config)
set(KORDF_INCLUDES ${KOMAIN_INCLUDES}
${CMAKE_SOURCE_DIR}/libs/rdf
)
if(SHOULD_BUILD_SCRIPTING)
set(KOKROSS_INCLUDES ${CMAKE_SOURCE_DIR}/libs/kokross ${CMAKE_BINARY_DIR}/libs/kokross)
endif(SHOULD_BUILD_SCRIPTING)
......
......@@ -298,6 +298,11 @@ bool KisDoc2::completeSaving(KoStore *store)
return true;
}
int KisDoc2::supportedSpecialFormats() const
{
return 0; // we don't support encryption.
}
bool KisDoc2::completeLoading(KoStore *store)
{
......
......@@ -70,6 +70,7 @@ public:
public:
virtual bool completeLoading(KoStore *store);
virtual bool completeSaving(KoStore*);
virtual int supportedSpecialFormats() const;
/// Unused
virtual bool loadOdf(KoOdfReadStore & odfStore);
......
......@@ -31,3 +31,8 @@ endif (SHOULD_BUILD_CALLIGRADB)
if (SHOULD_BUILD_KOREPORT)
add_subdirectory( koreport )
endif (SHOULD_BUILD_KOREPORT)
if (Soprano_FOUND)
add_subdirectory( rdf )
endif (Soprano_FOUND)
......@@ -37,6 +37,10 @@ class KoStore;
class KoXmlWriter;
class KoDocument;
///**
// * Dummy definition in case Soprano is not available.
// */
namespace Soprano
{
class Model;
......
......@@ -90,11 +90,7 @@
#include <kdebug.h>
#include "KoTextDebug.h"
#ifdef SHOULD_BUILD_RDF
#include <rdf/KoDocumentRdf.h>
#else
#include "KoTextSopranoRdfModel_p.h"
#endif
#include <KoDocumentRdfBase.h>
Q_DECLARE_METATYPE(QTextFrame*)
......
......@@ -28,7 +28,6 @@
#include <KoTextDocument.h>
#include <opendocument/KoTextSharedSavingData.h>
#include "KoTextSopranoRdfModel_p.h"
#include <QTextDocument>
......
......@@ -33,6 +33,7 @@
#include <kdebug.h>
#ifdef SHOULD_BUILD_RDF
#include "KoTextRdfCore.h"
#include <Soprano/Soprano>
#endif
class KoTextPaste::Private
......
/* This file is part of the KDE project
Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef KO_TEXT_SOPRANO_RDF_MODEL_H
#define KO_TEXT_SOPRANO_RDF_MODEL_H
/**
* Dummy definition in case Soprano is not available.
*/
#ifdef SHOULD_BUILD_RDF
#include <Soprano/Soprano>
#else
namespace Soprano
{
class Model
{
};
}
#endif
#endif
......@@ -39,9 +39,14 @@
#include "KoDocumentRdfBase.h"
#ifdef SHOULD_BUILD_RDF
#include <rdf/KoDocumentRdf.h>
#include <Soprano/Soprano>
#else
#include "KoTextSopranoRdfModel_p.h"
namespace Soprano
{
class Model
{
};
}
#endif
TextPasteCommand::TextPasteCommand(const QMimeData *mimeData,
......
......@@ -20,7 +20,7 @@ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
#include "KoTextSharedSavingData.h"
#include "KoGenChanges.h"
#include "KoTextSopranoRdfModel_p.h"
#include "KoDocumentRdfBase.h"
#include <QMap>
......
......@@ -85,8 +85,6 @@ set(komain_LIB_SRCS
KoTemplatesPane.cpp
KoTemplateTree.cpp
rdf/KoDocumentRdfEditWidgetBase.cpp
KoFindBase.cpp
KoFindMatch.cpp
KoFindText.cpp
......@@ -108,35 +106,6 @@ if( QT_QTDBUS_FOUND )
)
endif( QT_QTDBUS_FOUND )
if( Soprano_FOUND )
set(komain_LIB_SRCS ${komain_LIB_SRCS}
rdf/KoDocumentRdf.cpp
rdf/KoDocumentRdfEditWidget.cpp
rdf/KoSopranoTableModelDelegate.cpp
rdf/KoSopranoTableModel.cpp
rdf/KoRdfPrefixMapping.cpp
rdf/KoSemanticStylesheet.cpp
rdf/KoRdfSemanticItem.cpp
rdf/KoRdfFoaF.cpp
rdf/KoRdfCalendarEvent.cpp
rdf/KoRdfLocationEditWidget.cpp
rdf/KoRdfLocation.cpp
rdf/KoRdfSemanticItemViewSite.cpp
rdf/KoRdfSemanticTree.cpp
rdf/KoRdfSemanticTreeWidgetItem.cpp
rdf/KoRdfFoaFTreeWidgetItem.cpp
rdf/KoRdfCalendarEventTreeWidgetItem.cpp
rdf/KoRdfLocationTreeWidgetItem.cpp
rdf/KoSemanticStylesheetsEditor.cpp
rdf/KoChangeTrackerDisabledRAII.cpp
rdf/RdfSemanticTreeWidgetAction.cpp
rdf/RdfSemanticTreeWidgetSelectAction.cpp
rdf/InsertSemanticObjectActionBase.cpp
rdf/InsertSemanticObjectCreateAction.cpp
rdf/InsertSemanticObjectReferenceAction.cpp
)
endif( Soprano_FOUND )
if (APPLE)
set(komain_LIB_SRCS ${komain_LIB_SRCS}
MacSupport.mm
......@@ -150,30 +119,6 @@ kde4_add_ui_files( komain_LIB_SRCS
KoOpenPaneBase.ui
KoDetailsPaneBase.ui
)
if(Soprano_FOUND)
kde4_add_ui_files( komain_LIB_SRCS
rdf/KoDocumentRdfEditWidget.ui
rdf/KoRdfFoaFEditWidget.ui
rdf/KoRdfCalendarEventEditWidget.ui
rdf/KoSemanticStylesheetsEditor.ui
)
# if(MARBLE_FOUND)
# kde4_add_ui_files( komain_LIB_SRCS
# rdf/KoRdfLocationEditWidgetMarble.ui
# rdf/KoRdfLocationViewWidgetMarble.ui
# )
# else(MARBLE_FOUND)
kde4_add_ui_files( komain_LIB_SRCS
rdf/KoRdfLocationEditWidget.ui
rdf/KoRdfLocationViewWidget.ui
)
# endif(MARBLE_FOUND)
endif(Soprano_FOUND)
kde4_add_library(komain SHARED ${komain_LIB_SRCS})
target_link_libraries(komain ${extra_libs}
......@@ -185,15 +130,7 @@ target_link_libraries(komain ${extra_libs}
textlayout
)
if( Soprano_FOUND )
target_link_libraries(komain ${SOPRANO_LIBRARIES})
target_link_libraries(komain LINK_INTERFACE_LIBRARIES ${SOPRANO_LIBRARIES})
endif( Soprano_FOUND )
if( MARBLE_FOUND )
include_directories(${MARBLE_INCLUDE_DIR})
target_link_libraries(komain ${MARBLE_LIBRARIES})
target_link_libraries(komain LINK_INTERFACE_LIBRARIES ${MARBLE_LIBRARIES})
endif( MARBLE_FOUND )
if( KActivities_FOUND )
include_directories(${KACTIVITIES_INCLUDES})
target_link_libraries(komain ${KACTIVITIES_LIBRARY})
......@@ -262,30 +199,3 @@ if( QT_QTDBUS_FOUND )
DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
endif( QT_QTDBUS_FOUND )
if( Soprano_FOUND )
install( FILES
rdf/KoRdfFoaF.h
rdf/KoRdfCalendarEvent.h
rdf/KoRdfLocation.h
rdf/KoRdfFoaFTreeWidgetItem.h
rdf/KoRdfCalendarEventTreeWidgetItem.h
rdf/KoRdfLocationTreeWidgetItem.h
rdf/KoChangeTrackerDisabledRAII.h
rdf/RdfForward.h
rdf/KoDocumentRdf.h
rdf/KoSopranoTableModelDelegate.h
rdf/KoSopranoTableModel.h
rdf/KoSemanticStylesheet.h
rdf/KoRdfSemanticItem.h
rdf/KoRdfSemanticItemViewSite.h
rdf/KoRdfSemanticTree.h
rdf/KoRdfSemanticTreeWidgetItem.h
rdf/RdfSemanticTreeWidgetAction.h
rdf/RdfSemanticTreeWidgetSelectAction.h
rdf/InsertSemanticObjectActionBase.h
rdf/InsertSemanticObjectCreateAction.h
rdf/InsertSemanticObjectReferenceAction.h
rdf/KoSemanticStylesheetsEditor.h
DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
endif( Soprano_FOUND )
......@@ -32,9 +32,7 @@
#include "KoEmbeddedDocumentSaver.h"
#include "KoFilterManager.h"
#include "KoDocumentInfo.h"
#ifdef SHOULD_BUILD_RDF
#include "rdf/KoDocumentRdf.h"
#endif
#include "KoOdfStylesReader.h"
#include "KoOdfReadStore.h"
#include "KoOdfWriteStore.h"
......@@ -87,6 +85,8 @@
using namespace std;
class KoPageWidgetItem;
/**********************************************************
*
* KoDocument
......@@ -105,26 +105,27 @@ class KoDocument::Private
{
public:
Private() :
progressUpdater(0),
progressProxy(0),
profileStream(0),
filterManager(0),
specialOutputFlag(0), // default is native format
isImporting(false),
isExporting(false),
password(QString()),
modifiedAfterAutosave(false),
autosaving(false),
shouldCheckAutoSaveFile(true),
autoErrorHandlingEnabled(true),
backupFile(true),
backupPath(QString()),
doNotSaveExtDoc(false),
storeInternal(false),
isLoading(false),
undoStack(0),
parentPart(0)
docInfo(0),
docRdf(0),
progressUpdater(0),
progressProxy(0),
profileStream(0),
filterManager(0),
specialOutputFlag(0), // default is native format
isImporting(false),
isExporting(false),
password(QString()),
modifiedAfterAutosave(false),
autosaving(false),
shouldCheckAutoSaveFile(true),
autoErrorHandlingEnabled(true),
backupFile(true),
backupPath(QString()),
doNotSaveExtDoc(false),
storeInternal(false),
isLoading(false),
undoStack(0),
parentPart(0)
{
confirmNonNativeSave[0] = true;
confirmNonNativeSave[1] = true;
......@@ -137,11 +138,8 @@ public:
KoDocumentInfo *docInfo;
#ifdef SHOULD_BUILD_RDF
KoDocumentRdf *docRdf;
#else
KoDocumentRdfBase *docRdf;
#endif
KoProgressUpdater *progressUpdater;
KoProgressProxy *progressProxy;
QTextStream *profileStream;
......@@ -202,16 +200,6 @@ KoDocument::KoDocument(KoPart *parent, KUndo2Stack *undoStack)
setObjectName(newObjectName());
d->docInfo = new KoDocumentInfo(this);
d->docRdf = 0;
#ifdef SHOULD_BUILD_RDF
{
KConfigGroup cfgGrp(d->parentPart->componentData().config(), "RDF");
bool rdfEnabled = cfgGrp.readEntry("rdf_enabled", false);
if (rdfEnabled) {
setDocumentRdf(new KoDocumentRdf(this));
}
}
#endif
d->pageLayout.width = 0;
d->pageLayout.height = 0;
......@@ -521,31 +509,15 @@ KoDocumentInfo *KoDocument::documentInfo() const
KoDocumentRdfBase *KoDocument::documentRdf() const
{
#ifdef SHOULD_BUILD_RDF
if (d->docRdf && d->docRdf->model()) {
return d->docRdf;
}
#endif
return 0;
return d->docRdf;
}
void KoDocument::setDocumentRdf(KoDocumentRdf *rdfDocument)
void KoDocument::setDocumentRdf(KoDocumentRdfBase *rdfDocument)
{
delete d->docRdf;
d->docRdf = 0;
#ifdef SHOULD_BUILD_RDF
if (rdfDocument->model()) {
d->docRdf = rdfDocument;
}
#endif
d->docRdf = rdfDocument;
}
KoDocumentRdfBase *KoDocument::documentRdfBase() const
{
return d->docRdf;
}
bool KoDocument::isModified() const
{
if (d->parentPart->isModified()) {
......
......@@ -49,6 +49,7 @@ class KoDocumentInfo;
class KoDocumentRdf;
class KoDocumentRdfBase;
class KoProgressUpdater;
class KoPageWidgetItem;
class KoProgressProxy;
class KoVersionInfo
......@@ -428,13 +429,7 @@ public:
* will be deleted, and if RDF support is compiled out, KoDocument does not take ownership.
* Otherwise, KoDocument will own the rdf document.
*/
void setDocumentRdf(KoDocumentRdf *rdfDocument);
/**
* @return the Rdf metadata for this document.
* @see KoDocumentRdf
*/
KoDocumentRdfBase *documentRdfBase() const;
void setDocumentRdf(KoDocumentRdfBase *rdfDocument);
/**
* @return the object to report progress to.
......@@ -485,7 +480,6 @@ public:
int queryCloseDia();
/**
* Sets the backup path of the document
*/
......
This diff is collapsed.
......@@ -27,6 +27,24 @@ class KoDocumentInfo;
class KoDocumentRdfBase;
class KPageWidgetItem;
#include <kpagewidgetmodel.h>
#include "komain_export.h"
// This class can be implemented when we want to extend the
// dialog with new, specific pages.
class KOMAIN_EXPORT KoPageWidgetItem
{
public:
virtual ~KoPageWidgetItem() {}
virtual QWidget *widget() = 0;
virtual const QString name() const = 0;
virtual const QLatin1String icon() const = 0;
virtual bool shouldDialogCloseBeVetoed() = 0;
virtual void apply() = 0;
};
/**
* @short The dialog that shows information about the document
* @author Simon Hausmann <hausmann@kde.org>
......@@ -45,7 +63,7 @@ class KPageWidgetItem;
* KPageDialog and uses the face type Tabbed.
*/
class KoDocumentInfoDlg : public KPageDialog
class KOMAIN_EXPORT KoDocumentInfoDlg : public KPageDialog
{
Q_OBJECT
......@@ -55,7 +73,7 @@ public:
* @param parent a pointer to the parent widget
* @param docInfo a pointer to the shown KoDocumentInfo
*/
KoDocumentInfoDlg(QWidget *parent, KoDocumentInfo* docInfo, KoDocumentRdfBase* docRdf = 0);
KoDocumentInfoDlg(QWidget *parent, KoDocumentInfo* docInfo);
/** The destructor */
virtual ~KoDocumentInfoDlg();
......@@ -68,6 +86,8 @@ public:
/** Sets all fields to read-only mode. Used by the property dialog. */
void setReadOnly(bool ro);
void addPageItem(KoPageWidgetItem *item);
public slots:
/** Connected to the okClicked() signal */
void slotApply();
......
......@@ -1332,7 +1332,8 @@ void KoMainWindow::slotDocumentInfo()
if (!docInfo)
return;
KoDocumentInfoDlg *dlg = new KoDocumentInfoDlg(this, docInfo, rootDocument()->documentRdf());
KoDocumentInfoDlg *dlg = d->rootPart->createDocumentInfoDialog(this, docInfo);
if (dlg->exec()) {
if (dlg->isDocumentSaved()) {
rootDocument()->setModified(false);
......
......@@ -91,7 +91,6 @@ public:
* Retrieves the document that is displayed in the mainwindow.
*/
KoDocument *rootDocument() const;
KoPart *rootPart() const;
KoView *rootView() const;
/**
......
......@@ -33,6 +33,7 @@
#include "KoProgressProxy.h"
#include "KoFilterManager.h"
#include "KoServiceProvider.h"
#include <KoDocumentInfoDlg.h>
#include <kdebug.h>
#include <kstandarddirs.h>
......@@ -318,6 +319,11 @@ KoMainWindow *KoPart::currentShell() const
}
KoDocumentInfoDlg *KoPart::createDocumentInfoDialog(QWidget *parent, KoDocumentInfo *docInfo) const
{
return new KoDocumentInfoDlg(parent, docInfo);
}
void KoPart::showSavingErrorDialog()
{
if (d->document->errorMessage().isEmpty()) {
......
......@@ -37,7 +37,8 @@ class KoView;
class KoMainWindow;
class KoView;
class KoOpenPane;
class KoDocumentInfoDlg;
class KoDocumentInfo;
class QGraphicsItem;
/**
......@@ -133,6 +134,8 @@ public:
KoMainWindow *currentShell() const;
virtual KoDocumentInfoDlg* createDocumentInfoDialog(QWidget *parent, KoDocumentInfo *docInfo) const;
protected slots:
/**
......
/* This file is part of the KDE project
Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "KoDocumentRdfEditWidgetBase.h"
KoDocumentRdfEditWidgetBase::KoDocumentRdfEditWidgetBase(QWidget *parent, KoDocumentRdf *docRdf)
: QWidget(parent)
{
Q_UNUSED(docRdf);
}
bool KoDocumentRdfEditWidgetBase::shouldDialogCloseBeVetoed()
{
return false;
}
void KoDocumentRdfEditWidgetBase::apply()
{
}
/* This file is part of the KDE project
Copyright (C) 2010 KO GmbH <ben.martin@kogmbh.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __koDocumentRdfEditWidgetBase_h__
#define __koDocumentRdfEditWidgetBase_h__
#include <QWidget>
class KoDocumentRdf;
class KoDocumentRdfEditWidgetBase : public QWidget
{
Q_OBJECT
public:
KoDocumentRdfEditWidgetBase(QWidget *parent, KoDocumentRdf *docRdf);
virtual bool shouldDialogCloseBeVetoed();
virtual void apply();
};
#endif
......@@ -46,17 +46,3 @@ set(findmatch_test_SRCS testfindmatch.cpp )
kde4_add_unit_test(testfindmatch TESTNAME libs-komain-testfindmatch ${findmatch_test_SRCS})
target_link_libraries(testfindmatch komain ${QT_QTTEST_LIBRARY})
########### next target ###############
if( Soprano_FOUND )