Seafood/mainwindow.cpp
changeset 7 7ee47a65f1ad
parent 3 e6d1a78b6db9
child 10 79eeacfd15ff
equal deleted inserted replaced
6:e8f500c881af 7:7ee47a65f1ad
     1 #include <QFile>
     1 #include <QFile>
     2 #include <QIcon>
     2 #include <QIcon>
     3 #include <QListWidget>
     3 #include <QListWidget>
     4 #include <QMessageBox>
     4 #include <QMessageBox>
       
     5 #include <QStackedWidget>
     5 #include <QTableWidget>
     6 #include <QTableWidget>
     6 #include <QDesktopServices>
     7 #include <QDesktopServices>
       
     8 #include <QWebView>
     7 
     9 
     8 #include "Fishes.h"
    10 #include "Fishes.h"
     9 #include "mainwindow.h"
    11 #include "mainwindow.h"
    10 #include "ui_mainwindow.h"
    12 #include "ui_mainwindow.h"
    11 
    13 
    13 MainWindow::MainWindow(QWidget *parent) :
    15 MainWindow::MainWindow(QWidget *parent) :
    14     QMainWindow(parent),
    16     QMainWindow(parent),
    15     ui(new Ui::MainWindow)
    17     ui(new Ui::MainWindow)
    16 {
    18 {
    17     ui->setupUi(this);
    19     ui->setupUi(this);
       
    20     setContextMenuPolicy(Qt::NoContextMenu);
    18     Fishes *f = new Fishes();
    21     Fishes *f = new Fishes();
       
    22 
       
    23     this->stackedWidget = new QStackedWidget;
    19 
    24 
    20     this->tabWidget = new QTabWidget;
    25     this->tabWidget = new QTabWidget;
    21     // QIcon icon = new QIcon(":/database/icons/weather-sunny.svg");
    26     // QIcon icon = new QIcon(":/database/icons/weather-sunny.svg");
    22     // this->tabWidget->setTabIcon(1, icon);
    27     // this->tabWidget->setTabIcon(1, icon);
    23 
    28 
    30     this->tabWidget->addTab(this->okList, "ok");
    35     this->tabWidget->addTab(this->okList, "ok");
    31 
    36 
    32     this->worstList = new QListWidget;
    37     this->worstList = new QListWidget;
    33     this->worstList->addItems(f->GetWorst());
    38     this->worstList->addItems(f->GetWorst());
    34     this->tabWidget->addTab(this->worstList, "worst");
    39     this->tabWidget->addTab(this->worstList, "worst");
    35     setCentralWidget(tabWidget);
    40 
       
    41     this->stackedWidget->addWidget(tabWidget); // associated with EListPage
       
    42 
       
    43     this->ecoDetails = new QWebView;
       
    44     this->ecoDetails->setHtml("<html><title>Eco Details</title><ul><li>not yet implemented</li></ul></html>");
       
    45 
       
    46     this->stackedWidget->addWidget(this->ecoDetails); // associated with EEcoPage
       
    47 
       
    48     this->stackedWidget->addWidget(ui->centralWidget); // associated with ENutritionPage
       
    49 
       
    50     setCentralWidget(stackedWidget);
    36 }
    51 }
    37 
    52 
    38 MainWindow::~MainWindow()
    53 MainWindow::~MainWindow()
    39 {
    54 {
    40     delete ui;
    55     delete ui;
    41 }
    56 }
    42 
    57 
    43 void MainWindow::createMenus()
    58 void MainWindow::createMenus()
    44     {
    59     {
       
    60 
       
    61         ecoAction = new QAction(tr("&eco details"),this);
       
    62         menuBar()->addAction(ecoAction);
       
    63         connect(ecoAction, SIGNAL(triggered()),this, SLOT(displayEcoDetails()));
       
    64 
    45         nuAction = new QAction(tr("&Nutrition"),this);
    65         nuAction = new QAction(tr("&Nutrition"),this);
    46         menuBar()->addAction(nuAction);
    66         menuBar()->addAction(nuAction);
    47         connect(nuAction, SIGNAL(triggered()),this, SLOT(displayVersion()));
    67         connect(nuAction, SIGNAL(triggered()),this, SLOT(displayNutrition()));
       
    68 
       
    69         fishesAction = new QAction(tr("&List Fishes"),this);
       
    70         menuBar()->addAction(fishesAction);
       
    71         connect(fishesAction, SIGNAL(triggered()),this, SLOT(displayList()));
    48 
    72 
    49         verAction = new QAction(tr("&Version"),this);
    73         verAction = new QAction(tr("&Version"),this);
    50         menuBar()->addAction(verAction);
    74         menuBar()->addAction(verAction);
    51         connect(verAction, SIGNAL(triggered()),this, SLOT(displayVersion()));
    75         connect(verAction, SIGNAL(triggered()),this, SLOT(displayVersion()));
    52 
    76 
    55         connect(exitAction, SIGNAL(triggered()),this, SLOT(close()));
    79         connect(exitAction, SIGNAL(triggered()),this, SLOT(close()));
    56     }
    80     }
    57 
    81 
    58 void MainWindow::displayVersion()
    82 void MainWindow::displayVersion()
    59 {
    83 {
    60     QMessageBox::information(this,"Qt Version", qVersion());
    84 //    QMessageBox::information(this,"Qt Version", qVersion());
       
    85      QMessageBox::information(this,"selected item", "NYI");
       
    86 }
       
    87 
       
    88 void MainWindow::displayNutrition()
       
    89 {
       
    90     this->stackedWidget->setCurrentIndex(MainWindow::ENutritionPage);
       
    91 }
       
    92 
       
    93 void MainWindow::displayEcoDetails()
       
    94 {
       
    95     this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage);
       
    96 }
       
    97 
       
    98 void MainWindow::displayList()
       
    99 {
       
   100     this->stackedWidget->setCurrentIndex(MainWindow::EListPage);
    61 }
   101 }
    62 
   102 
    63 void MainWindow::displayPath()
   103 void MainWindow::displayPath()
    64 {
   104 {
    65     QString dbFile = QDesktopServices::storageLocation(QDesktopServices::DataLocation)
   105     QString dbFile = QDesktopServices::storageLocation(QDesktopServices::DataLocation)