contactengine/mainwindow.cpp
author wesleyt@symbian.org
Thu, 09 Sep 2010 11:30:41 -0700
changeset 45 b23ec2b62c45
parent 37 1ced6e446fd4
permissions -rwxr-xr-x
resizing layouts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
     1
#include <QComboBox>
30
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
     2
#include <QMenuBar>
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
     3
#include <QMessageBox>
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
     4
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
     5
#include <QDebug>
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
     6
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     7
#include "mainwindow.h"
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     8
#include "ui_mainwindow.h"
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
     9
#include "contactsengine.h"
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    10
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    11
MainWindow::MainWindow(QWidget *parent) :
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    12
    QMainWindow(parent),
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    13
    ui(new Ui::MainWindow)
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    14
{
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    15
    ui->setupUi(this);
34
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    16
    this->createMenus();
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    17
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    18
    this->ce = new ContactsEngine(this);
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    19
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    20
    connect(this->ce, SIGNAL(errorOccurred(QString)),
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    21
            this,SLOT(errorOccurred(QString)));
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    22
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    23
    connect(ui->comboBox, SIGNAL( activated ( const QString &  )),
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    24
            this->ce, SLOT(setManager(const QString &) ));
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    25
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    26
    this->ce->createManager();
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    27
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    28
    ui->comboBox->addItems(this->ce->dataSources());
23
51fcdd1558d8 clean up
John Kern <johnk@symbian.org>
parents: 19
diff changeset
    29
    ui->listView->setModel(this->ce);
30
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    30
34
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    31
    this->details = new DetailsGV(this,ui->graphicsView);
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    32
    connect(this->details,SIGNAL(closeMe()),this,SLOT(close()));
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    33
    connect(this->details,SIGNAL(backToList()),this, SLOT(displayList()));
37
1ced6e446fd4 Major contribution: Connected clicked signal from listbox to displayDetails slot
Sebastian Brannstrom <sebastianb@symbian.org>
parents: 34
diff changeset
    34
    connect(ui->listView, SIGNAL(clicked(QModelIndex)),this, SLOT(displayDetails()));
34
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    35
    ui->stackedWidget->setCurrentIndex(MainWindow::EListPage);
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    36
30
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    37
}
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    38
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    39
void MainWindow::createMenus()
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    40
    {
34
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    41
        detailsAction = new QAction(tr("&Details"),this);
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    42
        menuBar()->addAction(detailsAction);
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    43
        connect(detailsAction, SIGNAL(triggered()),this, SLOT(displayDetails()));
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    44
30
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    45
        verAction = new QAction(tr("&Version"),this);
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    46
        menuBar()->addAction(verAction);
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    47
        connect(verAction, SIGNAL(triggered()),this, SLOT(displayVersion()));
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    48
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    49
        exitAction = new QAction(tr("&Exit"),this);
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    50
        menuBar()->addAction(exitAction);
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    51
        connect(exitAction, SIGNAL(triggered()),this, SLOT(close()));
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    52
    }
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    53
34
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    54
void MainWindow::displayDetails()
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    55
{
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    56
    ui->stackedWidget->setCurrentIndex(MainWindow::EDetailsGV);
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    57
}
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    58
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    59
void MainWindow::displayList()
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    60
{
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    61
    ui->stackedWidget->setCurrentIndex(MainWindow::EListPage);
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    62
}
93c5a58496b6 add graphics view which presents contacts details
John Kern <johnk@symbian.org>
parents: 30
diff changeset
    63
30
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    64
void MainWindow::displayVersion()
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    65
{
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    66
    QMessageBox::information(this,"Qt Version", qVersion());
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    67
}
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    68
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    69
void MainWindow::errorOccurred(QString errMsg)
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    70
{
30
33e489bb7487 add options menu
John Kern <johnk@symbian.org>
parents: 25
diff changeset
    71
    QMessageBox::information(this,"Err Routed",errMsg);
25
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    72
    qDebug() << errMsg << endl;
adbe71832e2b runs on-device now; testing on 5800
John Kern <johnk@symbian.org>
parents: 23
diff changeset
    73
}
19
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    74
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    75
MainWindow::~MainWindow()
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    76
{
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    77
    delete ui;
e4b6ee329501 WIP: first draft of contact engine
John Kern <johnk@symbian.org>
parents:
diff changeset
    78
}