summaryrefslogtreecommitdiffstats
path: root/khelpcenter/htmlsearchconfig.cpp
blob: ea6dff669413dc949dac35943f8fdac37d85f3c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/**
 *  kcmhtmlsearch.cpp
 *
 *  Copyright (c) 2000 Matthias Hölzer-Klüpfel <hoelzer@kde.org>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#include <tqlayout.h>
#include <tqwhatsthis.h>

#include <kdebug.h>
#include <kstandarddirs.h>
#include <klocale.h>
#include <kurllabel.h>
#include <kapplication.h>
#include <kfiledialog.h>
#include <kurlrequester.h>
#include <klineedit.h>

#include "htmlsearchconfig.h"
#include "htmlsearchconfig.moc"

namespace KHC {

HtmlSearchConfig::HtmlSearchConfig(TQWidget *parent, const char *name)
  : TQWidget(parent, name)
{
  TQVBoxLayout *vbox = new TQVBoxLayout(this, 5);


  TQGroupBox *gb = new TQGroupBox(i18n("ht://dig"), this);
  vbox->addWidget(gb);

  TQGridLayout *grid = new TQGridLayout(gb, 3,2, 6,6);

  grid->addRowSpacing(0, gb->fontMetrics().lineSpacing());

  TQLabel *l = new TQLabel(i18n("The fulltext search feature makes use of the "
                  "ht://dig HTML search engine. "
                  "You can get ht://dig at the"), gb);
  l->setAlignment(TQLabel::WordBreak);
  l->setMinimumSize(l->sizeHint());
  grid->addMultiCellWidget(l, 1, 1, 0, 1);
  TQWhatsThis::add( gb, i18n( "Information about where to get the ht://dig package." ) );

  KURLLabel *url = new KURLLabel(gb);
  url->setURL("http://www.htdig.org");
  url->setText(i18n("ht://dig home page"));
  url->setAlignment(TQLabel::AlignHCenter);
  grid->addMultiCellWidget(url, 2,2, 0, 1);
  connect(url, TQT_SIGNAL(leftClickedURL(const TQString&)),
      this, TQT_SLOT(urlClicked(const TQString&)));

  gb = new TQGroupBox(i18n("Program Locations"), this);

  vbox->addWidget(gb);
  grid = new TQGridLayout(gb, 4,2, 6,6);
  grid->addRowSpacing(0, gb->fontMetrics().lineSpacing());

  mHtsearchUrl = new KURLRequester(gb);
  l = new TQLabel(mHtsearchUrl, i18n("htsearch:"), gb);
  l->setBuddy( mHtsearchUrl );
  grid->addWidget(l, 1,0);
  grid->addWidget(mHtsearchUrl, 1,1);
  connect( mHtsearchUrl->lineEdit(), TQT_SIGNAL( textChanged( const TQString & ) ),
           TQT_SIGNAL( changed() ) );
  TQString wtstr = i18n( "Enter the URL of the htsearch CGI program." );
  TQWhatsThis::add( mHtsearchUrl, wtstr );
  TQWhatsThis::add( l, wtstr );

  mIndexerBin = new KURLRequester(gb);
  l = new TQLabel(mIndexerBin, i18n("Indexer:"), gb);
  l->setBuddy( mIndexerBin );
  grid->addWidget(l, 2,0);
  grid->addWidget(mIndexerBin, 2,1);
  connect( mIndexerBin->lineEdit(), TQT_SIGNAL( textChanged( const TQString & ) ),
           TQT_SIGNAL( changed() ) );
  wtstr = i18n( "Enter the path to your htdig indexer program here." );
  TQWhatsThis::add( mIndexerBin, wtstr );
  TQWhatsThis::add( l, wtstr );

  mDbDir = new KURLRequester(gb);
  mDbDir->setMode( KFile::Directory | KFile::LocalOnly );
  l = new TQLabel(mDbDir, i18n("htdig database:"), gb);
  l->setBuddy( mDbDir );
  grid->addWidget(l, 3,0);
  grid->addWidget(mDbDir, 3,1);
  connect( mDbDir->lineEdit(), TQT_SIGNAL( textChanged( const TQString & ) ),
           TQT_SIGNAL( changed() ) );
  wtstr = i18n( "Enter the path to the htdig database folder." );
  TQWhatsThis::add( mDbDir, wtstr );
  TQWhatsThis::add( l, wtstr );
}

HtmlSearchConfig::~HtmlSearchConfig()
{
  kdDebug() << "~HtmlSearchConfig()" << endl;
}

void HtmlSearchConfig::makeReadOnly()
{
    mHtsearchUrl->setEnabled( false );
    mIndexerBin->setEnabled( false );
    mDbDir->setEnabled( false );
}

void HtmlSearchConfig::load( KConfig *config )
{
  config->setGroup("htdig");

  mHtsearchUrl->lineEdit()->setText(config->readPathEntry("htsearch", kapp->dirs()->findExe("htsearch")));
  mIndexerBin->lineEdit()->setText(config->readPathEntry("indexer"));
  mDbDir->lineEdit()->setText(config->readPathEntry("dbdir", "/opt/www/htdig/db/" ) );
}

void HtmlSearchConfig::save( KConfig *config )
{
  config->setGroup("htdig");

  config->writePathEntry("htsearch", mHtsearchUrl->lineEdit()->text());
  config->writePathEntry("indexer", mIndexerBin->lineEdit()->text());
  config->writePathEntry("dbdir", mDbDir->lineEdit()->text());
}

void HtmlSearchConfig::defaults()
{
    mHtsearchUrl->lineEdit()->setText(kapp->dirs()->findExe("htsearch"));
    mIndexerBin->lineEdit()->setText("");
    mDbDir->lineEdit()->setText("/opt/www/htdig/db/" );
}

void HtmlSearchConfig::urlClicked(const TQString &url)
{
  kapp->invokeBrowser(url);
}

} // End namespace KHC
// vim:ts=2:sw=2:et