diff options
| author | 2008-09-26 11:52:12 +0000 | |
|---|---|---|
| committer | 2008-09-26 11:52:12 +0000 | |
| commit | 2299e240fd82e6d9724aff7dc6e0a4f43602c7d4 (patch) | |
| tree | 75fd798dae366309a6f5ad81110ae589584ec813 /src | |
| parent | Win VS projects cleanup. (diff) | |
| download | KVIrc-2299e240fd82e6d9724aff7dc6e0a4f43602c7d4.tar.gz KVIrc-2299e240fd82e6d9724aff7dc6e0a4f43602c7d4.tar.bz2 KVIrc-2299e240fd82e6d9724aff7dc6e0a4f43602c7d4.zip | |
finished help module; still a small problem on window focus after search indexing
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2576 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp | 81 | ||||
| -rw-r--r-- | src/modules/help/helpwindow.cpp | 9 | ||||
| -rw-r--r-- | src/modules/help/helpwindow.h | 3 | ||||
| -rw-r--r-- | src/modules/help/index.cpp | 19 | ||||
| -rw-r--r-- | src/modules/help/index.h | 2 | ||||
| -rw-r--r-- | src/modules/help/libkvihelp.cpp | 91 |
6 files changed, 72 insertions, 133 deletions
diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp b/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp index fa8f66d83..8bec8eceb 100644 --- a/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp +++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp @@ -69,54 +69,51 @@ namespace KviKvsCoreSimpleCommands @title: help @syntax: - help [-s] <topic> + help.open [-n] [-m] [document: string] @short: - Shows a help page + Shows a help document @description: - Shows a help page about <topic>.[br] - <topic> can be a command name , or an identifier.[br] - If <topic> starts with a slash , it is assumed to be a full path - to a html file to be displayed in the help browser.[br] - This command is a shortcut for the [cmd]help.open[/cmd] module command.[br] + Finds the first available help browser in the current frame + then opens the specified [document]. + If no [document] is specified it the documentation index is shown. + If no help browser is available , a new one is created. + [document] can be an absolute path or a relative one: in this case + the document is searched in the KVIrc documentation directory.[br] + If no document has been found using absolute and relative paths, + the first document matching [document] in the help search database + is shown. Otherway, an error page is displayed.[br/] + The help browser has limited html browsing capabilities: you can + use it to view simple html files on your filesystem.[br] + This command is an alias for the [cmd]help.open[cmd] command exported + by the "help" module. + @switches: + !sw: -m | --mdi + The created browser is a MDI window, + otherwise it is a static window. + !sw: -n | --new + The window creation is forced even + if there are other help browsers already open.[br] + @seealso: + [cmd]help.open[/cmd] @examples: [example] - help run - help help - help index - help $mask - help /home/pragma/myfile.html + help /home/pragma/myfile.html //absolute path + help cmd_snd.play.html //relative path + help "Binding operator" //keyword search, remember quoting + help OnNickServAuth //keyword search for an event + help \$my.user //keyword search, $ needs to be escaped [/example] */ - static bool file_in_path(QStringList &pathlist,QString &file) - { - for(QStringList::Iterator it = pathlist.begin();it != pathlist.end();++it) - { - QString tmp = *it; - tmp.append('/'); - tmp.append(file); - KviFileUtils::adjustFilePath(tmp); - if(KviFileUtils::fileExists(tmp))return true; - } - return false; - } - KVSCSC(help) { - QString szTopic; + QString szParams; KVSCSC_PARAMETERS_BEGIN - KVSCSC_PARAMETER("topic",KVS_PT_STRING,KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING,szTopic) + KVSCSC_PARAMETER("params",KVS_PT_STRING,KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING,szParams) KVSCSC_PARAMETERS_END - szTopic.trimmed(); - if(szTopic.endsWith(";")) - { - szTopic.truncate(szTopic.length() - 1); - szTopic.trimmed(); - } - - // We don't care about the return value... - KviKvsScript s("help","help.open " + szTopic); + // We just alias the help.open function + KviKvsScript s("help","help.open " + szParams); s.run(KVSCSC_pContext->window()); return true; @@ -246,8 +243,8 @@ namespace KviKvsCoreSimpleCommands KVSCSC_REQUIRE_CONNECTION - if(!((KVSCSC_pWindow->type() == KVI_WINDOW_TYPE_CHANNEL) || - (KVSCSC_pWindow->type() == KVI_WINDOW_TYPE_QUERY) || + if(!((KVSCSC_pWindow->type() == KVI_WINDOW_TYPE_CHANNEL) || + (KVSCSC_pWindow->type() == KVI_WINDOW_TYPE_QUERY) || (KVSCSC_pWindow->type() == KVI_WINDOW_TYPE_CONSOLE))) { KVSCSC_pContext->warning(__tr2qs("The current window is not a channel, a query or a console")); @@ -566,13 +563,13 @@ namespace KviKvsCoreSimpleCommands if(!pTimerDict) return true; - + KviPointerHashTableIterator<QString,KviKvsTimer> it(*pTimerDict); - + KVSCSC_pContext->window()->outputNoFmt(KVI_OUT_VERBOSE,__tr2qs("List of active timers")); - + unsigned int uCnt = 0; - + while(KviKvsTimer * pTimer = it.current()) { QString szName = pTimer->name(); diff --git a/src/modules/help/helpwindow.cpp b/src/modules/help/helpwindow.cpp index dfcebeeb1..33ac9f351 100644 --- a/src/modules/help/helpwindow.cpp +++ b/src/modules/help/helpwindow.cpp @@ -59,12 +59,9 @@ KviHelpWindow::KviHelpWindow(KviFrame * lpFrm,const char * name) if ( QFileInfo( szDoclist ).exists() && QFileInfo( szDict ).exists() ) { g_pDocIndex->readDict(); } else { - QProgressDialog* pProgressDialog = new QProgressDialog( __tr2qs("Indexing help files"), __tr2qs("Cancel"), 0,100 ); - connect(g_pDocIndex,SIGNAL(indexingProgress(int)), pProgressDialog, SLOT(setValue(int)) ); g_pDocIndex->makeIndex(); g_pDocIndex->writeDict(); g_pDocIndex->writeDocumentList(); - delete pProgressDialog; } g_bIndexingDone=TRUE; } @@ -103,8 +100,7 @@ KviHelpWindow::KviHelpWindow(KviFrame * lpFrm,const char * name) m_pTabWidget->addTab(m_pSearchTab,__tr2qs("Search")); m_pTermsEdit = new QLineEdit(m_pSearchTab); -/* connect( m_pTermsEdit, SIGNAL( textChanged(const QString&) ), - this, SLOT( searchInIndex(const QString&) ) );*/ + connect( m_pTermsEdit, SIGNAL( returnPressed() ), this, SLOT( startSearch() ) ); @@ -142,12 +138,9 @@ void KviHelpWindow::loadProperties(KviConfig *cfg) void KviHelpWindow::refreshIndex() { m_pIndexListWidget->clear(); - QProgressDialog* pProgressDialog = new QProgressDialog( __tr2qs("Indexing help files"), __tr2qs("Cancel"), 0,100 ); - connect(g_pDocIndex,SIGNAL(indexingProgress(int)), pProgressDialog, SLOT(setValue(int)) ); g_pDocIndex->makeIndex(); g_pDocIndex->writeDict(); g_pDocIndex->writeDocumentList(); - delete pProgressDialog; g_bIndexingDone=TRUE; QStringList docList=g_pDocIndex->titlesList(); m_pIndexListWidget->addItems(docList); diff --git a/src/modules/help/helpwindow.h b/src/modules/help/helpwindow.h index 9b94e3913..e7676c64a 100644 --- a/src/modules/help/helpwindow.h +++ b/src/modules/help/helpwindow.h @@ -31,7 +31,6 @@ #include <QTabWidget> #include <QLineEdit> -#include <QProgressDialog> class QTextBrowser; class KviHelpWidget; @@ -48,7 +47,7 @@ protected: QTabWidget * m_pTabWidget; KviTalVBox * m_pIndexTab; KviTalVBox * m_pSearchTab; - + KviTalListWidget* m_pIndexListWidget; QLineEdit * m_pIndexSearch; QStringList m_foundDocs; diff --git a/src/modules/help/index.cpp b/src/modules/help/index.cpp index a9a028876..d65639e3f 100644 --- a/src/modules/help/index.cpp +++ b/src/modules/help/index.cpp @@ -29,6 +29,7 @@ #include "kvi_file.h" #include "kvi_qstring.h" #include "kvi_pointerhashtable.h" +#include "kvi_locale.h" #include <ctype.h> @@ -36,6 +37,7 @@ #include <QStringList> #include <QApplication> #include <QTextStream> +#include <QProgressDialog> int kvi_compare(const Term * p1,const Term * p2) { @@ -96,17 +98,18 @@ int Index::makeIndex() if ( docList.isEmpty() ) return 1; dict.clear(); QStringList::Iterator it = docList.begin(); - int steps = docList.count() / 100; - if ( !steps ) steps++; - int prog = 0; + +// QProgressDialog* pProgressDialog = new QProgressDialog( __tr2qs("Indexing help files"), __tr2qs("Cancel"), 0, docList.count() ); +// pProgressDialog->setWindowTitle(__tr2qs("KVIrc")); +// pProgressDialog->setMinimumDuration(500); +// pProgressDialog->setWindowModality(Qt::WindowModal); for ( int i = 0; it != docList.end(); ++it, ++i ) { - if ( lastWindowClosed ) return -1; +// if (lastWindowClosed ||pProgressDialog->wasCanceled()) +// break; parseDocument( *it, i ); - if ( i%steps == 0 ) { - prog++; - emit indexingProgress( prog ); - } +// pProgressDialog->setValue(i); } +// delete pProgressDialog; return 0; } diff --git a/src/modules/help/index.h b/src/modules/help/index.h index 791c11275..e7dbff7ad 100644 --- a/src/modules/help/index.h +++ b/src/modules/help/index.h @@ -83,8 +83,6 @@ public: void setupDocumentList(); const QStringList& documentList() { return docList; }; const QStringList& titlesList() { return titleList; }; -signals: - void indexingProgress( int ); private slots: void setLastWinClosed(); private: diff --git a/src/modules/help/libkvihelp.cpp b/src/modules/help/libkvihelp.cpp index 409984e17..556eb96f1 100644 --- a/src/modules/help/libkvihelp.cpp +++ b/src/modules/help/libkvihelp.cpp @@ -41,72 +41,6 @@ KviPointerList<KviHelpWidget> * g_pHelpWidgetList = 0; KviPointerList<KviHelpWindow> * g_pHelpWindowList = 0; /* - @doc: help.search - @type: - command - @title: - help.search - @short: - Searches the documentation - @syntax: - help.search [-n] [-m] <key terms> - @description: - Finds the first available help browser in the current frame - then searches the documentation for the specified <key terms>. - If no help browser is available it creates one first: - if the -m switch is present, the created browser is a MDI window, - otherwise it is a static window. - If the -n switch is present, the window creation is forced even - if there are other help browsers already open.[br] - The <key terms> are [b]space separated words[/b] - to be matched inside the document body (logical AND).[br] - This command is exported by the "help" module. -*/ - -/*tatic bool help_module_cmd_search(KviModule *m,KviCommand *c) -{ - ENTER_STACK_FRAME(c,"help_module_cmd_search"); - - KviStr keys; - if(!g_pZZZZZZUserParser->parseCmdFinalPart(c,keys))return false; - - if(keys.isEmpty())keys = "kvirc"; - - if(!c->hasSwitch('n')) - { - // look for an already open help widget in this frame - KviHelpWidget * w = (KviHelpWidget *)c->window()->frame()->child( - "help_widget","KviHelpWidget"); - - if(w) - { - w->doExactSearchFor(keys.ptr()); - return c->leaveStackFrame(); - } - } - - if(c->hasSwitch('m')) - { - KviHelpWindow *w = new KviHelpWindow(c->window()->frame(),"Help browser"); - w->helpWidget()->doExactSearchFor(keys.ptr()); - c->window()->frame()->addWindow(w); - } else { - KviHelpWidget *w = new KviHelpWidget(c->window()->frame()->splitter(), - c->window()->frame(),true); - w->doExactSearchFor(keys.ptr()); - w->show(); - } - - return c->leaveStackFrame(); -}*/ -/* -#ifdef COMPILE_NEW_KVS -static bool help_kvs_cmd_search(KviKvsModuleCommandCall * c) -{ -} -#endif -*/ -/* @doc: help.open @type: command @@ -123,6 +57,9 @@ static bool help_kvs_cmd_search(KviKvsModuleCommandCall * c) If no help browser is available , a new one is created. [document] can be an absolute path or a relative one: in this case the document is searched in the KVIrc documentation directory.[br] + If no document has been found using absolute and relative paths, + the first document matching [document] in the help search database + is shown. Otherway, an error page is displayed. The help browser has limited html browsing capabilities: you can use it to view simple html files on your filesystem.[br] This command is exported by the "help" module. @@ -133,6 +70,14 @@ static bool help_kvs_cmd_search(KviKvsModuleCommandCall * c) !sw: -n | --new The window creation is forced even if there are other help browsers already open.[br] + @examples: + [example] + help.open /home/pragma/myfile.html //absolute path + help.open cmd_snd.play.html //relative path + help.open "Binding operator" //keyword search, remember quoting + help.open OnNickServAuth //keyword search for an event + help.open \$my.user //keyword search, $ needs to be escaped + [/example] */ @@ -142,7 +87,7 @@ static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c) QDir dirHelp; KVSM_PARAMETERS_BEGIN(c) - KVSM_PARAMETER("document",KVS_PT_STRING,KVS_PF_OPTIONAL,szParam) + KVSM_PARAMETER("document",KVS_PT_STRING,KVS_PF_OPTIONAL | KVS_PF_APPENDREMAINING,szParam) KVSM_PARAMETERS_END(c) szDoc=szParam; @@ -153,7 +98,7 @@ static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c) if(szDoc.isEmpty()) { szDoc = dirHelp.absoluteFilePath("index.html"); - qDebug ("No file, use default at path %s",szDoc.toUtf8().data()); + //qDebug ("No file, use default at path %s",szDoc.toUtf8().data()); } // try absolute path @@ -162,14 +107,14 @@ static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c) { //try relative path szDoc = dirHelp.absoluteFilePath(szDoc); - qDebug("No abs path, trying relative path: %s",szDoc.toUtf8().data()); + //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.."); + //qDebug("No rel path, trying search.."); if(g_pDocIndex) { if (!g_pDocIndex->documentList().count()) @@ -180,6 +125,10 @@ static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c) if ( KviFileUtils::fileExists(szDoclist) && KviFileUtils::fileExists( szDict )) { g_pDocIndex->readDict(); + } else { + g_pDocIndex->makeIndex(); + g_pDocIndex->writeDict(); + g_pDocIndex->writeDocumentList(); } } int i=g_pDocIndex->titlesList().indexOf(szParam); @@ -196,7 +145,7 @@ static bool help_kvs_cmd_open(KviKvsModuleCommandCall * c) //everything failed => error szDoc = dirHelp.absoluteFilePath("nohelpavailable.html"); - qDebug("Document not found, defaulting to error page: %s",szDoc.toUtf8().data()); + //qDebug("Document not found, defaulting to error page: %s",szDoc.toUtf8().data()); f->setFile(szDoc); } |
