From 4aed2c8219774f5d797760606b8489a92ddc5163 Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- khelpcenter/htmlsearch.cpp | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 khelpcenter/htmlsearch.cpp (limited to 'khelpcenter/htmlsearch.cpp') 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 +#include + +#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 -- cgit v1.2.1