mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-01 15:06:41 +00:00
launcher: decouple Combo Box model from Plug-ins model.
fixes bug reported by scrawl 1. openmw.cfg had content files in order 'Bloodmoon.esm, Tribunal.esm, Morrowind.esm' 2. Blank_ESM_2.0.esm is in the Data Files directory 3. Do an ini file import. 4. Imported profile will have Blank_ESM_2.0.esm as the game file. Should be Morrowind.esm. Root cause: Game File combo box and Plugins Grid shared same data model, so changing plug-in file order also changed order of Game File combo box.
This commit is contained in:
parent
63af9d848a
commit
6878e317a7
4 changed files with 41 additions and 19 deletions
|
@ -489,6 +489,19 @@ void ContentSelectorModel::ContentModel::addFiles(const QString &path)
|
||||||
sortFiles();
|
sortFiles();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList ContentSelectorModel::ContentModel::gameFiles() const
|
||||||
|
{
|
||||||
|
QStringList gameFiles;
|
||||||
|
foreach(const ContentSelectorModel::EsmFile *file, mFiles)
|
||||||
|
{
|
||||||
|
if (file->isGameFile())
|
||||||
|
{
|
||||||
|
gameFiles.append(file->fileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return gameFiles;
|
||||||
|
}
|
||||||
|
|
||||||
void ContentSelectorModel::ContentModel::sortFiles()
|
void ContentSelectorModel::ContentModel::sortFiles()
|
||||||
{
|
{
|
||||||
//first, sort the model such that all dependencies are ordered upstream (gamefile) first.
|
//first, sort the model such that all dependencies are ordered upstream (gamefile) first.
|
||||||
|
@ -589,7 +602,7 @@ void ContentSelectorModel::ContentModel::checkForLoadOrderErrors()
|
||||||
QList<ContentSelectorModel::LoadOrderError> ContentSelectorModel::ContentModel::checkForLoadOrderErrors(const EsmFile *file, int row) const
|
QList<ContentSelectorModel::LoadOrderError> ContentSelectorModel::ContentModel::checkForLoadOrderErrors(const EsmFile *file, int row) const
|
||||||
{
|
{
|
||||||
QList<LoadOrderError> errors = QList<LoadOrderError>();
|
QList<LoadOrderError> errors = QList<LoadOrderError>();
|
||||||
foreach(QString dependentfileName, file->gameFiles())
|
foreach(const QString &dependentfileName, file->gameFiles())
|
||||||
{
|
{
|
||||||
const EsmFile* dependentFile = item(dependentfileName);
|
const EsmFile* dependentFile = item(dependentfileName);
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,7 @@ namespace ContentSelectorModel
|
||||||
|
|
||||||
QModelIndex indexFromItem(const EsmFile *item) const;
|
QModelIndex indexFromItem(const EsmFile *item) const;
|
||||||
const EsmFile *item(const QString &name) const;
|
const EsmFile *item(const QString &name) const;
|
||||||
|
QStringList gameFiles() const;
|
||||||
|
|
||||||
bool isEnabled (QModelIndex index) const;
|
bool isEnabled (QModelIndex index) const;
|
||||||
bool isChecked(const QString &filepath) const;
|
bool isChecked(const QString &filepath) const;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QModelIndex>
|
#include <QModelIndex>
|
||||||
|
#include <QDir>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
ContentSelectorView::ContentSelector::ContentSelector(QWidget *parent) :
|
||||||
|
@ -33,13 +34,7 @@ void ContentSelectorView::ContentSelector::buildGameFileView()
|
||||||
{
|
{
|
||||||
ui.gameFileView->setVisible (true);
|
ui.gameFileView->setVisible (true);
|
||||||
|
|
||||||
mGameFileProxyModel = new QSortFilterProxyModel(this);
|
|
||||||
mGameFileProxyModel->setFilterRegExp(QString::number((int)ContentSelectorModel::ContentType_GameFile));
|
|
||||||
mGameFileProxyModel->setFilterRole (Qt::UserRole);
|
|
||||||
mGameFileProxyModel->setSourceModel (mContentModel);
|
|
||||||
|
|
||||||
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
ui.gameFileView->setPlaceholderText(QString("Select a game file..."));
|
||||||
ui.gameFileView->setModel(mGameFileProxyModel);
|
|
||||||
|
|
||||||
connect (ui.gameFileView, SIGNAL (currentIndexChanged(int)),
|
connect (ui.gameFileView, SIGNAL (currentIndexChanged(int)),
|
||||||
this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
this, SLOT (slotCurrentGameFileIndexChanged(int)));
|
||||||
|
@ -129,6 +124,15 @@ void ContentSelectorView::ContentSelector::addFiles(const QString &path)
|
||||||
{
|
{
|
||||||
mContentModel->addFiles(path);
|
mContentModel->addFiles(path);
|
||||||
|
|
||||||
|
// add any game files to the combo box
|
||||||
|
foreach(const QString gameFileName, mContentModel->gameFiles())
|
||||||
|
{
|
||||||
|
if (ui.gameFileView->findText(gameFileName) == -1)
|
||||||
|
{
|
||||||
|
ui.gameFileView->addItem(gameFileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (ui.gameFileView->currentIndex() != -1)
|
if (ui.gameFileView->currentIndex() != -1)
|
||||||
ui.gameFileView->setCurrentIndex(-1);
|
ui.gameFileView->setCurrentIndex(-1);
|
||||||
|
|
||||||
|
@ -150,29 +154,33 @@ void ContentSelectorView::ContentSelector::slotCurrentGameFileIndexChanged(int i
|
||||||
{
|
{
|
||||||
static int oldIndex = -1;
|
static int oldIndex = -1;
|
||||||
|
|
||||||
QAbstractItemModel *const model = ui.gameFileView->model();
|
|
||||||
QSortFilterProxyModel *proxy = dynamic_cast<QSortFilterProxyModel *>(model);
|
|
||||||
|
|
||||||
if (proxy)
|
|
||||||
proxy->setDynamicSortFilter(false);
|
|
||||||
|
|
||||||
if (index != oldIndex)
|
if (index != oldIndex)
|
||||||
{
|
{
|
||||||
if (oldIndex > -1)
|
if (oldIndex > -1)
|
||||||
model->setData(model->index(oldIndex, 0), false, Qt::UserRole + 1);
|
{
|
||||||
|
setGameFileSelected(oldIndex, false);
|
||||||
|
}
|
||||||
|
|
||||||
oldIndex = index;
|
oldIndex = index;
|
||||||
|
|
||||||
model->setData(model->index(index, 0), true, Qt::UserRole + 1);
|
setGameFileSelected(index, true);
|
||||||
mContentModel->checkForLoadOrderErrors();
|
mContentModel->checkForLoadOrderErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (proxy)
|
|
||||||
proxy->setDynamicSortFilter(true);
|
|
||||||
|
|
||||||
emit signalCurrentGamefileIndexChanged (index);
|
emit signalCurrentGamefileIndexChanged (index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ContentSelectorView::ContentSelector::setGameFileSelected(int index, bool selected)
|
||||||
|
{
|
||||||
|
QString fileName = ui.gameFileView->itemText(index);
|
||||||
|
const ContentSelectorModel::EsmFile* file = mContentModel->item(fileName);
|
||||||
|
if (file != NULL)
|
||||||
|
{
|
||||||
|
QModelIndex index(mContentModel->indexFromItem(file));
|
||||||
|
mContentModel->setData(index, selected, Qt::UserRole + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ContentSelectorView::ContentSelector::slotAddonTableItemActivated(const QModelIndex &index)
|
void ContentSelectorView::ContentSelector::slotAddonTableItemActivated(const QModelIndex &index)
|
||||||
{
|
{
|
||||||
QModelIndex sourceIndex = mAddonProxyModel->mapToSource (index);
|
QModelIndex sourceIndex = mAddonProxyModel->mapToSource (index);
|
||||||
|
|
|
@ -19,7 +19,6 @@ namespace ContentSelectorView
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
ContentSelectorModel::ContentModel *mContentModel;
|
ContentSelectorModel::ContentModel *mContentModel;
|
||||||
QSortFilterProxyModel *mGameFileProxyModel;
|
|
||||||
QSortFilterProxyModel *mAddonProxyModel;
|
QSortFilterProxyModel *mAddonProxyModel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -52,6 +51,7 @@ namespace ContentSelectorView
|
||||||
void buildContentModel();
|
void buildContentModel();
|
||||||
void buildGameFileView();
|
void buildGameFileView();
|
||||||
void buildAddonView();
|
void buildAddonView();
|
||||||
|
void setGameFileSelected(int index, bool selected);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalCurrentGamefileIndexChanged (int);
|
void signalCurrentGamefileIndexChanged (int);
|
||||||
|
|
Loading…
Reference in a new issue