- Plugin interface added to MainWindow
[qtrapids] / src / plugins / searchplugin / SearchPlugin.cpp
index 656b5f9..10165f0 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>
@@ -13,6 +33,7 @@
 
 namespace qtrapids
 {
+<<<<<<< .mine
        SearchPlugin::SearchPlugin() : 
                comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
        {
@@ -44,7 +65,7 @@ namespace qtrapids
                        connect(searchButton_, SIGNAL(clicked()), this, SLOT(on_searchButton_clicked()));
                        //connect(this, SIGNAL(searchResult(QWidget*)), this, SLOT(on_searchResult(QWidget*)));
                        
-                       host_->setGui(pluginWidget);
+                       host_->setGui(this, pluginWidget);
                }
        }
        
@@ -68,9 +89,71 @@ namespace qtrapids
        {
                qDebug() << "on_searchResult()";
                if (host_) {
-                       host_->addPluginWidget(resultWidget);
+                       host_->addPluginWidget(this, resultWidget);
                }
        }
+=======
+SearchPlugin::SearchPlugin() :
+        comboBox_(NULL), searchLine_(NULL), searchButton_(NULL), host_(NULL)
+{
+    // TODO: Parse engine descriptions.
+    // -Add engines to model
+    // -Show model in comboBox
+>>>>>>> .r31
+
+}
+
+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);
+    }
+}
 
 } // namespace qtrapids