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()
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
*/
QLabel *infoLabel;
+
public slots:
/**
* @brief Public slot, which initiates toListViewAct action to switch view