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)
52 QWidget *pluginWidget = new QWidget;
53 QVBoxLayout *vbox = new QVBoxLayout;
54 QHBoxLayout *hbox = new QHBoxLayout;
55 comboBox_ = new QComboBox;
56 searchLine_ = new QLineEdit;
57 searchButton_ = new QPushButton("Search");
59 hbox->addWidget(searchLine_);
60 hbox->addWidget(searchButton_);
61 vbox->addWidget(comboBox_);
62 vbox->addLayout(hbox);
63 pluginWidget->setLayout(vbox);
65 connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
66 //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
68 host_->setGui(this, pluginWidget);
72 QWidget* SearchPlugin::getGui()
77 void SearchPlugin::on_searchButton_clicked()
79 QUrl searchUrl(QString("http://www.google.fi/search?q="
80 + searchLine_->text()));
81 qDebug() << searchUrl;
82 QWebView *result = new QWebView;
83 result->load(searchUrl);
85 on_searchResult((QWidget*)result);
88 void SearchPlugin::on_searchResult(QWidget* resultWidget)
90 qDebug() << "on_searchResult()";
92 host_->addPluginWidget(this, resultWidget);
96 SearchPlugin::SearchPlugin() :
97 comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
99 // TODO: Parse engine descriptions.
100 // -Add engines to model
101 // -Show model in comboBox
106 void SearchPlugin::initialize(PluginHostInterface* host)
113 QWidget *pluginWidget = new QWidget;
114 QVBoxLayout *vbox = new QVBoxLayout;
115 QHBoxLayout *hbox = new QHBoxLayout;
116 comboBox_ = new QComboBox;
117 searchLine_ = new QLineEdit;
118 searchButton_ = new QPushButton("Search");
120 hbox->addWidget(searchLine_);
121 hbox->addWidget(searchButton_);
122 vbox->addWidget(comboBox_);
123 vbox->addLayout(hbox);
124 pluginWidget->setLayout(vbox);
126 connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
127 //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
129 host_->setGui(pluginWidget);
133 QWidget* SearchPlugin::getGui()
138 void SearchPlugin::on_searchButton_clicked()
140 QUrl searchUrl(QString("http://www.google.fi/search?q="
141 + searchLine_->text()));
142 qDebug() << searchUrl;
143 QWebView *result = new QWebView;
144 result->load(searchUrl);
146 on_searchResult((QWidget*)result);
149 void SearchPlugin::on_searchResult(QWidget* resultWidget)
151 qDebug() << "on_searchResult()";
154 host_->addPluginWidget(resultWidget);
158 } // namespace qtrapids
160 Q_EXPORT_PLUGIN2(searchplugin, qtrapids::SearchPlugin)