Files
GoldenCheetah/src/ViewSelection.cpp
Mark Liversedge d10b08e86f switch from QToolBox to QComboBox
This patch removes the QToolBox from commit e93970 and replaces it with
a QComboBox instead. A new object ViewSelection can be included in any
new views and will manage the interaction with MainWindow to switch
between views. It is essentially a QComboBox with some code to interact
with MainWindow.

A new signal viewChanged(int) has been implemented in MainWindow to
notify of a view change. The parameter will be set to VIEW_ANALYSIS
or VIEW_TRAIN depending upon which view was selected.

In addition, a new TrainWindow object has been created which implements
the Realtime code and is comprised of the TrainTool and TrainTabs
implemented in e93970. It also sets its splitters from remembered values
in the same fashion as the central splitter on the Analysis view.
2009-12-21 13:34:28 -05:00

63 lines
1.9 KiB
C++

/*
* Copyright (c) 2009 Mark Liversedge (liversedge@gmail.com)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program 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 GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "ViewSelection.h"
#include "TrainTool.h"
#include "TrainTabs.h"
#include "MainWindow.h"
#include "Settings.h"
#include "Units.h"
#include <QApplication>
#include <QtGui>
#include <QFont>
#include <QFontMetrics>
ViewSelection::ViewSelection(const MainWindow *parent, const int homeView) :
QComboBox((QWidget *)parent),
main(parent),
homeView(homeView)
{
// don't make a fat ugly box...
setFixedHeight(((double)(QFontMetrics(font()).height()) * 1.6));
// set drop-down list
addItem(tr("Ride Analysis View"), VIEW_ANALYSIS);
addItem(tr("Train and Racing View"), VIEW_TRAIN);
// Default to home view
if (homeView == VIEW_ANALYSIS) setCurrentIndex(0);
if (homeView == VIEW_TRAIN) setCurrentIndex(1);
// set to this view
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(changeView(int)));
}
void
ViewSelection::changeView(int index)
{
int view = itemData(index).toInt();
if (view != homeView) {
((MainWindow *)main)->selectView(view);
}
// now reset back to the homeView!
if (homeView == VIEW_ANALYSIS) setCurrentIndex(0);
if (homeView == VIEW_TRAIN) setCurrentIndex(1);
}