OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
contentmodel.hpp
Go to the documentation of this file.
1 #ifndef CONTENTMODEL_HPP
2 #define CONTENTMODEL_HPP
3 
4 #include <QAbstractTableModel>
5 #include <QStringList>
6 #include <QSet>
7 #include <QIcon>
8 #include "loadordererror.hpp"
9 
10 namespace ContentSelectorModel
11 {
12  class EsmFile;
13 
14  typedef QList<EsmFile *> ContentFileList;
15 
17  {
20  };
21 
23  {
24  Q_OBJECT
25  public:
26  explicit ContentModel(QObject *parent, QIcon warningIcon);
27  ~ContentModel();
28 
29  void setEncoding(const QString &encoding);
30 
31  int rowCount(const QModelIndex &parent = QModelIndex()) const;
32  int columnCount(const QModelIndex &parent = QModelIndex()) const;
33 
34  QVariant data(const QModelIndex &index, int role) const;
35  Qt::ItemFlags flags(const QModelIndex &index) const;
36  bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
37 
38  bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
39  bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
40 
41  Qt::DropActions supportedDropActions() const;
42  QStringList mimeTypes() const;
43  QMimeData *mimeData(const QModelIndexList &indexes) const;
44  bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent);
45 
46  void addFiles(const QString &path);
47  void clearFiles();
48 
49  QModelIndex indexFromItem(const EsmFile *item) const;
50  const EsmFile *item(const QString &name) const;
51  QStringList gameFiles() const;
52 
53  bool isEnabled (QModelIndex index) const;
54  bool isChecked(const QString &filepath) const;
55  bool setCheckState(const QString &filepath, bool isChecked);
56  void setContentList(const QStringList &fileList);
58  void uncheckAll();
59 
60  void refreshModel();
61 
64 
65  private:
66 
67  void addFile(EsmFile *file);
68  const EsmFile *item(int row) const;
69  EsmFile *item(int row);
70 
71  void sortFiles();
72 
75  QList<LoadOrderError> checkForLoadOrderErrors(const EsmFile *file, int row) const;
76 
78  bool isLoadOrderError(const EsmFile *file) const;
79 
80  QString toolTip(const EsmFile *file) const;
81 
83  QHash<QString, Qt::CheckState> mCheckStates;
85  QString mEncoding;
86  QIcon mWarningIcon;
87 
88  public:
89 
90  QString mMimeType;
91  QStringList mMimeTypes;
93  Qt::DropActions mDropActions;
94  };
95 }
96 #endif // CONTENTMODEL_HPP
Definition: contentmodel.hpp:19
QStringList mMimeTypes
Definition: contentmodel.hpp:91
void checkForLoadOrderErrors()
Checks all plug-ins for load order errors and updates mPluginsWithLoadOrderError with plug-ins with i...
Definition: contentmodel.cpp:575
bool isLoadOrderError(const EsmFile *file) const
Definition: contentmodel.cpp:545
QHash< QString, Qt::CheckState > mCheckStates
Definition: contentmodel.hpp:83
int rowCount(const QModelIndex &parent=QModelIndex()) const
Definition: contentmodel.cpp:43
ContentModel(QObject *parent, QIcon warningIcon)
Definition: contentmodel.cpp:12
QStringList gameFiles() const
Definition: contentmodel.cpp:482
ContentFileList mFiles
Definition: contentmodel.hpp:82
void sortFiles()
Definition: contentmodel.cpp:495
bool removeRows(int position, int rows, const QModelIndex &index=QModelIndex())
Definition: contentmodel.cpp:318
QSet< QString > mPluginsWithLoadOrderError
Definition: contentmodel.hpp:84
QMimeData * mimeData(const QModelIndexList &indexes) const
Definition: contentmodel.cpp:345
QString mMimeType
Definition: contentmodel.hpp:90
QString toolTip(const EsmFile *file) const
Definition: contentmodel.cpp:618
Definition: esmfile.hpp:13
QIcon mWarningIcon
Definition: contentmodel.hpp:86
ContentFileList checkedItems() const
Definition: contentmodel.cpp:704
bool setCheckState(const QString &filepath, bool isChecked)
Definition: contentmodel.cpp:645
Definition: contentmodel.hpp:18
QStringList mimeTypes() const
Definition: contentmodel.cpp:340
~ContentModel()
Definition: contentmodel.cpp:24
Qt::ItemFlags flags(const QModelIndex &index) const
Definition: contentmodel.cpp:92
void addFile(EsmFile *file)
Definition: contentmodel.cpp:409
int mColumnCount
Definition: contentmodel.hpp:92
QVariant data(const QModelIndex &index, int role) const
Definition: contentmodel.cpp:145
void uncheckAll()
Definition: contentmodel.cpp:718
QString mEncoding
Definition: contentmodel.hpp:85
void addFiles(const QString &path)
Definition: contentmodel.cpp:420
void setContentList(const QStringList &fileList)
Definition: contentmodel.cpp:550
const EsmFile * item(const QString &name) const
Definition: contentmodel.cpp:66
Qt::DropActions mDropActions
Definition: contentmodel.hpp:93
bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole)
Definition: contentmodel.cpp:224
ContentType
Definition: contentmodel.hpp:16
void setEncoding(const QString &encoding)
Definition: contentmodel.cpp:30
QList< EsmFile * > ContentFileList
Definition: contentmodel.hpp:12
Definition: contentmodel.hpp:22
bool isChecked(const QString &filepath) const
Definition: contentmodel.cpp:532
void clearFiles()
Definition: contentmodel.cpp:475
bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent)
Definition: contentmodel.cpp:363
bool insertRows(int position, int rows, const QModelIndex &index=QModelIndex())
Definition: contentmodel.cpp:303
Qt::DropActions supportedDropActions() const
Definition: contentmodel.cpp:335
int columnCount(const QModelIndex &parent=QModelIndex()) const
Definition: contentmodel.cpp:35
void refreshModel()
Definition: contentmodel.cpp:640
QModelIndex indexFromItem(const EsmFile *item) const
Definition: contentmodel.cpp:81
bool isEnabled(QModelIndex index) const
Definition: contentmodel.cpp:540
const char * name
Definition: crashcatcher.cpp:59