aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/help
diff options
context:
space:
mode:
authorGravatar Fabio Bas2008-09-26 11:52:12 +0000
committerGravatar Fabio Bas2008-09-26 11:52:12 +0000
commit2299e240fd82e6d9724aff7dc6e0a4f43602c7d4 (patch)
tree75fd798dae366309a6f5ad81110ae589584ec813 /src/modules/help
parentWin VS projects cleanup. (diff)
downloadKVIrc-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/modules/help')
-rw-r--r--src/modules/help/helpwindow.cpp9
-rw-r--r--src/modules/help/helpwindow.h3
-rw-r--r--src/modules/help/index.cpp19
-rw-r--r--src/modules/help/index.h2
-rw-r--r--src/modules/help/libkvihelp.cpp91
5 files changed, 33 insertions, 91 deletions
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);
}