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"
36 SearchPlugin::SearchPlugin() :
37 comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
39 // TODO: Parse engine descriptions.
40 // -Add engines to model
41 // -Show model in comboBox
45 void SearchPlugin::initialize(PluginHostInterface* host)
51 QWidget *pluginWidget = new QWidget;
52 QVBoxLayout *vbox = new QVBoxLayout;
53 QHBoxLayout *hbox = new QHBoxLayout;
54 comboBox_ = new QComboBox;
55 searchLine_ = new QLineEdit;
56 searchButton_ = new QPushButton("Search");
58 hbox->addWidget(searchLine_);
59 hbox->addWidget(searchButton_);
60 vbox->addWidget(comboBox_);
61 vbox->addLayout(hbox);
62 pluginWidget->setLayout(vbox);
64 connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
65 //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
67 host_->setGui(pluginWidget, qtrapids::PluginHostInterface::BASE_WIDGET);
71 QWidget* SearchPlugin::getGui()
76 void SearchPlugin::on_searchButton_clicked()
78 QUrl searchUrl(QString("http://www.google.fi/search?q="
79 + searchLine_->text()));
80 qDebug() << searchUrl;
81 QWebView *result = new QWebView;
82 result->load(searchUrl);
84 on_searchResult((QWidget*)result);
87 void SearchPlugin::on_searchResult(QWidget* resultWidget)
89 qDebug() << "on_searchResult()";
91 host_->addPluginWidget(resultWidget, qtrapids::PluginHostInterface::TAB_PAGE);
95 } // namespace qtrapids
97 Q_EXPORT_PLUGIN2(searchplugin, qtrapids::SearchPlugin)