Seafood/mainwindow.cpp
changeset 7 7ee47a65f1ad
parent 3 e6d1a78b6db9
child 10 79eeacfd15ff
--- 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()