mirror of
https://github.com/tnodir/fort
synced 2024-11-15 05:36:09 +00:00
UI: Programs: Show app's auto-block time
This commit is contained in:
parent
4f4b7e45f1
commit
74df2accb8
@ -11,6 +11,7 @@
|
||||
#include <conf/appgroup.h>
|
||||
#include <conf/confmanager.h>
|
||||
#include <conf/firewallconf.h>
|
||||
#include <util/dateutil.h>>
|
||||
#include <util/fileutil.h>
|
||||
#include <util/guiutil.h>
|
||||
#include <util/iconcache.h>
|
||||
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user