From 38693e1d6ca7f05d9488348ddf298488d1cc0995 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Sun, 6 Sep 2015 23:35:58 +0200 Subject: GH-1047 parse world files and integrate MCEdit with world page --- logic/minecraft/WorldList.cpp | 34 ++++++++++++++++++++++++++++++---- 1 file changed, 30 insertions(+), 4 deletions(-) (limited to 'logic/minecraft/WorldList.cpp') 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 &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(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(); } -- cgit v1.2.3