- Search plugin interface changed: enum constants to define widget types to allow...
[qtrapids] / src / plugins / searchplugin / SearchPlugin.cpp
index f4ded6d..27417f1 100644 (file)
@@ -1,3 +1,23 @@
+/***************************************************************************
+ *   Copyright (C) 2009 by Lassi Väätämöinen   *
+ *   lassi.vaatamoinen@ixonos.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.,                                       *
+ *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
+ ***************************************************************************/
+
 #include <QDebug>
 #include <QtCore/qplugin.h>
 #include <QVBoxLayout>
 
 namespace qtrapids
 {
-SearchPlugin::SearchPlugin() :
-        comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
-{
-    // TODO: Parse engine descriptions.
-    // -Add engines to model
-    // -Show model in comboBox
-
-}
-
-void SearchPlugin::initialize(PluginHostInterface* host)
-{
-    host_ = host;
-
-    if (host_ != NULL)
-    {
-
-        QWidget *pluginWidget = new QWidget;
-        QVBoxLayout *vbox = new QVBoxLayout;
-        QHBoxLayout *hbox = new QHBoxLayout;
-        comboBox_ = new QComboBox;
-        searchLine_ = new QLineEdit;
-        searchButton_ = new QPushButton("Search");
-
-        hbox->addWidget(searchLine_);
-        hbox->addWidget(searchButton_);
-        vbox->addWidget(comboBox_);
-        vbox->addLayout(hbox);
-        pluginWidget->setLayout(vbox);
-
-        connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
-        //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
-
-        host_->setGui(pluginWidget);
-    }
-}
-
-QWidget* SearchPlugin::getGui()
-{
-    return NULL;
-}
-
-void SearchPlugin::on_searchButton_clicked()
-{
-    QUrl searchUrl(QString("http://www.google.fi/search?q="
-                           + searchLine_->text()));
-    qDebug() << searchUrl;
-    QWebView *result = new QWebView;
-    result->load(searchUrl);
-
-    on_searchResult((QWidget*)result);
-}
-
-void SearchPlugin::on_searchResult(QWidget* resultWidget)
-{
-    qDebug() << "on_searchResult()";
-    if (host_)
-    {
-        host_->addPluginWidget(resultWidget);
-    }
-}
+       SearchPlugin::SearchPlugin() : 
+               comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
+       {
+               // TODO: Parse engine descriptions.
+               // -Add engines to model
+               // -Show model in comboBox
+       
+       }
+       
+       void SearchPlugin::initialize(PluginHostInterface* host)
+       {
+               host_ = host;
+               
+               if (host_ != NULL) {
+                       
+                       QWidget *pluginWidget = new QWidget;
+                       QVBoxLayout *vbox = new QVBoxLayout;
+                       QHBoxLayout *hbox = new QHBoxLayout;
+                       comboBox_ = new QComboBox;
+                       searchLine_ = new QLineEdit;
+                       searchButton_ = new QPushButton("Search");
+                       
+                       hbox->addWidget(searchLine_);
+                       hbox->addWidget(searchButton_);
+                       vbox->addWidget(comboBox_);
+                       vbox->addLayout(hbox);
+                       pluginWidget->setLayout(vbox);
+       
+                       connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
+                       //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
+                       
+                       host_->setGui(pluginWidget, qtrapids::PluginHostInterface::BASE_WIDGET);
+               }
+       }
+       
+       QWidget* SearchPlugin::getGui()
+       {
+               return NULL;
+       }
+       
+       void SearchPlugin::on_searchButton_clicked()
+       {
+               QUrl searchUrl(QString("http://www.google.fi/search?q="
+                       + searchLine_->text()));
+               qDebug() << searchUrl;
+               QWebView *result = new QWebView;
+               result->load(searchUrl);
+               
+               on_searchResult((QWidget*)result);
+       }
+       
+       void SearchPlugin::on_searchResult(QWidget* resultWidget)
+       {
+               qDebug() << "on_searchResult()";
+               if (host_) {
+                       host_->addPluginWidget(resultWidget, qtrapids::PluginHostInterface::TAB_PAGE);
+               }
+       }
 
 } // namespace qtrapids