diff --git a/src/ui/model/applistmodel.cpp b/src/ui/model/applistmodel.cpp index a193b460..9f1262c0 100644 --- a/src/ui/model/applistmodel.cpp +++ b/src/ui/model/applistmodel.cpp @@ -11,6 +11,7 @@ #include #include #include +#include > #include #include #include @@ -72,12 +73,12 @@ int AppListModel::columnCount(const QModelIndex &parent) const QVariant AppListModel::headerData(int section, Qt::Orientation orientation, int role) const { if (orientation == Qt::Horizontal && (role == Qt::DisplayRole || role == Qt::ToolTipRole)) { - return headerDataDisplay(section, role); + return headerDataDisplay(section); } return QVariant(); } -QVariant AppListModel::headerDataDisplay(int section, int role) const +QVariant AppListModel::headerDataDisplay(int section) const { switch (section) { case 0: @@ -150,11 +151,12 @@ QVariant AppListModel::dataDisplay(const QModelIndex &index, int role) const QVariant AppListModel::dataDisplayState(const AppRow &appRow, int role) const { - return appStateText(appRow); - if (role == Qt::ToolTipRole && !appRow.endTime.isNull()) { - return appRow.endTime.toString(); + QString text = appStateText(appRow); + if (!appRow.endTime.isNull()) { + text += QStringLiteral(" (%1)").arg( + DateUtil::localeDateTime(appRow.endTime, QLocale::ShortFormat)); } - return QVariant(); + return text; } QVariant AppListModel::dataDecoration(const QModelIndex &index) const @@ -335,7 +337,7 @@ QString AppListModel::sqlOrderColumn() const columnsStr = "2"; break; case 2: // State - columnsStr = "6 " + sqlOrderAsc() + ", 7"; + columnsStr = "7 " + sqlOrderAsc() + ", 8, 9"; break; default: // Creation Time columnsStr = "1"; // App ID diff --git a/src/ui/model/applistmodel.h b/src/ui/model/applistmodel.h index aff8e99c..e4adfa5e 100644 --- a/src/ui/model/applistmodel.h +++ b/src/ui/model/applistmodel.h @@ -61,7 +61,7 @@ protected: QString sqlOrderColumn() const override; private: - QVariant headerDataDisplay(int section, int role = Qt::DisplayRole) const; + QVariant headerDataDisplay(int section) const; QVariant dataDisplay(const QModelIndex &index, int role) const; QVariant dataDisplayState(const AppRow &appRow, int role) const; diff --git a/src/ui/util/dateutil.cpp b/src/ui/util/dateutil.cpp index 7bd21d53..ad37c015 100644 --- a/src/ui/util/dateutil.cpp +++ b/src/ui/util/dateutil.cpp @@ -120,3 +120,8 @@ quint8 DateUtil::parseTimeMinute(const QString &period) { return quint8(toStringView(period).right(2).toUInt()); } + +QString DateUtil::localeDateTime(const QDateTime &dateTime, const QLocale::FormatType &format) +{ + return QLocale().toString(dateTime, format); +} diff --git a/src/ui/util/dateutil.h b/src/ui/util/dateutil.h index cab875b7..ae3e4980 100644 --- a/src/ui/util/dateutil.h +++ b/src/ui/util/dateutil.h @@ -39,6 +39,8 @@ public: Q_INVOKABLE static quint8 parseTimeHour(const QString &period); Q_INVOKABLE static quint8 parseTimeMinute(const QString &period); + + static QString localeDateTime(const QDateTime &dateTime, const QLocale::FormatType &format); }; #endif // DATEUTIL_H