GH-347 Add timestamp column to mod lists

It shows when the file was changed (in most cases added).
This commit is contained in:
Petr Mrázek 2016-11-17 02:55:02 +01:00
parent fd34ca5a0f
commit b09fad9cbf
4 changed files with 18 additions and 2 deletions

View File

@ -30,6 +30,7 @@
Mod::Mod(const QFileInfo &file) Mod::Mod(const QFileInfo &file)
{ {
repath(file); repath(file);
m_changedDateTime = file.lastModified();
} }
void Mod::repath(const QFileInfo &file) void Mod::repath(const QFileInfo &file)

View File

@ -15,6 +15,7 @@
#pragma once #pragma once
#include <QFileInfo> #include <QFileInfo>
#include <QDateTime>
class Mod class Mod
{ {
@ -86,6 +87,11 @@ public:
return m_credits; return m_credits;
} }
QDateTime dateTimeChanged() const
{
return m_changedDateTime;
}
bool enabled() const bool enabled() const
{ {
return m_enabled; return m_enabled;
@ -118,6 +124,7 @@ protected:
*/ */
QFileInfo m_file; QFileInfo m_file;
QDateTime m_changedDateTime;
QString m_mmc_id; QString m_mmc_id;
QString m_mod_id; QString m_mod_id;
bool m_enabled = true; bool m_enabled = true;

View File

@ -197,7 +197,7 @@ bool ModList::deleteMods(const QModelIndexList& indexes)
int ModList::columnCount(const QModelIndex &parent) const int ModList::columnCount(const QModelIndex &parent) const
{ {
return 3; return NUM_COLUMNS;
} }
QVariant ModList::data(const QModelIndex &index, int role) const 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(); return mods[row].name();
case VersionColumn: case VersionColumn:
return mods[row].version(); return mods[row].version();
case DateColumn:
return mods[row].dateTimeChanged();
default: default:
return QVariant(); return QVariant();
@ -273,6 +275,8 @@ QVariant ModList::headerData(int section, Qt::Orientation orientation, int role)
return tr("Name"); return tr("Name");
case VersionColumn: case VersionColumn:
return tr("Version"); return tr("Version");
case DateColumn:
return tr("Last changed");
default: default:
return QVariant(); return QVariant();
} }
@ -286,6 +290,8 @@ QVariant ModList::headerData(int section, Qt::Orientation orientation, int role)
return tr("The name of the mod."); return tr("The name of the mod.");
case VersionColumn: case VersionColumn:
return tr("The version of the mod."); return tr("The version of the mod.");
case DateColumn:
return tr("The date and time this mod was last changed (or added).");
default: default:
return QVariant(); return QVariant();
} }

View File

@ -40,7 +40,9 @@ public:
{ {
ActiveColumn = 0, ActiveColumn = 0,
NameColumn, NameColumn,
VersionColumn DateColumn,
VersionColumn,
NUM_COLUMNS
}; };
ModList(const QString &dir); ModList(const QString &dir);