summaryrefslogtreecommitdiffstats
path: root/konq-plugins/searchbar/searchbar.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:22:56 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-07-31 19:22:56 +0000
commit7346aee26bf190a7e70333c40fab4caca847cd27 (patch)
tree4b019b434f88dcc3eeaafe1d3f26240b4c4718e8 /konq-plugins/searchbar/searchbar.cpp
parent23a3d3aa5b44cbdf305495919866d9dbf4f6da54 (diff)
downloadtdeaddons-7346aee26bf190a7e70333c40fab4caca847cd27.tar.gz
tdeaddons-7346aee26bf190a7e70333c40fab4caca847cd27.zip
Trinity Qt initial conversion
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaddons@1157634 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'konq-plugins/searchbar/searchbar.cpp')
-rw-r--r--konq-plugins/searchbar/searchbar.cpp168
1 files changed, 84 insertions, 84 deletions
diff --git a/konq-plugins/searchbar/searchbar.cpp b/konq-plugins/searchbar/searchbar.cpp
index 739a871..b8cd24c 100644
--- a/konq-plugins/searchbar/searchbar.cpp
+++ b/konq-plugins/searchbar/searchbar.cpp
@@ -45,11 +45,11 @@
#include <kparts/mainwindow.h>
#include <kparts/partmanager.h>
-#include <qpainter.h>
-#include <qpopupmenu.h>
-#include <qtimer.h>
-#include <qstyle.h>
-#include <qwhatsthis.h>
+#include <tqpainter.h>
+#include <tqpopupmenu.h>
+#include <tqtimer.h>
+#include <tqstyle.h>
+#include <tqwhatsthis.h>
#include "searchbar.h"
typedef KGenericFactory<SearchBarPlugin> SearchBarPluginFactory;
@@ -57,8 +57,8 @@ K_EXPORT_COMPONENT_FACTORY(libsearchbarplugin,
SearchBarPluginFactory("searchbarplugin"))
-SearchBarPlugin::SearchBarPlugin(QObject *parent, const char *name,
- const QStringList &) :
+SearchBarPlugin::SearchBarPlugin(TQObject *parent, const char *name,
+ const TQStringList &) :
KParts::Plugin(parent, name),
m_searchCombo(0),
m_searchMode(UseSearchProvider),
@@ -81,15 +81,15 @@ SearchBarPlugin::SearchBarPlugin(QObject *parent, const char *name,
0, 0, actionCollection(), "toolbar_search_bar");
m_searchComboAction->setShortcutConfigurable(false);
- connect(m_searchCombo, SIGNAL(activated(const QString &)),
- SLOT(startSearch(const QString &)));
- connect(m_searchCombo, SIGNAL(iconClicked()), SLOT(showSelectionMenu()));
+ connect(m_searchCombo, TQT_SIGNAL(activated(const TQString &)),
+ TQT_SLOT(startSearch(const TQString &)));
+ connect(m_searchCombo, TQT_SIGNAL(iconClicked()), TQT_SLOT(showSelectionMenu()));
- QWhatsThis::add(m_searchCombo, i18n("Search Bar<p>"
+ TQWhatsThis::add(m_searchCombo, i18n("Search Bar<p>"
"Enter a search term. Click on the icon to change search mode or provider."));
new KAction( i18n( "Focus Searchbar" ), CTRL+Key_S,
- this, SLOT(focusSearchbar()),
+ this, TQT_SLOT(focusSearchbar()),
actionCollection(), "focus_search_bar");
configurationChanged();
@@ -100,15 +100,15 @@ SearchBarPlugin::SearchBarPlugin(QObject *parent, const char *name,
KParts::PartManager *partMan = static_cast<KParts::PartManager*>(mainWin->child(0, "KParts::PartManager"));
if (partMan)
{
- connect(partMan, SIGNAL(activePartChanged(KParts::Part*)),
- SLOT (partChanged (KParts::Part*)));
+ connect(partMan, TQT_SIGNAL(activePartChanged(KParts::Part*)),
+ TQT_SLOT (partChanged (KParts::Part*)));
partChanged(partMan->activePart());
}
- connect(this, SIGNAL(gsCompleteDelayed()), SLOT(gsStartDelay()));
- connect(&m_gsTimer, SIGNAL(timeout()), SLOT(gsMakeCompletionList()));
- connect(m_searchCombo->listBox(), SIGNAL(highlighted(const QString&)), SLOT(gsSetCompletedText(const QString&)));
- connect(m_searchCombo, SIGNAL(activated(const QString&)), SLOT(gsPutTextInBox(const QString&)));
+ connect(this, TQT_SIGNAL(gsCompleteDelayed()), TQT_SLOT(gsStartDelay()));
+ connect(&m_gsTimer, TQT_SIGNAL(timeout()), TQT_SLOT(gsMakeCompletionList()));
+ connect(m_searchCombo->listBox(), TQT_SIGNAL(highlighted(const TQString&)), TQT_SLOT(gsSetCompletedText(const TQString&)));
+ connect(m_searchCombo, TQT_SIGNAL(activated(const TQString&)), TQT_SLOT(gsPutTextInBox(const TQString&)));
}
SearchBarPlugin::~SearchBarPlugin()
@@ -123,19 +123,19 @@ SearchBarPlugin::~SearchBarPlugin()
m_searchCombo = 0L;
}
-QChar delimiter()
+TQChar delimiter()
{
KConfig config( "kuriikwsfilterrc", true, false );
config.setGroup( "General" );
return config.readNumEntry( "KeywordDelimiter", ':' );
}
-bool SearchBarPlugin::eventFilter(QObject *o, QEvent *e)
+bool SearchBarPlugin::eventFilter(TQObject *o, TQEvent *e)
{
- if( o==m_searchCombo->lineEdit() && e->type() == QEvent::KeyPress )
+ if( o==m_searchCombo->lineEdit() && e->type() == TQEvent::KeyPress )
{
- QKeyEvent *k = (QKeyEvent *)e;
- QString text = k->text();
+ TQKeyEvent *k = (TQKeyEvent *)e;
+ TQString text = k->text();
if(!text.isEmpty())
{
if(k->key() != Qt::Key_Return && k->key() != Key_Enter && k->key() != Key_Escape)
@@ -206,7 +206,7 @@ void SearchBarPlugin::nextSearchEntry()
}
else
{
- QStringList::ConstIterator it = m_searchEngines.find(m_currentEngine);
+ TQStringList::ConstIterator it = m_searchEngines.find(m_currentEngine);
it++;
if(it==m_searchEngines.end())
{
@@ -236,7 +236,7 @@ void SearchBarPlugin::previousSearchEntry()
}
else
{
- QStringList::ConstIterator it = m_searchEngines.find(m_currentEngine);
+ TQStringList::ConstIterator it = m_searchEngines.find(m_currentEngine);
if(it==m_searchEngines.begin())
{
m_searchMode = FindInThisPage;
@@ -250,7 +250,7 @@ void SearchBarPlugin::previousSearchEntry()
setIcon();
}
-void SearchBarPlugin::startSearch(const QString &_search)
+void SearchBarPlugin::startSearch(const TQString &_search)
{
if(m_urlEnterLock || _search.isEmpty() || !m_part)
return;
@@ -258,7 +258,7 @@ void SearchBarPlugin::startSearch(const QString &_search)
m_gsTimer.stop();
m_searchCombo->listBox()->hide();
- QString search = _search.section('(', 0, 0).stripWhiteSpace();
+ TQString search = _search.section('(', 0, 0).stripWhiteSpace();
if(m_searchMode == FindInThisPage)
{
@@ -270,18 +270,18 @@ void SearchBarPlugin::startSearch(const QString &_search)
m_urlEnterLock = true;
KService::Ptr service;
KURIFilterData data;
- QStringList list;
+ TQStringList list;
list << "kurisearchfilter" << "kuriikwsfilter";
- service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_currentEngine));
+ service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(m_currentEngine));
if (service) {
- const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + delimiter();
+ const TQString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + delimiter();
data.setData( searchProviderPrefix + search );
}
if(!service || !KURIFilter::self()->filterURI(data, list))
{
- data.setData( QString::fromLatin1( "google" ) + delimiter() + search );
+ data.setData( TQString::fromLatin1( "google" ) + delimiter() + search );
KURIFilter::self()->filterURI( data, list );
}
@@ -315,7 +315,7 @@ void SearchBarPlugin::startSearch(const QString &_search)
void SearchBarPlugin::setIcon()
{
- QString hinttext;
+ TQString hinttext;
if(m_searchMode == FindInThisPage)
{
m_searchIcon = SmallIcon("find");
@@ -323,28 +323,28 @@ void SearchBarPlugin::setIcon()
}
else
{
- QString providername;
+ TQString providername;
KService::Ptr service;
KURIFilterData data;
- QStringList list;
+ TQStringList list;
list << "kurisearchfilter" << "kuriikwsfilter";
- service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(m_currentEngine));
+ service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(m_currentEngine));
if (service) {
- const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + delimiter();
+ const TQString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + delimiter();
data.setData( searchProviderPrefix + "some keyword" );
}
if (service && KURIFilter::self()->filterURI(data, list))
{
- QString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");
+ TQString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");
if(iconPath.isEmpty())
{
m_searchIcon = SmallIcon("enhanced_browsing");
}
else
{
- m_searchIcon = QPixmap(iconPath);
+ m_searchIcon = TQPixmap(iconPath);
}
providername = service->name();
}
@@ -358,13 +358,13 @@ void SearchBarPlugin::setIcon()
static_cast<KLineEdit*>(m_searchCombo->lineEdit())->setClickMessage(hinttext);
// Create a bit wider icon with arrow
- QPixmap arrowmap = QPixmap(m_searchIcon.width()+5,m_searchIcon.height()+5);
+ TQPixmap arrowmap = TQPixmap(m_searchIcon.width()+5,m_searchIcon.height()+5);
arrowmap.fill(m_searchCombo->lineEdit()->backgroundColor());
- QPainter p( &arrowmap );
+ TQPainter p( &arrowmap );
p.drawPixmap(0, 2, m_searchIcon);
- QStyle::SFlags arrowFlags = QStyle::Style_Default;
- m_searchCombo->style().drawPrimitive(QStyle::PE_ArrowDown, &p, QRect(arrowmap.width()-6,
- arrowmap.height()-6, 6, 5), m_searchCombo->colorGroup(), arrowFlags, QStyleOption() );
+ TQStyle::SFlags arrowFlags = TQStyle::Style_Default;
+ m_searchCombo->style().drawPrimitive(TQStyle::PE_ArrowDown, &p, TQRect(arrowmap.width()-6,
+ arrowmap.height()-6, 6, 5), m_searchCombo->colorGroup(), arrowFlags, TQStyleOption() );
p.end();
m_searchIcon = arrowmap;
@@ -376,54 +376,54 @@ void SearchBarPlugin::showSelectionMenu()
if(!m_popupMenu)
{
KService::Ptr service;
- QPixmap icon;
+ TQPixmap icon;
KURIFilterData data;
- QStringList list;
+ TQStringList list;
list << "kurisearchfilter" << "kuriikwsfilter";
- m_popupMenu = new QPopupMenu(m_searchCombo, "search selection menu");
- m_popupMenu->insertItem(SmallIcon("find"), i18n("Find in This Page"), this, SLOT(useFindInThisPage()), 0, 999);
+ m_popupMenu = new TQPopupMenu(m_searchCombo, "search selection menu");
+ m_popupMenu->insertItem(SmallIcon("find"), i18n("Find in This Page"), this, TQT_SLOT(useFindInThisPage()), 0, 999);
m_popupMenu->insertSeparator();
int i=-1;
- for (QStringList::ConstIterator it = m_searchEngines.begin(); it != m_searchEngines.end(); ++it )
+ for (TQStringList::ConstIterator it = m_searchEngines.begin(); it != m_searchEngines.end(); ++it )
{
i++;
- service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(*it));
+ service = KService::serviceByDesktopPath(TQString("searchproviders/%1.desktop").arg(*it));
if(!service)
{
continue;
}
- const QString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + delimiter();
+ const TQString searchProviderPrefix = *(service->property("Keys").toStringList().begin()) + delimiter();
data.setData( searchProviderPrefix + "some keyword" );
if(KURIFilter::self()->filterURI(data, list))
{
- QString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");
+ TQString iconPath = locate("cache", KMimeType::favIconForURL(data.uri()) + ".png");
if(iconPath.isEmpty())
{
icon = SmallIcon("enhanced_browsing");
}
else
{
- icon = QPixmap( iconPath );
+ icon = TQPixmap( iconPath );
}
m_popupMenu->insertItem(icon, service->name(), i);
}
}
m_popupMenu->insertSeparator();
- m_googleMenu = new KSelectAction(i18n("Use Google Suggest"), SmallIconSet("ktip"), 0, this, SLOT(selectGoogleSuggestMode()), m_popupMenu);
- QStringList google_modes;
+ m_googleMenu = new KSelectAction(i18n("Use Google Suggest"), SmallIconSet("ktip"), 0, this, TQT_SLOT(selectGoogleSuggestMode()), m_popupMenu);
+ TQStringList google_modes;
google_modes << i18n("For Google Only") << i18n("For All Searches") << i18n("Never");
m_googleMenu->setItems(google_modes);
m_googleMenu->plug(m_popupMenu);
m_popupMenu->insertItem(SmallIcon("enhanced_browsing"), i18n("Select Search Engines..."),
- this, SLOT(selectSearchEngines()), 0, 1000);
- connect(m_popupMenu, SIGNAL(activated(int)), SLOT(useSearchProvider(int)));
+ this, TQT_SLOT(selectSearchEngines()), 0, 1000);
+ connect(m_popupMenu, TQT_SIGNAL(activated(int)), TQT_SLOT(useSearchProvider(int)));
}
m_googleMenu->setCurrentItem(m_googleMode);
- m_popupMenu->popup(m_searchCombo->mapToGlobal(QPoint(0, m_searchCombo->height() + 1)), 0);
+ m_popupMenu->popup(m_searchCombo->mapToGlobal(TQPoint(0, m_searchCombo->height() + 1)), 0);
}
void SearchBarPlugin::useFindInThisPage()
@@ -450,7 +450,7 @@ void SearchBarPlugin::selectSearchEngines()
*process << "kcmshell" << "ebrowsing";
- connect(process, SIGNAL(processExited(KProcess *)), SLOT(searchEnginesSelected(KProcess *)));
+ connect(process, TQT_SIGNAL(processExited(KProcess *)), TQT_SLOT(searchEnginesSelected(KProcess *)));
if(!process->start())
{
@@ -476,9 +476,9 @@ void SearchBarPlugin::configurationChanged()
{
KConfig *config = new KConfig("kuriikwsfilterrc");
config->setGroup("General");
- QString engine = config->readEntry("DefaultSearchEngine", "google");
+ TQString engine = config->readEntry("DefaultSearchEngine", "google");
- QStringList favoriteEngines;
+ TQStringList favoriteEngines;
favoriteEngines << "google" << "google_groups" << "google_news" << "webster" << "dmoz" << "wikipedia";
favoriteEngines = config->readListEntry("FavoriteSearchEngines", favoriteEngines);
@@ -486,7 +486,7 @@ void SearchBarPlugin::configurationChanged()
m_popupMenu = 0;
m_searchEngines.clear();
m_searchEngines << engine;
- for (QStringList::ConstIterator it = favoriteEngines.begin(); it != favoriteEngines.end(); ++it )
+ for (TQStringList::ConstIterator it = favoriteEngines.begin(); it != favoriteEngines.end(); ++it )
if(*it!=engine)
m_searchEngines << *it;
@@ -518,7 +518,7 @@ void SearchBarPlugin::partChanged(KParts::Part *newPart)
m_part = ::qt_cast<KHTMLPart*>(newPart);
//Delay since when destroying tabs part 0 gets activated for a bit, before the proper part
- QTimer::singleShot(0, this, SLOT(updateComboVisibility()));
+ TQTimer::singleShot(0, this, TQT_SLOT(updateComboVisibility()));
}
void SearchBarPlugin::updateComboVisibility()
@@ -537,24 +537,24 @@ void SearchBarPlugin::updateComboVisibility()
void SearchBarPlugin::focusSearchbar()
{
- QFocusEvent::setReason( QFocusEvent::Shortcut );
+ TQFocusEvent::setReason( TQFocusEvent::Shortcut );
m_searchCombo->setFocus();
- QFocusEvent::resetReason();
+ TQFocusEvent::resetReason();
}
-SearchBarCombo::SearchBarCombo(QWidget *parent, const char *name) :
+SearchBarCombo::SearchBarCombo(TQWidget *parent, const char *name) :
KHistoryCombo(parent, name),
m_pluginActive(true)
{
- connect(this, SIGNAL(cleared()), SLOT(historyCleared()));
+ connect(this, TQT_SIGNAL(cleared()), TQT_SLOT(historyCleared()));
}
-const QPixmap &SearchBarCombo::icon() const
+const TQPixmap &SearchBarCombo::icon() const
{
return m_icon;
}
-void SearchBarCombo::setIcon(const QPixmap &icon)
+void SearchBarCombo::setIcon(const TQPixmap &icon)
{
m_icon = icon;
@@ -571,7 +571,7 @@ void SearchBarCombo::setIcon(const QPixmap &icon)
}
}
-int SearchBarCombo::findHistoryItem(const QString &searchText)
+int SearchBarCombo::findHistoryItem(const TQString &searchText)
{
for(int i = 0; i < count(); i++)
{
@@ -584,9 +584,9 @@ int SearchBarCombo::findHistoryItem(const QString &searchText)
return -1;
}
-void SearchBarCombo::mousePressEvent(QMouseEvent *e)
+void SearchBarCombo::mousePressEvent(TQMouseEvent *e)
{
- int x0 = QStyle::visualRect( style().querySubControlMetrics( QStyle::CC_ComboBox, this, QStyle::SC_ComboBoxEditField ), this ).x();
+ int x0 = TQStyle::visualRect( style().querySubControlMetrics( TQStyle::CC_ComboBox, this, TQStyle::SC_ComboBoxEditField ), this ).x();
if(e->x() > x0 + 2 && e->x() < lineEdit()->x())
{
@@ -649,20 +649,20 @@ void SearchBarPlugin::gsMakeCompletionList()
{
KIO::TransferJob* tj =
KIO::get(KURL("http://www.google.com/complete/search?hl=en&js=true&qu=" + m_searchCombo->currentText()), false, false);
- connect(tj, SIGNAL(data(KIO::Job*, const QByteArray&)), this, SLOT(gsDataArrived(KIO::Job*, const QByteArray&)));
- connect(tj, SIGNAL(result(KIO::Job*)), this, SLOT(gsJobFinished(KIO::Job*)));
+ connect(tj, TQT_SIGNAL(data(KIO::Job*, const TQByteArray&)), this, TQT_SLOT(gsDataArrived(KIO::Job*, const TQByteArray&)));
+ connect(tj, TQT_SIGNAL(result(KIO::Job*)), this, TQT_SLOT(gsJobFinished(KIO::Job*)));
}
}
-void SearchBarPlugin::gsDataArrived(KIO::Job*, const QByteArray& data)
+void SearchBarPlugin::gsDataArrived(KIO::Job*, const TQByteArray& data)
{
- m_gsData += QString::fromUtf8(data.data());
+ m_gsData += TQString::fromUtf8(data.data());
}
-static QString reformatNumber(const QString& number)
+static TQString reformatNumber(const TQString& number)
{
static const char suffix[] = { 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' };
- QString s = number.stripWhiteSpace();
+ TQString s = number.stripWhiteSpace();
uint c = 0;
for (int i = s.length() - 1; i > 0 && s[i] == '0'; --i) ++c;
c /= 3;
@@ -676,18 +676,18 @@ void SearchBarPlugin::gsJobFinished(KIO::Job* job)
{
if (((KIO::TransferJob*)job)->error() == 0)
{
- QString temp;
+ TQString temp;
temp = m_gsData.mid(m_gsData.find('(') + 1, m_gsData.findRev(')') - m_gsData.find('(') - 1);
temp = temp.mid(temp.find('(') + 1, temp.find(')') - temp.find('(') - 1);
temp.remove('"');
- QStringList compList1 = QStringList::split(',', temp);
+ TQStringList compList1 = TQStringList::split(',', temp);
temp = m_gsData.mid(m_gsData.find(')') + 1, m_gsData.findRev(')') - m_gsData.find('(') - 1);
temp = temp.mid(temp.find('(') + 1, temp.find(')') - temp.find('(') - 1);
temp.remove('"');
temp.remove(',');
temp.remove('s');
- QStringList compList2 = QStringList::split("reult", temp);
- QStringList finalList;
+ TQStringList compList2 = TQStringList::split("reult", temp);
+ TQStringList finalList;
for(uint j = 0; j < compList1.count(); j++)
{
if (m_googleMode!=ForAll || m_currentEngine == "google")
@@ -710,9 +710,9 @@ void SearchBarPlugin::gsJobFinished(KIO::Job* job)
m_gsData = "";
}
-void SearchBarPlugin::gsSetCompletedText(const QString& text)
+void SearchBarPlugin::gsSetCompletedText(const TQString& text)
{
- QString currentText;
+ TQString currentText;
if (m_searchCombo->lineEdit()->hasSelectedText())
currentText = m_searchCombo->currentText().left(m_searchCombo->lineEdit()->selectionStart());
else
@@ -725,7 +725,7 @@ void SearchBarPlugin::gsSetCompletedText(const QString& text)
}
}
-void SearchBarPlugin::gsPutTextInBox(const QString& text)
+void SearchBarPlugin::gsPutTextInBox(const TQString& text)
{
m_searchCombo->lineEdit()->setText(text.section('(', 0, 0).stripWhiteSpace());
}