Created menu key actions and dummy QLabel to proove they work
[situare] / src / ui / mainwindow.cpp
1 /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Henri Lampela - henri.lampela@ixonos.com
6        Kaj Wallin - kaj.wallin@ixonos.com
7
8     Situare is free software; you can redistribute it and/or
9     modify it under the terms of the GNU General Public License
10     version 2 as published by the Free Software Foundation.
11
12     Situare is distributed in the hope that it will be useful,
13     but WITHOUT ANY WARRANTY; without even the implied warranty of
14     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15     GNU General Public License for more details.
16
17     You should have received a copy of the GNU General Public License
18     along with Situare; if not, write to the Free Software
19     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
20     USA.
21  */
22
23 #include <QtGui>
24 #include "mainwindow.h"
25
26 MainWindow::MainWindow(QWidget *parent)
27     : QMainWindow(parent)
28 {
29     QWidget *widget = new QWidget;
30     setCentralWidget(widget);
31 //    createViews();
32
33     QVBoxLayout *mainleiska = new QVBoxLayout;
34     infoLabel = new QLabel(tr("This is the beginning"),this);
35     mainleiska->addWidget(infoLabel);
36
37     widget->setLayout(mainleiska);
38     this->setWindowTitle(tr("Situare"));
39     createMenus();
40
41 }
42
43 MainWindow::~MainWindow()
44 {
45
46 }
47
48 void MainWindow::createMenus()
49 {
50     toListViewAct = new QAction(tr("List"), this);
51     connect(toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
52     toMapViewAct = new QAction(tr("Map"), this);
53     connect(toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
54     viewMenu = menuBar()->addMenu(tr("View"));
55     viewMenu->addAction(toListViewAct);
56     viewMenu->addAction(toMapViewAct);
57 }
58
59 void MainWindow::toListView()
60 {
61     infoLabel->setText(tr("List view invoked"));
62 }
63
64 void MainWindow::toMapView()
65 {
66     infoLabel->setText(tr("Map view invoked"));
67 }
68
69 void MainWindow::createViews()
70 {
71     situareViews = new QStackedWidget(this);
72     situareViews->addWidget(new SituareListView(this));
73     situareViews->addWidget(new SituareMapView(this));
74 }
75
76 SituareListView::SituareListView(QWidget *parent)
77     : QWidget(parent)
78 {
79     QPushButton *listViewButton = new QPushButton(tr("This is listview"));
80     QHBoxLayout *listViewLayout = new QHBoxLayout;
81     listViewLayout->addWidget(listViewButton);
82     setLayout(listViewLayout);
83 }
84
85 SituareMapView::SituareMapView(QWidget *parent)
86     : QWidget(parent)
87 {
88     QPushButton *mapViewButton = new QPushButton(tr("THIS IS MAPVIEW !!"));
89     QHBoxLayout *mapViewLayout = new QHBoxLayout;
90     mapViewLayout->addWidget(mapViewButton);
91     setLayout(mapViewLayout);
92 }