From 56cc8b084d8e8cc2a4d059824c09c87f12d81893 Mon Sep 17 00:00:00 2001 From: "Justin F. Knotzke" Date: Fri, 27 Mar 2009 18:02:34 +0000 Subject: [PATCH] Tom Montgomery's patch: I have made changes to the Import CSV dialog box; the new (proposed) behaviour is as follows: At first, the datePicker widget and OK button are disabled. The datePicker is preset to today's date (no longer really necessary, but the code is there). User clicks 'choose a file' and the usual file browser appears. If a file is selected, its creation date is stuffed into the datePicker. On return from the browser, the datePicker and OK buttons are re- enabled. User can modify the ride date, in case the file upload was not done on ride day. User clicks OK, the file is imported as before. --- src/DatePickerDialog.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/DatePickerDialog.cpp b/src/DatePickerDialog.cpp index 645e21071..4c8eef7e2 100644 --- a/src/DatePickerDialog.cpp +++ b/src/DatePickerDialog.cpp @@ -32,7 +32,7 @@ void DatePickerDialog::setupUi(QDialog *DatePickerDialog) lblOccur = new QLabel("When did this ride occur?", this); mainGrid->addWidget(lblOccur, 0,0); dateTimeEdit = new QDateTimeEdit(this); - + // preset dialog to today's date -thm QDateTime *dt = new QDateTime; date = dt->currentDateTime(); @@ -52,7 +52,7 @@ void DatePickerDialog::setupUi(QDialog *DatePickerDialog) mainGrid->addWidget(btnCancel, 3,1); DatePickerDialog->setWindowTitle( - QApplication::translate("DatePickerDialog", "Choose a date", 0, + QApplication::translate("DatePickerDialog", "Import CSV file", 0, QApplication::UnicodeUTF8)); btnBrowse->setText( @@ -69,6 +69,11 @@ void DatePickerDialog::setupUi(QDialog *DatePickerDialog) connect(btnBrowse, SIGNAL(clicked()), this, SLOT(on_btnBrowse_clicked())); connect(btnCancel, SIGNAL(clicked()), this, SLOT(on_btnCancel_clicked())); + // disable date picker and OK button until a file has been selected + dateTimeEdit->setEnabled(FALSE); + lblOccur->setEnabled(FALSE); + btnOK->setEnabled(FALSE); + Q_UNUSED(DatePickerDialog); } @@ -93,12 +98,24 @@ void DatePickerDialog::on_btnBrowse_clicked() ? lastDirVar.toString() : QDir::homePath(); fileName = QFileDialog::getOpenFileName( this, tr("Import CSV"), lastDir, - tr("Comma Seperated Values (*.csv)")); + tr("Comma Separated Values (*.csv)")); if (!fileName.isEmpty()) { lastDir = QFileInfo(fileName).absolutePath(); settings.setValue(GC_SETTINGS_LAST_IMPORT_PATH, lastDir); + + // get the creation date of the selected file + QFileInfo *qfi = new QFileInfo(fileName); + date = qfi->created(); + // and put it into the datePicker dialog + dateTimeEdit->setDateTime(date); + } txtBrowse->setText(fileName); + + // allow date to be changed, and enable OK button + dateTimeEdit->setEnabled(TRUE); + lblOccur->setEnabled(TRUE); + btnOK->setEnabled(TRUE); } void DatePickerDialog::on_btnCancel_clicked()