1 /***************************************************************************
2 * Copyright (C) 2009 by Lassi Väätämöinen *
3 * lassi.vaatamoinen@ixonos.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
22 #include <QtCore/qplugin.h>
23 #include <QVBoxLayout>
24 #include <QHBoxLayout>
27 #include <QPushButton>
32 #include "SearchPlugin.h"
37 SearchPlugin::SearchPlugin() :
38 comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
40 // TODO: Parse engine descriptions.
41 // -Add engines to model
42 // -Show model in comboBox
46 void SearchPlugin::initialize(PluginHostInterface* host)
53 QWidget *pluginWidget = new QWidget;
54 QVBoxLayout *vbox = new QVBoxLayout;
55 QHBoxLayout *hbox = new QHBoxLayout;
56 comboBox_ = new QComboBox;
57 searchLine_ = new QLineEdit;
58 searchButton_ = new QPushButton("Search");
60 hbox->addWidget(searchLine_);
61 hbox->addWidget(searchButton_);
62 vbox->addWidget(comboBox_);
63 vbox->addLayout(hbox);
64 pluginWidget->setLayout(vbox);
66 connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
67 //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
69 host_->setGui(this, pluginWidget);
73 QWidget* SearchPlugin::getGui()
78 void SearchPlugin::on_searchButton_clicked()
80 QUrl searchUrl(QString("http://www.google.fi/search?q="
81 + searchLine_->text()));
82 qDebug() << searchUrl;
83 QWebView *result = new QWebView;
84 result->load(searchUrl);
86 on_searchResult((QWidget*)result);
89 void SearchPlugin::on_searchResult(QWidget* resultWidget)
91 qDebug() << "on_searchResult()";
94 host_->addPluginWidget(this, resultWidget);
98 SearchPlugin::SearchPlugin() :
99 comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
101 // TODO: Parse engine descriptions.
102 // -Add engines to model
103 // -Show model in comboBox
108 void SearchPlugin::initialize(PluginHostInterface* host)
115 QWidget *pluginWidget = new QWidget;
116 QVBoxLayout *vbox = new QVBoxLayout;
117 QHBoxLayout *hbox = new QHBoxLayout;
118 comboBox_ = new QComboBox;
119 searchLine_ = new QLineEdit;
120 searchButton_ = new QPushButton("Search");
122 hbox->addWidget(searchLine_);
123 hbox->addWidget(searchButton_);
124 vbox->addWidget(comboBox_);
125 vbox->addLayout(hbox);
126 pluginWidget->setLayout(vbox);
128 connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
129 //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
131 host_->setGui(pluginWidget);
135 QWidget* SearchPlugin::getGui()
140 void SearchPlugin::on_searchButton_clicked()
142 QUrl searchUrl(QString("http://www.google.fi/search?q="
143 + searchLine_->text()));
144 qDebug() << searchUrl;
145 QWebView *result = new QWebView;
146 result->load(searchUrl);
148 on_searchResult((QWidget*)result);
151 void SearchPlugin::on_searchResult(QWidget* resultWidget)
153 qDebug() << "on_searchResult()";
156 host_->addPluginWidget(resultWidget);
160 } // namespace qtrapids
162 Q_EXPORT_PLUGIN2(searchplugin, qtrapids::SearchPlugin)