diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-12-04 23:46:44 -0600 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-12-04 23:46:44 -0600 |
commit | f36f86b179c62fb5b5028834c1eca82d92d50d09 (patch) | |
tree | ac1b651b8df9ac2a014220ad90ccd04863eda58e | |
parent | 6a910a82766476080d0968959624a67853f9f57b (diff) | |
download | horizon-f36f86b179c62fb5b5028834c1eca82d92d50d09.tar.gz horizon-f36f86b179c62fb5b5028834c1eca82d92d50d09.tar.bz2 horizon-f36f86b179c62fb5b5028834c1eca82d92d50d09.tar.xz horizon-f36f86b179c62fb5b5028834c1eca82d92d50d09.zip |
Qt UI: Fix choosing timezones
-rw-r--r-- | ui/qt5/datetimepage.cc | 8 | ||||
-rw-r--r-- | ui/qt5/datetimepage.hh | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/ui/qt5/datetimepage.cc b/ui/qt5/datetimepage.cc index a3356e7..7db62bf 100644 --- a/ui/qt5/datetimepage.cc +++ b/ui/qt5/datetimepage.cc @@ -16,11 +16,9 @@ #include <QGroupBox> #include <QHBoxLayout> #include <QLineEdit> -#include <QSortFilterProxyModel> #include <QTimeZone> #include <QVBoxLayout> -#include <iostream> #ifdef HAS_INSTALL_ENV # include <sys/capability.h> # include <time.h> @@ -52,6 +50,8 @@ TimeZone::TimeZone(QByteArray iana) { TimeZoneModel::TimeZoneModel(QWidget *parent) : QAbstractListModel(parent) { for(auto &iana : QTimeZone::availableTimeZoneIds()) { + /* we don't support raw timezones because tzdata doesn't */ + if(iana.startsWith("UTC") && iana.size() > 3) continue; TimeZone tzObj(iana); zones.push_back(tzObj); } @@ -187,7 +187,7 @@ DateTimePage::DateTimePage(QWidget *parent) : HorizonWizardPage(parent) { timeZoneSearch->addAction(QIcon::fromTheme("edit-find"), QLineEdit::LeadingPosition); timeZoneSearch->setPlaceholderText(tr("Search for a time zone")); - QSortFilterProxyModel *sortModel = new QSortFilterProxyModel(this); + sortModel = new QSortFilterProxyModel(this); sortModel->setFilterCaseSensitivity(Qt::CaseInsensitive); sortModel->setSourceModel(&zoneModel); connect(timeZoneSearch, &QLineEdit::textChanged, [=](const QString &text) { @@ -222,7 +222,7 @@ DateTimePage::DateTimePage(QWidget *parent) : HorizonWizardPage(parent) { QString DateTimePage::selectedTimeZone() { QModelIndex curr = timeZoneList->selectionModel()->currentIndex(); - return zoneModel.data(curr, Qt::ToolTipRole).toString(); + return sortModel->data(curr, Qt::ToolTipRole).toString(); } void DateTimePage::initializePage() { diff --git a/ui/qt5/datetimepage.hh b/ui/qt5/datetimepage.hh index 2c753dd..a861d90 100644 --- a/ui/qt5/datetimepage.hh +++ b/ui/qt5/datetimepage.hh @@ -18,6 +18,7 @@ #include <QAbstractListModel> #include <QDateEdit> #include <QListView> +#include <QSortFilterProxyModel> #include <QTimeEdit> #include <QTimer> #include <QVector> @@ -56,6 +57,7 @@ public: void cleanupPage(); TimeZoneModel zoneModel; + QSortFilterProxyModel *sortModel; QString selectedTimeZone(); signals: |