Added a user preference to change the Ride List sorting. Default should be ascending by date, as it has been. Disabling the "Sort ride list ascending" preference will sort the ride list descending by date.

Also, added margins to the widgets in the main window.
This commit is contained in:
Robert Carlsen
2009-01-05 01:47:37 +00:00
parent f8a94dc767
commit 8d2edd4c48
6 changed files with 36 additions and 5 deletions

View File

@@ -113,7 +113,8 @@ void ConfigDialog::save_Clicked()
{
QSettings settings(GC_SETTINGS_CO, GC_SETTINGS_APP);
settings.setValue(GC_UNIT, configPage->unitCombo->currentText());
settings.setValue(GC_ALLRIDES_ASCENDING, configPage->allRidesAscending->checkState());
//If the user never switched pages, then make sure we have up to date data.
if (cyclistPage->getCurrentRange() == 0 || cyclistPage->getCurrentRange() == zones->getRangeSize() - 1)
{

View File

@@ -91,6 +91,7 @@ MainWindow::MainWindow(const QDir &home) :
splitter = new QSplitter(this);
setCentralWidget(splitter);
splitter->setContentsMargins(10, 20, 10, 10); // attempting to follow some UI guides
treeWidget = new QTreeWidget;
treeWidget->setColumnCount(3);
@@ -393,8 +394,19 @@ MainWindow::MainWindow(const QDir &home) :
QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(tr("&About GoldenCheetah"), this, SLOT(aboutDialog()));
if (last != NULL)
treeWidget->setCurrentItem(last);
// This will read the user preferences and change the file list order as necessary:
QSettings settings(GC_SETTINGS_CO, GC_SETTINGS_APP);
QVariant isAscending = settings.value(GC_ALLRIDES_ASCENDING,Qt::Checked);
if(isAscending.toInt()>0){
if (last != NULL)
treeWidget->setCurrentItem(last);
} else {
// selects the first ride in the list:
if (allRides->child(0) != NULL){
treeWidget->scrollToItem(allRides->child(0), QAbstractItemView::EnsureVisible);
treeWidget->setCurrentItem(allRides->child(0));
}
}
}
void

View File

@@ -21,6 +21,14 @@ ConfigurationPage::ConfigurationPage(QWidget *parent)
else
unitCombo->setCurrentIndex(1);
allRidesAscending = new QCheckBox("Sort ride list ascending.", this);
QVariant isAscending = settings.value(GC_ALLRIDES_ASCENDING,Qt::Checked); // default is ascending sort
if(isAscending.toInt() > 0 ){
allRidesAscending->setCheckState(Qt::Checked);
} else {
allRidesAscending->setCheckState(Qt::Unchecked);
}
QLabel *warningLabel = new QLabel(tr("Requires Restart To Take Effect"));
QHBoxLayout *unitLayout = new QHBoxLayout;
@@ -32,6 +40,7 @@ ConfigurationPage::ConfigurationPage(QWidget *parent)
QVBoxLayout *configLayout = new QVBoxLayout;
configLayout->addLayout(unitLayout);
configLayout->addWidget(allRidesAscending);
configLayout->addLayout(warningLayout);
configGroup->setLayout(configLayout);

View File

@@ -9,12 +9,14 @@
#include "Zones.h"
#include <QLabel>
#include <QDateEdit>
#include <QCheckbox>
class ConfigurationPage : public QWidget
{
public:
ConfigurationPage(QWidget *parent = 0);
QComboBox *unitCombo;
QCheckBox *allRidesAscending;
};
class CyclistPage : public QWidget

View File

@@ -19,6 +19,7 @@
#include "RideFile.h"
#include <QtXml/QtXml>
#include <assert.h>
#include "Settings.h"
static void
markInterval(QDomDocument &xroot, QDomNode &xride, QDomNode &xintervals,
@@ -140,6 +141,12 @@ QStringList RideFileFactory::listRideFiles(const QDir &dir) const
i.next();
filters << ("*." + i.key());
}
return dir.entryList(filters, QDir::Files, QDir::Name);
// This will read the user preferences and change the file list order as necessary:
QSettings settings(GC_SETTINGS_CO, GC_SETTINGS_APP);
QVariant isAscending = settings.value(GC_ALLRIDES_ASCENDING,Qt::Checked);
if(isAscending.toInt()>0){
return dir.entryList(filters, QDir::Files, QDir::Name);
}
return dir.entryList(filters, QDir::Files, QDir::Name|QDir::Reversed);
}

View File

@@ -31,7 +31,7 @@
#define GC_DATETIME_FORMAT "ddd MMM dd, yyyy, hh:mm AP"
#define GC_UNIT "unit"
#define GC_SETTINGS_LAST_IMPORT_PATH "mainwindow/lastImportPath"
#define GC_ALLRIDES_ASCENDING "allRidesAscending"
#endif // _GC_Settings_h