Changed back to Menu-type views, as per given input on UI
authorKaj Wallin <kaj.wallin@ixonos.com>
Tue, 30 Mar 2010 12:08:51 +0000 (15:08 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Tue, 30 Mar 2010 12:08:51 +0000 (15:08 +0300)
src/ui/mainwindow.cpp
src/ui/mainwindow.h

index 7b8d2c3..358f97e 100644 (file)
@@ -31,22 +31,14 @@ MainWindow::MainWindow(QWidget *parent)
     QWidget *widget = new QWidget;
     setCentralWidget(widget);
     createViews();
-
-    QGridLayout *tabsLayout = new QGridLayout;
-    tabFieldLabel = new QLabel;
-    QFont font;
-    font.setPixelSize(10);
-    tabFieldLabel->setFont(font);
-    tabFieldLabel->setText(tr("This is TabBar label\nCurrent StackedWidget index: %1\nTsdaa: %2").arg(situareViews->currentIndex()).arg(2));
-    tabsLayout->addWidget(situareTabs,0,0,1,1);
-    tabsLayout->addWidget(tabFieldLabel,0,1,1,2);
-
     QVBoxLayout *mainLayout = new QVBoxLayout;
-    mainLayout->addLayout(tabsLayout);
+    infoLabel = new QLabel(tr("Click \"view\", to change between views"),this);
+    mainLayout->addWidget(infoLabel);
     mainLayout->addWidget(situareViews);
     widget->setLayout(mainLayout);
+    createMenus();
 
-    this->setWindowTitle(tr("Situare"));
+    this->setWindowTitle(tr("View"));
 }
 
 MainWindow::~MainWindow()
@@ -54,20 +46,34 @@ 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::createViews()
 {
     situareViews = new QStackedWidget(this);
     situareViews->addWidget(new SituareListView(this));
     situareViews->addWidget(new SituareMapView(this));
+}
 
-    situareTabs = new QTabBar(this);
-    situareTabs->addTab(tr("List"));
-    situareTabs->addTab(tr("Map"));
-    connect(situareTabs, SIGNAL(currentChanged(int)), situareViews, SLOT(setCurrentIndex(int)));
-    connect(situareTabs, SIGNAL(currentChanged(int)), this, SLOT(updateTabLabel()));
+void MainWindow::toListView()
+{
+    this->situareViews->setCurrentIndex(0);
+    infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
+    this->setWindowTitle("List");
 }
 
-void MainWindow::updateTabLabel()
+void MainWindow::toMapView()
 {
-    tabFieldLabel->setText(tr("This is TabBar label\nCurrent StackedWidget index: %1\nTsdaa: %2").arg(situareViews->currentIndex()).arg(2));
+    this->situareViews->setCurrentIndex(1);
+    infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
+    this->setWindowTitle("Map");
 }
index e84873c..d00090f 100644 (file)
@@ -53,7 +53,27 @@ public:
     */
     void createViews();
 
+    /**
+    * @brief Private method to create the Menu items
+    *
+    * @fn createMenus
+    */
+    void createMenus();
+    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
     *
@@ -61,9 +81,6 @@ public:
     */
     QStackedWidget *situareViews;
 
-    QTabBar *situareTabs;
-    QLabel *tabFieldLabel;
-
     /**
     * @brief DUMMY LABEL, REMOVE WHEN BOTH VIEWS ARE COMPLETE
     *
@@ -73,7 +90,18 @@ public:
     QLabel *infoLabel;
 
 public slots:
-    void updateTabLabel();
+    /**
+    * @brief Private slot, which initiates toListViewAct action
+    *
+    * @fn toListView
+    */
+    void toListView();
+    /**
+    * @brief Private slots, which initiates toMapViewAct action
+    *
+    * @fn toMapView
+    */
+    void toMapView();
 };
 
 #endif // MAINWINDOW_H