Modified menu-selectable UI to tab-selectable UI
authorKaj Wallin <kaj.wallin@ixonos.com>
Mon, 29 Mar 2010 11:03:50 +0000 (14:03 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Mon, 29 Mar 2010 11:03:50 +0000 (14:03 +0300)
src/ui/mainwindow.cpp
src/ui/mainwindow.h
tests/testUI/testui.cpp

index a6114da..f889552 100644 (file)
@@ -31,13 +31,10 @@ MainWindow::MainWindow(QWidget *parent)
     createViews();
 
     QVBoxLayout *mainLayout = new QVBoxLayout;
-    infoLabel = new QLabel(tr("This is the beginning"),this);
-    mainLayout->addWidget(infoLabel);
     mainLayout->addWidget(situareViews);
     widget->setLayout(mainLayout);
 
     this->setWindowTitle(tr("Situare"));
-    createMenus();
 }
 
 MainWindow::~MainWindow()
@@ -45,34 +42,11 @@ MainWindow::~MainWindow()
 
 }
 
-void MainWindow::createMenus()
-{
-    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()
-{
-    this->situareViews->setCurrentIndex(0);
-    infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
-}
-
-void MainWindow::toMapView()
-{
-    this->situareViews->setCurrentIndex(1);
-    infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
-}
-
 void MainWindow::createViews()
 {
-    situareViews = new QStackedWidget(this);
-    situareViews->addWidget(new SituareListView(this));
-    situareViews->addWidget(new SituareMapView(this));
+    situareViews = new QTabWidget(this);
+    situareViews->addTab(new SituareListView(this), tr("List"));
+    situareViews->addTab(new SituareMapView(this), tr("Map"));
 }
 
 SituareListView::SituareListView(QWidget *parent)
index ae4a600..7d8ff7d 100644 (file)
@@ -28,7 +28,7 @@
 
 class QMenu;
 class QAction;
-class QStackedWidget;
+class QTabWidget;
 class QLabel;
 
 /**
@@ -46,37 +46,19 @@ public:
 
 private:
     /**
-    * @brief Private method to create the Menu items
-    *
-    * @fn createMenus
-    */
-    void createMenus();
-    /**
     * @brief Private method to create List and Map views as a stacked widget
     *
     * @fn createViews
     */
     void createViews();
 
-    QMenu *viewMenu;
-    /**
-    * @brief Action item for changing view to List View
-    *
-    * @var toListViewAct
-    */
-    QAction *toListViewAct;
-    /**
-    * @brief Action item for changing view to Map View
-    *
-    * @var toMapViewAct
-    */
     QAction *toMapViewAct;
     /**
     * @brief Widget Stack object for the List and Map Views
     *
     * @var situareViews
     */
-    QStackedWidget *situareViews;
+    QTabWidget *situareViews;
 
     /**
     * @brief DUMMY LABEL, REMOVE WHEN BOTH VIEWS ARE COMPLETE
@@ -86,19 +68,6 @@ private:
     */
     QLabel *infoLabel;
 
-private slots:
-    /**
-    * @brief Private slot, which initiates toListViewAct action
-    *
-    * @fn toListView
-    */
-    void toListView();
-    /**
-    * @brief Private slots, which initiates toMapViewAct action
-    *
-    * @fn toMapView
-    */
-    void toMapView();
 };
 
 /**
index 651ee5d..606309b 100755 (executable)
@@ -3,6 +3,7 @@
     Copyright (C) 2010  Ixonos Plc. Authors:
 
        Henri Lampela - henri.lampela@ixonos.com
+       Kaj Wallin - kaj.wallin@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License
@@ -29,8 +30,7 @@ class TestUi: public QObject
 
 private slots:
     void testUi();
-
-
+    void testViews();
 };
 
 void TestUi::testUi()
@@ -42,6 +42,11 @@ void TestUi::testUi()
     QCOMPARE(lineEdit.text(), QString("UI test"));
 }
 
+void TestUi::testViews()
+{
+
+}
+
 
 QTEST_MAIN(TestUi)
 #include "testui.moc"