4 * Copyright (c) 2000 Matthias Hölzer-Klüpfel <hoelzer@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "htmlsearchconfig.h"
26 #include <QVBoxLayout>
27 #include <QGridLayout>
30 #include <kstandarddirs.h>
32 #include <kurllabel.h>
33 #include <kapplication.h>
34 #include <kfiledialog.h>
35 #include <kurlrequester.h>
36 #include <klineedit.h>
37 #include <ktoolinvocation.h>
41 HtmlSearchConfig::HtmlSearchConfig(QWidget
*parent
, const char *name
)
44 setObjectName( name
);
46 QVBoxLayout
*vbox
= new QVBoxLayout(this);
50 QGroupBox
*gb
= new QGroupBox(i18n("ht://dig"), this);
53 QGridLayout
*grid
= new QGridLayout(gb
);
55 grid
->setSpacing( 6 );
57 grid
->addItem( new QSpacerItem( 0, gb
->fontMetrics().lineSpacing() ), 0, 0 );
59 QLabel
*l
= new QLabel(i18n("The fulltext search feature makes use of the "
60 "ht://dig HTML search engine."), gb
);
61 l
->setMinimumSize(l
->sizeHint());
62 grid
->addWidget(l
, 1, 1, 0, 1);
63 gb
->setWhatsThis( i18n( "Information about where to get the ht://dig package." ) );
65 KUrlLabel
*url
= new KUrlLabel(gb
);
66 url
->setUrl(QLatin1String("http://www.htdig.org"));
67 url
->setText(i18n("You can get ht://dig at the ht://dig home page"));
68 url
->setAlignment(Qt::AlignHCenter
);
69 grid
->addWidget(url
, 2,2, 0, 1);
70 connect(url
, SIGNAL(leftClickedUrl(const QString
&)),
71 this, SLOT(urlClicked(const QString
&)));
73 gb
= new QGroupBox(i18n("Program Locations"), this);
76 grid
= new QGridLayout(gb
);
78 grid
->setSpacing( 6 );
79 grid
->addItem( new QSpacerItem( 0, gb
->fontMetrics().lineSpacing() ), 0, 0 );
81 mHtsearchUrl
= new KUrlRequester(gb
);
82 l
= new QLabel(i18n("htsearch:"), gb
);
83 l
->setBuddy( mHtsearchUrl
);
84 grid
->addWidget(l
, 1,0);
85 grid
->addWidget(mHtsearchUrl
, 1,1);
86 connect( mHtsearchUrl
->lineEdit(), SIGNAL( textChanged( const QString
& ) ),
87 SIGNAL( changed() ) );
88 QString wtstr
= i18n( "Enter the URL of the htsearch CGI program." );
89 mHtsearchUrl
->setWhatsThis( wtstr
);
90 l
->setWhatsThis( wtstr
);
92 mIndexerBin
= new KUrlRequester(gb
);
93 l
= new QLabel(i18n("Indexer:"), gb
);
94 l
->setBuddy( mIndexerBin
);
95 grid
->addWidget(l
, 2,0);
96 grid
->addWidget(mIndexerBin
, 2,1);
97 connect( mIndexerBin
->lineEdit(), SIGNAL( textChanged( const QString
& ) ),
98 SIGNAL( changed() ) );
99 wtstr
= i18n( "Enter the path to your htdig indexer program here." );
100 mIndexerBin
->setWhatsThis( wtstr
);
101 l
->setWhatsThis( wtstr
);
103 mDbDir
= new KUrlRequester(gb
);
104 mDbDir
->setMode( KFile::Directory
| KFile::LocalOnly
);
105 l
= new QLabel(i18n("htdig database:"), gb
);
106 l
->setBuddy( mDbDir
);
107 grid
->addWidget(l
, 3,0);
108 grid
->addWidget(mDbDir
, 3,1);
109 connect( mDbDir
->lineEdit(), SIGNAL( textChanged( const QString
& ) ),
110 SIGNAL( changed() ) );
111 wtstr
= i18n( "Enter the path to the htdig database folder." );
112 mDbDir
->setWhatsThis( wtstr
);
113 l
->setWhatsThis( wtstr
);
116 HtmlSearchConfig::~HtmlSearchConfig()
118 kDebug() << "~HtmlSearchConfig()";
121 void HtmlSearchConfig::makeReadOnly()
123 mHtsearchUrl
->setEnabled( false );
124 mIndexerBin
->setEnabled( false );
125 mDbDir
->setEnabled( false );
128 void HtmlSearchConfig::load( KConfig
*config
)
130 mHtsearchUrl
->lineEdit()->setText(config
->group("htdig").readPathEntry("htsearch", KGlobal::mainComponent().dirs()->findExe("htsearch")));
131 mIndexerBin
->lineEdit()->setText(config
->group("htdig").readPathEntry("indexer", QString()));
132 mDbDir
->lineEdit()->setText(config
->group("htdig").readPathEntry("dbdir", "/opt/www/htdig/db/" ) );
135 void HtmlSearchConfig::save( KConfig
*config
)
137 config
->group("htdig").writePathEntry("htsearch", mHtsearchUrl
->lineEdit()->text());
138 config
->group("htdig").writePathEntry("indexer", mIndexerBin
->lineEdit()->text());
139 config
->group("htdig").writePathEntry("dbdir", mDbDir
->lineEdit()->text());
142 void HtmlSearchConfig::defaults()
144 mHtsearchUrl
->lineEdit()->setText(KGlobal::mainComponent().dirs()->findExe("htsearch"));
145 mIndexerBin
->lineEdit()->setText("");
146 mDbDir
->lineEdit()->setText(QLatin1String("/opt/www/htdig/db/") );
149 void HtmlSearchConfig::urlClicked(const QString
&url
)
151 KToolInvocation::invokeBrowser(url
);
154 } // End namespace KHC
157 #include "htmlsearchconfig.moc"