2013-09-07 20:57:40 +00:00
|
|
|
#ifndef CONTENTMODEL_HPP
|
|
|
|
#define CONTENTMODEL_HPP
|
|
|
|
|
2014-12-31 06:19:54 +00:00
|
|
|
#include "loadordererror.hpp"
|
2013-09-07 20:57:40 +00:00
|
|
|
#include <QAbstractTableModel>
|
2015-01-17 05:11:03 +00:00
|
|
|
#include <QIcon>
|
2014-12-31 06:19:54 +00:00
|
|
|
#include <QSet>
|
|
|
|
#include <QStringList>
|
|
|
|
|
2013-09-22 04:06:29 +00:00
|
|
|
namespace ContentSelectorModel
|
2013-09-07 20:57:40 +00:00
|
|
|
{
|
|
|
|
class EsmFile;
|
|
|
|
|
|
|
|
typedef QList<EsmFile*> ContentFileList;
|
|
|
|
|
2013-09-22 04:06:29 +00:00
|
|
|
enum ContentType
|
|
|
|
{
|
|
|
|
ContentType_GameFile,
|
|
|
|
ContentType_Addon
|
|
|
|
};
|
|
|
|
|
2013-09-07 20:57:40 +00:00
|
|
|
class ContentModel : public QAbstractTableModel
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-10-29 18:09:47 +00:00
|
|
|
explicit ContentModel(QObject* parent, QIcon warningIcon, bool showOMWScripts);
|
2014-12-23 19:44:25 +00:00
|
|
|
~ContentModel();
|
2013-09-07 20:57:40 +00:00
|
|
|
|
2013-10-07 03:10:38 +00:00
|
|
|
void setEncoding(const QString& encoding);
|
2013-09-07 20:57:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
|
|
|
int columnCount(const QModelIndex& parent = QModelIndex()) const override;
|
2013-09-07 20:57:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
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;
|
2013-09-07 20:57:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
bool insertRows(int position, int rows, const QModelIndex& index = QModelIndex()) override;
|
|
|
|
bool removeRows(int position, int rows, const QModelIndex& index = QModelIndex()) override;
|
2013-09-07 20:57:40 +00:00
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
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;
|
2013-09-07 20:57:40 +00:00
|
|
|
|
2020-04-26 13:31:39 +00:00
|
|
|
void addFiles(const QString& path, bool newfiles);
|
2021-11-07 13:15:30 +00:00
|
|
|
void sortFiles();
|
2020-04-26 13:31:39 +00:00
|
|
|
bool containsDataFiles(const QString& path);
|
2015-06-16 02:48:45 +00:00
|
|
|
void clearFiles();
|
2013-09-07 20:57:40 +00:00
|
|
|
|
2013-09-22 04:06:29 +00:00
|
|
|
QModelIndex indexFromItem(const EsmFile* item) const;
|
2013-09-23 11:51:49 +00:00
|
|
|
const EsmFile* item(const QString& name) const;
|
2018-09-28 22:54:00 +00:00
|
|
|
const EsmFile* item(int row) const;
|
|
|
|
EsmFile* item(int row);
|
2015-02-24 07:06:06 +00:00
|
|
|
QStringList gameFiles() const;
|
2013-09-07 20:57:40 +00:00
|
|
|
|
2021-06-25 19:52:02 +00:00
|
|
|
bool isEnabled(const QModelIndex& index) const;
|
2014-06-10 17:23:42 +00:00
|
|
|
bool isChecked(const QString& filepath) const;
|
|
|
|
bool setCheckState(const QString& filepath, bool isChecked);
|
2020-04-26 13:31:39 +00:00
|
|
|
bool isNew(const QString& filepath) const;
|
|
|
|
void setNew(const QString& filepath, bool isChecked);
|
2015-02-23 06:41:41 +00:00
|
|
|
void setContentList(const QStringList& fileList);
|
2013-09-07 20:57:40 +00:00
|
|
|
ContentFileList checkedItems() const;
|
|
|
|
void uncheckAll();
|
2013-09-18 07:36:23 +00:00
|
|
|
|
2013-11-03 20:02:41 +00:00
|
|
|
void refreshModel();
|
|
|
|
|
2015-01-17 05:11:03 +00:00
|
|
|
/// Checks all plug-ins for load order errors and updates mPluginsWithLoadOrderError with plug-ins with issues
|
|
|
|
void checkForLoadOrderErrors();
|
|
|
|
|
2013-09-07 20:57:40 +00:00
|
|
|
private:
|
|
|
|
void addFile(EsmFile* file);
|
2013-09-23 11:51:49 +00:00
|
|
|
|
2015-01-07 22:18:42 +00:00
|
|
|
/// 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;
|
2013-09-07 20:57:40 +00:00
|
|
|
|
|
|
|
ContentFileList mFiles;
|
2020-04-26 13:31:39 +00:00
|
|
|
QStringList mArchives;
|
2013-09-07 20:57:40 +00:00
|
|
|
QHash<QString, Qt::CheckState> mCheckStates;
|
2020-04-26 13:31:39 +00:00
|
|
|
QHash<QString, bool> mNewFiles;
|
2015-01-07 22:18:42 +00:00
|
|
|
QSet<QString> mPluginsWithLoadOrderError;
|
2014-07-17 18:40:40 +00:00
|
|
|
QString mEncoding;
|
2015-01-17 05:11:03 +00:00
|
|
|
QIcon mWarningIcon;
|
2021-10-29 18:09:47 +00:00
|
|
|
bool mShowOMWScripts;
|
2013-09-07 20:57:40 +00:00
|
|
|
|
2013-09-19 11:53:09 +00:00
|
|
|
public:
|
|
|
|
QString mMimeType;
|
|
|
|
QStringList mMimeTypes;
|
|
|
|
int mColumnCount;
|
|
|
|
Qt::DropActions mDropActions;
|
2013-09-07 20:57:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif // CONTENTMODEL_HPP
|