summaryrefslogtreecommitdiffstats
path: root/logic/minecraft/WorldList.cpp
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-09-06 23:35:58 +0200
committerPetr Mrázek <peterix@gmail.com>2015-09-06 23:35:58 +0200
commit38693e1d6ca7f05d9488348ddf298488d1cc0995 (patch)
treed99551fc3ebbef931d10ee45cb34f2ee791cc1fe /logic/minecraft/WorldList.cpp
parent40b233448c7a3977d45831b8aa6cf31019c03940 (diff)
downloadMultiMC-38693e1d6ca7f05d9488348ddf298488d1cc0995.tar
MultiMC-38693e1d6ca7f05d9488348ddf298488d1cc0995.tar.gz
MultiMC-38693e1d6ca7f05d9488348ddf298488d1cc0995.tar.lz
MultiMC-38693e1d6ca7f05d9488348ddf298488d1cc0995.tar.xz
MultiMC-38693e1d6ca7f05d9488348ddf298488d1cc0995.zip
GH-1047 parse world files and integrate MCEdit with world page
Diffstat (limited to 'logic/minecraft/WorldList.cpp')
-rw-r--r--logic/minecraft/WorldList.cpp34
1 files changed, 30 insertions, 4 deletions
diff --git a/logic/minecraft/WorldList.cpp b/logic/minecraft/WorldList.cpp
index 7d54c0ba..7066093c 100644
--- a/logic/minecraft/WorldList.cpp
+++ b/logic/minecraft/WorldList.cpp
@@ -66,7 +66,7 @@ void WorldList::internalSort(QList<World> &what)
{
auto predicate = [](const World &left, const World &right)
{
- return left.name().localeAwareCompare(right.name()) < 0;
+ return left.folderName().localeAwareCompare(right.folderName()) < 0;
};
std::sort(what.begin(), what.end(), predicate);
}
@@ -142,7 +142,7 @@ bool WorldList::deleteWorlds(int first, int last)
int WorldList::columnCount(const QModelIndex &parent) const
{
- return 1;
+ return 2;
}
QVariant WorldList::data(const QModelIndex &index, int role) const
@@ -156,20 +156,42 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
if (row < 0 || row >= worlds.size())
return QVariant();
+ auto & world = worlds[row];
switch (role)
{
case Qt::DisplayRole:
switch (column)
{
case NameColumn:
- return worlds[row].name();
+ return world.name();
+
+ case LastPlayedColumn:
+ return world.lastPlayed();
default:
return QVariant();
}
case Qt::ToolTipRole:
- return worlds[row].name();
+ {
+ return world.folderName();
+ }
+ case FolderRole:
+ {
+ return QDir::toNativeSeparators(dir().absoluteFilePath(world.folderName()));
+ }
+ case SeedRole:
+ {
+ return qVariantFromValue<qlonglong>(world.seed());
+ }
+ case NameRole:
+ {
+ return world.name();
+ }
+ case LastPlayedRole:
+ {
+ return world.lastPlayed();
+ }
default:
return QVariant();
}
@@ -184,6 +206,8 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol
{
case NameColumn:
return tr("Name");
+ case LastPlayedColumn:
+ return tr("Last Played");
default:
return QVariant();
}
@@ -193,6 +217,8 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol
{
case NameColumn:
return tr("The name of the world.");
+ case LastPlayedColumn:
+ return tr("Date and time the world was last played.");
default:
return QVariant();
}