summaryrefslogtreecommitdiffstats
path: root/khelpcenter/htmlsearch.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'khelpcenter/htmlsearch.cpp')
-rw-r--r--khelpcenter/htmlsearch.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/khelpcenter/htmlsearch.cpp b/khelpcenter/htmlsearch.cpp
new file mode 100644
index 000000000..9c469ae88
--- /dev/null
+++ b/khelpcenter/htmlsearch.cpp
@@ -0,0 +1,61 @@
+#include <kdebug.h>
+#include <kconfig.h>
+
+#include "docentry.h"
+
+#include "htmlsearch.h"
+#include "htmlsearch.moc"
+
+using namespace KHC;
+
+HTMLSearch::HTMLSearch()
+{
+ mConfig = new KConfig("khelpcenterrc", true);
+ mConfig->setGroup( "htdig" );
+}
+
+HTMLSearch::~HTMLSearch()
+{
+ delete mConfig;
+}
+
+void HTMLSearch::setupDocEntry( KHC::DocEntry *entry )
+{
+// kdDebug() << "HTMLSearch::setupDocEntry(): " << entry->name() << endl;
+
+ if ( entry->searchMethod().lower() != "htdig" ) return;
+
+ if ( entry->search().isEmpty() )
+ entry->setSearch( defaultSearch( entry ) );
+ if ( entry->indexer().isEmpty() )
+ entry->setIndexer( defaultIndexer( entry ) );
+ if ( entry->indexTestFile().isEmpty() )
+ entry->setIndexTestFile( defaultIndexTestFile( entry ) );
+
+// entry->dump();
+}
+
+QString HTMLSearch::defaultSearch( KHC::DocEntry *entry )
+{
+ QString htsearch = "cgi:";
+ htsearch += mConfig->readPathEntry( "htsearch" );
+ htsearch += "?words=%k&method=and&format=-desc&config=";
+ htsearch += entry->identifier();
+
+ return htsearch;
+}
+
+QString HTMLSearch::defaultIndexer( KHC::DocEntry * )
+{
+ QString indexer = mConfig->readPathEntry( "indexer" );
+ indexer += " --indexdir=%i %f";
+
+ return indexer;
+}
+
+QString HTMLSearch::defaultIndexTestFile( KHC::DocEntry *entry )
+{
+ return entry->identifier() + ".exists";
+}
+
+// vim:ts=2:sw=2:et