Have the libraries tab show tweaker mods instead of libraries

This commit is contained in:
Jan Dalheimer 2014-01-27 20:17:29 +01:00
parent f9ea3dbfde
commit 176783c8ca
4 changed files with 23 additions and 43 deletions

View File

@ -35,6 +35,13 @@
<layout class="QHBoxLayout" name="horizontalLayout"> <layout class="QHBoxLayout" name="horizontalLayout">
<item> <item>
<layout class="QVBoxLayout" name="verticalLayout_10"> <layout class="QVBoxLayout" name="verticalLayout_10">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Tweakers:</string>
</property>
</widget>
</item>
<item> <item>
<widget class="ModListView" name="libraryTreeView"> <widget class="ModListView" name="libraryTreeView">
<property name="verticalScrollBarPolicy"> <property name="verticalScrollBarPolicy">
@ -43,6 +50,9 @@
<property name="horizontalScrollBarPolicy"> <property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum> <enum>Qt::ScrollBarAlwaysOff</enum>
</property> </property>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</widget> </widget>
</item> </item>
<item> <item>

View File

@ -53,7 +53,7 @@ bool LiteLoaderInstaller::add(OneSixInstance *to)
QJsonObject obj; QJsonObject obj;
obj.insert("mainClass", QString("net.minecraft.launchwrapper.Launch")); 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); obj.insert("order", 10);
QJsonArray libraries; QJsonArray libraries;

View File

@ -27,11 +27,15 @@ OneSixVersion::OneSixVersion(OneSixInstance *instance, QObject *parent)
bool OneSixVersion::reload(QWidget *widgetParent, const bool excludeCustom) 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() void OneSixVersion::clear()
{ {
beginResetModel();
id.clear(); id.clear();
time.clear(); time.clear();
releaseTime.clear(); releaseTime.clear();
@ -43,6 +47,7 @@ void OneSixVersion::clear()
mainClass.clear(); mainClass.clear();
libraries.clear(); libraries.clear();
tweakers.clear(); tweakers.clear();
endResetModel();
} }
void OneSixVersion::dump() const void OneSixVersion::dump() const
@ -109,21 +114,14 @@ QVariant OneSixVersion::data(const QModelIndex &index, int role) const
int row = index.row(); int row = index.row();
int column = index.column(); int column = index.column();
if (row < 0 || row >= libraries.size()) if (row < 0 || row >= tweakers.size())
return QVariant(); return QVariant();
if (role == Qt::DisplayRole) if (role == Qt::DisplayRole)
{ {
switch (column) if (column == 0)
{ {
case 0: return tweakers.at(row);
return libraries[row]->name();
case 1:
return libraries[row]->type();
case 2:
return libraries[row]->version();
default:
return QVariant();
} }
} }
return QVariant(); return QVariant();
@ -133,43 +131,17 @@ Qt::ItemFlags OneSixVersion::flags(const QModelIndex &index) const
{ {
if (!index.isValid()) if (!index.isValid())
return Qt::NoItemFlags; return Qt::NoItemFlags;
int row = index.row(); return Qt::ItemIsSelectable | Qt::ItemIsEnabled;
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();
}
} }
int OneSixVersion::rowCount(const QModelIndex &parent) const int OneSixVersion::rowCount(const QModelIndex &parent) const
{ {
return libraries.size(); return tweakers.size();
} }
int OneSixVersion::columnCount(const QModelIndex &parent) const int OneSixVersion::columnCount(const QModelIndex &parent) const
{ {
return 3; return 1;
} }
QDebug operator<<(QDebug &dbg, const OneSixVersion *version) QDebug operator<<(QDebug &dbg, const OneSixVersion *version)

View File

@ -33,8 +33,6 @@ public:
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
virtual int rowCount(const QModelIndex &parent = QModelIndex()) 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 int columnCount(const QModelIndex &parent) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const;