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()
}
+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");
}
*/
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
*
*/
QStackedWidget *situareViews;
- QTabBar *situareTabs;
- QLabel *tabFieldLabel;
-
/**
* @brief DUMMY LABEL, REMOVE WHEN BOTH VIEWS ARE COMPLETE
*
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