Move version stuff to the model and reimplement reordering
This commit is contained in:
@ -42,16 +42,6 @@
|
||||
#include "logic/LiteLoaderInstaller.h"
|
||||
#include "logic/OneSixVersionBuilder.h"
|
||||
|
||||
template <typename A, typename B> QMap<A, B> invert(const QMap<B, A> &in)
|
||||
{
|
||||
QMap<A, B> out;
|
||||
for (auto it = in.begin(); it != in.end(); ++it)
|
||||
{
|
||||
out.insert(it.value(), it.key());
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
OneSixModEditDialog::OneSixModEditDialog(OneSixInstance *inst, QWidget *parent)
|
||||
: QDialog(parent), ui(new Ui::OneSixModEditDialog), m_inst(inst)
|
||||
{
|
||||
@ -164,25 +154,57 @@ void OneSixModEditDialog::on_removeLibraryBtn_clicked()
|
||||
|
||||
void OneSixModEditDialog::on_resetLibraryOrderBtn_clicked()
|
||||
{
|
||||
// FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
|
||||
try
|
||||
{
|
||||
m_version->resetOrder();
|
||||
}
|
||||
catch (MMCError &e)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), e.cause());
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_moveLibraryUpBtn_clicked()
|
||||
{
|
||||
// FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
|
||||
if (ui->libraryTreeView->selectionModel()->selectedRows().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row();
|
||||
const int newRow = 0;m_version->move(row, VersionFinal::MoveUp);
|
||||
//ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
catch (MMCError &e)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), e.cause());
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_moveLibraryDownBtn_clicked()
|
||||
{
|
||||
// FIXME: IMPLEMENT LOGIC IN MODEL. SEE LEGACY DIALOG FOR EXAMPLE(S).
|
||||
if (ui->libraryTreeView->selectionModel()->selectedRows().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
const int row = ui->libraryTreeView->selectionModel()->selectedRows().first().row();
|
||||
const int newRow = 0;m_version->move(row, VersionFinal::MoveDown);
|
||||
//ui->libraryTreeView->selectionModel()->setCurrentIndex(m_version->index(newRow), QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
catch (MMCError &e)
|
||||
{
|
||||
QMessageBox::critical(this, tr("Error"), e.cause());
|
||||
}
|
||||
}
|
||||
|
||||
void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||
{
|
||||
// FIXME: use actual model, not reloading. Move logic to model.
|
||||
|
||||
// FIXME: model::isCustom();
|
||||
if (QDir(m_inst->instanceRoot()).exists("custom.json"))
|
||||
if (m_version->isCustom())
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Revert?"),
|
||||
tr("This action will remove your custom.json. Continue?")) !=
|
||||
@ -190,8 +212,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||
{
|
||||
return;
|
||||
}
|
||||
// FIXME: model::revertToBase();
|
||||
QDir(m_inst->instanceRoot()).remove("custom.json");
|
||||
m_version->revertToBase();
|
||||
reloadInstanceVersion();
|
||||
}
|
||||
VersionSelectDialog vselect(MMC->forgelist().get(), tr("Select Forge version"), this);
|
||||
@ -242,8 +263,7 @@ void OneSixModEditDialog::on_forgeBtn_clicked()
|
||||
|
||||
void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||
{
|
||||
// FIXME: model...
|
||||
if (QDir(m_inst->instanceRoot()).exists("custom.json"))
|
||||
if (m_version->isCustom())
|
||||
{
|
||||
if (QMessageBox::question(this, tr("Revert?"),
|
||||
tr("This action will remove your custom.json. Continue?")) !=
|
||||
@ -251,7 +271,7 @@ void OneSixModEditDialog::on_liteloaderBtn_clicked()
|
||||
{
|
||||
return;
|
||||
}
|
||||
QDir(m_inst->instanceRoot()).remove("custom.json");
|
||||
m_version->revertToBase();
|
||||
reloadInstanceVersion();
|
||||
}
|
||||
VersionSelectDialog vselect(MMC->liteloaderlist().get(), tr("Select LiteLoader version"),
|
||||
|
@ -99,9 +99,6 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="moveLibraryUpBtn">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This isn't implemented yet.</string>
|
||||
</property>
|
||||
@ -112,9 +109,6 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="moveLibraryDownBtn">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This isn't implemented yet.</string>
|
||||
</property>
|
||||
@ -125,9 +119,6 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetLibraryOrderBtn">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>This isn't implemented yet.</string>
|
||||
</property>
|
||||
|
Reference in New Issue
Block a user