Commit cefa4de6 authored by Jonathan Marten's avatar Jonathan Marten

Man ioslave: Port away from KDELibs4Support

Differential Revision: https://phabricator.kde.org/D5564
parent c285acd0
......@@ -8,7 +8,7 @@ set(kio_man_PART_SRCS man2html.cpp kio_man.cpp request_hash.cpp kio_man_debug.cp
ecm_gperf_generate(requests.gperf ${CMAKE_CURRENT_BINARY_DIR}/request_gperf.h kio_man_PART_SRCS)
add_library(kio_man MODULE ${kio_man_PART_SRCS})
target_link_libraries(kio_man KF5::KIOCore Qt5::Widgets KF5::Archive KF5::KDELibs4Support)
target_link_libraries(kio_man KF5::KIOCore Qt5::Widgets KF5::Archive KF5::I18n KF5::Codecs)
set_target_properties(kio_man PROPERTIES OUTPUT_NAME "man")
install(TARGETS kio_man DESTINATION ${PLUGIN_INSTALL_DIR}/kf5/kio)
......@@ -17,7 +17,7 @@ install(TARGETS kio_man DESTINATION ${PLUGIN_INSTALL_DIR}/kf5/kio)
add_library(kmanpart kmanpart.cpp )
target_compile_definitions(kmanpart PRIVATE -DPROJECT_VERSION="${PROJECT_VERSION}")
target_link_libraries(kmanpart KF5::KHtml KF5::KDELibs4Support)
target_link_libraries(kmanpart KF5::KHtml)
install(TARGETS kmanpart DESTINATION ${PLUGIN_INSTALL_DIR} )
install(FILES man.protocol kmanpart.desktop DESTINATION ${SERVICES_INSTALL_DIR})
......@@ -35,10 +35,9 @@
#include <QRegExp>
#include <QStandardPaths>
#include <QTextCodec>
#include <QProcess>
#include <KLocalizedString>
#include <KProcess>
#include <kglobal.h>
#include <kencodingprober.h>
#include "man2html.h"
......@@ -211,10 +210,12 @@ QMap<QString, QString> MANProtocol::buildIndexMap(const QString &section)
break;
}
if ( it_name == names.constEnd() ) {
KProcess proc;
proc << "whatis" << "-M" << (*it_dir) << "-w" << "*";
proc.setOutputChannelMode( KProcess::OnlyStdoutChannel );
proc.execute();
QProcess proc;
proc.setProgram("whatis");
proc.setArguments(QStringList() << "-M" << (*it_dir) << "-w" << "*");
proc.setProcessChannelMode( QProcess::ForwardedErrorChannel );
proc.start();
proc.waitForFinished();
QTextStream t( proc.readAllStandardOutput(), QIODevice::ReadOnly );
parseWhatIs( i, t, mark );
}
......@@ -237,14 +238,14 @@ QStringList MANProtocol::manDirectories()
{
// Translated pages in "<mandir>/<lang>" if the directory
// exists
QStringList languages = KLocale::global()->languageList();
for (QStringList::ConstIterator it_lang = languages.constBegin();
it_lang != languages.constEnd();
it_lang++ )
QList<QLocale> locales = QLocale::matchingLocales(QLocale::AnyLanguage, QLocale::AnyScript, QLocale::AnyCountry);
for (QList<QLocale>::ConstIterator it_loc = locales.constBegin();
it_loc != locales.constEnd();
it_loc++ )
{
if ( !(*it_lang).isEmpty() && (*it_lang) != QString("C") ) {
QString dir = (*it_dir) + '/' + (*it_lang);
QString lang = QLocale::languageToString((*it_loc).language());
if ( !lang.isEmpty() && lang!=QString("C") ) {
QString dir = (*it_dir) + '/' + lang;
struct stat sbuf;
......@@ -542,12 +543,14 @@ char *MANProtocol::readManPage(const char *_filename)
//QString file_mimetype = KMimeType::findByPath(QString(filename), 0, false)->name();
if (QString(filename).contains("sman", Qt::CaseInsensitive)) //file_mimetype == "text/html" || )
{
KProcess proc;
QProcess proc;
// Determine path to sgml2roff, if not already done.
getProgramPath();
proc << mySgml2RoffPath << filename;
proc.setOutputChannelMode( KProcess::OnlyStdoutChannel );
proc.execute();
proc.setProgram(mySgml2RoffPath);
proc.setArguments(QStringList() << filename);
proc.setProcessChannelMode( QProcess::ForwardedErrorChannel );
proc.start();
proc.waitForFinished();
array = proc.readAllStandardOutput();
}
else
......
......@@ -23,7 +23,6 @@
#include <KLocalizedString>
#include <kpluginfactory.h>
#include <kdeversion.h>
#include <QUrl>
static KAboutData createAboutData()
......
......@@ -141,9 +141,9 @@
#else
# include <QTextCodec>
# include <QTextDocument>
# include <QDebug>
# include <KLocalizedString>
# include <kdebug.h>
# include <kdeversion.h>
# include <plasma_version.h>
# define BYTEARRAY(x) x
#endif
......@@ -294,7 +294,7 @@ static void InitStringDefinitions(void)
// \*S "Change to default font size"
#ifndef SIMPLE_MAN2HTML
// Special KDE KIO man:
const QByteArray kdeversion(KDE_VERSION_STRING);
const QByteArray kdeversion(PLASMA_VERSION_STRING);
s_stringDefinitionMap.insert(".KDE_VERSION_STRING", StringDefinition(kdeversion.length(), kdeversion));
#endif
}
......@@ -1511,13 +1511,13 @@ static int read_only_number_register(const QByteArray& name)
#ifndef SIMPLE_MAN2HTML
// Special KDE KIO man:
else if (name == ".KDE_VERSION_MAJOR")
return KDE_VERSION_MAJOR;
return PLASMA_VERSION_MAJOR;
else if (name == ".KDE_VERSION_MINOR")
return KDE_VERSION_MINOR;
return PLASMA_VERSION_MINOR;
else if (name == ".KDE_VERSION_RELEASE")
return KDE_VERSION_RELEASE;
return PLASMA_VERSION_PATCH;
else if (name == ".KDE_VERSION")
return KDE_VERSION;
return PLASMA_VERSION;
#endif
else if ( name == ".T" )
return 0; // Set to 1 in nroff, if -T option used; always 0 in troff.
......@@ -3310,9 +3310,9 @@ static void request_while(char*& c, int j, bool mdoc)
// Unlike for a normal macro, we have the condition at start, so we do not need to prepend extra bytes
char* liveloop = qstrdup(macro.data());
qCDebug(KIO_MAN_LOG) << "Scanning .while condition";
kDebug(7101) << "Loop macro " << liveloop;
qCDebug(KIO_MAN_LOG) << "Loop macro " << liveloop;
char* end_expression = scan_expression(liveloop, &result);
kDebug(7101) << "After " << end_expression;
qCDebug(KIO_MAN_LOG) << "After " << end_expression;
if (result)
{
qCDebug(KIO_MAN_LOG) << "New .while iteration";
......@@ -6012,7 +6012,7 @@ void scan_man_page(const char *man_page)
output_real("Generated by kio_man");
#else
output_real("Generated by kio_man, KDE version ");
output_real(Qt::escape(QLatin1String(KDE_VERSION_STRING)).toUtf8());
output_real(QString(PLASMA_VERSION_STRING).toHtmlEscaped().toLocal8Bit());
#endif
output_real("</div></div>\n\n");
......
......@@ -15,7 +15,7 @@ ecm_gperf_generate(../requests.gperf ${CMAKE_CURRENT_BINARY_DIR}/request_gperf.h
add_executable(kio_man_test ${kio_man_test_SRCS})
ecm_mark_as_test(kio_man_test)
set_target_properties(kio_man_test PROPERTIES COMPILE_FLAGS "-DSIMPLE_MAN2HTML -DKIO_MAN_TEST")
target_link_libraries(kio_man_test KF5::KIOCore KF5::Archive KF5::KDELibs4Support)
target_link_libraries(kio_man_test Qt5::Widgets KF5::I18n KF5::KIOCore KF5::Archive KF5::Codecs)
########### next target ###############
......@@ -30,5 +30,4 @@ ecm_gperf_generate(../requests.gperf ${CMAKE_CURRENT_BINARY_DIR}/request_gperf.h
add_executable(man2html ${man2html_SRCS})
ecm_mark_as_test(man2html)
set_target_properties(man2html PROPERTIES COMPILE_FLAGS -DSIMPLE_MAN2HTML)
target_link_libraries(man2html KF5::KDELibs4Support)
target_link_libraries(man2html Qt5::Core)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment