wip
authorJohn Kern <johnk@symbian.org>
Thu, 25 Mar 2010 16:49:34 -0700
changeset 7 7ee47a65f1ad
parent 6 e8f500c881af
child 8 10275049db7b
wip
Seafood/Fishes.cpp
Seafood/SeafoodTabbed.pro
Seafood/mainwindow.cpp
Seafood/mainwindow.h
Seafood/mainwindow.ui
--- a/Seafood/Fishes.cpp	Thu Mar 25 16:21:13 2010 -0700
+++ b/Seafood/Fishes.cpp	Thu Mar 25 16:49:34 2010 -0700
@@ -21,8 +21,8 @@
         qWarning("db not found ");
     } else {
         qWarning("found db ");
-        qWarning(dbFile.toStdString().c_str());
     }
+    qWarning(dbFile.toStdString().c_str());
     db.setDatabaseName(dbFile);
 
     // Open databasee
--- a/Seafood/SeafoodTabbed.pro	Thu Mar 25 16:21:13 2010 -0700
+++ b/Seafood/SeafoodTabbed.pro	Thu Mar 25 16:49:34 2010 -0700
@@ -4,7 +4,7 @@
 #
 #-------------------------------------------------
 
-QT       += core gui sql svg
+QT       += core gui sql svg webkit network
 
 TARGET = SeafoodTabbed
 TEMPLATE = app
--- a/Seafood/mainwindow.cpp	Thu Mar 25 16:21:13 2010 -0700
+++ b/Seafood/mainwindow.cpp	Thu Mar 25 16:49:34 2010 -0700
@@ -2,8 +2,10 @@
 #include <QIcon>
 #include <QListWidget>
 #include <QMessageBox>
+#include <QStackedWidget>
 #include <QTableWidget>
 #include <QDesktopServices>
+#include <QWebView>
 
 #include "Fishes.h"
 #include "mainwindow.h"
@@ -15,8 +17,11 @@
     ui(new Ui::MainWindow)
 {
     ui->setupUi(this);
+    setContextMenuPolicy(Qt::NoContextMenu);
     Fishes *f = new Fishes();
 
+    this->stackedWidget = new QStackedWidget;
+
     this->tabWidget = new QTabWidget;
     // QIcon icon = new QIcon(":/database/icons/weather-sunny.svg");
     // this->tabWidget->setTabIcon(1, icon);
@@ -32,7 +37,17 @@
     this->worstList = new QListWidget;
     this->worstList->addItems(f->GetWorst());
     this->tabWidget->addTab(this->worstList, "worst");
-    setCentralWidget(tabWidget);
+
+    this->stackedWidget->addWidget(tabWidget); // associated with EListPage
+
+    this->ecoDetails = new QWebView;
+    this->ecoDetails->setHtml("<html><title>Eco Details</title><ul><li>not yet implemented</li></ul></html>");
+
+    this->stackedWidget->addWidget(this->ecoDetails); // associated with EEcoPage
+
+    this->stackedWidget->addWidget(ui->centralWidget); // associated with ENutritionPage
+
+    setCentralWidget(stackedWidget);
 }
 
 MainWindow::~MainWindow()
@@ -42,9 +57,18 @@
 
 void MainWindow::createMenus()
     {
+
+        ecoAction = new QAction(tr("&eco details"),this);
+        menuBar()->addAction(ecoAction);
+        connect(ecoAction, SIGNAL(triggered()),this, SLOT(displayEcoDetails()));
+
         nuAction = new QAction(tr("&Nutrition"),this);
         menuBar()->addAction(nuAction);
-        connect(nuAction, SIGNAL(triggered()),this, SLOT(displayVersion()));
+        connect(nuAction, SIGNAL(triggered()),this, SLOT(displayNutrition()));
+
+        fishesAction = new QAction(tr("&List Fishes"),this);
+        menuBar()->addAction(fishesAction);
+        connect(fishesAction, SIGNAL(triggered()),this, SLOT(displayList()));
 
         verAction = new QAction(tr("&Version"),this);
         menuBar()->addAction(verAction);
@@ -57,7 +81,23 @@
 
 void MainWindow::displayVersion()
 {
-    QMessageBox::information(this,"Qt Version", qVersion());
+//    QMessageBox::information(this,"Qt Version", qVersion());
+     QMessageBox::information(this,"selected item", "NYI");
+}
+
+void MainWindow::displayNutrition()
+{
+    this->stackedWidget->setCurrentIndex(MainWindow::ENutritionPage);
+}
+
+void MainWindow::displayEcoDetails()
+{
+    this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage);
+}
+
+void MainWindow::displayList()
+{
+    this->stackedWidget->setCurrentIndex(MainWindow::EListPage);
 }
 
 void MainWindow::displayPath()
--- a/Seafood/mainwindow.h	Thu Mar 25 16:21:13 2010 -0700
+++ b/Seafood/mainwindow.h	Thu Mar 25 16:49:34 2010 -0700
@@ -3,8 +3,10 @@
 
 #include <QMainWindow>
 
+class QStackedWidget;
 class QTabWidget;
 class QListWidget;
+class QWebView;
 
 namespace Ui {
     class MainWindow;
@@ -16,22 +18,34 @@
     explicit MainWindow(QWidget *parent = 0);
     ~MainWindow();
 
+    enum {EListPage = 0,
+          EEcoPage,
+          ENutritionPage};
+
     void createMenus();
 
 public slots:
     void displayVersion();
     void displayPath();
+    void displayEcoDetails();
+    void displayList();
+    void displayNutrition();
 
 protected:
     void changeEvent(QEvent *e);
 
 private:
     Ui::MainWindow *ui;
+    QStackedWidget *stackedWidget;
     QTabWidget *tabWidget;
     QListWidget *bestList;
     QListWidget *okList;
     QListWidget *worstList;
 
+    QWebView *ecoDetails;
+
+    QAction *ecoAction;
+    QAction *fishesAction;
     QAction *nuAction;
     QAction *verAction;
     QAction *exitAction;
--- a/Seafood/mainwindow.ui	Thu Mar 25 16:21:13 2010 -0700
+++ b/Seafood/mainwindow.ui	Thu Mar 25 16:49:34 2010 -0700
@@ -13,7 +13,42 @@
   <property name="windowTitle">
    <string>MainWindow</string>
   </property>
-  <widget class="QWidget" name="centralWidget"/>
+  <widget class="QWidget" name="centralWidget">
+   <widget class="QWidget" name="">
+    <property name="geometry">
+     <rect>
+      <x>60</x>
+      <y>80</y>
+      <width>258</width>
+      <height>242</height>
+     </rect>
+    </property>
+    <layout class="QVBoxLayout" name="verticalLayout">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="font">
+        <font>
+         <pointsize>14</pointsize>
+        </font>
+       </property>
+       <property name="text">
+        <string>Nutrition information</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QTableWidget" name="tableWidget"/>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Source: USDA</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </widget>
+  </widget>
   <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
     <rect>