this method is used by testtabs unit test.
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
+ qt trace modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
Situare is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ qt trace MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
- You should have received a copy of the GNU General Public License
+ qt trace You should have received a copy of the GNU General Public License
along with Situare; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
widget->setLayout(mainLayout);
createMenus();
- this->setWindowTitle(tr("View"));
+ setWindowTitle(tr("View"));
}
MainWindow::~MainWindow()
void MainWindow::createViews()
{
qDebug() << __PRETTY_FUNCTION__;
- situareViews = new QStackedWidget(this);
- situareViews->addWidget(new ListViewScreen(this));
- situareViews->addWidget(new MapViewScreen(this));
+ situareViews = new QStackedWidget;
+ situareViews->addWidget(new ListViewScreen);
+ situareViews->addWidget(new MapViewScreen);
}
void MainWindow::toListView()
{
qDebug() << __PRETTY_FUNCTION__;
- this->situareViews->setCurrentIndex(0);
+ situareViews->setCurrentIndex(0);
infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
- this->setWindowTitle("List");
+ setWindowTitle("List");
}
void MainWindow::toMapView()
{
qDebug() << __PRETTY_FUNCTION__;
- this->situareViews->setCurrentIndex(1);
+ situareViews->setCurrentIndex(1);
infoLabel->setText(tr("Current: %1").arg(situareViews->currentIndex()));
- this->setWindowTitle("Map");
+ setWindowTitle("Map");
+}
+
+int MainWindow::getViewIndex()
+{
+ return situareViews->currentIndex();
}
~MainWindow();
/**
- * @brief Widget Stack object for the List and Map Views
+ * @brief Public method to get current index of the view. Used for Unit testing
*
- * @var situareViews
+ * @fn getViewIndex
*/
- QStackedWidget *situareViews;
+ int getViewIndex();
private:
/**
* @fn createViews
*/
void createViews();
+ /**
+ * @brief Widget Stack object for the List and Map Views
+ *
+ * @var situareViews
+ */
+ QStackedWidget *situareViews;
/**
* @brief Private method to create the Menu items
public slots:
/**
- * @brief Private slot, which initiates toListViewAct action
+ * @brief Public slot, which initiates toListViewAct action to switch view
*
* @fn toListView
*/
void toListView();
/**
- * @brief Private slot, which initiates toMapViewAct action
+ * @brief Public slot, which initiates toMapViewAct action to switch view
*
* @fn toMapView
*/
{
MainWindow mainwindow;
mainwindow.toListView();
- QCOMPARE(mainwindow.situareViews->currentIndex(), 0);
+ QCOMPARE(mainwindow.getViewIndex(), 0);
mainwindow.toMapView();
- QCOMPARE(mainwindow.situareViews->currentIndex(), 1);
+ QCOMPARE(mainwindow.getViewIndex(), 1);
mainwindow.toMapView();
- QCOMPARE(mainwindow.situareViews->currentIndex(), 1);
+ QCOMPARE(mainwindow.getViewIndex(), 1);
mainwindow.toListView();
- QCOMPARE(mainwindow.situareViews->currentIndex(), 0);
+ QCOMPARE(mainwindow.getViewIndex(), 0);
}
QTEST_MAIN(testTabs)