Skip to content

Commit b746340

Browse files
authored
Merge pull request #707 from firelab/weather-model-date-time
2 parents 0892a5b + f303cca commit b746340

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

src/gui/weatherModelInput.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ WeatherModelInput::WeatherModelInput(Ui::MainWindow* ui, QObject* parent)
5353
connect(ui->weatherModelTimeSelectAllButton, &QPushButton::clicked, this, &WeatherModelInput::weatherModelTimeSelectAllButtonClicked);
5454
connect(ui->weatherModelTimeSelectNoneButton, &QPushButton::clicked, this, &WeatherModelInput::weatherModelTimeSelectNoneButtonClicked);
5555
connect(ui->timeZoneComboBox, &QComboBox::currentTextChanged, this, &WeatherModelInput::updatePastcastDateTimeEdits);
56-
//connect(ui->timeZoneComboBox, &QComboBox::currentTextChanged, this, &WeatherModelInput::updateTreeViewTime);
5756

5857
connect(this, &WeatherModelInput::updateProgressMessageSignal, this, &WeatherModelInput::updateProgressMessage, Qt::QueuedConnection);
5958
}
@@ -393,6 +392,7 @@ void WeatherModelInput::updateTreeView()
393392
timeHeader->setVisible(false);
394393

395394
connect(ui->weatherModelFileTreeView->selectionModel(), &QItemSelectionModel::selectionChanged, this, &WeatherModelInput::weatherModelFileTreeViewItemSelectionChanged);
395+
connect(ui->timeZoneComboBox, &QComboBox::currentTextChanged, this, &WeatherModelInput::updateTreeViewTime);
396396
}
397397

398398
void WeatherModelInput::weatherModelFileTreeViewItemSelectionChanged(const QItemSelection &selected)
@@ -484,23 +484,32 @@ void WeatherModelInput::updatePastcastDateTimeEdits()
484484
QDate earliestDate(2014, 7, 30);
485485
QDateTime utcDateTime(earliestDate, QTime(18, 0), Qt::UTC);
486486
QDateTime localDateTime = utcDateTime.toTimeZone(timeZone);
487-
ui->pastcastGroupBox->setTitle("Earliest Pastcast Datetime: " + localDateTime.toString("MM/dd/yyyy hh:mm"));
487+
ui->pastcastGroupBox->setTitle(
488+
"Earliest Pastcast Datetime: "
489+
+ localDateTime.toString("MM/dd/yyyy hh:mm")
490+
+ " " + timeZone.abbreviation(localDateTime)
491+
);
488492
ui->pastcastGroupBox->updateGeometry();
489493

490494
// Update Date Time Edits
491-
QDateTime demTime = QDateTime::currentDateTime().toTimeZone(timeZone);
492-
// Has to be set to avoid unnecessary conversions, use timeZoneComboBox for time zone info
493-
demTime.setTimeSpec(Qt::LocalTime);
494-
495-
ui->pastcastStartDateTimeEdit->setDateTime(demTime);
496-
ui->pastcastEndDateTimeEdit->setDateTime(demTime);
495+
QDateTime demDateTime = QDateTime::currentDateTime().toTimeZone(timeZone);
496+
QTime demTime = demDateTime.time();
497+
demTime.setHMS(demTime.hour()-1, 0, 0, 0);
498+
demDateTime.setTime(demTime);
499+
demDateTime.setTimeSpec(Qt::LocalTime); // Has to be set to avoid unnecessary conversions, use timeZoneComboBox for time zone info
500+
501+
ui->pastcastStartDateTimeEdit->setDateTime(demDateTime);
502+
ui->pastcastEndDateTimeEdit->setDateTime(demDateTime);
497503
}
498504

499505
void WeatherModelInput::updateTreeViewTime()
500506
{
501-
ui->weatherModelFileTreeView->clearSelection();
502-
timeModel->clear();
503-
emit updateState();
507+
if(ui->weatherModelFileTreeView->selectionModel()->hasSelection())
508+
{
509+
ui->weatherModelFileTreeView->clearSelection();
510+
timeModel->clear();
511+
emit updateState();
512+
}
504513
}
505514

506515
void WeatherModelInput::initNinjaTools()

0 commit comments

Comments
 (0)