summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuigi Toscano <[email protected]>2017-07-24 12:46:02 +0200
committerLuigi Toscano <[email protected]>2017-07-24 12:46:21 +0200
commitbc0bc0f139cf28ccb1020d37cc270be451b0362b (patch)
tree17a55ec21f16d7ef33c67328fd52c48bb6b89d62
parent5a80f8340b8fc4ce9d700e3dd2cb97207952ab93 (diff)
Optional usage of documentationDirs from KDocTools
Summary: Only if available. Unfortunately a bug in KDocTools prevents for looking for its version, so use another the version of another core library part of Frameworks. Test Plan: The new code compiles without regression in functionalities: - the cache is created for toc entries - the documentation is found. Reviewers: aacid, cfeck Reviewed By: aacid Subscribers: #documentation Tags: #documentation Differential Revision: https://phabricator.kde.org/D6790
-rw-r--r--CMakeLists.txt3
-rw-r--r--searchhandlers/CMakeLists.txt3
-rw-r--r--searchhandlers/xapianindexer.cpp21
-rw-r--r--toc.cpp9
-rw-r--r--view.cpp10
5 files changed, 45 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b54da31..0ec87e8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,6 +98,9 @@ kconfig_add_kcfg_files(khelpcenter_KDEINIT_SRCS prefs.kcfgc )
kf5_add_kdeinit_executable( khelpcenter ${khelpcenter_KDEINIT_SRCS})
target_compile_definitions(kdeinit_khelpcenter PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
target_link_libraries(kdeinit_khelpcenter KF5::KHtml KF5::Service KF5::DBusAddons KF5::ConfigGui KF5::WindowSystem KF5::Bookmarks Qt5::Xml Grantlee5::Templates)
+if (${KF5_VERSION} VERSION_GREATER 5.36.0)
+ target_link_libraries(kdeinit_khelpcenter KF5::DocTools)
+endif()
install(TARGETS kdeinit_khelpcenter ${INSTALL_TARGETS_DEFAULT_ARGS} )
install(TARGETS khelpcenter ${INSTALL_TARGETS_DEFAULT_ARGS})
diff --git a/searchhandlers/CMakeLists.txt b/searchhandlers/CMakeLists.txt
index 98e2345..f39fa1f 100644
--- a/searchhandlers/CMakeLists.txt
+++ b/searchhandlers/CMakeLists.txt
@@ -17,6 +17,9 @@ add_executable(khc_xapianindexer ${khc_xapianindexer_SOURCES})
kde_target_enable_exceptions(khc_xapianindexer PRIVATE)
ecm_mark_nongui_executable(khc_xapianindexer)
target_link_libraries(khc_xapianindexer Qt5::Core KF5::Archive ${XAPIAN_LIBRARIES} ${LIBXML2_LIBRARIES})
+if (${KF5_VERSION} VERSION_GREATER 5.36.0)
+ target_link_libraries(khc_xapianindexer KF5::DocTools)
+endif()
install(TARGETS khc_xapianindexer DESTINATION ${LIBEXEC_INSTALL_DIR})
# Xapian search
diff --git a/searchhandlers/xapianindexer.cpp b/searchhandlers/xapianindexer.cpp
index 53a16b6..e2416e4 100644
--- a/searchhandlers/xapianindexer.cpp
+++ b/searchhandlers/xapianindexer.cpp
@@ -23,6 +23,11 @@
#include "htmltextdump.h"
#include "xapiancommon.h"
+#include <kcoreaddons_version.h>
+#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
+#include <docbookxslt.h>
+#endif
+
#include <QCoreApplication>
#include <QCommandLineParser>
#include <QDebug>
@@ -30,6 +35,7 @@
#include <QDirIterator>
#include <QLoggingCategory>
#include <QStandardPaths>
+#include <QStringBuilder>
namespace {
@@ -222,7 +228,22 @@ int main( int argc, char *argv[] )
QSet<Xapian::docid> handledDocuments;
const std::string std_lang = lang.toStdString();
+#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
+ const QStringList docDirs = KDocTools::documentationDirs();
+
+ QStringList localDoc;
+
+ QStringList::ConstIterator it = docDirs.constBegin();
+ for ( ; it != docDirs.constEnd(); ++it ) {
+ const QString docDirLangName = QString( ( *it ) % "/" % lang % "/" );
+ QFileInfo docDirLang = QFileInfo( docDirLangName );
+ if ( docDirLang.exists() && docDirLang.isDir() ) {
+ localDoc << docDirLangName;
+ }
+ }
+#else
const QStringList localDoc = QStandardPaths::locateAll( QStandardPaths::GenericDataLocation, QStringLiteral("doc/HTML/") + lang + "/", QStandardPaths::LocateDirectory );
+#endif
qCDebug(LOG) << "documentation directories:" << localDoc;
Q_FOREACH ( const QString &path, localDoc ) {
walkFiles( path, std_lang, db, xgen, &handledDocuments );
diff --git a/toc.cpp b/toc.cpp
index f154958..929c2d9 100644
--- a/toc.cpp
+++ b/toc.cpp
@@ -25,6 +25,11 @@
#include <KProcess>
#include <KXmlGuiWindow>
+#include <kcoreaddons_version.h>
+#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
+#include <docbookxslt.h>
+#endif
+
#include <QStatusBar>
#include <QFileInfo>
@@ -83,7 +88,11 @@ void TOC::build( const QString &file )
{
QFileInfo fileInfo( file );
QString fileName = fileInfo.absoluteFilePath();
+#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
+ const QStringList resourceDirs = KDocTools::documentationDirs();
+#else
const QStringList resourceDirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "doc/HTML", QStandardPaths::LocateDirectory);
+#endif
QStringList::ConstIterator it = resourceDirs.begin();
QStringList::ConstIterator end = resourceDirs.end();
for ( ; it != end; ++it ) {
diff --git a/view.cpp b/view.cpp
index f4f65bc..0df177e 100644
--- a/view.cpp
+++ b/view.cpp
@@ -14,7 +14,10 @@
#include <KHTMLView>
#include <KToolBarPopupAction>
#include <KSharedConfig>
-#include <ki18n_version.h>
+#include <kcoreaddons_version.h>
+#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
+#include <docbookxslt.h>
+#endif
#include <QFileInfo>
#include <QClipboard>
@@ -94,8 +97,13 @@ QString View::langLookup( const QString &fname )
{
QStringList search;
+#if KCOREADDONS_VERSION >= QT_VERSION_CHECK(5, 36, 0)
+ // retrieve the local search path
+ const QStringList localDoc = KDocTools::documentationDirs();
+#else
// assemble the local search paths
const QStringList localDoc = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("doc/HTML"), QStandardPaths::LocateDirectory);
+#endif
QStringList langs = KLocalizedString::languages();
langs.append(QStringLiteral("en"));