Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/library/basetracktablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ void BaseTrackTableModel::setApplyPlayedTrackColor(bool apply) {
s_bApplyPlayedTrackColor = apply;
}

const QString BaseTrackTableModel::kDateFormatDefault = QString();
QString BaseTrackTableModel::s_dateFormat = BaseTrackTableModel::kDateFormatDefault;

void BaseTrackTableModel::setDateFormat(const QString& format) {
s_dateFormat = format;
}

BaseTrackTableModel::BaseTrackTableModel(
QObject* parent,
TrackCollectionManager* pTrackCollectionManager,
Expand Down Expand Up @@ -689,10 +696,10 @@ QVariant BaseTrackTableModel::roleValue(
if (field == ColumnCache::COLUMN_PLAYLISTTRACKSTABLE_DATETIMEADDED) {
// Timestamp column in history feature:
// Use localized date/time format without text: "5/20/98 03:40 AM"
return mixxx::displayLocalDateTime(dt);
return mixxx::displayLocalDateTime(dt, s_dateFormat);
}
// For Date Added, use just the date: "5/20/98"
return dt.date();
return mixxx::formatDate(dt.date(), s_dateFormat);
}
case ColumnCache::COLUMN_LIBRARYTABLE_LAST_PLAYED_AT: {
QDateTime lastPlayedAt;
Expand All @@ -718,7 +725,7 @@ QVariant BaseTrackTableModel::roleValue(
if (role == Qt::ToolTipRole || role == kDataExportRole) {
return dt;
}
return dt.date();
return mixxx::formatDate(dt.date(), s_dateFormat);
}
case ColumnCache::COLUMN_LIBRARYTABLE_BPM: {
mixxx::Bpm bpm;
Expand Down
14 changes: 14 additions & 0 deletions src/library/basetracktablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "library/trackmodel.h"
#include "track/track_decl.h"
#include "util/color/colorpalette.h"
#include "util/datetime.h"

class TrackCollectionManager;

Expand Down Expand Up @@ -132,6 +133,18 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
static constexpr bool kApplyPlayedTrackColorDefault = true;
static void setApplyPlayedTrackColor(bool apply);

enum class DateFormat {
Native = 0, // System Default
ISO8601 = 1, // yyyy-MM-dd
RegionalShort = 2, // d/M/yy
RegionalLong = 3, // dd.MM.yyyy
Custom = 4,
};
Q_ENUM(DateFormat)

static const QString kDateFormatDefault;
static void setDateFormat(const QString& format);

protected:
// Build a map from the column names to their indices
// used by fieldIndex().
Expand Down Expand Up @@ -307,4 +320,5 @@ class BaseTrackTableModel : public QAbstractTableModel, public TrackModel {
static std::optional<ColorPalette> s_keyColorPalette;

static bool s_bApplyPlayedTrackColor;
static QString s_dateFormat;
};
5 changes: 5 additions & 0 deletions src/library/library_prefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,8 @@ const ConfigKey mixxx::library::prefs::kTagFetcherApplyCoverConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("TagFetcherApplyCover")};

const ConfigKey mixxx::library::prefs::kDateFormatConfigKey =
ConfigKey{
mixxx::library::prefs::kConfigGroup,
QStringLiteral("DateFormat")};
2 changes: 2 additions & 0 deletions src/library/library_prefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ extern const ConfigKey kTagFetcherApplyTagsConfigKey;

extern const ConfigKey kTagFetcherApplyCoverConfigKey;

extern const ConfigKey kDateFormatConfigKey;

} // namespace prefs

} // namespace library
Expand Down
Loading
Loading