diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-11-17 02:55:02 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-11-17 02:55:02 +0100 |
commit | b09fad9cbf1f297ba2abb852d683f9fe5cfb9b3b (patch) | |
tree | bcc221b12f9169e856bc3525c20f229b45f9bc03 | |
parent | fd34ca5a0f4492c4b280df8aa3d9d82154b5d9bc (diff) | |
download | MultiMC-b09fad9cbf1f297ba2abb852d683f9fe5cfb9b3b.tar MultiMC-b09fad9cbf1f297ba2abb852d683f9fe5cfb9b3b.tar.gz MultiMC-b09fad9cbf1f297ba2abb852d683f9fe5cfb9b3b.tar.lz MultiMC-b09fad9cbf1f297ba2abb852d683f9fe5cfb9b3b.tar.xz MultiMC-b09fad9cbf1f297ba2abb852d683f9fe5cfb9b3b.zip |
GH-347 Add timestamp column to mod lists
It shows when the file was changed (in most cases added).
-rw-r--r-- | api/logic/minecraft/Mod.cpp | 1 | ||||
-rw-r--r-- | api/logic/minecraft/Mod.h | 7 | ||||
-rw-r--r-- | api/logic/minecraft/ModList.cpp | 8 | ||||
-rw-r--r-- | api/logic/minecraft/ModList.h | 4 |
4 files changed, 18 insertions, 2 deletions
diff --git a/api/logic/minecraft/Mod.cpp b/api/logic/minecraft/Mod.cpp index 9b9f76f9..3f53038d 100644 --- a/api/logic/minecraft/Mod.cpp +++ b/api/logic/minecraft/Mod.cpp @@ -30,6 +30,7 @@ Mod::Mod(const QFileInfo &file) { repath(file); + m_changedDateTime = file.lastModified(); } void Mod::repath(const QFileInfo &file) diff --git a/api/logic/minecraft/Mod.h b/api/logic/minecraft/Mod.h index 19f4c740..0a2e5881 100644 --- a/api/logic/minecraft/Mod.h +++ b/api/logic/minecraft/Mod.h @@ -15,6 +15,7 @@ #pragma once #include <QFileInfo> +#include <QDateTime> class Mod { @@ -86,6 +87,11 @@ public: return m_credits; } + QDateTime dateTimeChanged() const + { + return m_changedDateTime; + } + bool enabled() const { return m_enabled; @@ -118,6 +124,7 @@ protected: */ QFileInfo m_file; + QDateTime m_changedDateTime; QString m_mmc_id; QString m_mod_id; bool m_enabled = true; diff --git a/api/logic/minecraft/ModList.cpp b/api/logic/minecraft/ModList.cpp index 20963729..7396cd65 100644 --- a/api/logic/minecraft/ModList.cpp +++ b/api/logic/minecraft/ModList.cpp @@ -197,7 +197,7 @@ bool ModList::deleteMods(const QModelIndexList& indexes) int ModList::columnCount(const QModelIndex &parent) const { - return 3; + return NUM_COLUMNS; } QVariant ModList::data(const QModelIndex &index, int role) const @@ -220,6 +220,8 @@ QVariant ModList::data(const QModelIndex &index, int role) const return mods[row].name(); case VersionColumn: return mods[row].version(); + case DateColumn: + return mods[row].dateTimeChanged(); default: return QVariant(); @@ -273,6 +275,8 @@ QVariant ModList::headerData(int section, Qt::Orientation orientation, int role) return tr("Name"); case VersionColumn: return tr("Version"); + case DateColumn: + return tr("Last changed"); default: return QVariant(); } @@ -286,6 +290,8 @@ QVariant ModList::headerData(int section, Qt::Orientation orientation, int role) return tr("The name of the mod."); case VersionColumn: return tr("The version of the mod."); + case DateColumn: + return tr("The date and time this mod was last changed (or added)."); default: return QVariant(); } diff --git a/api/logic/minecraft/ModList.h b/api/logic/minecraft/ModList.h index 1b91764b..47ccd2cb 100644 --- a/api/logic/minecraft/ModList.h +++ b/api/logic/minecraft/ModList.h @@ -40,7 +40,9 @@ public: { ActiveColumn = 0, NameColumn, - VersionColumn + DateColumn, + VersionColumn, + NUM_COLUMNS }; ModList(const QString &dir); |