-Code formatted using script
[qtrapids] / src / plugins / searchplugin / SearchPlugin.cpp
1 /***************************************************************************
2  *   Copyright (C) 2009 by Lassi Väätämöinen   *
3  *   lassi.vaatamoinen@ixonos.com   *
4  *                                                                         *
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.                                   *
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20
21 #include <QDebug>
22 #include <QtCore/qplugin.h>
23 #include <QVBoxLayout>
24 #include <QHBoxLayout>
25 #include <QComboBox>
26 #include <QLineEdit>
27 #include <QPushButton>
28 #include <QUrl>
29 #include <QWebView>
30
31
32 #include "SearchPlugin.h"
33
34 namespace qtrapids
35 {
36 <<<<<<< .mine
37 SearchPlugin::SearchPlugin() :
38         comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
39 {
40     // TODO: Parse engine descriptions.
41     // -Add engines to model
42     // -Show model in comboBox
43
44 }
45
46 void SearchPlugin::initialize(PluginHostInterface* host)
47 {
48     host_ = host;
49
50     if (host_ != NULL)
51     {
52
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");
59
60         hbox->addWidget(searchLine_);
61         hbox->addWidget(searchButton_);
62         vbox->addWidget(comboBox_);
63         vbox->addLayout(hbox);
64         pluginWidget->setLayout(vbox);
65
66         connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
67         //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
68
69         host_->setGui(this, pluginWidget);
70     }
71 }
72
73 QWidget* SearchPlugin::getGui()
74 {
75     return NULL;
76 }
77
78 void SearchPlugin::on_searchButton_clicked()
79 {
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);
85
86     on_searchResult((QWidget*)result);
87 }
88
89 void SearchPlugin::on_searchResult(QWidget* resultWidget)
90 {
91     qDebug() << "on_searchResult()";
92     if (host_)
93     {
94         host_->addPluginWidget(this, resultWidget);
95     }
96 }
97 =======
98     SearchPlugin::SearchPlugin() :
99             comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
100 {
101     // TODO: Parse engine descriptions.
102     // -Add engines to model
103     // -Show model in comboBox
104     >>>>>>> .r31
105
106 }
107
108 void SearchPlugin::initialize(PluginHostInterface* host)
109 {
110     host_ = host;
111
112     if (host_ != NULL)
113     {
114
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");
121
122         hbox->addWidget(searchLine_);
123         hbox->addWidget(searchButton_);
124         vbox->addWidget(comboBox_);
125         vbox->addLayout(hbox);
126         pluginWidget->setLayout(vbox);
127
128         connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
129         //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
130
131         host_->setGui(pluginWidget);
132     }
133 }
134
135 QWidget* SearchPlugin::getGui()
136 {
137     return NULL;
138 }
139
140 void SearchPlugin::on_searchButton_clicked()
141 {
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);
147
148     on_searchResult((QWidget*)result);
149 }
150
151 void SearchPlugin::on_searchResult(QWidget* resultWidget)
152 {
153     qDebug() << "on_searchResult()";
154     if (host_)
155     {
156         host_->addPluginWidget(resultWidget);
157     }
158 }
159
160 } // namespace qtrapids
161
162 Q_EXPORT_PLUGIN2(searchplugin, qtrapids::SearchPlugin)