From 2299e240fd82e6d9724aff7dc6e0a4f43602c7d4 Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 26 Sep 2008 11:52:12 +0000 Subject: 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 --- src/modules/help/helpwindow.cpp | 9 +--- src/modules/help/helpwindow.h | 3 +- src/modules/help/index.cpp | 19 +++++---- src/modules/help/index.h | 2 - src/modules/help/libkvihelp.cpp | 91 +++++++++-------------------------------- 5 files changed, 33 insertions(+), 91 deletions(-) (limited to 'src/modules') 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 #include -#include 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 @@ -36,6 +37,7 @@ #include #include #include +#include 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 @@ -40,72 +40,6 @@ Index * g_pDocIndex = 0; KviPointerList * g_pHelpWidgetList = 0; KviPointerList * g_pHelpWindowList = 0; -/* - @doc: help.search - @type: - command - @title: - help.search - @short: - Searches the documentation - @syntax: - help.search [-n] [-m] - @description: - Finds the first available help browser in the current frame - then searches the documentation for the specified . - 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 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: @@ -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); } -- cgit v1.3.1-10-gc9f91