Merge pull request #462 from Scrumplex/fix-world-size-sort
fix: use size in bytes to sort by world size
This commit is contained in:
commit
405c44c9e1
@ -17,6 +17,7 @@
|
|||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include <FileSystem.h>
|
#include <FileSystem.h>
|
||||||
|
#include <Qt>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
@ -190,6 +191,16 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
|
|||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case Qt::UserRole:
|
||||||
|
switch (column)
|
||||||
|
{
|
||||||
|
case SizeColumn:
|
||||||
|
return qVariantFromValue<qlonglong>(world.bytes());
|
||||||
|
|
||||||
|
default:
|
||||||
|
return data(index, Qt::DisplayRole);
|
||||||
|
}
|
||||||
|
|
||||||
case Qt::ToolTipRole:
|
case Qt::ToolTipRole:
|
||||||
{
|
{
|
||||||
return world.folderName();
|
return world.folderName();
|
||||||
@ -216,7 +227,7 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
|
|||||||
}
|
}
|
||||||
case SizeRole:
|
case SizeRole:
|
||||||
{
|
{
|
||||||
return locale.formattedDataSize(world.bytes());
|
return qVariantFromValue<qlonglong>(world.bytes());
|
||||||
}
|
}
|
||||||
case IconFileRole:
|
case IconFileRole:
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
#include <QTreeView>
|
#include <QTreeView>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <Qt>
|
||||||
|
|
||||||
#include "tools/MCEditTool.h"
|
#include "tools/MCEditTool.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
@ -92,6 +93,7 @@ WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worl
|
|||||||
WorldListProxyModel * proxy = new WorldListProxyModel(this);
|
WorldListProxyModel * proxy = new WorldListProxyModel(this);
|
||||||
proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
proxy->setSortCaseSensitivity(Qt::CaseInsensitive);
|
||||||
proxy->setSourceModel(m_worlds.get());
|
proxy->setSourceModel(m_worlds.get());
|
||||||
|
proxy->setSortRole(Qt::UserRole);
|
||||||
ui->worldTreeView->setSortingEnabled(true);
|
ui->worldTreeView->setSortingEnabled(true);
|
||||||
ui->worldTreeView->setModel(proxy);
|
ui->worldTreeView->setModel(proxy);
|
||||||
ui->worldTreeView->installEventFilter(this);
|
ui->worldTreeView->installEventFilter(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user