|
|
|
#ifndef CONTENTMODEL_HPP
|
|
|
|
#define CONTENTMODEL_HPP
|
|
|
|
|
|
|
|
#include "loadordererror.hpp"
|
|
|
|
#include <QAbstractTableModel>
|
|
|
|
#include <QIcon>
|
|
|
|
#include <QSet>
|
|
|
|
#include <QStringList>
|
|
|
|
|
|
|
|
#include <set>
|
|
|
|
|
|
|
|
namespace ContentSelectorModel
|
|
|
|
{
|
|
|
|
class EsmFile;
|
|
|
|
|
|
|
|
typedef QList<EsmFile*> ContentFileList;
|
|
|
|
|
|
|
|
enum ContentType
|
|
|
|
{
|
|
|
|
ContentType_GameFile,
|
|
|
|
ContentType_Addon
|
|
|
|
};
|
|
|
|
|
|
|
|
class ContentModel : public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit ContentModel(QObject* parent, QIcon& warningIcon, QIcon& errorIcon, bool showOMWScripts);
|
|
|
|
~ContentModel();
|
|
|
|
|
|
|
|
void setEncoding(const QString& encoding);
|
|
|
|
|
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
|
|
|
|
QVariant data(const QModelIndex& index, int role) const override;
|
|
|
|
Qt::ItemFlags flags(const QModelIndex& index) const override;
|
|
|
|
bool setData(const QModelIndex& index, const QVariant& value, int role = Qt::EditRole) override;
|
|
|
|
|
|
|
|
bool insertRows(int position, int rows, const QModelIndex& index = QModelIndex()) override;
|
|
|
|
bool removeRows(int position, int rows, const QModelIndex& index = QModelIndex()) override;
|
|
|
|
|
|
|
|
Qt::DropActions supportedDropActions() const override;
|
|
|
|
QStringList mimeTypes() const override;
|
|
|
|
QMimeData* mimeData(const QModelIndexList& indexes) const override;
|
|
|
|
bool dropMimeData(
|
|
|
|
const QMimeData* data, Qt::DropAction action, int row, int column, const QModelIndex& parent) override;
|
|
|
|
|
|
|
|
void addFiles(const QString& path, bool newfiles);
|
|
|
|
void sortFiles();
|
|
|
|
bool containsDataFiles(const QString& path);
|
|
|
|
void clearFiles();
|
|
|
|
|
|
|
|
QModelIndex indexFromItem(const EsmFile* item) const;
|
|
|
|
const EsmFile* item(const QString& name) const;
|
|
|
|
const EsmFile* item(int row) const;
|
|
|
|
EsmFile* item(int row);
|
|
|
|
QStringList gameFiles() const;
|
|
|
|
void setCurrentGameFile(const EsmFile* file);
|
|
|
|
|
|
|
|
bool isEnabled(const QModelIndex& index) const;
|
|
|
|
bool setCheckState(const QString& filepath, bool isChecked);
|
|
|
|
bool isNew(const QString& filepath) const;
|
|
|
|
void setNew(const QString& filepath, bool isChecked);
|
Track source of settings
This one's a biggie.
The basic idea's that GameSettings should know:
* what the interpreted value of a setting is, so it can actually be used.
* what the original value the user put in their config was, so it can be put back when the config's saved.
* which path it's processing the openmw.cfg from so relative paths can be resolved correctly.
* whether a setting's a user setting that can be modified, or from one of the other openmw.cfg files that can't necessarily be modified.
This had fairly wide-reaching implications.
The first is that paths are resolved properly in cases where they previously wouldn't have been.
Without this commit, if the launcher saw a relative path in an openmw.cfg, it'd be resolved relative to the process' working directory (which we always set to the binary directory for reasons I won't get into).
That's not what the engine does, so is bad.
It's also not something a user's likely to suspect.
This mess is no longer a problem as paths are resolved correctly when they're loaded instead of on demand when they're used by whatever uses them.
Another problem was that if paths used slugs like ?userconfig? would be written back to openmw.cfg with the slugs replaced, which defeats the object of using the slugs.
This is also fixed.
Tracking which settings are user settings and which are in a non-editable openmw.cfg allows the launcher to grey out rows so they can't be edited (which is sensible as they can't be edited on-disk) while still being aware of content files that are provided by non-user data directories etc.
This is done in a pretty straightforward way for the data directories and fallback-archives, as those bits of UI are basic, but it's more complicated for content files as that uses a nmodel/view approach and has a lot more moving parts.
Thankfully, I'd already implemented that when dealing with builtin.omwscripts, so it just needed wiring up.
One more thing of note is that I made the SettingValue struct storable as a QVariant so it could be attached to the UI widgets as userdata, and then I could just grab the original representation and use it instead of needing any complicated mapping from display value to on-disk value.
10 months ago
|
|
|
void setNonUserContent(const QStringList& fileList);
|
|
|
|
void setContentList(const QStringList& fileList);
|
|
|
|
ContentFileList checkedItems() const;
|
|
|
|
void uncheckAll();
|
|
|
|
|
|
|
|
void refreshModel();
|
|
|
|
|
|
|
|
/// Checks all plug-ins for load order errors and updates mPluginsWithLoadOrderError with plug-ins with issues
|
|
|
|
void checkForLoadOrderErrors();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void addFile(EsmFile* file);
|
|
|
|
|
|
|
|
/// Checks a specific plug-in for load order errors
|
|
|
|
/// \return all errors found for specific plug-in
|
|
|
|
QList<LoadOrderError> checkForLoadOrderErrors(const EsmFile* file, int row) const;
|
|
|
|
|
|
|
|
/// \return true if plug-in has a Load Order error
|
|
|
|
bool isLoadOrderError(const EsmFile* file) const;
|
|
|
|
|
|
|
|
QString toolTip(const EsmFile* file) const;
|
|
|
|
|
|
|
|
const EsmFile* mGameFile;
|
|
|
|
ContentFileList mFiles;
|
|
|
|
QStringList mNonUserContent;
|
|
|
|
std::set<const EsmFile*> mCheckedFiles;
|
|
|
|
QHash<QString, bool> mNewFiles;
|
|
|
|
QSet<QString> mPluginsWithLoadOrderError;
|
|
|
|
QString mEncoding;
|
|
|
|
QIcon mWarningIcon;
|
|
|
|
QIcon mErrorIcon;
|
|
|
|
bool mShowOMWScripts;
|
|
|
|
|
|
|
|
QString mErrorToolTips[ContentSelectorModel::LoadOrderError::ErrorCode_LoadOrder]
|
|
|
|
= { tr("Unable to find dependent file: %1"), tr("Dependent file needs to be active: %1"),
|
|
|
|
tr("This file needs to load after %1") };
|
|
|
|
|
|
|
|
public:
|
|
|
|
QString mMimeType;
|
|
|
|
QStringList mMimeTypes;
|
|
|
|
int mColumnCount;
|
|
|
|
Qt::DropActions mDropActions;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // CONTENTMODEL_HPP
|