Seafood/mainwindow.cpp
author John Kern <johnk@symbian.org>
Wed, 14 Apr 2010 10:40:46 -0700
changeset 16 e26c25b72a12
parent 15 0f80a0f39475
permissions -rwxr-xr-x
fix the table layout looks presentable
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     1
#include <QFile>
15
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
     2
#include <QtGlobal>
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
     3
 #include <QDebug>
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     4
#include <QIcon>
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     5
#include <QListWidget>
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     6
#include <QMessageBox>
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
     7
#include <QStackedWidget>
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     8
#include <QTableWidget>
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
     9
#include <QDesktopServices>
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    10
#include <QWebView>
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    11
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    12
#include "Fishes.h"
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    13
#include "mainwindow.h"
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    14
#include "ui_mainwindow.h"
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    15
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    16
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    17
MainWindow::MainWindow(QWidget *parent) :
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    18
    QMainWindow(parent),
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    19
    ui(new Ui::MainWindow)
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    20
{
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    21
    ui->setupUi(this);
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    22
    setContextMenuPolicy(Qt::NoContextMenu);
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    23
    this->fishDb = new Fishes(this);
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    24
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    25
    this->stackedWidget = new QStackedWidget;
16
e26c25b72a12 fix the table layout looks presentable
John Kern <johnk@symbian.org>
parents: 15
diff changeset
    26
    this->stackedWidget->setSizePolicy(QSizePolicy::Maximum,QSizePolicy::Maximum);
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    27
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    28
    // lists of fish
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    29
    this->tabWidget = new QTabWidget;
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    30
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    31
    this->bestList = new QListWidget;
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    32
    this->bestList->addItems(this->fishDb->getBest());
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    33
    this->tabWidget->addTab(this->bestList, "best");
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    34
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    35
    this->okList = new QListWidget;
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    36
    this->okList->addItems(this->fishDb->getOK());
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    37
    this->tabWidget->addTab(this->okList, "ok");
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    38
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    39
    this->worstList = new QListWidget;
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    40
    this->worstList->addItems(this->fishDb->getWorst());
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    41
    this->tabWidget->addTab(this->worstList, "worst");
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    42
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    43
    this->index = EBestList;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    44
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    45
    connect(this->tabWidget, SIGNAL(currentChanged(int)),
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    46
            this, SLOT(setCurrentList(int)));
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    47
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    48
    this->stackedWidget->addWidget(tabWidget); // associated with EListPage
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    49
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    50
    // Eco details
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    51
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    52
    this->ecoDetails = new QWebView;
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    53
    this->ecoDetails->setHtml("<html><title>Eco Details</title><ul><li>not yet implemented</li></ul></html>");
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    54
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    55
    this->stackedWidget->addWidget(this->ecoDetails); // associated with EEcoPage
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    56
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    57
    // Nutrition page
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    58
    this->stackedWidget->addWidget(ui->centralWidget); // associated with ENutritionPage
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    59
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    60
    setCentralWidget(stackedWidget);
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    61
}
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    62
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    63
MainWindow::~MainWindow()
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    64
{
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    65
    delete ui;
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    66
}
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    67
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    68
void MainWindow::createMenus()
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    69
    {
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    70
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    71
        ecoAction = new QAction(tr("&eco details"),this);
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    72
        menuBar()->addAction(ecoAction);
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    73
        connect(ecoAction, SIGNAL(triggered()),this, SLOT(displayEcoDetails()));
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    74
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    75
        nuAction = new QAction(tr("&Nutrition"),this);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    76
        menuBar()->addAction(nuAction);
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    77
        connect(nuAction, SIGNAL(triggered()),this, SLOT(displayNutrition()));
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    78
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    79
        fishesAction = new QAction(tr("&List Fishes"),this);
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    80
        menuBar()->addAction(fishesAction);
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    81
        connect(fishesAction, SIGNAL(triggered()),this, SLOT(displayList()));
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    82
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    83
        verAction = new QAction(tr("&Version"),this);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    84
        menuBar()->addAction(verAction);
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    85
        connect(verAction, SIGNAL(triggered()),this, SLOT(displayVersion()));
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    86
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    87
        exitAction = new QAction(tr("&Exit"),this);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    88
        menuBar()->addAction(exitAction);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    89
        connect(exitAction, SIGNAL(triggered()),this, SLOT(close()));
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    90
    }
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    91
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    92
void MainWindow::displayVersion()
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
    93
{
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
    94
    QMessageBox::information(this,"Qt Version", qVersion());
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    95
}
John Kern <johnk@symbian.org>
parents: 3
diff changeset
    96
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    97
 QString MainWindow::currentlySelectedItem()
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    98
 {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
    99
     QString selectedName;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   100
     QListWidgetItem *item=NULL;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   101
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   102
     switch (this->index)
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   103
     {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   104
     case EBestList:
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   105
         item = this->bestList->currentItem();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   106
         if (item)
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   107
         {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   108
             selectedName = item->text();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   109
         }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   110
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   111
         break;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   112
     case EOkList:
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   113
         item = this->okList->currentItem();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   114
         if (item) {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   115
             selectedName = item->text();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   116
         }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   117
         break;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   118
     case EWorstList:
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   119
         item = this->worstList->currentItem();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   120
         if (item) {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   121
             selectedName = item->text();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   122
         }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   123
         break;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   124
     }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   125
     return selectedName;
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   126
 }
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   127
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   128
void MainWindow::displayEcoDetails()
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   129
{
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   130
    QString selectedName = this->currentlySelectedItem();
11
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   131
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   132
    if (selectedName.isEmpty()) {
11
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   133
        QMessageBox::information(this,"warning","select an item from list." );
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   134
    } else {
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   135
        this->ecoDetails->setHtml( this->fishDb->getEcoDetails(selectedName));
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   136
        this->stackedWidget->setCurrentIndex(MainWindow::EEcoPage);
f3dbeee07821 instrumented with debugging output
John Kern <johnk@symbian.org>
parents: 10
diff changeset
   137
    }
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   138
}
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   139
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   140
void MainWindow::displayNutrition()
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   141
{
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   142
    QString selectedName = this->currentlySelectedItem();
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   143
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   144
    if (selectedName.isEmpty()) {
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   145
        QMessageBox::information(this,"warning","select an item from list." );
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   146
    } else {
15
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   147
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   148
        QMap<Fishes::TNUTRITION, QString> nutrition (this->fishDb->getNutrition(selectedName));
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   149
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   150
        const int COLUMN = 1;
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   151
        int row=0;
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   152
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   153
        QTableWidgetItem *newItem;
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   154
        newItem = new QTableWidgetItem(nutrition[Fishes::ECalories] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   155
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   156
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   157
        newItem = new QTableWidgetItem(nutrition[Fishes::ETotalFat] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   158
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   159
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   160
        newItem = new QTableWidgetItem(nutrition[Fishes::ETotalProtein] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   161
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   162
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   163
        newItem = new QTableWidgetItem(nutrition[Fishes::EOmega3] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   164
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   165
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   166
        newItem = new QTableWidgetItem(nutrition[Fishes::ECholesterol] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   167
        this->ui->tableWidget->setItem(row++,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   168
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   169
        newItem = new QTableWidgetItem(nutrition[Fishes::ESodium] );
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   170
        this->ui->tableWidget->setItem(row,COLUMN, newItem);
0f80a0f39475 populate the nutrition table
John Kern <johnk@symbian.org>
parents: 14
diff changeset
   171
14
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   172
        this->stackedWidget->setCurrentIndex(MainWindow::ENutritionPage);
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   173
    }
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   174
}
a16afe3df8c9 get nutrition information from db
John Kern <johnk@symbian.org>
parents: 11
diff changeset
   175
7
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   176
void MainWindow::displayList()
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   177
{
John Kern <johnk@symbian.org>
parents: 3
diff changeset
   178
    this->stackedWidget->setCurrentIndex(MainWindow::EListPage);
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   179
}
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   180
10
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   181
void MainWindow::setCurrentList(int l)
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   182
{
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   183
    switch (l)
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   184
    {
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   185
    case 0:
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   186
        this->index = EBestList;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   187
        break;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   188
    case 1:
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   189
        this->index = EOkList;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   190
        break;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   191
    case 2:
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   192
        this->index = EWorstList;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   193
        break;
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   194
    }
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   195
}
79eeacfd15ff implement eco details with webview
User@User-PC.domain_not_set.invalid
parents: 7
diff changeset
   196
3
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   197
void MainWindow::changeEvent(QEvent *e)
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   198
{
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   199
    QMainWindow::changeEvent(e);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   200
    switch (e->type()) {
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   201
    case QEvent::LanguageChange:
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   202
        ui->retranslateUi(this);
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   203
        break;
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   204
    default:
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   205
        break;
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   206
    }
e6d1a78b6db9 wip - start of an example for my forthcoming presentation
John Kern <johnk@symbian.org>
parents:
diff changeset
   207
}