From 176783c8caacafd5d320c2fef7374335ee54796b Mon Sep 17 00:00:00 2001 From: Jan Dalheimer Date: Mon, 27 Jan 2014 20:17:29 +0100 Subject: [PATCH] Have the libraries tab show tweaker mods instead of libraries --- gui/dialogs/OneSixModEditDialog.ui | 10 ++++++ logic/LiteLoaderInstaller.cpp | 2 +- logic/OneSixVersion.cpp | 52 +++++++----------------------- logic/OneSixVersion.h | 2 -- 4 files changed, 23 insertions(+), 43 deletions(-) diff --git a/gui/dialogs/OneSixModEditDialog.ui b/gui/dialogs/OneSixModEditDialog.ui index d57d0f85..67642c23 100644 --- a/gui/dialogs/OneSixModEditDialog.ui +++ b/gui/dialogs/OneSixModEditDialog.ui @@ -35,6 +35,13 @@ + + + + Tweakers: + + + @@ -43,6 +50,9 @@ Qt::ScrollBarAlwaysOff + + false + diff --git a/logic/LiteLoaderInstaller.cpp b/logic/LiteLoaderInstaller.cpp index 1ce9d3f4..1c38fd5e 100644 --- a/logic/LiteLoaderInstaller.cpp +++ b/logic/LiteLoaderInstaller.cpp @@ -53,7 +53,7 @@ bool LiteLoaderInstaller::add(OneSixInstance *to) QJsonObject obj; obj.insert("mainClass", QString("net.minecraft.launchwrapper.Launch")); - obj.insert("+minecraftArguments", QString(" --tweakClass com.mumfrey.liteloader.launch.LiteLoaderTweaker")); + obj.insert("+tweakers", QJsonArray::fromStringList(QStringList() << "com.mumfrey.liteloader.launch.LiteLoaderTweaker")); obj.insert("order", 10); QJsonArray libraries; diff --git a/logic/OneSixVersion.cpp b/logic/OneSixVersion.cpp index 1b6bc9cb..1abd5114 100644 --- a/logic/OneSixVersion.cpp +++ b/logic/OneSixVersion.cpp @@ -27,11 +27,15 @@ OneSixVersion::OneSixVersion(OneSixInstance *instance, QObject *parent) bool OneSixVersion::reload(QWidget *widgetParent, const bool excludeCustom) { - return OneSixVersionBuilder::build(this, m_instance, widgetParent, excludeCustom); + beginResetModel(); + bool ret = OneSixVersionBuilder::build(this, m_instance, widgetParent, excludeCustom); + endResetModel(); + return ret; } void OneSixVersion::clear() { + beginResetModel(); id.clear(); time.clear(); releaseTime.clear(); @@ -43,6 +47,7 @@ void OneSixVersion::clear() mainClass.clear(); libraries.clear(); tweakers.clear(); + endResetModel(); } void OneSixVersion::dump() const @@ -109,21 +114,14 @@ QVariant OneSixVersion::data(const QModelIndex &index, int role) const int row = index.row(); int column = index.column(); - if (row < 0 || row >= libraries.size()) + if (row < 0 || row >= tweakers.size()) return QVariant(); if (role == Qt::DisplayRole) { - switch (column) + if (column == 0) { - case 0: - return libraries[row]->name(); - case 1: - return libraries[row]->type(); - case 2: - return libraries[row]->version(); - default: - return QVariant(); + return tweakers.at(row); } } return QVariant(); @@ -133,43 +131,17 @@ Qt::ItemFlags OneSixVersion::flags(const QModelIndex &index) const { if (!index.isValid()) return Qt::NoItemFlags; - int row = index.row(); - if (libraries[row]->isActive()) - { - return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemNeverHasChildren; - } - else - { - return Qt::ItemNeverHasChildren; - } - // return QAbstractListModel::flags(index); -} - -QVariant OneSixVersion::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (role != Qt::DisplayRole || orientation != Qt::Horizontal) - return QVariant(); - switch (section) - { - case 0: - return QString("Name"); - case 1: - return QString("Type"); - case 2: - return QString("Version"); - default: - return QString(); - } + return Qt::ItemIsSelectable | Qt::ItemIsEnabled; } int OneSixVersion::rowCount(const QModelIndex &parent) const { - return libraries.size(); + return tweakers.size(); } int OneSixVersion::columnCount(const QModelIndex &parent) const { - return 3; + return 1; } QDebug operator<<(QDebug &dbg, const OneSixVersion *version) diff --git a/logic/OneSixVersion.h b/logic/OneSixVersion.h index 767e05db..98a4b418 100644 --- a/logic/OneSixVersion.h +++ b/logic/OneSixVersion.h @@ -33,8 +33,6 @@ public: virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; virtual int rowCount(const QModelIndex &parent = QModelIndex()) const; - virtual QVariant headerData(int section, Qt::Orientation orientation, - int role = Qt::DisplayRole) const; virtual int columnCount(const QModelIndex &parent) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const;