diff options
author | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
---|---|---|
committer | toma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2009-11-25 17:56:58 +0000 |
commit | 4aed2c8219774f5d797760606b8489a92ddc5163 (patch) | |
tree | 3f8c130f7d269626bf6a9447407ef6c35954426a /kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp | |
download | tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.tar.gz tdebase-4aed2c8219774f5d797760606b8489a92ddc5163.zip |
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
Diffstat (limited to 'kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp')
-rw-r--r-- | kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp b/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp new file mode 100644 index 000000000..ca7161b1c --- /dev/null +++ b/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2000 Malte Starostik <malte@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 <qlabel.h> +#include <qlayout.h> +#include <qpushbutton.h> +#include <qwhatsthis.h> + +#include <kapplication.h> +#include <klocale.h> +#include <kglobal.h> +#include <kcharsets.h> +#include <klineedit.h> +#include <kcombobox.h> +#include <kmessagebox.h> + +#include "searchproviderdlg_ui.h" +#include "searchproviderdlg.h" +#include "searchprovider.h" + +SearchProviderDialog::SearchProviderDialog(SearchProvider *provider, + QWidget *parent, const char *name) + :KDialogBase(parent, name, true, QString::null, Ok|Cancel), + m_provider(provider) +{ + m_dlg = new SearchProviderDlgUI (this); + setMainWidget(m_dlg); + + enableButtonSeparator(true); + + m_dlg->leQuery->setMinimumWidth(kapp->fontMetrics().maxWidth() * 40); + + connect(m_dlg->leName, SIGNAL(textChanged(const QString &)), SLOT(slotChanged())); + connect(m_dlg->leQuery, SIGNAL(textChanged(const QString &)), SLOT(slotChanged())); + connect(m_dlg->leShortcut, SIGNAL(textChanged(const QString &)), SLOT(slotChanged())); + + // Data init + QStringList charsets = KGlobal::charsets()->availableEncodingNames(); + charsets.prepend(i18n("Default")); + m_dlg->cbCharset->insertStringList(charsets); + + if (m_provider) + { + setPlainCaption(i18n("Modify Search Provider")); + m_dlg->leName->setText(m_provider->name()); + m_dlg->leQuery->setText(m_provider->query()); + m_dlg->leShortcut->setText(m_provider->keys().join(",")); + m_dlg->cbCharset->setCurrentItem(m_provider->charset().isEmpty() ? 0 : charsets.findIndex(m_provider->charset())); + m_dlg->leName->setEnabled(false); + m_dlg->leQuery->setFocus(); + } + else + { + setPlainCaption(i18n("New Search Provider")); + m_dlg->leName->setFocus(); + enableButton(Ok, false); + } +} + +void SearchProviderDialog::slotChanged() +{ + enableButton(Ok, !(m_dlg->leName->text().isEmpty() + || m_dlg->leShortcut->text().isEmpty() + || m_dlg->leQuery->text().isEmpty())); +} + +void SearchProviderDialog::slotOk() +{ + if ((m_dlg->leQuery->text().find("\\{") == -1) + && KMessageBox::warningContinueCancel(0, + i18n("The URI does not contain a \\{...} placeholder for the user query.\n" + "This means that the same page is always going to be visited, " + "regardless of what the user types."), + QString::null, i18n("Keep It")) == KMessageBox::Cancel) + return; + + if (!m_provider) + m_provider = new SearchProvider; + m_provider->setName(m_dlg->leName->text().stripWhiteSpace()); + m_provider->setQuery(m_dlg->leQuery->text().stripWhiteSpace()); + m_provider->setKeys(QStringList::split(",", m_dlg->leShortcut->text().stripWhiteSpace())); + m_provider->setCharset(m_dlg->cbCharset->currentItem() ? m_dlg->cbCharset->currentText() : QString::null); + KDialog::accept(); +} + +#include "searchproviderdlg.moc" |