Initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#include "date_time_delegate.h"
|
||||
|
||||
DateTimeDelegate::DateTimeDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent) {}
|
||||
|
||||
QString DateTimeDelegate::displayText(const QVariant &value,
|
||||
const QLocale &locale) const {
|
||||
QDateTime datetime = QDateTime::fromString(value.toString(), Qt::ISODate);
|
||||
if (!datetime.isValid()) {
|
||||
return value.toString(); // Return raw value if parsing fails
|
||||
}
|
||||
|
||||
QString formattedDateTime = locale.toString(datetime, QLocale::LongFormat);
|
||||
if (!formattedDateTime.isEmpty()) {
|
||||
// Capitalize the first letter of the formatted date string
|
||||
formattedDateTime[0] = formattedDateTime[0].toUpper();
|
||||
}
|
||||
return formattedDateTime;
|
||||
}
|
||||
Reference in New Issue
Block a user