Created new private utility funtion to handle view changes. Added test
authorKaj Wallin <kaj.wallin@ixonos.com>
Thu, 1 Apr 2010 08:26:09 +0000 (11:26 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Thu, 1 Apr 2010 08:26:09 +0000 (11:26 +0300)
binary to .gitignore.

.gitignore
src/ui/mainwindow.cpp
src/ui/mainwindow.h
tests/testUI/testtabs/testtabs

index 30fa4cc..73ae3af 100644 (file)
@@ -11,4 +11,5 @@ moc_*
 *.moc
 *.pro.user
 Makefile
-situare
\ No newline at end of file
+situare
+testtabs
\ No newline at end of file
index de92a5e..91ef5a3 100644 (file)
@@ -75,17 +75,35 @@ void MainWindow::createViews()
 void MainWindow::toListView()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    situareViews->setCurrentIndex(0);
-    infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
-    setWindowTitle(tr("List"));
+    switchView(0);
 }
 
 void MainWindow::toMapView()
 {
     qDebug() << __PRETTY_FUNCTION__;
-    situareViews->setCurrentIndex(1);
+    switchView(1);
+}
+
+void MainWindow::switchView(int nextIndex)
+{
+    qDebug() << __PRETTY_FUNCTION__ << ":" << nextIndex;
+    if (nextIndex < 0 || nextIndex > 1) {
+        qDebug() << tr("Illegal parameter value in MainWindow::switchView");
+        return;
+    }
+    situareViews->setCurrentIndex(nextIndex);
     infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
-    setWindowTitle(tr("Map"));
+    switch (situareViews->currentIndex()) {
+        case 0:
+            setWindowTitle(tr("List"));
+            break;
+        case 1:
+            setWindowTitle(tr("Map"));
+            break;
+        default:
+            qDebug() << tr("Illegal switch value in MainWindow::switchView");
+            break;
+    }
 }
 
 int MainWindow::getViewIndex()
index 1475146..7651280 100644 (file)
@@ -87,6 +87,14 @@ private:
     QAction *toMapViewAct;
 
     /**
+    * @brief Method used to switch active view.
+    *
+    * @fn switchView
+    * @param int 0 for listview, 1 for mapview
+    */
+    void switchView(int);
+
+    /**
     * @brief DUMMY LABEL, REMOVE WHEN BOTH VIEWS ARE COMPLETE
     *
     * @var infoLabel
@@ -94,6 +102,7 @@ private:
     */
     QLabel *infoLabel;
 
+
 public slots:
     /**
     * @brief Public slot, which initiates toListViewAct action to switch view
index 819acad..0fce2ba 100755 (executable)
Binary files a/tests/testUI/testtabs/testtabs and b/tests/testUI/testtabs/testtabs differ