Merge branch 'develop' into fix/network_and_signals

Signed-off-by: Rachel Powers <508861+Ryex@users.noreply.github.com>
This commit is contained in:
Rachel Powers
2023-05-12 01:13:17 -07:00
committed by GitHub
121 changed files with 4944 additions and 2471 deletions

View File

@ -45,8 +45,8 @@
#include <QFileSystemWatcher>
#include <QDebug>
WorldList::WorldList(const QString &dir)
: QAbstractListModel(), m_dir(dir)
WorldList::WorldList(const QString &dir, std::shared_ptr<const BaseInstance> instance)
: QAbstractListModel(), m_instance(instance), m_dir(dir)
{
FS::ensureFolderPathExists(m_dir.absolutePath());
m_dir.setFilter(QDir::Readable | QDir::NoDotAndDotDot | QDir::Files | QDir::Dirs);
@ -127,6 +127,10 @@ bool WorldList::isValid()
return m_dir.exists() && m_dir.isReadable();
}
QString WorldList::instDirPath() const {
return QFileInfo(m_instance->instanceRoot()).absoluteFilePath();
}
bool WorldList::deleteWorld(int index)
{
if (index >= worlds.size() || index < 0)
@ -172,7 +176,7 @@ bool WorldList::resetIcon(int row)
int WorldList::columnCount(const QModelIndex &parent) const
{
return parent.isValid()? 0 : 4;
return parent.isValid()? 0 : 5;
}
QVariant WorldList::data(const QModelIndex &index, int role) const
@ -206,6 +210,14 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
case SizeColumn:
return locale.formattedDataSize(world.bytes());
case InfoColumn:
if (world.isSymLinkUnder(instDirPath())) {
return tr("This world is symbolically linked from elsewhere.");
}
if (world.isMoreThanOneHardLink()) {
return tr("\nThis world is hard linked elsewhere.");
}
return "";
default:
return QVariant();
}
@ -221,7 +233,16 @@ QVariant WorldList::data(const QModelIndex &index, int role) const
}
case Qt::ToolTipRole:
{
{
if (column == InfoColumn) {
if (world.isSymLinkUnder(instDirPath())) {
return tr("Warning: This world is symbolically linked from elsewhere. Editing it will also change the original."
"\nCanonical Path: %1").arg(world.canonicalFilePath());
}
if (world.isMoreThanOneHardLink()) {
return tr("Warning: This world is hard linked elsewhere. Editing it will also change the original.");
}
}
return world.folderName();
}
case ObjectRole:
@ -273,6 +294,9 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol
case SizeColumn:
//: World size on disk
return tr("Size");
case InfoColumn:
//: special warnings?
return tr("Info");
default:
return QVariant();
}
@ -288,6 +312,8 @@ QVariant WorldList::headerData(int section, Qt::Orientation orientation, int rol
return tr("Date and time the world was last played.");
case SizeColumn:
return tr("Size of the world on disk.");
case InfoColumn:
return tr("Information and warnings about the world.");
default:
return QVariant();
}