Created menu key actions and dummy QLabel to proove they work
authorKaj Wallin <kaj.wallin@ixonos.com>
Mon, 29 Mar 2010 09:00:50 +0000 (12:00 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Mon, 29 Mar 2010 09:00:50 +0000 (12:00 +0300)
src/ui/mainwindow.cpp
src/ui/mainwindow.h

index 2c797e3..ffcb436 100644 (file)
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
 {
+    QWidget *widget = new QWidget;
+    setCentralWidget(widget);
+//    createViews();
+
+    QVBoxLayout *mainleiska = new QVBoxLayout;
+    infoLabel = new QLabel(tr("This is the beginning"),this);
+    mainleiska->addWidget(infoLabel);
+
+    widget->setLayout(mainleiska);
     this->setWindowTitle(tr("Situare"));
     createMenus();
+
 }
 
 MainWindow::~MainWindow()
@@ -37,9 +47,46 @@ MainWindow::~MainWindow()
 
 void MainWindow::createMenus()
 {
-    toListViewAct = new QAction(tr("List"),this);
-    toMapViewAct = new QAction(tr("Map"),this);
+    toListViewAct = new QAction(tr("List"), this);
+    connect(toListViewAct, SIGNAL(triggered()), this, SLOT(toListView()));
+    toMapViewAct = new QAction(tr("Map"), this);
+    connect(toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
     viewMenu = menuBar()->addMenu(tr("View"));
     viewMenu->addAction(toListViewAct);
     viewMenu->addAction(toMapViewAct);
 }
+
+void MainWindow::toListView()
+{
+    infoLabel->setText(tr("List view invoked"));
+}
+
+void MainWindow::toMapView()
+{
+    infoLabel->setText(tr("Map view invoked"));
+}
+
+void MainWindow::createViews()
+{
+    situareViews = new QStackedWidget(this);
+    situareViews->addWidget(new SituareListView(this));
+    situareViews->addWidget(new SituareMapView(this));
+}
+
+SituareListView::SituareListView(QWidget *parent)
+    : QWidget(parent)
+{
+    QPushButton *listViewButton = new QPushButton(tr("This is listview"));
+    QHBoxLayout *listViewLayout = new QHBoxLayout;
+    listViewLayout->addWidget(listViewButton);
+    setLayout(listViewLayout);
+}
+
+SituareMapView::SituareMapView(QWidget *parent)
+    : QWidget(parent)
+{
+    QPushButton *mapViewButton = new QPushButton(tr("THIS IS MAPVIEW !!"));
+    QHBoxLayout *mapViewLayout = new QHBoxLayout;
+    mapViewLayout->addWidget(mapViewButton);
+    setLayout(mapViewLayout);
+}
index 7f40d92..46f6997 100644 (file)
 #define MAINWINDOW_H
 
 #include <QtGui/QMainWindow>
+#include <QWidget>
 
 class QMenu;
 class QAction;
+class QStackedWidget;
+class QLabel;
 
 class MainWindow : public QMainWindow
 {
@@ -38,10 +41,30 @@ public:
 
 private:
     void createMenus();
+    void createViews();
 
     QMenu *viewMenu;
     QAction *toListViewAct;
     QAction *toMapViewAct;
+    QStackedWidget *situareViews;
+
+    QLabel *infoLabel;
+
+private slots:
+    void toListView();
+    void toMapView();
+};
+
+class SituareListView : public QWidget
+{
+public:
+    SituareListView(QWidget *parent = 0);
+};
+
+class SituareMapView : public QWidget
+{
+public:
+    SituareMapView(QWidget *parent = 0);
 };
 
 #endif // MAINWINDOW_H