mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-05 16:19:10 +00:00
Read UDS entry times directly and pretty-print on-demand
This avoids creating a QDateTime object with all the timezone processing that comes with it since we're only interested in the actual pretty date once we show the role to the user. Differential Revision: https://phabricator.kde.org/D14880
This commit is contained in:
parent
523c95bed0
commit
9134951cb0
|
@ -78,7 +78,13 @@ QString KFileItemListWidgetInformant::roleText(const QByteArray& role,
|
||||||
const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
|
const KIO::filesize_t size = roleValue.value<KIO::filesize_t>();
|
||||||
text = KFormat().formatByteSize(size);
|
text = KFormat().formatByteSize(size);
|
||||||
}
|
}
|
||||||
} else if (role == "modificationtime" || role == "creationtime" || role == "accesstime" || role == "deletiontime" || role == "imageDateTime") {
|
} else if (role == "modificationtime" || role == "creationtime" || role == "accesstime") {
|
||||||
|
bool ok;
|
||||||
|
const long long time = roleValue.toLongLong(&ok);
|
||||||
|
if (ok && time != -1) {
|
||||||
|
return QLocale().toString(QDateTime::fromSecsSinceEpoch(time), QLocale::ShortFormat);
|
||||||
|
}
|
||||||
|
} else if (role == "deletiontime" || role == "imageDateTime") {
|
||||||
const QDateTime dateTime = roleValue.toDateTime();
|
const QDateTime dateTime = roleValue.toDateTime();
|
||||||
text = QLocale().toString(dateTime, QLocale::ShortFormat);
|
text = QLocale().toString(dateTime, QLocale::ShortFormat);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1563,26 +1563,26 @@ QHash<QByteArray, QVariant> KFileItemModel::retrieveData(const KFileItem& item,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_requestRole[ModificationTimeRole]) {
|
if (m_requestRole[ModificationTimeRole]) {
|
||||||
// Don't use KFileItem::timeString() as this is too expensive when
|
// Don't use KFileItem::timeString() or KFileItem::time() as this is too expensive when
|
||||||
// having several thousands of items. Instead the formatting of the
|
// having several thousands of items. Instead read the raw number from UDSEntry directly
|
||||||
// date-time will be done on-demand by the view when the date will be shown.
|
// and the formatting of the date-time will be done on-demand by the view when the date will be shown.
|
||||||
const QDateTime dateTime = item.time(KFileItem::ModificationTime);
|
const long long dateTime = item.entry().numberValue(KIO::UDSEntry::UDS_MODIFICATION_TIME, -1);
|
||||||
data.insert(sharedValue("modificationtime"), dateTime);
|
data.insert(sharedValue("modificationtime"), dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_requestRole[CreationTimeRole]) {
|
if (m_requestRole[CreationTimeRole]) {
|
||||||
// Don't use KFileItem::timeString() as this is too expensive when
|
// Don't use KFileItem::timeString() or KFileItem::time() as this is too expensive when
|
||||||
// having several thousands of items. Instead the formatting of the
|
// having several thousands of items. Instead read the raw number from UDSEntry directly
|
||||||
// date-time will be done on-demand by the view when the date will be shown.
|
// and the formatting of the date-time will be done on-demand by the view when the date will be shown.
|
||||||
const QDateTime dateTime = item.time(KFileItem::CreationTime);
|
const long long dateTime = item.entry().numberValue(KIO::UDSEntry::UDS_CREATION_TIME, -1);
|
||||||
data.insert(sharedValue("creationtime"), dateTime);
|
data.insert(sharedValue("creationtime"), dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_requestRole[AccessTimeRole]) {
|
if (m_requestRole[AccessTimeRole]) {
|
||||||
// Don't use KFileItem::timeString() as this is too expensive when
|
// Don't use KFileItem::timeString() or KFileItem::time() as this is too expensive when
|
||||||
// having several thousands of items. Instead the formatting of the
|
// having several thousands of items. Instead read the raw number from UDSEntry directly
|
||||||
// date-time will be done on-demand by the view when the date will be shown.
|
// and the formatting of the date-time will be done on-demand by the view when the date will be shown.
|
||||||
const QDateTime dateTime = item.time(KFileItem::AccessTime);
|
const long long dateTime = item.entry().numberValue(KIO::UDSEntry::UDS_ACCESS_TIME, -1);
|
||||||
data.insert(sharedValue("accesstime"), dateTime);
|
data.insert(sharedValue("accesstime"), dateTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue