diff options
Diffstat (limited to 'plugins/search')
| -rw-r--r-- | plugins/search/Makefile.am | 28 | ||||
| -rw-r--r-- | plugins/search/htmlpart.cpp | 198 | ||||
| -rw-r--r-- | plugins/search/htmlpart.h | 73 | ||||
| -rw-r--r-- | plugins/search/ktsearchplugin.desktop | 60 | ||||
| -rw-r--r-- | plugins/search/ktsearchplugin.kcfg | 30 | ||||
| -rw-r--r-- | plugins/search/searchbar.ui | 110 | ||||
| -rw-r--r-- | plugins/search/searchenginelist.cpp | 137 | ||||
| -rw-r--r-- | plugins/search/searchenginelist.h | 60 | ||||
| -rw-r--r-- | plugins/search/searchplugin.cpp | 157 | ||||
| -rw-r--r-- | plugins/search/searchplugin.h | 67 | ||||
| -rw-r--r-- | plugins/search/searchpluginsettings.kcfgc | 7 | ||||
| -rw-r--r-- | plugins/search/searchpref.ui | 312 | ||||
| -rw-r--r-- | plugins/search/searchprefpage.cpp | 284 | ||||
| -rw-r--r-- | plugins/search/searchprefpage.h | 79 | ||||
| -rw-r--r-- | plugins/search/searchtab.cpp | 169 | ||||
| -rw-r--r-- | plugins/search/searchtab.h | 78 | ||||
| -rw-r--r-- | plugins/search/searchwidget.cpp | 272 | ||||
| -rw-r--r-- | plugins/search/searchwidget.h | 90 |
18 files changed, 0 insertions, 2211 deletions
diff --git a/plugins/search/Makefile.am b/plugins/search/Makefile.am deleted file mode 100644 index ebc85aa..0000000 --- a/plugins/search/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -INCLUDES = -I$(srcdir)/../../libktorrent $(all_includes) -METASOURCES = AUTO -kde_module_LTLIBRARIES = ktsearchplugin.la -noinst_HEADERS = searchplugin.h searchprefpage.h searchtab.h searchenginelist.h -ktsearchplugin_la_SOURCES = searchplugin.cpp htmlpart.cpp searchbar.ui \ - searchpref.ui searchwidget.cpp searchprefpage.cpp searchpluginsettings.kcfgc \ - searchtab.cpp searchenginelist.cpp - -# Libs needed by the plugin -ktsearchplugin_la_LIBADD = ../../libktorrent/libktorrent.la \ - $(LIB_TDEHTML) $(LIB_TDEPARTS) $(LIB_QT) \ - $(LIB_TDECORE) $(LIB_TDEUI) $(LIB_TDEFILE) - -# LD flags for the plugin -# -module says: this is a module, i.e. something you're going to dlopen -# so e.g. it has no version number like a normal shared lib would have. -ktsearchplugin_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) - -# rc file containing the GUI for the plugin -# pluginsdir = $(kde_datadir)/ktsearchplugin -# plugins_DATA = ktsearchpluginui.rc - -# Install the desktop file needed to detect the plugin -kde_services_DATA = ktsearchplugin.desktop - -kde_kcfg_DATA = ktsearchplugin.kcfg - -KDE_CXXFLAGS = $(USE_EXCEPTIONS) $(USE_RTTI) diff --git a/plugins/search/htmlpart.cpp b/plugins/search/htmlpart.cpp deleted file mode 100644 index 2c57aeb..0000000 --- a/plugins/search/htmlpart.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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 <tdemessagebox.h> -#include <tdeio/job.h> -#include <tdeio/jobclasses.h> -//#include <tqfile.h> -#include <tqclipboard.h> -#include <tqapplication.h> -#include <tdeio/netaccess.h> -#include <tdelocale.h> -#include <tdefiledialog.h> -#include <tdeparts/browserextension.h> -#include <util/constants.h> -#include <tdehtmlview.h> -#include "htmlpart.h" - -using namespace bt; - -namespace kt -{ - - HTMLPart::HTMLPart(TQWidget *parent) - : TDEHTMLPart(parent) - { - setJScriptEnabled(true); - setJavaEnabled(true); - setMetaRefreshEnabled(true); - setPluginsEnabled(false); - setStatusMessagesEnabled(false); - KParts::BrowserExtension* ext = this->browserExtension(); - connect(ext,TQT_SIGNAL(openURLRequest(const KURL&,const KParts::URLArgs&)), - this,TQT_SLOT(openURLRequest(const KURL&, const KParts::URLArgs& ))); - - ext->enableAction("copy",true); - ext->enableAction("paste",true); - active_job = 0; - } - - - HTMLPart::~HTMLPart() - {} - - void HTMLPart::copy() - { - TQString txt = selectedText(); - TQClipboard *cb = TQApplication::clipboard(); - // Copy text into the clipboard - if (cb) - cb->setText(txt,TQClipboard::Clipboard); - } - - void HTMLPart::openURLRequest(const KURL &u,const KParts::URLArgs &) - { - if (active_job) - { - active_job->kill(true); - active_job = 0; - } - - TDEIO::TransferJob* j = TDEIO::get(u,false,false); - connect(j,TQT_SIGNAL(data(TDEIO::Job*,const TQByteArray &)), - this,TQT_SLOT(dataRecieved(TDEIO::Job*, const TQByteArray& ))); - connect(j,TQT_SIGNAL(result(TDEIO::Job*)),this,TQT_SLOT(jobDone(TDEIO::Job* ))); - connect(j,TQT_SIGNAL(mimetype(TDEIO::Job*, const TQString &)), - this,TQT_SLOT(mimetype(TDEIO::Job*, const TQString& ))); - - active_job = j; - curr_data.resize(0); - mime_type = TQString(); - curr_url = u; - } - - void HTMLPart::back() - { - if (history.count() <= 1) - { - backAvailable(false); - } - else - { - history.pop_back(); - KURL u = history.back(); - openURL(u); - backAvailable(history.count() > 1 ? true : false); - - } - } - - void HTMLPart::addToHistory(const KURL & url) - { - history.append(url); - if (history.count() > 1) - backAvailable(true); - } - - void HTMLPart::reload() - { - openURL(url()); - } - - void HTMLPart::dataRecieved(TDEIO::Job* job,const TQByteArray & data) - { - if (job != active_job) - { - job->kill(true); - return; - } - - if (data.size() == 0) - return; - - Uint32 off = curr_data.size(); - curr_data.resize(curr_data.size() + data.size()); - for (Uint32 i = 0;i < data.size();i++) - { - curr_data[i + off] = data[i]; - } - } - - void HTMLPart::mimetype(TDEIO::Job* job,const TQString & mt) - { - if (job != active_job) - { - job->kill(true); - return; - } - - mime_type = mt; - } - - void HTMLPart::jobDone(TDEIO::Job* job) - { - if (job != active_job) - { - job->kill(true); - return; - } - - if (job->error() == 0) - { - bool is_bencoded_data = curr_data.size() > 0 && - curr_data[0] == 'd' && - curr_data[curr_data.size()-1] == 'e'; - - if (is_bencoded_data || mime_type == "application/x-bittorrent") - { - int ret = KMessageBox::questionYesNoCancel(0, - i18n("Do you want to download or save the torrent?"), - i18n("Download Torrent"), - KGuiItem(i18n("to download", "Download"),"go-down"), - KStdGuiItem::save()); - - if (ret == KMessageBox::Yes) - openTorrent(curr_url); - else if (ret == KMessageBox::No) - saveTorrent(curr_url); - } - else - { - addToHistory(curr_url); - begin(curr_url); - write(curr_data.data(),curr_data.size()); - end(); - view()->ensureVisible(0,0); - searchFinished(); - } - } - else - { - begin(curr_url); - write(TDEIO::buildErrorString(job->error(),job->errorText()));/*,&curr_url));**/ - end(); - } - active_job = 0; - curr_data.resize(0); - curr_url = KURL(); - mime_type = TQString(); - } -} - -#include "htmlpart.moc" diff --git a/plugins/search/htmlpart.h b/plugins/search/htmlpart.h deleted file mode 100644 index 091c82f..0000000 --- a/plugins/search/htmlpart.h +++ /dev/null @@ -1,73 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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. * - ***************************************************************************/ -#ifndef HTMLPART_H -#define HTMLPART_H - -#include <tdehtml_part.h> - -namespace TDEIO -{ - class Job; -} - - -namespace kt -{ - - /** - @author Joris Guisson - */ - class HTMLPart : public TDEHTMLPart - { - Q_OBJECT - - public: - HTMLPart(TQWidget *parent = 0); - virtual ~HTMLPart(); - - public slots: - void back(); - void reload(); - void copy(); - void openURLRequest(const KURL &url, const KParts::URLArgs &args); - - private slots: - void addToHistory(const KURL & url); - void dataRecieved(TDEIO::Job* job,const TQByteArray & data); - void mimetype(TDEIO::Job* job,const TQString & mt); - void jobDone(TDEIO::Job* job); - - - signals: - void backAvailable(bool yes); - void openTorrent(const KURL & url); - void saveTorrent(const KURL & url); - void searchFinished(); - - private: - KURL::List history; - TDEIO::Job* active_job; - TQByteArray curr_data; - TQString mime_type; - KURL curr_url; - }; -} - -#endif diff --git a/plugins/search/ktsearchplugin.desktop b/plugins/search/ktsearchplugin.desktop deleted file mode 100644 index 9feabe0..0000000 --- a/plugins/search/ktsearchplugin.desktop +++ /dev/null @@ -1,60 +0,0 @@ -[Desktop Entry] -Name=SearchPlugin -Name[bg]=Приставка за търсене -Name[br]=Lugent klask -Name[da]=SøgePlugin -Name[de]=Suche-Modul -Name[el]=Πρόσθετο αναζήτησης -Name[es]=Complemento de búsqueda -Name[et]=Otsimisplugin -Name[fa]=وصلۀ جستجو -Name[it]=Plugin di ricerca -Name[nb]=Søkemodul -Name[nds]=Söök-Moduul -Name[nl]=Zoekplugin -Name[pl]=Wtyczka wyszukiwania -Name[pt]='Plugin' de Procura -Name[pt_BR]=Plugin de Busca -Name[sk]=Vyhľadávací Plugin -Name[sr]=Прикључак претраге -Name[sr@Latn]=Priključak pretrage -Name[sv]=Sökinsticksprogram -Name[tr]=Arama Eklentisi -Name[uk]=Втулок пошуку -Name[xx]=xxSearchPluginxx -Name[zh_CN]=搜索插件 -Name[zh_TW]=搜尋外掛程式 -Comment=Search plugin for KTorrent -Comment[ar]=قابس البحث لِــ KTorrent -Comment[bg]=Приставка за търсене (KTorrent) -Comment[br]=Lugent klask evit KTorrent -Comment[ca]=Connector de cerca per a KTorrent -Comment[cs]=Vyhledávací modul pro KTorrent -Comment[da]=Søge-plugin for KTorrent -Comment[de]=Suche-Modul für KTorrent -Comment[el]=Πρόσθετο αναζήτησης για το KTorrent -Comment[es]=Complemento de búsqueda para KTorrent -Comment[et]=KTorrenti otsimisplugin -Comment[fa]=وصلۀ جستجو برای KTorrent -Comment[gl]=Plugin de procuras para KTorrent -Comment[it]=Plugin di ricerca per KTorrent -Comment[ja]=KTorrent のための検索プラグイン -Comment[ka]=ძებნის მოდული KTorrent-თვის -Comment[nb]=Søkemodul for KTorrent -Comment[nds]=Söök-Moduul för KTorrent -Comment[nl]=Zoekplugin voor KTorrent -Comment[pl]=Wtyczka wyszukiwania dla KTorrent -Comment[pt]='Plugin' de procura para o KTorrent -Comment[pt_BR]=Busca de plug-in para o KTorrent -Comment[sk]=Vyhľadávací plugin pre KTorrent -Comment[sr]=Прикључак претраге за KTorrent -Comment[sr@Latn]=Priključak pretrage za KTorrent -Comment[sv]=Sökinsticksprogram för Ktorrent -Comment[tr]=KTorrent için arama eklentisi -Comment[uk]=Втулок пошуку для KTorrent -Comment[xx]=xxSearch plugin for KTorrentxx -Comment[zh_CN]=KTorrent 的搜索插件 -Comment[zh_TW]=KTorrent 搜尋外掛程式 -X-TDE-ServiceTypes=KTorrent/Plugin -Type=Service -X-TDE-Library=ktsearchplugin diff --git a/plugins/search/ktsearchplugin.kcfg b/plugins/search/ktsearchplugin.kcfg deleted file mode 100644 index fdcc141..0000000 --- a/plugins/search/ktsearchplugin.kcfg +++ /dev/null @@ -1,30 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<kcfg xmlns="http://www.kde.org/standards/kcfg/1.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.kde.org/standards/kcfg/1.0 - http://www.kde.org/standards/kcfg/1.0/kcfg.xsd" > - - <kcfgfile name="ktsearchpluginrc"/> - <group name="general"> - <entry name="searchEngine" type="Int"> - <label>Current search engine</label> - <default>0</default> - </entry> - - <entry name="useDefaultBrowser" type ="Bool"> - <label>Use default browser</label> - <default>true</default> - </entry> - <entry name="useCustomBrowser" type ="Bool"> - <label>Use custom browser</label> - <default>false</default> - </entry> - <entry name="customBrowser" type ="String"> - <label>Custom browser executable path</label> - <default>/usr/bin/firefox</default> - </entry> - <entry name="openInExternal" type = "Bool"> - <default>false</default> - </entry> - </group> -</kcfg> diff --git a/plugins/search/searchbar.ui b/plugins/search/searchbar.ui deleted file mode 100644 index 562a0dd..0000000 --- a/plugins/search/searchbar.ui +++ /dev/null @@ -1,110 +0,0 @@ -<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> -<class>SearchBar</class> -<widget class="TQWidget"> - <property name="name"> - <cstring>SearchBar</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>804</width> - <height>52</height> - </rect> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="KPushButton"> - <property name="name"> - <cstring>m_back</cstring> - </property> - <property name="text"> - <string></string> - </property> - </widget> - <widget class="KPushButton"> - <property name="name"> - <cstring>m_reload</cstring> - </property> - <property name="text"> - <string></string> - </property> - </widget> - <widget class="KPushButton"> - <property name="name"> - <cstring>m_clear_button</cstring> - </property> - <property name="text"> - <string></string> - </property> - </widget> - <widget class="KLineEdit"> - <property name="name"> - <cstring>m_search_text</cstring> - </property> - </widget> - <widget class="KPushButton"> - <property name="name"> - <cstring>m_search_button</cstring> - </property> - <property name="text"> - <string>Search</string> - </property> - </widget> - <spacer> - <property name="name"> - <cstring>spacer1</cstring> - </property> - <property name="orientation"> - <enum>Horizontal</enum> - </property> - <property name="sizeType"> - <enum>Maximum</enum> - </property> - <property name="sizeHint"> - <size> - <width>60</width> - <height>20</height> - </size> - </property> - </spacer> - <widget class="TQLabel"> - <property name="name"> - <cstring>textLabel1</cstring> - </property> - <property name="text"> - <string>Engine:</string> - </property> - </widget> - <widget class="KComboBox"> - <property name="name"> - <cstring>m_search_engine</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>150</width> - <height>0</height> - </size> - </property> - </widget> - </hbox> -</widget> -<customwidgets> -</customwidgets> -<layoutdefaults spacing="6" margin="11"/> -<includes> - <include location="global" impldecl="in implementation">kcombobox.h</include> - <include location="global" impldecl="in implementation">klineedit.h</include> - <include location="global" impldecl="in implementation">kpushbutton.h</include> -</includes> -</UI> diff --git a/plugins/search/searchenginelist.cpp b/plugins/search/searchenginelist.cpp deleted file mode 100644 index 3381bf0..0000000 --- a/plugins/search/searchenginelist.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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 <tqfile.h> -#include <tqtextstream.h> -#include <tqstringlist.h> -#include "searchenginelist.h" - -using namespace bt; - -namespace kt -{ - - SearchEngineList::SearchEngineList() - {} - - - SearchEngineList::~SearchEngineList() - {} - - void SearchEngineList::save(const TQString& file) - { - TQFile fptr(file); - if (!fptr.open(IO_WriteOnly)) - return; - - TQTextStream out(&fptr); - out << "# PLEASE DO NOT MODIFY THIS FILE. Use KTorrent configuration dialog for adding new search engines." << ::endl; - out << "# SEARCH ENGINES list" << ::endl; - - TQValueList<SearchEngine>::iterator i = m_search_engines.begin(); - while (i != m_search_engines.end()) - { - SearchEngine & e = *i; - - // replace spaces by %20 - TQString name = e.name; - name = name.replace(" ","%20"); - TQString u = e.url.prettyURL(); - u = u.replace(" ","%20"); - out << name << " " << u << ::endl; - i++; - } - } - - void SearchEngineList::load(const TQString& file) - { - m_search_engines.clear(); - - TQFile fptr(file); - - if(!fptr.exists()) - makeDefaultFile(file); - - if (!fptr.open(IO_ReadOnly)) - return; - - TQTextStream in(&fptr); - - int id = 0; - - while (!in.atEnd()) - { - TQString line = in.readLine(); - - if(line.startsWith("#") || line.startsWith(" ") || line.isEmpty() ) continue; - - TQStringList tokens = TQStringList::split(" ", line); - - SearchEngine se; - se.name = tokens[0]; - se.name = se.name.replace("%20"," "); - se.url = KURL::fromPathOrURL(tokens[1]); - - for(Uint32 i=2; i<tokens.count(); ++i) - se.url.addQueryItem(tokens[i].section("=",0,0), tokens[i].section("=", 1, 1)); - - m_search_engines.append(se); - } - } - - void SearchEngineList::makeDefaultFile(const TQString& file) - { - TQFile fptr(file); - if (!fptr.open(IO_WriteOnly)) - return; - - TQTextStream out(&fptr); - out << "# PLEASE DO NOT MODIFY THIS FILE. Use KTorrent configuration dialog for adding new search engines." << ::endl; - out << "# SEARCH ENGINES list" << ::endl; - out << "isohunt.to http://isohunt.to/torrents/?ihq=FOOBAR" << ::endl; - out << "mininova.org http://www.mininova.org/search.php?search=FOOBAR" << ::endl; - out << "thepiratebay.se http://thepiratebay.se/search.php?q=FOOBAR" << ::endl; - out << "kickass.to http://kickass.to/usearch/FOOBAR" << ::endl; - out << "torrentfunk.com http://www.torrentfunk.com/all/torrents/FOOBAR.html" << ::endl; - out << "yourbittorrent.com http://yourbittorrent.com/?q=FOOBAR" << ::endl; - out << "torlock.com http://www.torlock.com/all/torrents/FOOBAR.html" << ::endl; - out << "torrentz.eu http://torrentz.eu/search?f=FOOBAR" << ::endl; - out << "torrentcrazy.com http://torrentcrazy.com/s/FOOBAR" << ::endl; - out << "bitsnoop.com http://bitsnoop.com/search/all/FOOBAR/c/d/1/" << ::endl; - out << "torrents.net http://www.torrents.net/find/FOOBAR/" << ::endl; - out << "btmon.com http://www.btmon.com/torrent/?f=FOOBAR" << ::endl; - } - - KURL SearchEngineList::getSearchURL(bt::Uint32 engine) const - { - if (engine >= m_search_engines.count()) - return KURL(); - else - return m_search_engines[engine].url; - } - - TQString SearchEngineList::getEngineName(bt::Uint32 engine) const - { - if (engine >= m_search_engines.count()) - return TQString(); - else - return m_search_engines[engine].name; - } - -} diff --git a/plugins/search/searchenginelist.h b/plugins/search/searchenginelist.h deleted file mode 100644 index 4b4d68e..0000000 --- a/plugins/search/searchenginelist.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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. * - ***************************************************************************/ -#ifndef KTSEARCHENGINELIST_H -#define KTSEARCHENGINELIST_H - -#include <kurl.h> -#include <tqvaluelist.h> -#include <util/constants.h> - -namespace kt -{ - - - /** - @author Joris Guisson <joris.guisson@gmail.com> - */ - class SearchEngineList - { - struct SearchEngine - { - TQString name; - KURL url; - }; - - TQValueList<SearchEngine> m_search_engines; - public: - SearchEngineList(); - virtual ~SearchEngineList(); - - void save(const TQString& file); - void load(const TQString& file); - void makeDefaultFile(const TQString& file); - - KURL getSearchURL(bt::Uint32 engine) const; - TQString getEngineName(bt::Uint32 engine) const; - - /// Get the number of engines - bt::Uint32 getNumEngines() const {return m_search_engines.count();} - }; - -} - -#endif diff --git a/plugins/search/searchplugin.cpp b/plugins/search/searchplugin.cpp deleted file mode 100644 index e1126f5..0000000 --- a/plugins/search/searchplugin.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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 <kgenericfactory.h> -#include <tdeglobal.h> -#include <tdelocale.h> -#include <kiconloader.h> -#include <kstdaction.h> -#include <tdepopupmenu.h> -#include <tdeapplication.h> -#include <kstandarddirs.h> -#include <krun.h> -#include <interfaces/guiinterface.h> -#include "searchplugin.h" -#include "searchwidget.h" -#include "searchprefpage.h" -#include "searchtab.h" -#include "searchpluginsettings.h" -#include "searchenginelist.h" - - -#define NAME "Search" -#define AUTHOR "Joris Guisson" -#define EMAIL "joris.guisson@gmail.com" - - - -K_EXPORT_COMPONENT_FACTORY(ktsearchplugin,KGenericFactory<kt::SearchPlugin>("ktsearchplugin")) - -namespace kt -{ - - SearchPlugin::SearchPlugin(TQObject* parent, const char* name, const TQStringList& args) - : Plugin(parent, name, args,NAME,i18n("Search"),AUTHOR,EMAIL, - i18n("Search for torrents on several popular torrent search engines"),"viewmag") - { - // setXMLFile("ktsearchpluginui.rc"); - pref = 0; - tab = 0; - } - - - SearchPlugin::~SearchPlugin() - {} - - - void SearchPlugin::load() - { - engines.load(TDEGlobal::dirs()->saveLocation("data","ktorrent") + "search_engines"); - TDEToolBar* tb = getGUI()->addToolBar("search"); - tab = new SearchTab(tb); - connect(tab,TQT_SIGNAL(search( const TQString&, int, bool )), - this,TQT_SLOT(search( const TQString&, int, bool ))); - - pref = new SearchPrefPage(this); - getGUI()->addPrefPage(pref); - pref->updateData(); - tab->updateSearchEngines(engines); - } - - void SearchPlugin::unload() - { - tab->saveSettings(); - SearchWidget* s = 0; - while ((s = searches.first()) != 0) - { - getGUI()->removeTabPage(s); - searches.removeFirst(); - delete s; - } - getGUI()->removeToolBar(tab->getToolBar()); - getGUI()->removePrefPage(pref); - delete pref; - pref = 0; - delete tab; - tab = 0; - } - - void SearchPlugin::search(const TQString & text,int engine,bool external) - { - if(external) - { - const SearchEngineList& sl = getSearchEngineList(); - - if (engine < 0 || engine >= sl.getNumEngines()) - engine = 0; - - TQString s_url = sl.getSearchURL(engine).prettyURL(); - s_url.replace("FOOBAR", KURL::encode_string(text), true); - KURL url = KURL::fromPathOrURL(s_url); - - if(SearchPluginSettings::useDefaultBrowser()) - kapp->invokeBrowser(url.url()); - else - KRun::runCommand(TQString("%1 \"%2\"").arg(SearchPluginSettings::customBrowser()).arg(url.url()), SearchPluginSettings::customBrowser(), "viewmag" ); - - return; - } - - TDEIconLoader* iload = TDEGlobal::iconLoader(); - - SearchWidget* search = new SearchWidget(this); - getGUI()->addTabPage(search,iload->loadIconSet("viewmag", TDEIcon::Small),text,this); - - TDEAction* copy_act = KStdAction::copy(TQT_TQOBJECT(search),TQT_SLOT(copy()),actionCollection()); - copy_act->plug(search->rightClickMenu(),0); - searches.append(search); - - search->updateSearchEngines(engines); - search->search(text,engine); - } - - void SearchPlugin::preferencesUpdated() - { - engines.load(TDEGlobal::dirs()->saveLocation("data","ktorrent") + "search_engines"); - if (tab) - tab->updateSearchEngines(engines); - - for (TQPtrList<SearchWidget>::iterator i = searches.begin(); i != searches.end();i++) - { - SearchWidget* w = *i; - w->updateSearchEngines(engines); - } - } - - void SearchPlugin::tabCloseRequest(kt::GUIInterface* gui,TQWidget* tab) - { - if (searches.contains((SearchWidget*)tab)) - { - searches.remove((SearchWidget*)tab); - gui->removeTabPage(tab); - tab->deleteLater(); - } - } - - bool SearchPlugin::versionCheck(const TQString & version) const - { - return version == KT_VERSION_MACRO; - } -} -#include "searchplugin.moc" diff --git a/plugins/search/searchplugin.h b/plugins/search/searchplugin.h deleted file mode 100644 index 6d6f2dd..0000000 --- a/plugins/search/searchplugin.h +++ /dev/null @@ -1,67 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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. * - ***************************************************************************/ -#ifndef KTSEARCHPLUGIN_H -#define KTSEARCHPLUGIN_H - -#include <tqptrlist.h> -#include <interfaces/plugin.h> -#include <interfaces/guiinterface.h> -#include "searchenginelist.h" - -namespace kt -{ - class SearchWidget; - class SearchPrefPage; - class SearchTab; - - /** - @author Joris Guisson - */ - class SearchPlugin : public Plugin, public kt::CloseTabListener - { - Q_OBJECT - - public: - SearchPlugin(TQObject* parent, const char* name, const TQStringList& args); - virtual ~SearchPlugin(); - - virtual void load(); - virtual void unload(); - virtual bool versionCheck(const TQString& version) const; - - void preferencesUpdated(); - - const SearchEngineList & getSearchEngineList() const {return engines;} - private slots: - void search(const TQString & text,int engine,bool external); - - private: - virtual void tabCloseRequest(kt::GUIInterface* gui,TQWidget* tab); - - private: - SearchPrefPage* pref; - SearchTab* tab; - SearchEngineList engines; - TQPtrList<SearchWidget> searches; - }; - -} - -#endif diff --git a/plugins/search/searchpluginsettings.kcfgc b/plugins/search/searchpluginsettings.kcfgc deleted file mode 100644 index 09cfd64..0000000 --- a/plugins/search/searchpluginsettings.kcfgc +++ /dev/null @@ -1,7 +0,0 @@ -# Code generation options for tdeconfig_compiler -File=ktsearchplugin.kcfg -ClassName=SearchPluginSettings -Namespace=kt -Singleton=true -Mutators=true -# will create the necessary code for setting those variables diff --git a/plugins/search/searchpref.ui b/plugins/search/searchpref.ui deleted file mode 100644 index 8f5761c..0000000 --- a/plugins/search/searchpref.ui +++ /dev/null @@ -1,312 +0,0 @@ -<!DOCTYPE UI><UI version="3.3" stdsetdef="1"> -<class>SEPreferences</class> -<widget class="TQWidget"> - <property name="name"> - <cstring>SEPreferences</cstring> - </property> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>529</width> - <height>515</height> - </rect> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>1</hsizetype> - <vsizetype>5</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>500</width> - <height>350</height> - </size> - </property> - <property name="caption"> - <string>Search Preferences</string> - </property> - <vbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQButtonGroup"> - <property name="name"> - <cstring>buttonGroup1</cstring> - </property> - <property name="title"> - <string>External Browser</string> - </property> - <vbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQCheckBox"> - <property name="name"> - <cstring>openExternal</cstring> - </property> - <property name="text"> - <string>Open searches in external browser</string> - </property> - </widget> - <widget class="TQRadioButton"> - <property name="name"> - <cstring>useDefaultBrowser</cstring> - </property> - <property name="text"> - <string>Use default browser</string> - </property> - </widget> - <widget class="TQLayoutWidget"> - <property name="name"> - <cstring>layout29</cstring> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQRadioButton"> - <property name="name"> - <cstring>useCustomBrowser</cstring> - </property> - <property name="text"> - <string>Custom browser path:</string> - </property> - </widget> - <widget class="KLineEdit"> - <property name="name"> - <cstring>customBrowser</cstring> - </property> - </widget> - <spacer> - <property name="name"> - <cstring>spacer20</cstring> - </property> - <property name="orientation"> - <enum>Horizontal</enum> - </property> - <property name="sizeType"> - <enum>Expanding</enum> - </property> - <property name="sizeHint"> - <size> - <width>40</width> - <height>20</height> - </size> - </property> - </spacer> - </hbox> - </widget> - </vbox> - </widget> - <widget class="TQGroupBox"> - <property name="name"> - <cstring>groupBox8</cstring> - </property> - <property name="title"> - <string>Search Engines</string> - </property> - <vbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="KActiveLabel"> - <property name="name"> - <cstring>m_infoLabel</cstring> - </property> - <property name="text"> - <string></string> - </property> - </widget> - <widget class="TQLayoutWidget"> - <property name="name"> - <cstring>layout22</cstring> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQLabel"> - <property name="name"> - <cstring>textLabel3</cstring> - </property> - <property name="text"> - <string>Search engine name:</string> - </property> - </widget> - <widget class="KLineEdit"> - <property name="name"> - <cstring>m_engine_name</cstring> - </property> - </widget> - </hbox> - </widget> - <widget class="TQLayoutWidget"> - <property name="name"> - <cstring>layout23</cstring> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQLabel"> - <property name="name"> - <cstring>textLabel4</cstring> - </property> - <property name="text"> - <string>URL:</string> - </property> - </widget> - <widget class="KLineEdit"> - <property name="name"> - <cstring>m_engine_url</cstring> - </property> - </widget> - <widget class="TQPushButton"> - <property name="name"> - <cstring>btnAdd</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>0</hsizetype> - <vsizetype>0</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="text"> - <string>&Add</string> - </property> - </widget> - </hbox> - </widget> - <widget class="TQListView"> - <column> - <property name="text"> - <string>Engines</string> - </property> - <property name="clickable"> - <bool>true</bool> - </property> - <property name="resizable"> - <bool>true</bool> - </property> - </column> - <column> - <property name="text"> - <string>URL</string> - </property> - <property name="clickable"> - <bool>true</bool> - </property> - <property name="resizable"> - <bool>true</bool> - </property> - </column> - <property name="name"> - <cstring>m_engines</cstring> - </property> - <property name="sizePolicy"> - <sizepolicy> - <hsizetype>7</hsizetype> - <vsizetype>7</vsizetype> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>0</width> - <height>50</height> - </size> - </property> - <property name="resizeMode"> - <enum>AllColumns</enum> - </property> - </widget> - <widget class="TQLayoutWidget"> - <property name="name"> - <cstring>layout5</cstring> - </property> - <hbox> - <property name="name"> - <cstring>unnamed</cstring> - </property> - <widget class="TQPushButton"> - <property name="name"> - <cstring>btnRemove</cstring> - </property> - <property name="text"> - <string>&Remove</string> - </property> - </widget> - <widget class="TQPushButton"> - <property name="name"> - <cstring>btnRemoveAll</cstring> - </property> - <property name="text"> - <string>R&emove All</string> - </property> - </widget> - <spacer> - <property name="name"> - <cstring>spacer19</cstring> - </property> - <property name="orientation"> - <enum>Horizontal</enum> - </property> - <property name="sizeType"> - <enum>Maximum</enum> - </property> - <property name="sizeHint"> - <size> - <width>16</width> - <height>20</height> - </size> - </property> - </spacer> - <widget class="TQPushButton"> - <property name="name"> - <cstring>btn_add_default</cstring> - </property> - <property name="text"> - <string>Add Defau&lt</string> - </property> - </widget> - <widget class="KPushButton"> - <property name="name"> - <cstring>btnUpdate</cstring> - </property> - <property name="text"> - <string>Update From Internet</string> - </property> - </widget> - </hbox> - </widget> - </vbox> - </widget> - </vbox> -</widget> -<customwidgets> -</customwidgets> -<connections> - <connection> - <sender>btnUpdate</sender> - <signal>clicked()</signal> - <receiver>SEPreferences</receiver> - <slot>btnUpdate_clicked()</slot> - </connection> -</connections> -<Q_SLOTS> - <slot>btnUpdate_clicked()</slot> -</Q_SLOTS> -<layoutdefaults spacing="6" margin="11"/> -<includes> - <include location="global" impldecl="in implementation">kactivelabel.h</include> - <include location="global" impldecl="in implementation">klineedit.h</include> - <include location="global" impldecl="in implementation">kpushbutton.h</include> -</includes> -</UI> diff --git a/plugins/search/searchprefpage.cpp b/plugins/search/searchprefpage.cpp deleted file mode 100644 index cc9e6d3..0000000 --- a/plugins/search/searchprefpage.cpp +++ /dev/null @@ -1,284 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson, Ivan Vasic * - * joris.guisson@gmail.com * - * ivasic@gmail.com * - * * - * 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 <kurl.h> -#include <tqtooltip.h> -#include <tqfile.h> -#include <tdelocale.h> -#include <tdeglobal.h> -#include <kstandarddirs.h> -#include <kiconloader.h> -#include <kactivelabel.h> -#include <kpushbutton.h> -#include <tdelistview.h> -#include <klineedit.h> -#include <tdemessagebox.h> -#include <tdeio/netaccess.h> -#include <klineedit.h> - -#include <tqlabel.h> -#include <tqcheckbox.h> -#include <tqradiobutton.h> - -#include <util/constants.h> -#include "searchprefpage.h" -#include "searchplugin.h" -#include "searchenginelist.h" -#include "searchpluginsettings.h" - -using namespace bt; - -namespace kt -{ - SearchPrefPageWidget::SearchPrefPageWidget(TQWidget *parent) : SEPreferences(parent) - { - TQString info = i18n("Use your web browser to search for the string %1" - " (capital letters) on the search engine you want to add. <br> " - "Then copy the URL in the addressbar after the search is finished, and paste it here.<br><br>Searching for %1" - " on Google for example, will result in http://www.google.com/search?q=FOOBAR&ie=UTF-8&oe=UTF-8. <br> " - "If you add this URL here, ktorrent can search using Google.").arg("FOOBAR").arg("FOOBAR"); - TQString info_short = i18n("Use your web browser to search for the string %1 (capital letters) " - "on the search engine you want to add. Use the resulting URL below.").arg("FOOBAR"); - m_infoLabel->setText(info_short); - TQToolTip::add(m_infoLabel,info); - TQToolTip::add(m_engine_name,info); - - connect(btnAdd, TQT_SIGNAL(clicked()), this, TQT_SLOT(addClicked())); - connect(btnRemove, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeClicked())); - connect(btn_add_default, TQT_SIGNAL(clicked()), this, TQT_SLOT(addDefaultClicked())); - connect(btnRemoveAll, TQT_SIGNAL(clicked()), this, TQT_SLOT(removeAllClicked())); - - connect(useCustomBrowser, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(customToggled( bool ))); - - useCustomBrowser->setChecked(SearchPluginSettings::useCustomBrowser()); - useDefaultBrowser->setChecked(SearchPluginSettings::useDefaultBrowser()); - customBrowser->setText(SearchPluginSettings::customBrowser()); - - customBrowser->setEnabled(useCustomBrowser->isChecked()); - openExternal->setChecked(SearchPluginSettings::openInExternal()); - } - - void SearchPrefPageWidget::updateSearchEngines(const SearchEngineList & se) - { - m_engines->clear(); - - for (Uint32 i = 0;i < se.getNumEngines();i++) - { - new TQListViewItem(m_engines,se.getEngineName(i),se.getSearchURL(i).prettyURL()); - } - } - - bool SearchPrefPageWidget::apply() - { - saveSearchEngines(); - - SearchPluginSettings::setUseCustomBrowser(useCustomBrowser->isChecked()); - SearchPluginSettings::setUseDefaultBrowser(useDefaultBrowser->isChecked()); - SearchPluginSettings::setCustomBrowser(customBrowser->text()); - SearchPluginSettings::setOpenInExternal(openExternal->isChecked()); - SearchPluginSettings::writeConfig(); - return true; - } - - void SearchPrefPageWidget::saveSearchEngines() - { - TQFile fptr(TDEGlobal::dirs()->saveLocation("data","ktorrent") + "search_engines"); - if (!fptr.open(IO_WriteOnly)) - return; - TQTextStream out(&fptr); - out << "# PLEASE DO NOT MODIFY THIS FILE. Use KTorrent configuration dialog for adding new search engines." << ::endl; - out << "# SEARCH ENGINES list" << ::endl; - - TQListViewItemIterator itr(m_engines); - while (itr.current()) - { - TQListViewItem* item = itr.current(); - TQString u = item->text(1); - TQString name = item->text(0); - out << name.replace(" ","%20") << " " << u.replace(" ","%20") << endl; - itr++; - } - } - - void SearchPrefPageWidget::addClicked() - { - if ( m_engine_url->text().isEmpty() || m_engine_name->text().isEmpty() ) - { - KMessageBox::error(this, i18n("You must enter the search engine's name and URL")); - } - else if ( m_engine_url->text().contains("FOOBAR") ) - { - KURL url = KURL::fromPathOrURL(m_engine_url->text()); - if ( !url.isValid() ) - { - KMessageBox::error(this, i18n("Malformed URL.")); - return; - } - - if (m_engines->findItem(m_engine_name->text(), 0)) - { - KMessageBox::error(this, i18n("A search engine with the same name already exists. Please use a different name.")); return; - } - - new TQListViewItem(m_engines, m_engine_name->text(), m_engine_url->text()); - m_engine_url->setText(""); - m_engine_name->setText(""); - } - else - { - KMessageBox::error(this, i18n("Bad URL. You should search for FOOBAR with your Internet browser and copy/paste the exact URL here.")); - } - } - - void SearchPrefPageWidget::removeClicked() - { - if ( m_engines->selectedItem() == 0 ) - return; - - TQListViewItem* item = m_engines->selectedItem(); - m_engines->takeItem(item); - delete item; - } - - void SearchPrefPageWidget::addDefaultClicked() - { - TQListViewItem* se = new TQListViewItem(m_engines, "isohunt.to", "http://isohunt.to/torrents/?ihq=FOOBAR"); - se = new TQListViewItem(m_engines, "mininova.org", "http://www.mininova.org/search.php?search=FOOBAR"); - se = new TQListViewItem(m_engines, "thepiratebay.se", "http://thepiratebay.se/search.php?q=FOOBAR"); - se = new TQListViewItem(m_engines, "kickass.to", "http://kickass.to/usearch/FOOBAR"); - se = new TQListViewItem(m_engines, "torrentfunk.com", "http://www.torrentfunk.com/all/torrents/FOOBAR.html"); - se = new TQListViewItem(m_engines, "yourbittorrent.com", "http://yourbittorrent.com/?q=FOOBAR"); - se = new TQListViewItem(m_engines, "torlock.com", "http://www.torlock.com/all/torrents/FOOBAR.html"); - se = new TQListViewItem(m_engines, "torrentz.eu", "http://torrentz.eu/search?f=FOOBAR"); - se = new TQListViewItem(m_engines, "torrentcrazy.com", "http://torrentcrazy.com/s/FOOBAR"); - se = new TQListViewItem(m_engines, "bitsnoop.com", "http://bitsnoop.com/search/all/FOOBAR/c/d/1/"); - se = new TQListViewItem(m_engines, "torrents.net", "http://www.torrents.net/find/FOOBAR/"); - se = new TQListViewItem(m_engines, "btmon.com", "http://www.btmon.com/torrent/?f=FOOBAR"); - } - - void SearchPrefPageWidget::removeAllClicked() - { - m_engines->clear(); - } - - void SearchPrefPageWidget::btnUpdate_clicked() - { - TQString fn = TDEGlobal::dirs()->saveLocation("data","ktorrent") + "search_engines.tmp"; - KURL source("http://www.ktorrent.org/downloads/search_engines"); - - if (TDEIO::NetAccess::download(source,fn,NULL)) - { - //list successfully downloaded, remove temporary file - updateList(fn); - saveSearchEngines(); - TDEIO::NetAccess::removeTempFile(fn); - } - } - - void SearchPrefPageWidget::updateList(TQString& source) - { - TQFile fptr(source); - - if (!fptr.open(IO_ReadOnly)) - return; - - TQTextStream in(&fptr); - - TQMap<TQString,KURL> engines; - - while (!in.atEnd()) - { - TQString line = in.readLine(); - - if(line.startsWith("#") || line.startsWith(" ") || line.isEmpty() ) - continue; - - TQStringList tokens = TQStringList::split(" ", line); - TQString name = tokens[0]; - name = name.replace("%20"," "); - - KURL url = KURL::fromPathOrURL(tokens[1]); - for(Uint32 i=2; i<tokens.count(); ++i) - url.addQueryItem(tokens[i].section("=",0,0), tokens[i].section("=", 1, 1)); - - engines.insert(name,url); - } - - TQMap<TQString,KURL>::iterator i = engines.begin(); - while (i != engines.end()) - { - TQListViewItem* item = m_engines->findItem(i.key(),0); - // if we have found the item, replace it if not make a new one - if (item) - item->setText(1, i.data().prettyURL()); - else - new TQListViewItem(m_engines,i.key(),i.data().prettyURL()); - - i++; - } - } - - //////////////////////////////////////////////////////////////////////////////////////////// - - - SearchPrefPage::SearchPrefPage(SearchPlugin* plugin) - : PrefPageInterface(i18n("a noun", "Search"), i18n("Search Engine Options"), - TDEGlobal::iconLoader()->loadIcon("viewmag",TDEIcon::NoGroup)), m_plugin(plugin) - { - widget = 0; - } - - - SearchPrefPage::~SearchPrefPage() - {} - - - bool SearchPrefPage::apply() - { - bool ret = widget->apply(); - if(ret) - m_plugin->preferencesUpdated(); - - return ret; - } - - void SearchPrefPage::createWidget(TQWidget* parent) - { - widget = new SearchPrefPageWidget(parent); - } - - void SearchPrefPage::deleteWidget() - { - delete widget; - } - - void SearchPrefPage::updateData() - { - widget->updateSearchEngines(m_plugin->getSearchEngineList()); - - } - - void SearchPrefPageWidget::customToggled(bool toggled) - { - customBrowser->setEnabled(toggled); - } -} - -#include "searchprefpage.moc" diff --git a/plugins/search/searchprefpage.h b/plugins/search/searchprefpage.h deleted file mode 100644 index fb2565a..0000000 --- a/plugins/search/searchprefpage.h +++ /dev/null @@ -1,79 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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. * - ***************************************************************************/ -#ifndef KTSEARCHPREFPAGE_H -#define KTSEARCHPREFPAGE_H - - -#include <interfaces/prefpageinterface.h> -#include "searchpref.h" - -#include <tqstring.h> - -namespace kt -{ - class SearchPlugin; - class SearchEngineList; - - class SearchPrefPageWidget : public SEPreferences - { - Q_OBJECT - - public: - SearchPrefPageWidget(TQWidget *parent = 0); - - bool apply(); - void saveSearchEngines(); - void updateList(TQString& source); - - void updateSearchEngines(const SearchEngineList & se); - - public slots: - virtual void btnUpdate_clicked(); - void customToggled(bool toggled); - - private slots: - void addClicked(); - void removeClicked(); - void addDefaultClicked(); - void removeAllClicked(); - }; - - /** - @author Joris Guisson - */ - class SearchPrefPage : public PrefPageInterface - { - public: - SearchPrefPage(SearchPlugin* plugin); - virtual ~SearchPrefPage(); - - virtual bool apply(); - virtual void createWidget(TQWidget* parent); - virtual void updateData(); - virtual void deleteWidget(); - - private: - SearchPrefPageWidget* widget; - SearchPlugin* m_plugin; - }; - -} - -#endif diff --git a/plugins/search/searchtab.cpp b/plugins/search/searchtab.cpp deleted file mode 100644 index c752bc5..0000000 --- a/plugins/search/searchtab.cpp +++ /dev/null @@ -1,169 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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 <tqfile.h> -#include <tqtextstream.h> -#include <tqapplication.h> -#include <tqlistbox.h> -#include <tqcheckbox.h> -#include <tdeglobal.h> -#include <kpushbutton.h> -#include <kiconloader.h> -#include <kcombobox.h> -#include <kcompletion.h> -#include <tqlabel.h> -#include <tdelocale.h> -#include "searchtab.h" -#include "searchenginelist.h" -#include "searchpluginsettings.h" -#include "functions.h" - -using namespace bt; - -namespace kt -{ - - SearchTab::SearchTab(TDEToolBar* tb) : m_tool_bar(tb) - { - m_search_text = new KComboBox(tb); - m_search_text->setEditable(true); - - m_clear_button = new KPushButton(tb); - m_search_new_tab = new KPushButton(i18n("Search"),tb); - m_search_engine = new KComboBox(tb); - - m_clear_button->setIconSet(SmallIconSet(TQApplication::reverseLayout() ? "clear_left" : "locationbar_erase")); - m_clear_button->setEnabled(false); - - connect(m_search_new_tab,TQT_SIGNAL(clicked()),this,TQT_SLOT(searchNewTabPressed())); - connect(m_search_text,TQT_SIGNAL(returnPressed(const TQString&)),this,TQT_SLOT(searchBoxReturn( const TQString& ))); - connect(m_search_text,TQT_SIGNAL(textChanged(const TQString &)),this,TQT_SLOT(textChanged( const TQString& ))); - connect(m_clear_button,TQT_SIGNAL(clicked()),this,TQT_SLOT(clearButtonPressed())); - m_search_text->setMaxCount(20); - m_search_new_tab->setEnabled(false); - m_search_text->setInsertionPolicy(TQComboBox::NoInsertion); - - tb->insertWidget(1,-1,m_clear_button); - tb->insertWidget(2,-1,m_search_text); - tb->insertWidget(3,-1,m_search_new_tab); - tb->insertWidget(4,-1,new TQLabel(i18n(" Engine: "),tb)); - tb->insertWidget(5,-1,m_search_engine); - loadSearchHistory(); - } - - SearchTab::~SearchTab() - { - } - - void SearchTab::saveSettings() - { - SearchPluginSettings::setSearchEngine(m_search_engine->currentItem()); - SearchPluginSettings::writeConfig(); - } - - void SearchTab::updateSearchEngines(const SearchEngineList & sl) - { - int ci = 0; - if (m_search_engine->count() == 0) - ci = SearchPluginSettings::searchEngine(); - else - ci = m_search_engine->currentItem(); - - m_search_engine->clear(); - for (Uint32 i = 0;i < sl.getNumEngines();i++) - { - m_search_engine->insertItem(sl.getEngineName(i)); - } - m_search_engine->setCurrentItem(ci); - } - - void SearchTab::searchBoxReturn(const TQString & str) - { - TDECompletion *comp = m_search_text->completionObject(); - if (!m_search_text->contains(str)) - { - comp->addItem(str); - m_search_text->insertItem(str); - } - m_search_text->clearEdit(); - saveSearchHistory(); - search(str,m_search_engine->currentItem(),SearchPluginSettings::openInExternal()); - } - - void SearchTab::clearButtonPressed() - { - m_search_text->clearEdit(); - } - - void SearchTab::searchNewTabPressed() - { - searchBoxReturn(m_search_text->currentText()); - } - - void SearchTab::textChanged(const TQString & str) - { - m_search_new_tab->setEnabled(str.length() > 0); - m_clear_button->setEnabled(str.length() > 0); - } - - void SearchTab::loadSearchHistory() - { - TQFile fptr(kt::DataDir() + "search_history"); - if (!fptr.open(IO_ReadOnly)) - return; - - TDECompletion *comp = m_search_text->completionObject(); - - Uint32 cnt = 0; - TQTextStream in(&fptr); - while (!in.atEnd() && cnt < 50) - { - TQString line = in.readLine(); - if (line.isNull()) - break; - - if (!m_search_text->contains(line)) - { - comp->addItem(line); - m_search_text->insertItem(line); - } - cnt++; - } - - m_search_text->clearEdit(); - } - - void SearchTab::saveSearchHistory() - { - TQFile fptr(kt::DataDir() + "search_history"); - if (!fptr.open(IO_WriteOnly)) - return; - - TQTextStream out(&fptr); - TDECompletion *comp = m_search_text->completionObject(); - TQStringList items = comp->items(); - for (TQStringList::iterator i = items.begin();i != items.end();i++) - { - out << *i << endl; - } - } -} - -#include "searchtab.moc" - diff --git a/plugins/search/searchtab.h b/plugins/search/searchtab.h deleted file mode 100644 index 2f63ab1..0000000 --- a/plugins/search/searchtab.h +++ /dev/null @@ -1,78 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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. * - ***************************************************************************/ - -#ifndef SEARCHTAB_H -#define SEARCHTAB_H - -#include <tdetoolbar.h> - -class KComboBox; -class KPushButton; - -namespace kt -{ - class SearchEngineList; - - /** - Holds all widgets of the toolbar of the search plugin. - */ - class SearchTab : public TQObject - { - Q_OBJECT - - - public: - SearchTab(TDEToolBar* toolbar); - virtual ~SearchTab(); - - /// Get the tool bar - TDEToolBar* getToolBar() {return m_tool_bar;} - - /// Update the search engine list - void updateSearchEngines(const SearchEngineList & sl); - - /// Save settings like current search engine - void saveSettings(); - - protected slots: - void clearButtonPressed(); - void searchNewTabPressed(); - void searchBoxReturn(const TQString & str); - void textChanged(const TQString & str); - - signals: - /// Emitted when the user presses enter or clicks search - void search(const TQString & text,int engine,bool external); - - private: - void loadSearchHistory(); - void saveSearchHistory(); - - private: - TDEToolBar* m_tool_bar; - KComboBox* m_search_text; - KComboBox* m_search_engine; - KPushButton* m_clear_button; - KPushButton* m_search_new_tab; - }; -} - -#endif - diff --git a/plugins/search/searchwidget.cpp b/plugins/search/searchwidget.cpp deleted file mode 100644 index 128ceeb..0000000 --- a/plugins/search/searchwidget.cpp +++ /dev/null @@ -1,272 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson, Ivan Vasic * - * joris.guisson@gmail.com * - * ivasic@gmail.com * - * * - * 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 <tdeapplication.h> -#include <tdehtmlview.h> -#include <tqlayout.h> -#include <tqfile.h> -#include <tqtextstream.h> -#include <tqstring.h> -#include <tqstringlist.h> -#include <klineedit.h> -#include <kpushbutton.h> -#include <tdeglobal.h> -#include <tdelocale.h> -#include <kstandarddirs.h> -#include <kiconloader.h> -#include <kcombobox.h> -#include <tdepopupmenu.h> -#include <tdeparts/partmanager.h> -#include <tdeio/job.h> -#include <tdemessagebox.h> -#include <tdefiledialog.h> -#include <kprogress.h> -#include <util/log.h> -#include <torrent/globals.h> -#include <interfaces/guiinterface.h> -#include <interfaces/coreinterface.h> -#include "searchwidget.h" -#include "searchbar.h" -#include "htmlpart.h" -#include "searchplugin.h" -#include "searchenginelist.h" - - - -using namespace bt; - -namespace kt -{ - - - SearchWidget::SearchWidget(SearchPlugin* sp) : html_part(0),sp(sp) - { - TQVBoxLayout* layout = new TQVBoxLayout(this); - layout->setAutoAdd(true); - sbar = new SearchBar(this); - html_part = new HTMLPart(this); - - right_click_menu = new TDEPopupMenu(this); - right_click_menu->insertSeparator(); - back_id = right_click_menu->insertItem( - TDEGlobal::iconLoader()->loadIconSet(TQApplication::reverseLayout() - ? "forward" : "back",TDEIcon::Small), - i18n("Back"),html_part,TQT_SLOT(back())); - right_click_menu->insertItem( - TDEGlobal::iconLoader()->loadIconSet("reload",TDEIcon::Small), - i18n("Reload"),html_part,TQT_SLOT(reload())); - - right_click_menu->setItemEnabled(back_id,false); - sbar->m_back->setEnabled(false); - connect(sbar->m_search_button,TQT_SIGNAL(clicked()),this,TQT_SLOT(searchPressed())); - connect(sbar->m_clear_button,TQT_SIGNAL(clicked()),this,TQT_SLOT(clearPressed())); - connect(sbar->m_search_text,TQT_SIGNAL(returnPressed()),this,TQT_SLOT(searchPressed())); - connect(sbar->m_back,TQT_SIGNAL(clicked()),html_part,TQT_SLOT(back())); - connect(sbar->m_reload,TQT_SIGNAL(clicked()),html_part,TQT_SLOT(reload())); - - sbar->m_clear_button->setIconSet( - TDEGlobal::iconLoader()->loadIconSet(TQApplication::reverseLayout() - ? "clear_left" : "locationbar_erase",TDEIcon::Small)); - sbar->m_back->setIconSet( - TDEGlobal::iconLoader()->loadIconSet(TQApplication::reverseLayout() - ? "forward" : "back", TDEIcon::Small)); - sbar->m_reload->setIconSet( - TDEGlobal::iconLoader()->loadIconSet("reload",TDEIcon::Small)); - - - connect(html_part,TQT_SIGNAL(backAvailable(bool )), - this,TQT_SLOT(onBackAvailable(bool ))); - connect(html_part,TQT_SIGNAL(onURL(const TQString& )), - this,TQT_SLOT(onURLHover(const TQString& ))); - connect(html_part,TQT_SIGNAL(openTorrent(const KURL& )), - this,TQT_SLOT(onOpenTorrent(const KURL& ))); - connect(html_part,TQT_SIGNAL(popupMenu(const TQString&, const TQPoint& )), - this,TQT_SLOT(showPopupMenu(const TQString&, const TQPoint& ))); - connect(html_part,TQT_SIGNAL(searchFinished()),this,TQT_SLOT(onFinished())); - connect(html_part,TQT_SIGNAL(saveTorrent(const KURL& )), - this,TQT_SLOT(onSaveTorrent(const KURL& ))); - - KParts::PartManager* pman = html_part->partManager(); - connect(pman,TQT_SIGNAL(partAdded(KParts::Part*)),this,TQT_SLOT(onFrameAdded(KParts::Part* ))); - - connect(html_part->browserExtension(),TQT_SIGNAL(loadingProgress(int)),this,TQT_SLOT(loadingProgress(int))); - prog = 0; - } - - - SearchWidget::~SearchWidget() - { - if (prog) - { - sp->getGUI()->removeProgressBarFromStatusBar(prog); - prog = 0; - } - } - - void SearchWidget::updateSearchEngines(const SearchEngineList & sl) - { - int ci = sbar->m_search_engine->currentItem(); - sbar->m_search_engine->clear(); - for (Uint32 i = 0;i < sl.getNumEngines();i++) - { - sbar->m_search_engine->insertItem(sl.getEngineName(i)); - } - sbar->m_search_engine->setCurrentItem(ci); - } - - void SearchWidget::onBackAvailable(bool available) - { - sbar->m_back->setEnabled(available); - right_click_menu->setItemEnabled(back_id,available); - } - - void SearchWidget::onFrameAdded(KParts::Part* p) - { - TDEHTMLPart* frame = dynamic_cast<TDEHTMLPart*>(p); - if (frame) - { - connect(frame,TQT_SIGNAL(popupMenu(const TQString&, const TQPoint& )), - this,TQT_SLOT(showPopupMenu(const TQString&, const TQPoint& ))); - } - } - - void SearchWidget::copy() - { - if (!html_part) - return; - html_part->copy(); - } - - void SearchWidget::search(const TQString & text,int engine) - { - if (!html_part) - return; - - if (sbar->m_search_text->text() != text) - sbar->m_search_text->setText(text); - - if (sbar->m_search_engine->currentItem() != engine) - sbar->m_search_engine->setCurrentItem(engine); - - const SearchEngineList & sl = sp->getSearchEngineList(); - - if (engine < 0 || (Uint32)engine >= sl.getNumEngines()) - engine = sbar->m_search_engine->currentItem(); - - TQString s_url = sl.getSearchURL(engine).prettyURL(); - s_url.replace("FOOBAR", KURL::encode_string(text), true); - KURL url = KURL::fromPathOrURL(s_url); - - statusBarMsg(i18n("Searching for %1...").arg(text)); - //html_part->openURL(url); - html_part->openURLRequest(url,KParts::URLArgs()); - } - - void SearchWidget::searchPressed() - { - search(sbar->m_search_text->text(),sbar->m_search_engine->currentItem()); - } - - void SearchWidget::clearPressed() - { - sbar->m_search_text->clear(); - } - - void SearchWidget::onURLHover(const TQString & url) - { - statusBarMsg(url); - } - - void SearchWidget::onFinished() - { - } - - void SearchWidget::onOpenTorrent(const KURL & url) - { - openTorrent(url); - } - - void SearchWidget::onSaveTorrent(const KURL & url) - { - KFileDialog fdlg(TQString(),"*.torrent | " + i18n("torrent files"),this,0,true); - fdlg.setSelection(url.fileName()); - fdlg.setOperationMode(KFileDialog::Saving); - if (fdlg.exec() == TQDialog::Accepted) - { - KURL save_url = fdlg.selectedURL(); - // start a copy job - TDEIO::Job* j = TDEIO::file_copy(url,save_url,-1,true); - // let it deal with the errors - j->setAutoErrorHandlingEnabled(true,0); - } - } - - void SearchWidget::showPopupMenu(const TQString & url,const TQPoint & p) - { - right_click_menu->popup(p); - } - - TDEPopupMenu* SearchWidget::rightClickMenu() - { - return right_click_menu; - } - - void SearchWidget::onShutDown() - { - delete html_part; - html_part = 0; - } - - void SearchWidget::statusBarMsg(const TQString & url) - { - sp->getGUI()->changeStatusbar(url); - } - - void SearchWidget::openTorrent(const KURL & url) - { - sp->getCore()->load(url); - } - - void SearchWidget::loadingProgress(int perc) - { - if (perc < 100 && !prog) - { - prog = sp->getGUI()->addProgressBarToStatusBar(); - if (prog) - prog->setValue(perc); - } - else if (prog && perc < 100) - { - prog->setValue(perc); - } - else if (perc == 100) - { - if (prog) - { - sp->getGUI()->removeProgressBarFromStatusBar(prog); - prog = 0; - } - statusBarMsg(i18n("Search finished")); - } - } -} - -#include "searchwidget.moc" diff --git a/plugins/search/searchwidget.h b/plugins/search/searchwidget.h deleted file mode 100644 index 9d42b93..0000000 --- a/plugins/search/searchwidget.h +++ /dev/null @@ -1,90 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2005 by Joris Guisson * - * joris.guisson@gmail.com * - * * - * 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. * - ***************************************************************************/ -#ifndef BTSEARCHWIDGET_H -#define BTSEARCHWIDGET_H - -#include <tqwidget.h> -#include <tqvaluevector.h> -#include <kurl.h> - -class SearchBar; -class KProgress; -class TDEPopupMenu; - -namespace KParts -{ - class Part; -} - -namespace kt -{ - class HTMLPart; - class SearchPlugin; - class SearchEngineList; - - - /** - @author Joris Guisson - - Widget which shows a TDEHTML window with the users search in it - */ - class SearchWidget : public TQWidget - { - Q_OBJECT - - public: - SearchWidget(SearchPlugin* sp); - virtual ~SearchWidget(); - - TDEPopupMenu* rightClickMenu(); - - void updateSearchEngines(const SearchEngineList & sl); - - public slots: - void search(const TQString & text,int engine = 0); - void copy(); - void onShutDown(); - - private slots: - void searchPressed(); - void clearPressed(); - void onURLHover(const TQString & url); - void onFinished(); - void onOpenTorrent(const KURL & url); - void onSaveTorrent(const KURL & url); - void showPopupMenu(const TQString & s,const TQPoint & p); - void onBackAvailable(bool available); - void onFrameAdded(KParts::Part* p); - void statusBarMsg(const TQString & url); - void openTorrent(const KURL & url); - void loadingProgress(int perc); - - private: - HTMLPart* html_part; - SearchBar* sbar; - TDEPopupMenu* right_click_menu; - int back_id; - SearchPlugin* sp; - KProgress* prog; - }; - -} - -#endif |
