diff options
| author | 2008-09-25 17:06:11 +0000 | |
|---|---|---|
| committer | 2008-09-25 17:06:11 +0000 | |
| commit | 345cc56416491a268266523c207d0485499f72bd (patch) | |
| tree | 61540c9796c8639d012d5dd6f89da083b4f111d3 /src | |
| parent | quick fix (diff) | |
| download | KVIrc-345cc56416491a268266523c207d0485499f72bd.tar.gz KVIrc-345cc56416491a268266523c207d0485499f72bd.tar.bz2 KVIrc-345cc56416491a268266523c207d0485499f72bd.zip | |
more work on the help search
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2569 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kernel/kvi_internalcmd.cpp | 4 | ||||
| -rw-r--r-- | src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp | 113 | ||||
| -rw-r--r-- | src/modules/help/libkvihelp.cpp | 77 |
3 files changed, 46 insertions, 148 deletions
diff --git a/src/kvirc/kernel/kvi_internalcmd.cpp b/src/kvirc/kernel/kvi_internalcmd.cpp index aa4e34c2c..2381af875 100644 --- a/src/kvirc/kernel/kvi_internalcmd.cpp +++ b/src/kvirc/kernel/kvi_internalcmd.cpp @@ -31,8 +31,8 @@ static const char * internalCommandTable[KVI_NUM_INTERNAL_COMMANDS]= { "echo INTERNAL COMMAND ERROR: INDEX OUT OF RANGE", - "help.open -n -m index.html", - "help.open -n index.html", + "help.open -n -m", + "help.open -n", "about.kvirc", "if($option(boolShowGeneralOptionsDialogAsToplevel))options.dialog -t; else options.dialog", "codetester.open", diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp b/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp index 6ffa9c8ca..fa8f66d83 100644 --- a/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp +++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp @@ -115,119 +115,8 @@ namespace KviKvsCoreSimpleCommands szTopic.trimmed(); } - QString szCommand; - if(szTopic.isEmpty())szCommand = "help.open index.html"; - else { -/* FIXME removed this usage if the evil goto. better if reimplemented directly in the help module - - bool bWasFunc = false; - if(szTopic[0] == QChar('$')) - { - bWasFunc = true; - szTopic.remove(0,1); - } - - QString szOriginal = szTopic; - - QString topik = szTopic; - QStringList pl = Q3MimeSourceFactory::defaultFactory()->filePath(); - - bool bLowCaseTried = false; - bool bFound = KviFileUtils::fileExists(szTopic); - -try_again: - if((!bFound) && bWasFunc) - { - topik = szTopic; - topik += ".html"; - topik.prepend("fnc_"); - bFound = file_in_path(pl,topik); - } - - if(!bFound) - { - topik = szTopic; - bFound = file_in_path(pl,topik); - } - - if(!bFound) - { - topik = szTopic; - topik += ".html"; - bFound = file_in_path(pl,topik); - } - - if(!bFound) - { - topik = szTopic; - topik += ".html"; - topik.prepend("cmd_"); - bFound = file_in_path(pl,topik); - } - - if(!bFound) - { - topik = szTopic; - topik += ".html"; - topik.prepend("doc_"); - bFound = file_in_path(pl,topik); - } - - if(!bFound) - { - topik = szTopic; - topik += ".html"; - topik.prepend("event_"); - bFound = file_in_path(pl,topik); - } - - if(!bFound) - { - topik = szTopic; - topik += ".html"; - topik.prepend("module_"); - bFound = file_in_path(pl,topik); - } - - if(!bFound) - { - topik = szTopic; - topik += ".html"; - topik.prepend("widget_"); - bFound = file_in_path(pl,topik); - } - - if(!bFound) - { - topik = szTopic; - topik += ".html"; - topik.prepend("class_"); - bFound = file_in_path(pl,topik); - } - - if(!bFound && !bLowCaseTried) - { - // try again with lowercase - szTopic = szTopic.toLower(); - bLowCaseTried = true; - goto try_again; - } - - if(!bFound) - { - // let the help.open function decide... - topik = szOriginal; - topik += ".html"; - } - - szCommand = "help.open "; - szCommand += topik; -*/ - szCommand = "help.open " + szTopic; - } - // We don't care about the return value... - KviKvsScript s("help",szCommand); + KviKvsScript s("help","help.open " + szTopic); s.run(KVSCSC_pContext->window()); return true; diff --git a/src/modules/help/libkvihelp.cpp b/src/modules/help/libkvihelp.cpp index a4d096ceb..409984e17 100644 --- a/src/modules/help/libkvihelp.cpp +++ b/src/modules/help/libkvihelp.cpp @@ -138,57 +138,66 @@ static bool help_kvs_cmd_search(KviKvsModuleCommandCall * c) static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c) { - QString szDoc, szHelpDir; + QString szDoc, szHelpDir, szParam; QDir dirHelp; KVSM_PARAMETERS_BEGIN(c) - KVSM_PARAMETER("document",KVS_PT_STRING,KVS_PF_OPTIONAL,szDoc) + KVSM_PARAMETER("document",KVS_PT_STRING,KVS_PF_OPTIONAL,szParam) KVSM_PARAMETERS_END(c) + szDoc=szParam; g_pApp->getGlobalKvircDirectory(szHelpDir,KviApp::Help); dirHelp = QDir(szHelpDir); - if(szDoc.isEmpty()){ + // no document => index + if(szDoc.isEmpty()) + { szDoc = dirHelp.absoluteFilePath("index.html"); qDebug ("No file, use default at path %s",szDoc.toUtf8().data()); - } else qDebug("Doc set from user to %s",szDoc.toUtf8().data()); - - if (g_pDocIndex && !szDoc.isEmpty()) + } + + // try absolute path + QFileInfo * f= new QFileInfo(szDoc); + if(!f->exists()) { - if (!g_pDocIndex->documentList().count()) + //try relative path + szDoc = dirHelp.absoluteFilePath(szDoc); + qDebug("No abs path, trying relative path: %s",szDoc.toUtf8().data()); + f->setFile(szDoc); + } + + if(!f->exists()) + { + //try search + qDebug("No rel path, trying search.."); + if(g_pDocIndex) { - QString szDoclist,szDict; - g_pApp->getLocalKvircDirectory(szDoclist,KviApp::Help,"help.doclist." KVI_SOURCES_DATE); - g_pApp->getLocalKvircDirectory(szDict,KviApp::Help,"help.dict." KVI_SOURCES_DATE); - if ( KviFileUtils::fileExists(szDoclist) && KviFileUtils::fileExists( szDict )) g_pDocIndex->readDict(); - else + if (!g_pDocIndex->documentList().count()) + { + QString szDoclist,szDict; + g_pApp->getLocalKvircDirectory(szDoclist,KviApp::Help,"help.doclist." KVI_SOURCES_DATE); + g_pApp->getLocalKvircDirectory(szDict,KviApp::Help,"help.dict." KVI_SOURCES_DATE); + if ( KviFileUtils::fileExists(szDoclist) && KviFileUtils::fileExists( szDict )) + { + g_pDocIndex->readDict(); + } + } + int i=g_pDocIndex->titlesList().indexOf(szParam); + if (i!=-1) { - c->warning(__tr2qs("Docs database is not builded")); - return true; + szDoc=QUrl::fromLocalFile(g_pDocIndex->documentList()[ i ]).path(); + f->setFile(szDoc); } } - int i=g_pDocIndex->titlesList().indexOf(szDoc); - if (i!=-1) - { - szDoc=QUrl::fromLocalFile(g_pDocIndex->documentList()[ i ]).path(); - if (szDoc.left(1)=="/") szDoc.remove(0,1); - } } - QFileInfo * f= new QFileInfo(szDoc); - if(f) + + if(!f->exists()) { - if(!f->exists()) - { - szDoc = dirHelp.absoluteFilePath(szDoc); - qDebug("No abs path, trying relative path: %s",szDoc.toUtf8().data()); - f->setFile(szDoc); - } - if(!f->exists()) - { - szDoc = dirHelp.absoluteFilePath("nohelpavailable.html"); - qDebug("No rel path, defaulting to error page: %s",szDoc.toUtf8().data()); - f->setFile(szDoc); - } + //everything failed => error + szDoc = dirHelp.absoluteFilePath("nohelpavailable.html"); + + qDebug("Document not found, defaulting to error page: %s",szDoc.toUtf8().data()); + f->setFile(szDoc); } if(!c->switches()->find('n',"new")) |
