summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilippe Mavridis <philippe.mavridis@yandex.com>2025-11-22 14:13:01 +0200
committerPhilippe Mavridis <philippe.mavridis@yandex.com>2026-01-02 11:34:45 +0200
commit59e49db8870a64a2eca80e6271c1aac1553761b3 (patch)
treed0dabaf534cfe54a5aad38f876e981c536220538
parentbe5a0967f061e5c8f197fc95b090dbf52b05feed (diff)
downloadtdebase-feat/searchproviders-update-2025.tar.gz
tdebase-feat/searchproviders-update-2025.zip
Web Shortcuts: add support for groupsfeat/searchproviders-update-2025
The web shortcuts can now be displayed in groups based on their category (Web, Images, Development, etc.). The user can modify the category of an item by picking one of the built-in categories or creating custom groups by providing a different category name. When the category groups are hidden, the user can still see the categories appear in a third column in the list view. This commit also updates the search engines enabled by default to some sensible defaults and makes the minimum size of the dialog smaller. Signed-off-by: Philippe Mavridis <philippe.mavridis@yandex.com>
-rw-r--r--kcontrol/ebrowsing/plugins/ikws/ikwsopts.cpp192
-rw-r--r--kcontrol/ebrowsing/plugins/ikws/ikwsopts.h8
-rw-r--r--kcontrol/ebrowsing/plugins/ikws/ikwsopts_ui.ui449
-rw-r--r--kcontrol/ebrowsing/plugins/ikws/searchprovider.cpp52
-rw-r--r--kcontrol/ebrowsing/plugins/ikws/searchprovider.h27
-rw-r--r--kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp18
-rw-r--r--kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.h3
-rw-r--r--kcontrol/ebrowsing/plugins/ikws/searchproviderdlg_ui.ui29
8 files changed, 534 insertions, 244 deletions
diff --git a/kcontrol/ebrowsing/plugins/ikws/ikwsopts.cpp b/kcontrol/ebrowsing/plugins/ikws/ikwsopts.cpp
index 622cec32c..f5e15b6ad 100644
--- a/kcontrol/ebrowsing/plugins/ikws/ikwsopts.cpp
+++ b/kcontrol/ebrowsing/plugins/ikws/ikwsopts.cpp
@@ -49,6 +49,30 @@
#include "searchproviderdlg.h"
+class CategoryItem : public TQListViewItem
+{
+ public:
+ CategoryItem(TQListView *parent, TQString category)
+ : TQListViewItem(parent), m_category(category)
+ {
+ if (category.isNull())
+ m_category = "Misc";
+
+ setText(0, displayName());
+ }
+
+ const TQString& key() const { return m_category; }
+
+ const TQString& displayName() const
+ {
+ return SearchProvider::searchCategoryName(m_category);
+ }
+
+ private:
+ TQString m_category;
+};
+
+
class SearchProviderItem : public TQCheckListItem
{
public:
@@ -84,7 +108,7 @@ FilterOptions::FilterOptions(TDEInstance *instance, TQWidget *parent, const char
m_dlg = new FilterOptionsUI (this);
mainLayout->addWidget(m_dlg);
- m_dlg->lvSearchProviders->header()->setLabel(0, SmallIconSet("bookmark"),i18n("Name"));
+ m_dlg->lvSearchProviders->header()->setLabel(0, SmallIconSet("bookmark"), i18n("Name"));
m_dlg->lvSearchProviders->setSorting(0);
// Load the options
@@ -123,7 +147,7 @@ void FilterOptions::load( bool useDefaults )
TQString defaultSearchEngine = config.readEntry("DefaultSearchEngine");
m_favoriteEngines.clear();
- m_favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia";
+ m_favoriteEngines << "duckduckgo" << "wikipedia_en";
m_favoriteEngines = config.readListEntry("FavoriteSearchEngines", m_favoriteEngines);
const TDETrader::OfferList services = TDETrader::self()->query("SearchProvider");
@@ -151,6 +175,8 @@ void FilterOptions::load( bool useDefaults )
TQ_SLOT(setWebShortcutState()));
connect(m_dlg->cbEnableShortcuts, TQ_SIGNAL(clicked()), this,
TQ_SLOT(configChanged()));
+ connect(m_dlg->cbCategories, TQ_SIGNAL(toggled(bool)), this,
+ TQ_SLOT(setCategoriesShown(bool)));
connect(m_dlg->lvSearchProviders, TQ_SIGNAL(selectionChanged(TQListViewItem *)),
this, TQ_SLOT(updateSearchProvider()));
@@ -166,6 +192,10 @@ void FilterOptions::load( bool useDefaults )
this, TQ_SLOT(checkFavoritesChanged()));
connect(m_dlg->lvSearchProviders, TQ_SIGNAL(clicked(TQListViewItem *)),
this, TQ_SLOT(checkFavoritesChanged()));
+ connect(m_dlg->lvSearchProviders, TQ_SIGNAL(expanded(TQListViewItem *)),
+ this, TQ_SLOT(adjustColumns()));
+ connect(m_dlg->lvSearchProviders, TQ_SIGNAL(collapsed(TQListViewItem *)),
+ this, TQ_SLOT(adjustColumns()));
connect(m_dlg->cmbDefaultEngine, TQ_SIGNAL(activated(const TQString &)), this,
@@ -177,6 +207,8 @@ void FilterOptions::load( bool useDefaults )
connect(m_dlg->pbChange, TQ_SIGNAL(clicked()), this, TQ_SLOT(changeSearchProvider()));
connect(m_dlg->pbDelete, TQ_SIGNAL(clicked()), this, TQ_SLOT(deleteSearchProvider()));
+ adjustColumns();
+ updateSearchProvider();
emit changed( useDefaults );
}
@@ -230,8 +262,7 @@ void FilterOptions::save()
for (TQListViewItemIterator it(m_dlg->lvSearchProviders); it.current(); ++it)
{
SearchProviderItem *item = dynamic_cast<SearchProviderItem *>(it.current());
-
- Q_ASSERT(item);
+ if (!item) continue;
SearchProvider *provider = item->provider();
@@ -281,6 +312,7 @@ void FilterOptions::save()
service.writeEntry("Name", provider->name());
service.writeEntry("Query", provider->query(), true, false, true);
service.writeEntry("Keys", provider->keys());
+ service.writeEntry("Category", provider->category());
service.writeEntry("Charset", provider->charset());
// we might be overwriting a hidden entry
@@ -342,8 +374,7 @@ void FilterOptions::checkFavoritesChanged()
for (TQListViewItemIterator it(m_dlg->lvSearchProviders); it.current(); ++it)
{
SearchProviderItem *item = dynamic_cast<SearchProviderItem *>(it.current());
-
- Q_ASSERT(item);
+ if (!item) continue;
if (item->isOn())
currentFavoriteEngines << item->provider()->desktopEntryName();
@@ -368,26 +399,138 @@ void FilterOptions::setWebShortcutState()
m_dlg->cmbDefaultEngine->setEnabled (use_keywords);
}
+void FilterOptions::adjustColumns()
+{
+ m_dlg->lvSearchProviders->adjustColumn(1);
+ m_dlg->lvSearchProviders->adjustColumn(2);
+}
+
+void FilterOptions::setCategoriesShown(bool shown)
+{
+ if (shown)
+ {
+ m_dlg->lvSearchProviders->removeColumn(2);
+ }
+ else
+ {
+ m_dlg->lvSearchProviders->addColumn(i18n("Category"));
+ adjustColumns();
+ }
+
+ // Move search provider items between the list root and the appropriate
+ // category items.
+ TQListViewItemIterator it(m_dlg->lvSearchProviders);
+ while (it.current())
+ {
+ SearchProviderItem *sp = dynamic_cast<SearchProviderItem*>(it.current());
+ ++it;
+
+ if (!sp) continue;
+
+ TQString category = sp->provider()->category();
+
+ if (shown)
+ {
+ if (sp->depth() > 0) continue;
+
+ if (!m_categories.contains(category))
+ {
+ m_categories[category] = new CategoryItem(m_dlg->lvSearchProviders, category);
+ }
+
+ m_dlg->lvSearchProviders->takeItem(sp);
+ m_categories[category]->insertItem(sp);
+ }
+ else
+ {
+ if (sp->depth() < 1) continue;
+
+ sp->parent()->takeItem(sp);
+ m_dlg->lvSearchProviders->insertItem(sp);
+
+ sp->setText(2, category);
+ }
+ }
+
+ // Delete category items if no longer needed
+ if (!shown)
+ {
+ TQListViewItem *item = m_dlg->lvSearchProviders->firstChild();
+ TQListViewItem *next;
+ do
+ {
+ next = item->nextSibling();
+ if (dynamic_cast<CategoryItem *>(item))
+ delete item;
+ }
+ while (item = next);
+ m_categories.clear();
+ }
+
+ m_dlg->lvSearchProviders->adjustColumn(0);
+ m_dlg->lvSearchProviders->setTreeStepSize(shown ? 20 : 0);
+ m_dlg->lvSearchProviders->sort();
+}
+
+const TQString& FilterOptions::getCurrentCategory()
+{
+ TQListViewItem *item = m_dlg->lvSearchProviders->currentItem();
+ if (!item) return TQString::null;
+
+ CategoryItem *cat = dynamic_cast<CategoryItem*>(item);
+ if (cat) return cat->key();
+
+ SearchProviderItem *sp = dynamic_cast<SearchProviderItem*>(item);
+ if (sp) return sp->provider()->category();
+
+ return TQString::null;
+}
+
void FilterOptions::addSearchProvider()
{
- SearchProviderDialog dlg(0, this);
- if (dlg.exec())
- {
- m_dlg->lvSearchProviders->setSelected(displaySearchProvider(dlg.provider()), true);
- configChanged();
- }
+ SearchProviderDialog dlg(0, getCurrentCategory(), this);
+ if (dlg.exec())
+ {
+ m_dlg->lvSearchProviders->setSelected(displaySearchProvider(dlg.provider()), true);
+ configChanged();
+ }
}
void FilterOptions::changeSearchProvider()
{
SearchProviderItem *item = dynamic_cast<SearchProviderItem *>(m_dlg->lvSearchProviders->currentItem());
- Q_ASSERT(item);
+ if (!item) return;
- SearchProviderDialog dlg(item->provider(), this);
+ SearchProviderDialog dlg(item->provider(), item->provider()->category(), this);
if (dlg.exec())
{
m_dlg->lvSearchProviders->setSelected(displaySearchProvider(dlg.provider()), true);
+
+ if (m_dlg->cbCategories->isChecked())
+ {
+ // check if we need to move the item to another category
+ CategoryItem *category = static_cast<CategoryItem*>(item->parent());
+
+ if (category->key() != dlg.provider()->category())
+ {
+ TQString c = dlg.provider()->category();
+ if (!m_categories.contains(c))
+ {
+ m_categories[c] = new CategoryItem(m_dlg->lvSearchProviders, c);
+ }
+ CategoryItem *newCategory = m_categories[c];
+
+ category->takeItem(item);
+ newCategory->insertItem(item);
+
+ if (category->childCount() < 1)
+ {
+ delete category;
+ }
+ }
+ }
+
configChanged();
}
}
@@ -395,7 +538,7 @@ void FilterOptions::changeSearchProvider()
void FilterOptions::deleteSearchProvider()
{
SearchProviderItem *item = dynamic_cast<SearchProviderItem *>(m_dlg->lvSearchProviders->currentItem());
- Q_ASSERT(item);
+ if (!item) return;
// Update the combo box to go to None if the fallback was deleted.
int current = m_dlg->cmbDefaultEngine->currentItem();
@@ -428,14 +571,15 @@ void FilterOptions::deleteSearchProvider()
void FilterOptions::updateSearchProvider()
{
- m_dlg->pbChange->setEnabled(m_dlg->lvSearchProviders->currentItem());
- m_dlg->pbDelete->setEnabled(m_dlg->lvSearchProviders->currentItem());
+ SearchProviderItem *item = dynamic_cast<SearchProviderItem*>(m_dlg->lvSearchProviders->currentItem());
+ m_dlg->pbChange->setEnabled(item);
+ m_dlg->pbDelete->setEnabled(item);
}
SearchProviderItem *FilterOptions::displaySearchProvider(SearchProvider *p, bool fallback)
{
// Show the provider in the list.
- SearchProviderItem *item = 0L;
+ SearchProviderItem *item = nullptr;
TQListViewItemIterator it(m_dlg->lvSearchProviders);
@@ -444,7 +588,6 @@ SearchProviderItem *FilterOptions::displaySearchProvider(SearchProvider *p, bool
if (it.current()->text(0) == p->name())
{
item = dynamic_cast<SearchProviderItem *>(it.current());
- Q_ASSERT(item);
break;
}
}
@@ -459,6 +602,17 @@ SearchProviderItem *FilterOptions::displaySearchProvider(SearchProvider *p, bool
item = new SearchProviderItem(m_dlg->lvSearchProviders, p);
+ if (m_dlg->cbCategories->isChecked())
+ {
+ if (!m_categories.contains(p->category()))
+ {
+ m_categories[p->category()] = new CategoryItem(m_dlg->lvSearchProviders, p->category());
+ }
+
+ m_dlg->lvSearchProviders->takeItem(item);
+ m_categories[p->category()]->insertItem(item);
+ }
+
if (m_favoriteEngines.find(p->desktopEntryName())!=m_favoriteEngines.end())
item->setOn(true);
diff --git a/kcontrol/ebrowsing/plugins/ikws/ikwsopts.h b/kcontrol/ebrowsing/plugins/ikws/ikwsopts.h
index 661a3abb0..1304ce8ae 100644
--- a/kcontrol/ebrowsing/plugins/ikws/ikwsopts.h
+++ b/kcontrol/ebrowsing/plugins/ikws/ikwsopts.h
@@ -29,6 +29,7 @@
class FilterOptionsUI;
class SearchProvider;
class SearchProviderItem;
+class CategoryItem;
class FilterOptions : public TDECModule
{
@@ -43,11 +44,17 @@ public:
void defaults();
TQString quickHelp() const;
+protected:
+ const TQString& getCurrentCategory();
+
protected slots:
void configChanged();
void checkFavoritesChanged();
void setWebShortcutState();
+ void setCategoriesShown(bool shown);
+
+ void adjustColumns();
void addSearchProvider();
void changeSearchProvider();
@@ -64,6 +71,7 @@ private:
// these are marked as deleted in the user's homedirectory
// on save if a global service file exists for it.
TQStringList m_deletedProviders;
+ TQMap <TQString, CategoryItem*> m_categories;
TQMap <TQString, TQString> m_defaultEngineMap;
TQStringList m_favoriteEngines;
diff --git a/kcontrol/ebrowsing/plugins/ikws/ikwsopts_ui.ui b/kcontrol/ebrowsing/plugins/ikws/ikwsopts_ui.ui
index 3c5fd2e3b..c4ee4f3da 100644
--- a/kcontrol/ebrowsing/plugins/ikws/ikwsopts_ui.ui
+++ b/kcontrol/ebrowsing/plugins/ikws/ikwsopts_ui.ui
@@ -1,4 +1,4 @@
-<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
<class>FilterOptionsUI</class>
<widget class="TQWidget">
<property name="name">
@@ -8,18 +8,21 @@
<rect>
<x>0</x>
<y>0</y>
- <width>360</width>
- <height>327</height>
+ <width>371</width>
+ <height>355</height>
</rect>
</property>
- <vbox>
+ <property name="caption">
+ <string>FilterOptionsUI</string>
+ </property>
+ <grid>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
- <number>0</number>
+ <number>5</number>
</property>
- <widget class="TQCheckBox">
+ <widget class="TQCheckBox" row="0" column="0" rowspan="1" colspan="3">
<property name="name">
<cstring>cbEnableShortcuts</cstring>
</property>
@@ -32,218 +35,241 @@ Enable shortcuts that allow you to quickly search for information on the web. Fo
&lt;/qt&gt;</string>
</property>
</widget>
- <widget class="TQLayoutWidget">
+ <widget class="TQPushButton" row="2" column="2">
+ <property name="name">
+ <cstring>pbChange</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Chan&amp;ge...</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Modify a search provider.</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="3" column="2">
+ <property name="name">
+ <cstring>pbDelete</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>De&amp;lete</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Delete the selected search provider.</string>
+ </property>
+ </widget>
+ <widget class="TQPushButton" row="1" column="2">
+ <property name="name">
+ <cstring>pbNew</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;New...</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Add a search provider.</string>
+ </property>
+ </widget>
+ <widget class="TQCheckBox" row="5" column="0" rowspan="1" colspan="2">
<property name="name">
- <cstring>layout10</cstring>
+ <cstring>cbCategories</cstring>
</property>
- <grid>
- <property name="name">
- <cstring>unnamed</cstring>
+ <property name="text">
+ <string>Show grouped in &amp;categories</string>
+ </property>
+ <property name="accel">
+ <string>Alt+C</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;
+ If checked, the search providers will be shown grouped by category (Web Search, Images, etc.). Otherwise, all the engines are shown ungrouped in alphabetic order.
+ &lt;/qt&gt;</string>
+ </property>
+ </widget>
+ <spacer row="4" column="2">
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>21</width>
+ <height>150</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="Line" row="6" column="0" rowspan="1" colspan="3">
+ <property name="name">
+ <cstring>line1</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="7" column="1" rowspan="1" colspan="2">
+ <item>
+ <property name="text">
+ <string>None</string>
</property>
- <widget class="TQLabel" row="5" column="0">
- <property name="name">
- <cstring>lbDelimiter</cstring>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>5</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>&amp;Keyword delimiter:</string>
- </property>
- <property name="buddy" stdset="0">
- <cstring>cmbDelimiter</cstring>
- </property>
- <property name="whatsThis" stdset="0">
- <string>Choose the delimiter that separates the keyword from the phrase or word to be searched.</string>
- </property>
- </widget>
- <widget class="TQLabel" row="4" column="0">
- <property name="name">
- <cstring>lbDefaultEngine</cstring>
- </property>
- <property name="enabled">
- <bool>true</bool>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>5</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="text">
- <string>Default &amp;search engine:</string>
- </property>
- <property name="buddy" stdset="0">
- <cstring>cmbDefaultEngine</cstring>
- </property>
- <property name="whatsThis" stdset="0">
- <string>&lt;qt&gt;
+ </item>
+ <property name="name">
+ <cstring>cmbDefaultEngine</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;
Select the search engine to use for input boxes that provide automatic lookup services when you type in normal words and phrases instead of a URL. To disable this feature select &lt;b&gt;None&lt;/b&gt; from the list.
&lt;/qt&gt;</string>
- </property>
- </widget>
- <widget class="KComboBox" row="4" column="1">
- <item>
- <property name="text">
- <string>None</string>
- </property>
- </item>
- <property name="name">
- <cstring>cmbDefaultEngine</cstring>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="whatsThis" stdset="0">
- <string>&lt;qt&gt;
+ </property>
+ </widget>
+ <widget class="TQLabel" row="7" column="0">
+ <property name="name">
+ <cstring>lbDefaultEngine</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Default &amp;search engine:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cmbDefaultEngine</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;qt&gt;
Select the search engine to use for input boxes that provide automatic lookup services when you type in normal words and phrases instead of a URL. To disable this feature select &lt;b&gt;None&lt;/b&gt; from the list.
&lt;/qt&gt;</string>
- </property>
- </widget>
- <widget class="TQPushButton" row="1" column="2">
- <property name="name">
- <cstring>pbChange</cstring>
- </property>
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>Chan&amp;ge...</string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>Modify a search provider.</string>
- </property>
- </widget>
- <widget class="TQPushButton" row="2" column="2">
- <property name="name">
- <cstring>pbDelete</cstring>
- </property>
- <property name="enabled">
- <bool>false</bool>
- </property>
- <property name="text">
- <string>De&amp;lete</string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>Delete the selected search provider.</string>
- </property>
- </widget>
- <widget class="TQPushButton" row="0" column="2">
- <property name="name">
- <cstring>pbNew</cstring>
- </property>
- <property name="text">
- <string>&amp;New...</string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>Add a search provider.</string>
- </property>
- </widget>
- <spacer row="3" column="2" rowspan="3" colspan="1">
- <property name="name">
- <cstring>spacer1</cstring>
- </property>
- <property name="orientation">
- <enum>Vertical</enum>
- </property>
- <property name="sizeType">
- <enum>Expanding</enum>
- </property>
- <property name="sizeHint">
- <size>
- <width>21</width>
- <height>170</height>
- </size>
- </property>
- </spacer>
- <widget class="TDEListView" row="0" column="0" rowspan="4" colspan="2">
- <column>
- <property name="text">
- <string>Name</string>
- </property>
- <property name="clickable">
- <bool>true</bool>
- </property>
- <property name="resizable">
- <bool>true</bool>
- </property>
- </column>
- <column>
- <property name="text">
- <string>Shortcuts</string>
- </property>
- <property name="clickable">
- <bool>true</bool>
- </property>
- <property name="resizable">
- <bool>true</bool>
- </property>
- </column>
- <property name="name">
- <cstring>lvSearchProviders</cstring>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>5</vsizetype>
- <horstretch>1</horstretch>
- <verstretch>1</verstretch>
- </sizepolicy>
- </property>
- <property name="showSortIndicator">
- <bool>true</bool>
- </property>
- <property name="resizeMode">
- <enum>AllColumns</enum>
- </property>
- <property name="treeStepSize">
- <number>0</number>
- </property>
- <property name="whatsThis" stdset="0">
- <string>List of search providers, their associated shortcuts and whether they shall be listed in menus.</string>
- </property>
- </widget>
- <widget class="KComboBox" row="5" column="1">
- <item>
- <property name="text">
- <string>Colon</string>
- </property>
- </item>
- <item>
- <property name="text">
- <string>Space</string>
- </property>
- </item>
- <property name="name">
- <cstring>cmbDelimiter</cstring>
- </property>
- <property name="sizePolicy">
- <sizepolicy>
- <hsizetype>5</hsizetype>
- <vsizetype>0</vsizetype>
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
- <property name="whatsThis" stdset="0">
- <string>Choose the delimiter that separates the keyword from the phrase or word to be searched.</string>
- </property>
- </widget>
- </grid>
+ </property>
+ </widget>
+ <widget class="TQLabel" row="8" column="0">
+ <property name="name">
+ <cstring>lbDelimiter</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&amp;Keyword delimiter:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cmbDelimiter</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Choose the delimiter that separates the keyword from the phrase or word to be searched.</string>
+ </property>
</widget>
- </vbox>
+ <widget class="KComboBox" row="8" column="1" rowspan="1" colspan="2">
+ <item>
+ <property name="text">
+ <string>Colon</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Space</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>cmbDelimiter</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Choose the delimiter that separates the keyword from the phrase or word to be searched.</string>
+ </property>
+ </widget>
+ <widget class="TDEListView" row="1" column="0" rowspan="4" colspan="2">
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Shortcuts</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>lvSearchProviders</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="showSortIndicator">
+ <bool>true</bool>
+ </property>
+ <property name="resizeMode">
+ <enum>AllColumns</enum>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>List of search providers, their associated shortcuts and whether they shall be listed in menus.</string>
+ </property>
+ </widget>
+ </grid>
</widget>
<tabstops>
<tabstop>cbEnableShortcuts</tabstop>
@@ -254,8 +280,9 @@ Select the search engine to use for input boxes that provide automatic lookup se
<tabstop>cmbDefaultEngine</tabstop>
<tabstop>cmbDelimiter</tabstop>
</tabstops>
-<layoutdefaults spacing="6" margin="11"/>
<includes>
<include location="global" impldecl="in implementation">kcombobox.h</include>
+ <include location="global" impldecl="in implementation">tdelistview.h</include>
</includes>
+<layoutdefaults spacing="6" margin="11"/>
</UI>
diff --git a/kcontrol/ebrowsing/plugins/ikws/searchprovider.cpp b/kcontrol/ebrowsing/plugins/ikws/searchprovider.cpp
index f2cbdfc6f..eff7727ff 100644
--- a/kcontrol/ebrowsing/plugins/ikws/searchprovider.cpp
+++ b/kcontrol/ebrowsing/plugins/ikws/searchprovider.cpp
@@ -16,10 +16,13 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
+#include <tdelocale.h>
#include <ktrader.h>
#include "searchprovider.h"
+SearchCategoryMap SearchProvider::searchCategories;
+
SearchProvider::SearchProvider(const KService::Ptr service)
: m_dirty(false)
{
@@ -28,6 +31,27 @@ SearchProvider::SearchProvider(const KService::Ptr service)
m_query = service->property("Query").toString();
m_keys = service->property("Keys").toStringList();
m_charset = service->property("Charset").toString();
+ m_category = service->property("Category", TQVariant::String).toString();
+
+ if (!searchCategories.count())
+ {
+ initSearchCategories();
+ }
+}
+
+void SearchProvider::initSearchCategories()
+{
+ searchCategories["Web"] = i18n("Web Search");
+ searchCategories["Dictionaries"] = i18n("Dictionaries");
+ searchCategories["Images"] = i18n("Images");
+ searchCategories["Music"] = i18n("Music");
+ searchCategories["Video"] = i18n("Video");
+ searchCategories["Software"] = i18n("Software");
+ searchCategories["Movies"] = i18n("Movies");
+ searchCategories["Development"] = i18n("Development");
+ searchCategories["Academic"] = i18n("Academic");
+ searchCategories["Maps"] = i18n("Maps");
+ searchCategories["Misc"] = i18n("Miscellaneous");
}
void SearchProvider::setName(const TQString &name)
@@ -62,6 +86,15 @@ void SearchProvider::setCharset(const TQString &charset)
m_dirty = true;
}
+void SearchProvider::setCategory(const TQString &category)
+{
+ if (m_category == category)
+ return;
+
+ m_category = searchCategoryKey(category);
+ m_dirty = true;
+}
+
SearchProvider *SearchProvider::findByDesktopName(const TQString &name)
{
KService::Ptr service =
@@ -76,3 +109,22 @@ SearchProvider *SearchProvider::findByKey(const TQString &key)
return providers.count() ? new SearchProvider(providers[0]) : 0;
}
+const TQString& SearchProvider::searchCategoryName(const TQString& category)
+{
+ auto it = searchCategories.find(category);
+ if (it != searchCategories.end())
+ {
+ return it.data();
+ }
+ return category;
+}
+
+const TQString& SearchProvider::searchCategoryKey(const TQString& displayName)
+{
+ SearchCategoryMap::Iterator it;
+ for (it = searchCategories.begin(); it != searchCategories.end(); ++it)
+ {
+ if (it.data() == displayName) return it.key();
+ }
+ return displayName; // user-defined key
+} \ No newline at end of file
diff --git a/kcontrol/ebrowsing/plugins/ikws/searchprovider.h b/kcontrol/ebrowsing/plugins/ikws/searchprovider.h
index 45309939c..895a4ba0c 100644
--- a/kcontrol/ebrowsing/plugins/ikws/searchprovider.h
+++ b/kcontrol/ebrowsing/plugins/ikws/searchprovider.h
@@ -21,33 +21,48 @@
#define __SEARCHPROVIDER_H___
#include <kservice.h>
+#include <tqmap.h>
-class SearchProvider
+typedef TQMap<TQString, TQString> SearchCategoryMap;
+
+class SearchProvider
{
public:
SearchProvider() : m_dirty(false) {};
SearchProvider(const KService::Ptr service);
- const TQString &desktopEntryName() const { return m_desktopEntryName; }
- const TQString &name() const { return m_name; }
- const TQString &query() const { return m_query; }
- const TQStringList &keys() const { return m_keys; }
- const TQString &charset() const { return m_charset; }
+ const TQString& desktopEntryName() const { return m_desktopEntryName; }
+ const TQString& name() const { return m_name; }
+ const TQString& query() const { return m_query; }
+ const TQStringList& keys() const { return m_keys; }
+ const TQString& charset() const { return m_charset; }
+ const TQString& category() const { return m_category; }
bool isDirty() const { return m_dirty; }
void setName(const TQString &);
void setQuery(const TQString &);
void setKeys(const TQStringList &);
void setCharset(const TQString &);
+ void setCategory(const TQString &);
static SearchProvider *findByDesktopName(const TQString &);
static SearchProvider *findByKey(const TQString &);
+
+ static const TQString& searchCategoryName(const TQString& category);
+ static const TQString& searchCategoryKey(const TQString& displayName);
+
+ static SearchCategoryMap searchCategories;
+
+private:
+ void initSearchCategories();
+
private:
TQString m_desktopEntryName;
TQString m_name;
TQString m_query;
TQStringList m_keys;
TQString m_charset;
+ TQString m_category;
bool m_dirty;
};
diff --git a/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp b/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp
index bf295462f..2af0aaa80 100644
--- a/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp
+++ b/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.cpp
@@ -33,17 +33,19 @@
#include "searchproviderdlg.h"
#include "searchprovider.h"
-SearchProviderDialog::SearchProviderDialog(SearchProvider *provider,
+SearchProviderDialog::SearchProviderDialog(SearchProvider *provider, const TQString& category,
TQWidget *parent, const char *name)
- :KDialogBase(parent, name, true, TQString::null, Ok|Cancel),
- m_provider(provider)
+ : KDialogBase(parent, name, true, TQString::null, Ok|Cancel),
+ m_provider(provider)
{
m_dlg = new SearchProviderDlgUI (this);
setMainWidget(m_dlg);
enableButtonSeparator(true);
- m_dlg->leQuery->setMinimumWidth(tdeApp->fontMetrics().maxWidth() * 40);
+ m_dlg->leQuery->setMinimumWidth(tdeApp->fontMetrics().maxWidth() * 16);
+ m_dlg->cbCategory->setDuplicatesEnabled(false);
+ m_dlg->cbCategory->setEditable(true);
connect(m_dlg->leName, TQ_SIGNAL(textChanged(const TQString &)), TQ_SLOT(slotChanged()));
connect(m_dlg->leQuery, TQ_SIGNAL(textChanged(const TQString &)), TQ_SLOT(slotChanged()));
@@ -54,12 +56,19 @@ SearchProviderDialog::SearchProviderDialog(SearchProvider *provider,
charsets.prepend(i18n("Default"));
m_dlg->cbCharset->insertStringList(charsets);
+ m_dlg->cbCategory->insertStringList(SearchProvider::searchCategories.values());
+ if (!category.isNull())
+ {
+ m_dlg->cbCategory->setCurrentText(SearchProvider::searchCategoryName(category));
+ }
+
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->cbCategory->setCurrentText(SearchProvider::searchCategoryName(m_provider->category()));
m_dlg->cbCharset->setCurrentItem(m_provider->charset().isEmpty() ? 0 : charsets.findIndex(m_provider->charset()));
m_dlg->leName->setEnabled(false);
m_dlg->leQuery->setFocus();
@@ -95,6 +104,7 @@ void SearchProviderDialog::slotOk()
m_provider->setQuery(m_dlg->leQuery->text().stripWhiteSpace());
m_provider->setKeys(TQStringList::split(",", m_dlg->leShortcut->text().stripWhiteSpace()));
m_provider->setCharset(m_dlg->cbCharset->currentItem() ? m_dlg->cbCharset->currentText() : TQString::null);
+ m_provider->setCategory(m_dlg->cbCategory->currentText());
KDialog::accept();
}
diff --git a/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.h b/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.h
index a698ee626..8f68788ce 100644
--- a/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.h
+++ b/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg.h
@@ -30,7 +30,8 @@ class SearchProviderDialog : public KDialogBase
TQ_OBJECT
public:
- SearchProviderDialog(SearchProvider *provider, TQWidget *parent = 0, const char *name = 0);
+ SearchProviderDialog(SearchProvider *provider, const TQString &category = TQString::null,
+ TQWidget *parent = nullptr, const char *name = nullptr);
SearchProvider *provider() { return m_provider; }
diff --git a/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg_ui.ui b/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg_ui.ui
index 9fe898c83..f3c79a6db 100644
--- a/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg_ui.ui
+++ b/kcontrol/ebrowsing/plugins/ikws/searchproviderdlg_ui.ui
@@ -27,7 +27,7 @@
<string>Enter the human readable name of the search provider here.</string>
</property>
</widget>
- <widget class="TQLabel" row="6" column="0">
+ <widget class="TQLabel" row="8" column="0">
<property name="name">
<cstring>lbCharset</cstring>
</property>
@@ -109,14 +109,36 @@ Recommended is \{@}, since it removes all query variables (name=value) from the
&lt;/qt&gt;</string>
</property>
</widget>
- <widget class="KComboBox" row="7" column="0">
+ <widget class="KComboBox" row="9" column="0">
<property name="name">
<cstring>cbCharset</cstring>
</property>
<property name="whatsThis" stdset="0">
<string>Select the character set that will be used to encode your search query.</string>
</property>
- </widget>
+ </widget>
+ <widget class="TQLabel" row="6" column="0">
+ <property name="name">
+ <cstring>lbCategory</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Category:</string>
+ </property>
+ <property name="buddy" stdset="0">
+ <cstring>cbCategory</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Select the category the search engine will be grouped under.</string>
+ </property>
+ </widget>
+ <widget class="KComboBox" row="7" column="0">
+ <property name="name">
+ <cstring>cbCategory</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>Select the category the search engine will be grouped under.</string>
+ </property>
+ </widget>
</grid>
</widget>
<customwidgets>
@@ -125,6 +147,7 @@ Recommended is \{@}, since it removes all query variables (name=value) from the
<tabstop>leName</tabstop>
<tabstop>leQuery</tabstop>
<tabstop>leShortcut</tabstop>
+ <tabstop>cbCategory</tabstop>
<tabstop>cbCharset</tabstop>
</tabstops>
<layoutdefaults spacing="6" margin="11"/>