1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 09:23:53 +00:00
openmw/components/contentselector/model/contentmodel.hpp
fredzio b88d32ff5b Add 3 tabs in the "Data Files" page
1 with the data directories
2 with the BSA archives
3 with the content selector

When user select a directory to be added, first we walk the directory
hierarchy to make a list of all potential data= entries. If we find
none, the selected directory is added.

If more than one data directory is found, user is presented with a
directory list to check which one(s) are to be added.

Directories containing one or more content file are marked with an icon.

data= and fallback-archive= lines are handled like content= lines:
- they are part of the profile in launcher.cfg, prefixed by the profile
name
- they are updated in openmw.cfg when profile is selected / created

Directories can be moved in the list by drag and drop or by buttons.
Insertion is possible anywhere in the list.
Global data path and data local are shown but are greyed out, as they
are always included.

No attempt is made to ensure that the user choice are valid
(dependencies, overwrite of content).

After a profile is loaded, any added content is highlighted in green.
2022-04-23 09:54:45 +02:00

101 lines
3.4 KiB
C++

#ifndef CONTENTMODEL_HPP
#define CONTENTMODEL_HPP
#include <QAbstractTableModel>
#include <QStringList>
#include <QSet>
#include <QIcon>
#include "loadordererror.hpp"
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, 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;
bool isEnabled (const QModelIndex& index) const;
bool isChecked(const QString &filepath) const;
bool setCheckState(const QString &filepath, bool isChecked);
bool isNew(const QString &filepath) const;
void setNew(const QString &filepath, bool isChecked);
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;
ContentFileList mFiles;
QStringList mArchives;
QHash<QString, Qt::CheckState> mCheckStates;
QHash<QString, bool> mNewFiles;
QSet<QString> mPluginsWithLoadOrderError;
QString mEncoding;
QIcon mWarningIcon;
bool mShowOMWScripts;
public:
QString mMimeType;
QStringList mMimeTypes;
int mColumnCount;
Qt::DropActions mDropActions;
};
}
#endif // CONTENTMODEL_HPP