From e03da7a558d79e399e3704a5b2f35646e92dacb7 Mon Sep 17 00:00:00 2001 From: Slávek Banko Date: Mon, 23 Sep 2013 00:43:43 +0200 Subject: Initial TQt conversion --- src/renderer.cpp | 226 +++++++++++++++++++++++++++---------------------------- 1 file changed, 113 insertions(+), 113 deletions(-) (limited to 'src/renderer.cpp') diff --git a/src/renderer.cpp b/src/renderer.cpp index 60a13bc..6aad63a 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -48,8 +48,8 @@ #include // QT -#include -#include +#include +#include // Standard C/C++ #include @@ -66,32 +66,32 @@ using namespace sword; namespace KioSword { - static const QString prev("
  • « %1"); - static QString makePrevLink(const QString& caption, const QString& url) + static const TQString prev("
  • « %1"); + static TQString makePrevLink(const TQString& caption, const TQString& url) { return prev.arg(caption).arg(url); } - static const QString next("
  • %1 »"); - static QString makeNextLink(const QString& caption, const QString& url) + static const TQString next("
  • %1 »"); + static TQString makeNextLink(const TQString& caption, const TQString& url) { return next.arg(caption).arg(url); } - static const QString treeup("
  • %1 %2"); - static QString makeTreeUpLink(const QString& caption1, const QString& caption2, const QString& url) + static const TQString treeup("
  • %1 %2"); + static TQString makeTreeUpLink(const TQString& caption1, const TQString& caption2, const TQString& url) { return treeup.arg(caption1).arg(caption2).arg(url); } - static const QString bibleup("
  • %1"); - static QString makeBibleUpLink(const QString& caption, const QString& url) + static const TQString bibleup("
  • %1"); + static TQString makeBibleUpLink(const TQString& caption, const TQString& url) { return bibleup.arg(caption).arg(url); } - static const QString genlink("
  • %1"); - static QString makeGeneralLink(const QString& caption, const QString& url) + static const TQString genlink("
  • %1"); + static TQString makeGeneralLink(const TQString& caption, const TQString& url) { return genlink.arg(caption).arg(url); } @@ -106,7 +106,7 @@ namespace KioSword { for (int i = 0; i < NUM_MODULE_TYPES; i++) { m_moduleTypes.push_back(""); - m_moduleTypeNames.push_back(QString("")); + m_moduleTypeNames.push_back(TQString("")); } m_moduleTypes[BIBLE] = "Biblical Texts"; @@ -156,9 +156,9 @@ namespace KioSword /** Return an HTML hyperlinked list of all modules, * categorised, and including descriptions */ - QString Renderer::listModules(const SwordOptions &options) { - QString output; - QString temp; + TQString Renderer::listModules(const SwordOptions &options) { + TQString output; + TQString temp; ModMap::iterator it; vector::size_type i; SWModule *curMod; @@ -170,16 +170,16 @@ namespace KioSword return output; } - output += QString("

    %1

    ") + output += TQString("

    %1

    ") .arg(i18n("Modules")); for (i = 0; i < m_moduleTypes.size(); i++) { - output += QString("

    %1

    \n" + output += TQString("

    %1

    \n" "
      \n").arg(m_moduleTypeNames[i]); for (it = Modules.begin(); it != Modules.end(); it++) { curMod = (*it).second; if (!strcmp(curMod->Type(), m_moduleTypes[i])) { - output += QString("
    • %1 : %2\n") + output += TQString("
    • %1 : %2\n") .arg(curMod->Name()) .arg(curMod->Description()) .arg(swordUrl(curMod->Name(), options)); @@ -194,14 +194,14 @@ namespace KioSword /** Return a sorted list of all module names * */ - QStringList Renderer::moduleList() { - QStringList output; + TQStringList Renderer::moduleList() { + TQStringList output; ModMap::iterator it; SWModule *curMod; for (it = Modules.begin(); it != Modules.end(); it++) { curMod = (*it).second; - output += QString(curMod->Name()); + output += TQString(curMod->Name()); } output.sort(); return output; @@ -318,8 +318,8 @@ namespace KioSword } - void Renderer::moduleQuery(const QString &modname, const QString &ref, const SwordOptions &options, Template* tmplt) { - QString nav; + void Renderer::moduleQuery(const TQString &modname, const TQString &ref, const SwordOptions &options, Template* tmplt) { + TQString nav; SWModule *module = 0; SWKey *skey = 0; KeyType keyt = SWKEY; @@ -335,7 +335,7 @@ namespace KioSword module = getModule(modname.latin1()); if (module == 0) { - QString output; + TQString output; output += "

      " + i18n("The module '%1' could not be found.").arg(modname) + "


      "; @@ -360,7 +360,7 @@ namespace KioSword } modtype = getModuleType(module); - nav += QString("
    • %1 %2
    • ") + nav += TQString("
    • %1 %2
    • ") .arg(i18n("Module:")) .arg(modname) .arg(swordUrl(modname, options)); @@ -378,12 +378,12 @@ namespace KioSword return; } - QString Renderer::search(const QString &modname, const QString &query, const SearchType searchType, const SwordOptions &options) { + TQString Renderer::search(const TQString &modname, const TQString &query, const SearchType searchType, const SwordOptions &options) { SWModule *module = 0; - QString output; + TQString output; ListKey lk; int stype = SEARCH_WORDS; - QString stypename; + TQString stypename; ModuleType modtype; setOptions(options); @@ -413,7 +413,7 @@ namespace KioSword } output += "

      " + i18n("Search results:") + "

      "; - output += QString("
      %1%2
      %3%4
      %5%6
      ") + output += TQString("
      %1%2
      %3%4
      %5%6
      ") .arg(i18n("Module:")) .arg(modname) .arg(i18n("Query:")) @@ -429,17 +429,17 @@ namespace KioSword output += "

      " + i18n("1 match returned:", "%1 matches returned:", lk.Count()).arg(lk.Count()); output += "

        "; for (int i = 0; i < lk.Count(); ++i) { - QString ref; - ref = QString::fromUtf8(lk.getElement(i)->getText()); + TQString ref; + ref = TQString::fromUtf8(lk.getElement(i)->getText()); if (modtype == BIBLE) { module->setKey(lk.getElement(i)); - output += QString("
      • %1: %2
      • ") + output += TQString("
      • %1: %2
      • ") .arg(ref) .arg(renderText(module)) .arg(swordUrl(modname, ref, options)); } else { - output += QString("
      • %1
      • ") + output += TQString("
      • %1
      • ") .arg(ref) .arg(swordUrl(modname, ref, options)); } @@ -450,17 +450,17 @@ namespace KioSword return output; } - QString Renderer::renderText(SWModule *module) { - return QString::fromUtf8(module->RenderText()); + TQString Renderer::renderText(SWModule *module) { + return TQString::fromUtf8(module->RenderText()); } /** Fill in template with formatted text for the query of a verse based module * Links are appended to navlinks. */ - void Renderer::verseQuery(SWModule *module, const QString &ref, const SwordOptions &options, - ModuleType modtype, Template* tmplt, QString &navlinks) { - QString modname(module->Name()); - QString text; + void Renderer::verseQuery(SWModule *module, const TQString &ref, const SwordOptions &options, + ModuleType modtype, Template* tmplt, TQString &navlinks) { + TQString modname(module->Name()); + TQString text; bool doindex = false; const char* modtextdir; // text direction of the module @@ -505,13 +505,13 @@ namespace KioSword // List books and link for viewing entire book SwordOptions options_wholebook(options); options_wholebook.wholeBook.set(true); // set just for creating the URL - text += QString("

        %1

        " + text += TQString("

        %1

        " "

        %2

        " "

        %3

        ") .arg(element->getBookName()) .arg(i18n("Chapters:")) .arg(chapterList(modname, element, options)) - + QString("

        %1

        ") + + TQString("

        %1

        ") .arg(i18n("View entire book.")) .arg(swordUrl(module->Name(), element->getBookName(), options_wholebook)); if (!upToBookListShown) @@ -558,7 +558,7 @@ namespace KioSword text += "
      "; inDirectionedDiv = false; } - text += "

      " + QString(curvk->getBookName()) + "

      "; + text += "

      " + TQString(curvk->getBookName()) + "

      "; chapter = 0; } if (curvk->Chapter() != chapter) { @@ -572,12 +572,12 @@ namespace KioSword } if (!inDirectionedDiv) { - text += QString("
      ").arg(modtextdir); + text += TQString("
      ").arg(modtextdir); inDirectionedDiv = true; } if (options.verseNumbers() && modtype == BIBLE) { - text += QString("%1 ") + text += TQString("%1 ") .arg(curvk->Verse()) .arg(swordUrl(module->Name(), module->KeyText(), options)); } @@ -617,8 +617,8 @@ namespace KioSword // Single verse module->Key(*lk.GetElement(i)); element = dynamic_cast(module->getKey()); - text += QString("

      %1

      ").arg(module->KeyText()); - text += QString("
      ").arg(modtextdir); + text += TQString("

      %1

      ").arg(module->KeyText()); + text += TQString("
      ").arg(modtextdir); text += renderText(module); text += "
      "; if (lk.Count() == 1) @@ -631,27 +631,27 @@ namespace KioSword } while (false); // Title: depends on what got printed above - QString title; + TQString title; if (doindex) { if (!text.isEmpty()) { // an error message was printed - text = QString("

      %1

      ").arg(module->Description()).arg(ref) + text = TQString("

      %1

      ").arg(module->Description()).arg(ref) + text; title = "Error - Kio-Sword"; } else { - title = QString("%1 - Kio-Sword").arg(module->Name()); + title = TQString("%1 - Kio-Sword").arg(module->Name()); } } else { if (modtype == COMMENTARY) { - text = QString("

      %1

      ").arg(module->Description()) + text = TQString("

      %1

      ").arg(module->Description()) + text; - title = QString("%1 - %2 - Kio-Sword") + title = TQString("%1 - %2 - Kio-Sword") .arg(lk.getShortText()) .arg(module->Name()); } else if (modtype == BIBLE) { - text += QString("
      (%1)
      ").arg(module->Description()); - title = QString("%1 - %2 - Kio-Sword") + text += TQString("
      (%1)
      ").arg(module->Description()); + title = TQString("%1 - %2 - Kio-Sword") .arg(lk.getShortText()) .arg(module->Name()); } @@ -667,7 +667,7 @@ namespace KioSword } else { SwordOptions options_doindex(options); options_doindex.doBibleIndex.set(true); - text += QString("

      %1

      ") + text += TQString("

      %1

      ") .arg(i18n("Index of books")) .arg(swordUrl(modname, options_doindex)); } @@ -675,17 +675,17 @@ namespace KioSword tmplt->setContent(text); } - void Renderer::treeQuery(SWModule *module, const QString &ref, const SwordOptions &options, - ModuleType modtype, Template* tmplt, QString &navlinks) { - QString output; - QString modname(module->Name()); + void Renderer::treeQuery(SWModule *module, const TQString &ref, const SwordOptions &options, + ModuleType modtype, Template* tmplt, TQString &navlinks) { + TQString output; + TQString modname(module->Name()); bool doindex; TreeKey *tk = dynamic_cast(module->getKey()); if (!tk) return; - output += QString("

      %1

      ").arg(module->Description()); + output += TQString("

      %1

      ").arg(module->Description()); if (ref.isEmpty()) { doindex = true; } else { @@ -697,17 +697,17 @@ namespace KioSword output += "
      "; doindex = true; } else { - QString link; + TQString link; output += renderText(module); if (tk->previousSibling()) { - link = QString::fromUtf8(module->KeyText()); // FIXME ? local8Bit or utf8 + link = TQString::fromUtf8(module->KeyText()); // FIXME ? local8Bit or utf8 navlinks += makePrevLink(shorten(link.section('/', -1, -1), 20), swordUrl(modname, link, options)); tk->nextSibling(); } SWKey *saved = tk->clone(); if (tk->parent()) { - link = QString::fromUtf8(module->KeyText()); + link = TQString::fromUtf8(module->KeyText()); navlinks += makeTreeUpLink(i18n("Up:"), shorten(link.section('/', -1, -1), 20), swordUrl(modname, link, options)); @@ -715,7 +715,7 @@ namespace KioSword } delete saved; if (tk->nextSibling()) { - link = QString::fromUtf8(module->KeyText()); + link = TQString::fromUtf8(module->KeyText()); navlinks += makeNextLink(shorten(link.section('/', -1, -1), 20), swordUrl(modname, link, options)); tk->previousSibling(); @@ -734,35 +734,35 @@ namespace KioSword if (options.doFullTreeIndex()) { options_doindex.doFullTreeIndex.set(false); output += indexTree(module, options, true, -1); - output += QString("

      %1

      ") + output += TQString("

      %1

      ") .arg(i18n("View simple index")) .arg(swordUrl(modname, options_doindex)); } else { options_doindex.doFullTreeIndex.set(true); output += indexTree(module, options, true, 1); - output += QString("

      %1

      ") + output += TQString("

      %1

      ") .arg(i18n("View full index")) .arg(swordUrl(modname, options_doindex)); } - tmplt->setTitle(QString("%1 - %2 - Kio-Sword").arg(tk->getShortText()).arg(module->Name())); + tmplt->setTitle(TQString("%1 - %2 - Kio-Sword").arg(tk->getShortText()).arg(module->Name())); } else { - tmplt->setTitle(QString("%1 - Kio-Sword").arg(module->Name())); + tmplt->setTitle(TQString("%1 - Kio-Sword").arg(module->Name())); } tmplt->setContent(output); } - void Renderer::normalQuery(SWModule *module, const QString &ref, const SwordOptions &options, - ModuleType modtype, Template* tmplt, QString &navlinks) { - QString output; - QString modname(module->Name()); + void Renderer::normalQuery(SWModule *module, const TQString &ref, const SwordOptions &options, + ModuleType modtype, Template* tmplt, TQString &navlinks) { + TQString output; + TQString modname(module->Name()); bool doindex; SWKey *skey = module->getKey(); - output += QString("

      %1

      ").arg(module->Description()); + output += TQString("

      %1

      ").arg(module->Description()); if (ref.isEmpty()) { doindex = true; @@ -771,14 +771,14 @@ namespace KioSword skey->setText(ref.utf8()); doindex = false; if (skey->Error()) { - output += "

      " + QString(i18n("Couldn't find reference '%1'.")).arg(ref) + "

      "; + output += "

      " + TQString(i18n("Couldn't find reference '%1'.")).arg(ref) + "

      "; output += "
      "; doindex = true; } else { - output += QString("

      %1

      ").arg(module->KeyText()); + output += TQString("

      %1

      ").arg(module->KeyText()); output += renderText(module); module->decrement(); - QString link; + TQString link; if (!module->Error()) { link = module->KeyText(); navlinks += makePrevLink(link, swordUrl(modname, link, options)); @@ -800,7 +800,7 @@ namespace KioSword output += indexBook(module, options); } else { - output += QString("
      " + output += TQString("" "%1 " "
      ") .arg(i18n("Enter query term: ")) @@ -809,15 +809,15 @@ namespace KioSword SwordOptions options_doindex(options); options_doindex.doDictIndex.set(true); options_doindex.doOtherIndex.set(true); - output += QString("

      %1

      ") + output += TQString("

      %1

      ") .arg(i18n("View complete index")) .arg(swordUrl(modname, options_doindex)); } - tmplt->setTitle(QString("%1 - Kio-Sword").arg(module->Name())); + tmplt->setTitle(TQString("%1 - Kio-Sword").arg(module->Name())); } else { - tmplt->setTitle(QString("%1 - %2 - Kio-Sword").arg(skey->getShortText()).arg(module->Name())); + tmplt->setTitle(TQString("%1 - %2 - Kio-Sword").arg(skey->getShortText()).arg(module->Name())); } tmplt->setContent(output); } @@ -827,8 +827,8 @@ namespace KioSword * @param module The module to retrieve. Must be a Bible/commentary */ - QString Renderer::indexBible(SWModule *module, const SwordOptions& options) { - QString output; + TQString Renderer::indexBible(SWModule *module, const SwordOptions& options) { + TQString output; char book; char testament; VerseKey *vk = dynamic_cast(module->getKey()); @@ -847,7 +847,7 @@ namespace KioSword output += "
        \n"; while (vk->Testament() == testament) { while (vk->Book() == book && !module->Error()) { - output += QString("
      • %1\n") + output += TQString("
      • %1\n") .arg(vk->getBookName()) .arg(swordUrl(module->Name(), vk->getBookName(), options)); vk->Book(++book); @@ -869,15 +869,15 @@ namespace KioSword * @param module The module to retrieve. Must have key type SWKey */ - QString Renderer::indexBook(SWModule *module, const SwordOptions& options) { - QString output; - QString ref; + TQString Renderer::indexBook(SWModule *module, const SwordOptions& options) { + TQString output; + TQString ref; module->setPosition(sword::TOP); output += "
          \n"; do { - ref = QString::fromUtf8(module->KeyText()); - output += QString("
        • %1
        • ") + ref = TQString::fromUtf8(module->KeyText()); + output += TQString("
        • %1
        • ") .arg(ref) .arg(swordUrl(module->Name(), ref, options)); (*module)++; @@ -892,9 +892,9 @@ namespace KioSword * @param fromTop If true, get the index from the top level * @param depth How many levels to scan, -1 for all */ - QString Renderer::indexTree(SWModule *module, const SwordOptions& options, bool fromTop, const int depth) { - QString output; - QString ref; + TQString Renderer::indexTree(SWModule *module, const SwordOptions& options, bool fromTop, const int depth) { + TQString output; + TQString ref; bool gonext; bool cont; @@ -914,8 +914,8 @@ namespace KioSword gonext = false; do { if (!gonext) { - ref = QString::fromUtf8(module->KeyText()); - output += QString("
        • %1\n") + ref = TQString::fromUtf8(module->KeyText()); + output += TQString("
        • %1\n") .arg(ref.section('/', -1)) .arg(swordUrl(module->Name(), ref, options)); } @@ -951,13 +951,13 @@ namespace KioSword } - QString Renderer::chapterList(const QString &modname, const VerseKey *vk, const SwordOptions& options) { + TQString Renderer::chapterList(const TQString &modname, const VerseKey *vk, const SwordOptions& options) { VerseKey cp(vk->LowerBound()); - QString output; + TQString output; do { cp.Verse(0); if (!output.isNull()) output += " | "; - output += QString("%1") + output += TQString("%1") .arg(cp.Chapter()) .arg(chapterLink(modname, &cp, options)); cp.Chapter(cp.Chapter()+1); @@ -965,63 +965,63 @@ namespace KioSword return output; } - QString Renderer::chapterLink(const QString &modname, const VerseKey *vk, const SwordOptions& options) { + TQString Renderer::chapterLink(const TQString &modname, const VerseKey *vk, const SwordOptions& options) { return swordUrl(modname, bookChapter(vk), options); } - QString Renderer::chapterLink(const QString &modname, const SWKey *sk, const SwordOptions& options) { + TQString Renderer::chapterLink(const TQString &modname, const SWKey *sk, const SwordOptions& options) { const VerseKey *vk = dynamic_cast(sk); if (vk) return chapterLink(modname, vk, options); else - return QString::null; + return TQString::null; } - QString Renderer::bookLink(const QString &modname, const VerseKey *vk, const SwordOptions& options) { + TQString Renderer::bookLink(const TQString &modname, const VerseKey *vk, const SwordOptions& options) { return swordUrl(modname, bookName(vk), options); } - QString Renderer::bookLink(const QString &modname, const SWKey *sk, const SwordOptions& options) { + TQString Renderer::bookLink(const TQString &modname, const SWKey *sk, const SwordOptions& options) { const VerseKey *vk = dynamic_cast(sk); if (vk) return bookLink(modname, vk, options); else - return QString::null; + return TQString::null; } - QString Renderer::bookChapter(const VerseKey *vk) { - return QString("%1 %2").arg(vk->getBookName()).arg(vk->Chapter()); + TQString Renderer::bookChapter(const VerseKey *vk) { + return TQString("%1 %2").arg(vk->getBookName()).arg(vk->Chapter()); } - QString Renderer::bookChapter(const SWKey *sk) { + TQString Renderer::bookChapter(const SWKey *sk) { const VerseKey *vk = dynamic_cast(sk); if (vk) return bookChapter(vk); else - return QString::null; + return TQString::null; } - QString Renderer::bookName(const VerseKey *vk) { - return QString(vk->getBookName()); + TQString Renderer::bookName(const VerseKey *vk) { + return TQString(vk->getBookName()); } - QString Renderer::bookName(const SWKey *sk) { + TQString Renderer::bookName(const SWKey *sk) { const VerseKey *vk = dynamic_cast(sk); if (vk) return bookName(vk); else - return QString::null; + return TQString::null; } - QStringList Renderer::availableLocales() + TQStringList Renderer::availableLocales() { list locales = LocaleMgr::getSystemLocaleMgr()->getAvailableLocales(); list::const_iterator it; list::const_iterator it_end = locales.end(); - QStringList output; + TQStringList output; for (it = locales.begin(); it != it_end; it++) { - output.append(QString((*it).c_str())); + output.append(TQString((*it).c_str())); } return output; } -- cgit v1.2.3