Fix last active time in devices page
This commit is contained in:
@@ -5,6 +5,9 @@
|
|||||||
|
|
||||||
#include "controller.h"
|
#include "controller.h"
|
||||||
|
|
||||||
|
#include <QDateTime>
|
||||||
|
#include <QLocale>
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
#include <Quotient/csapi/device_management.h>
|
#include <Quotient/csapi/device_management.h>
|
||||||
@@ -52,6 +55,12 @@ QVariant DevicesModel::data(const QModelIndex &index, int role) const
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case TimestampString:
|
||||||
|
if (device.lastSeenTs) {
|
||||||
|
return QDateTime::fromMSecsSinceEpoch(*device.lastSeenTs).toString(QLocale().dateTimeFormat(QLocale::ShortFormat));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
case Type:
|
case Type:
|
||||||
if (device.deviceId == m_connection->deviceId()) {
|
if (device.deviceId == m_connection->deviceId()) {
|
||||||
return This;
|
return This;
|
||||||
@@ -81,6 +90,7 @@ QHash<int, QByteArray> DevicesModel::roleNames() const
|
|||||||
{DisplayName, "displayName"},
|
{DisplayName, "displayName"},
|
||||||
{LastIp, "lastIp"},
|
{LastIp, "lastIp"},
|
||||||
{LastTimestamp, "lastTimestamp"},
|
{LastTimestamp, "lastTimestamp"},
|
||||||
|
{TimestampString, "timestamp"},
|
||||||
{Type, "type"},
|
{Type, "type"},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ public:
|
|||||||
DisplayName, /**< Display name set by the user for this device. */
|
DisplayName, /**< Display name set by the user for this device. */
|
||||||
LastIp, /**< The IP address where this device was last seen. */
|
LastIp, /**< The IP address where this device was last seen. */
|
||||||
LastTimestamp, /**< The timestamp when this devices was last seen. */
|
LastTimestamp, /**< The timestamp when this devices was last seen. */
|
||||||
|
TimestampString, /**< String for the timestamp when this devices was last seen. */
|
||||||
Type, /**< The category to sort this device into. */
|
Type, /**< The category to sort this device into. */
|
||||||
};
|
};
|
||||||
Q_ENUM(Roles)
|
Q_ENUM(Roles)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ MobileForm.AbstractFormDelegate {
|
|||||||
id: deviceDelegate
|
id: deviceDelegate
|
||||||
|
|
||||||
required property string id
|
required property string id
|
||||||
required property int lastTimestamp
|
required property string timestamp
|
||||||
required property string displayName
|
required property string displayName
|
||||||
|
|
||||||
property bool editDeviceName: false
|
property bool editDeviceName: false
|
||||||
@@ -49,7 +49,7 @@ MobileForm.AbstractFormDelegate {
|
|||||||
|
|
||||||
QQC2.Label {
|
QQC2.Label {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: deviceDelegate.id + ", Last activity: " + (new Date(deviceDelegate.lastTimestamp)).toLocaleString(Qt.locale(), Locale.ShortFormat)
|
text: i18nc("@label", "%1, Last activity: %2", deviceDelegate.id, deviceDelegate.timestamp)
|
||||||
color: Kirigami.Theme.disabledTextColor
|
color: Kirigami.Theme.disabledTextColor
|
||||||
font: Kirigami.Theme.smallFont
|
font: Kirigami.Theme.smallFont
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
@@ -131,4 +131,4 @@ MobileForm.AbstractFormDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user