From a266e5d0ccafe1585bafd471d7a71181358ceb59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Tue, 27 Aug 2013 20:29:27 +0200 Subject: [PATCH] Slight refactor of the mod edit dialog constructor Also some other insignificant refactors --- gui/LegacyModEditDialog.cpp | 63 +++++++++++++++++++++++-------------- logic/LegacyInstance.cpp | 4 +-- logic/LegacyInstance.h | 2 +- 3 files changed, 43 insertions(+), 26 deletions(-) diff --git a/gui/LegacyModEditDialog.cpp b/gui/LegacyModEditDialog.cpp index e16f979c..27856bb5 100644 --- a/gui/LegacyModEditDialog.cpp +++ b/gui/LegacyModEditDialog.cpp @@ -28,29 +28,46 @@ LegacyModEditDialog::LegacyModEditDialog( LegacyInstance* inst, QWidget* parent ui(new Ui::LegacyModEditDialog) { ui->setupUi(this); - ensureFolderPathExists(m_inst->coreModsDir()); - ensureFolderPathExists(m_inst->mlModsDir()); - ensureFolderPathExists(m_inst->jarModsDir()); - m_mods = m_inst->loaderModList(); - m_coremods = m_inst->coreModList(); - m_jarmods = m_inst->jarModList(); - m_texturepacks = m_inst->texturePackList(); - - ui->jarModsTreeView->setModel(m_jarmods.data()); - //ui->jarModsTreeView->setDragDropMode(QAbstractItemView::DragDrop); - ui->coreModsTreeView->setModel(m_coremods.data()); - ui->mlModTreeView->setModel(m_mods.data()); - ui->texPackTreeView->setModel(m_texturepacks.data()); - - ui->jarModsTreeView->installEventFilter( this ); - ui->coreModsTreeView->installEventFilter( this ); - ui->mlModTreeView->installEventFilter( this ); - ui->texPackTreeView->installEventFilter( this ); - m_mods->startWatching(); - m_coremods->startWatching(); - m_jarmods->startWatching(); - m_texturepacks->startWatching(); + // Jar mods + { + ensureFolderPathExists(m_inst->jarModsDir()); + m_jarmods = m_inst->jarModList(); + ui->jarModsTreeView->setModel(m_jarmods.data()); + + /* + // FIXME: internal DnD causes segfaults later + ui->jarModsTreeView->setDragDropMode(QAbstractItemView::DragDrop); + // FIXME: DnD is glitched with contiguous (we move only first item in selection) + ui->jarModsTreeView->setSelectionMode(QAbstractItemView::SingleSelection); + */ + + ui->jarModsTreeView->installEventFilter( this ); + m_jarmods->startWatching(); + } + // Core mods + { + ensureFolderPathExists(m_inst->coreModsDir()); + m_coremods = m_inst->coreModList(); + ui->coreModsTreeView->setModel(m_coremods.data()); + ui->coreModsTreeView->installEventFilter( this ); + m_coremods->startWatching(); + } + // Loader mods + { + ensureFolderPathExists(m_inst->loaderModsDir()); + m_mods = m_inst->loaderModList(); + ui->mlModTreeView->setModel(m_mods.data()); + ui->mlModTreeView->installEventFilter( this ); + m_mods->startWatching(); + } + // texture packs + { + m_texturepacks = m_inst->texturePackList(); + ui->texPackTreeView->setModel(m_texturepacks.data()); + ui->texPackTreeView->installEventFilter( this ); + m_texturepacks->startWatching(); + } } LegacyModEditDialog::~LegacyModEditDialog() @@ -294,7 +311,7 @@ void LegacyModEditDialog::on_viewCoreBtn_clicked() } void LegacyModEditDialog::on_viewModBtn_clicked() { - openDirInDefaultProgram(m_inst->mlModsDir(), true); + openDirInDefaultProgram(m_inst->loaderModsDir(), true); } void LegacyModEditDialog::on_viewTexPackBtn_clicked() { diff --git a/logic/LegacyInstance.cpp b/logic/LegacyInstance.cpp index 7209793c..73a02cbd 100644 --- a/logic/LegacyInstance.cpp +++ b/logic/LegacyInstance.cpp @@ -124,7 +124,7 @@ QSharedPointer< ModList > LegacyInstance::loaderModList() I_D(LegacyInstance); if(!d->loader_mod_list) { - d->loader_mod_list.reset(new ModList(mlModsDir())); + d->loader_mod_list.reset(new ModList(loaderModsDir())); } else d->loader_mod_list->update(); @@ -171,7 +171,7 @@ QString LegacyInstance::savesDir() const return PathCombine(minecraftRoot(), "saves"); } -QString LegacyInstance::mlModsDir() const +QString LegacyInstance::loaderModsDir() const { return PathCombine(minecraftRoot(), "mods"); } diff --git a/logic/LegacyInstance.h b/logic/LegacyInstance.h index 97502945..4df884d2 100644 --- a/logic/LegacyInstance.h +++ b/logic/LegacyInstance.h @@ -29,7 +29,7 @@ public: QString texturePackDir() const; QString jarModsDir() const; QString binDir() const; - QString mlModsDir() const; + QString loaderModsDir() const; QString coreModsDir() const; QString resourceDir() const; virtual QString instanceConfigFolder() const;