summaryrefslogtreecommitdiffstats
path: root/khelpcenter
diff options
context:
space:
mode:
Diffstat (limited to 'khelpcenter')
-rw-r--r--khelpcenter/kcmhelpcenter.cpp7
-rw-r--r--khelpcenter/kcmhelpcenter.h5
-rw-r--r--khelpcenter/navigator.cpp10
-rw-r--r--khelpcenter/searchhandlers/Makefile.am2
-rw-r--r--khelpcenter/searchhandlers/docbook.desktop4
-rw-r--r--khelpcenter/searchhandlers/khc_beagle_index.pl49
-rw-r--r--khelpcenter/searchhandlers/khc_beagle_search.pl88
7 files changed, 160 insertions, 5 deletions
diff --git a/khelpcenter/kcmhelpcenter.cpp b/khelpcenter/kcmhelpcenter.cpp
index c3b3e3094..aadce700a 100644
--- a/khelpcenter/kcmhelpcenter.cpp
+++ b/khelpcenter/kcmhelpcenter.cpp
@@ -321,6 +321,7 @@ bool KCMHelpCenter::save()
void KCMHelpCenter::load()
{
+ findWriteableIndexDir();
mIndexDirLabel->setText( Prefs::indexDirectory() );
mListView->clear();
@@ -675,6 +676,12 @@ void KCMHelpCenter::checkSelection()
enableButtonOK( count != 0 );
}
+void KCMHelpCenter::findWriteableIndexDir()
+{
+ TQFileInfo currentDir( Prefs::indexDirectory() );
+ if ( !currentDir.isWritable() )
+ Prefs::setIndexDirectory( KGlobal::dirs()->saveLocation("data", "khelpcenter/index/") );
+}
#include "kcmhelpcenter.moc"
// vim:ts=2:sw=2:et
diff --git a/khelpcenter/kcmhelpcenter.h b/khelpcenter/kcmhelpcenter.h
index 4715d1a0a..8bf2f3b6c 100644
--- a/khelpcenter/kcmhelpcenter.h
+++ b/khelpcenter/kcmhelpcenter.h
@@ -146,6 +146,11 @@ class KCMHelpCenter : public KDialogBase, virtual public KCMHelpCenterIface
void advanceProgress();
+ /**
+ * Find a user-writeable location for the indices, if the current location
+ * is not.
+ */
+ void findWriteableIndexDir();
private:
KHC::SearchEngine *mEngine;
diff --git a/khelpcenter/navigator.cpp b/khelpcenter/navigator.cpp
index 48ae76dd0..ad308cfc6 100644
--- a/khelpcenter/navigator.cpp
+++ b/khelpcenter/navigator.cpp
@@ -120,8 +120,6 @@ Navigator::Navigator( View *view, TQWidget *parent, const char *name )
mTabWidget = new TQTabWidget( this );
topLayout->addWidget( mTabWidget );
- connect( mTabWidget, TQT_SIGNAL( currentChanged( TQWidget * ) ),
- TQT_SLOT( slotTabChanged( TQWidget * ) ) );
setupContentsTab();
setupGlossaryTab();
@@ -135,6 +133,9 @@ Navigator::Navigator( View *view, TQWidget *parent, const char *name )
mSearchWidget->updateScopeList();
mSearchWidget->readConfig( KGlobal::config() );
}
+
+ connect( mTabWidget, TQT_SIGNAL( currentChanged( QWidget * ) ),
+ TQT_SLOT( slotTabChanged( QWidget * ) ) );
}
Navigator::~Navigator()
@@ -336,6 +337,11 @@ void Navigator::selectItem( const KURL &url )
item = item->nextSibling() ) {
NavigatorAppItem *appItem = dynamic_cast<NavigatorAppItem *>( item );
if ( appItem ) appItem->populate( true /* recursive */ );
+ for ( QListViewItem *subitem = item->firstChild(); subitem;
+ subitem = subitem->nextSibling() ) {
+ appItem = dynamic_cast<NavigatorAppItem *>( subitem );
+ if ( appItem ) appItem->populate( true /* recursive */ );
+ }
}
}
diff --git a/khelpcenter/searchhandlers/Makefile.am b/khelpcenter/searchhandlers/Makefile.am
index 65f4060b6..f2ebd57ff 100644
--- a/khelpcenter/searchhandlers/Makefile.am
+++ b/khelpcenter/searchhandlers/Makefile.am
@@ -3,7 +3,7 @@ searchhandlers_DATA = htdig.desktop man.desktop docbook.desktop
searchhandlersdir = $(kde_datadir)/khelpcenter/searchhandlers
kde_bin_SCRIPTS = khc_htdig.pl khc_htsearch.pl khc_mansearch.pl \
- khc_docbookdig.pl
+ khc_docbookdig.pl khc_beagle_search.pl khc_beagle_index.pl
htdigdata_DATA = htdig_long.html
diff --git a/khelpcenter/searchhandlers/docbook.desktop b/khelpcenter/searchhandlers/docbook.desktop
index 08208c187..5c6d11284 100644
--- a/khelpcenter/searchhandlers/docbook.desktop
+++ b/khelpcenter/searchhandlers/docbook.desktop
@@ -2,5 +2,5 @@
DocumentTypes=text/docbook
-SearchCommand=khc_htsearch.pl --docbook --indexdir=%d --config=%i --words=%w --method=%o --maxnum=%m --lang=en
-IndexCommand=khc_docbookdig.pl --indexdir=%d --docpath=%p --identifier=%i
+SearchCommand=khc_beagle_search.pl --method=%o --maxnum=%m %w
+IndexCommand=khc_beagle_index.pl %d %i
diff --git a/khelpcenter/searchhandlers/khc_beagle_index.pl b/khelpcenter/searchhandlers/khc_beagle_index.pl
new file mode 100644
index 000000000..02f1b9330
--- /dev/null
+++ b/khelpcenter/searchhandlers/khc_beagle_index.pl
@@ -0,0 +1,49 @@
+#!/usr/bin/perl
+# vim:sw=4:et
+
+use warnings;
+
+sub getKDEDocDir()
+{
+ my $prefix = `kde-config --prefix`;
+ chomp $prefix;
+
+ $prefix = "/opt/kde" if (not defined($prefix));
+ return "$prefix/share/doc";
+}
+
+sub addRoot()
+{
+ my $kdedocdir = &getKDEDocDir;
+
+ open (IN, "-|") || exec "beagle-config", "indexing", "ListRoots";
+
+ my $kdedoc_found = 0;
+ while(<IN>) {
+ if (/^$kdedocdir/o) {
+ $kdedoc_found = 1;
+ last;
+ }
+ }
+ close(IN);
+
+ if (not $kdedoc_found) {
+ `beagle-config indexing AddRoot $kdedocdir`;
+ `beagle-config indexing AddRoot $kdedocdir-bundle`;
+ }
+}
+
+sub createExistsFile($$)
+{
+ my ($idir, $ident) = @_;
+
+ open(OUT, ">", "$idir/$idir");
+ close(OUT);
+}
+
+my $idir = $ARGV[0];
+my $ident = $ARGV[1];
+
+if (addRoot) {
+ createExistsFile($idir, $ident);
+}
diff --git a/khelpcenter/searchhandlers/khc_beagle_search.pl b/khelpcenter/searchhandlers/khc_beagle_search.pl
new file mode 100644
index 000000000..d7a1f44b8
--- /dev/null
+++ b/khelpcenter/searchhandlers/khc_beagle_search.pl
@@ -0,0 +1,88 @@
+#!/usr/bin/perl -w
+# vim:sw=4:et
+
+use warnings;
+use strict;
+use Getopt::Long;
+
+sub isBeagleRunning()
+{
+ open(IN, "-|") || exec "beagle-ping";
+ while(<IN>) {
+ if (/^Daemon version:/) {
+ close(IN);
+ return 1;
+ }
+ }
+ close(IN);
+ return 0;
+}
+
+sub formatHTML($$)
+{
+ my ($query, $hits) = @_;
+
+ print "<html>\n<body\n<ul>\n";
+
+ foreach my $hit(@$hits) {
+ print "<li>$hit</li>\n";
+ }
+ print "</ul>\n</body>\n</html>\n";
+}
+
+sub beagleQuery($$$)
+{
+ my ($words, $method, $maxnum) = @_;
+
+ my @hits = ();
+
+ open(IN, "-|") || exec "beagle-query", "--type", "DocbookEntry", "--type", "File", "--max-hits", $maxnum, @$words, "ext:docbook";
+ while(<IN>) {
+ chop;
+ next if (/^Debug:/);
+
+ my $uri = $_;
+ $uri = $1 if ($uri =~ /^file:\/\/(.*)$/);
+
+ print "uri: $uri\n";
+ my $helpLink = &makeHelpLink($uri);
+
+ push(@hits, $helpLink) if (!grep { /^$helpLink$/ } @hits);
+ }
+ close(IN);
+ return @hits;
+}
+
+sub makeHelpLink($)
+{
+ # Try to figure out the name of the application from the path to its index.docbook file
+
+ my ($path) = @_;
+ my @pathcomponents = split '/', $path;
+
+ my $appName = $pathcomponents[-2];
+ my $appName2 = $pathcomponents[-3];
+
+ if ($appName eq $appName2 or $appName2 eq "doc"
+ or (-d "/usr/share/locale/$appName2")) {
+ return "<a href=\"help:/$appName\">$appName</a>";
+ }
+ return "<a href=\"help:/$appName2/$appName\">$appName ($appName2)</a>";
+}
+
+my $method = "and";
+my $maxnum = 100;
+
+GetOptions("method=s", \$method, "maxnum=i", \$maxnum);
+
+my @hits = ("The Beagle daemon is not running, search is not available");
+
+my @words = @ARGV;
+
+if (isBeagleRunning()) {
+ @hits = beagleQuery(\@words, $method, $maxnum);
+}
+
+@hits = ("There are no search results") if ($#hits < 0);
+
+formatHTML(\@words, \@hits);