1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#include "shared/fileentry.h"
class PluginContainer;
class ConflictItem
{
public:
ConflictItem(QString before, QString relativeName, QString after,
MOShared::FileIndex index, QString fileName, bool hasAltOrigins,
QString altOrigin, bool archive);
const QString& before() const;
const QString& relativeName() const;
const QString& after() const;
const QString& fileName() const;
const QString& altOrigin() const;
bool hasAlts() const;
bool isArchive() const;
MOShared::FileIndex fileIndex() const;
bool canHide() const;
bool canUnhide() const;
bool canRun() const;
bool canOpen() const;
bool canPreview(PluginContainer& pluginContainer) const;
bool canExplore() const;
private:
QString m_before;
QString m_relativeName;
QString m_after;
MOShared::FileIndex m_index;
QString m_fileName;
bool m_hasAltOrigins;
QString m_altOrigin;
bool m_isArchive;
};
class ConflictListModel : public QAbstractItemModel
{
Q_OBJECT;
public:
struct Column
{
QString caption;
const QString& (ConflictItem::*getText)() const;
};
ConflictListModel(QTreeView* tree, std::vector<Column> columns);
void clear();
void reserve(std::size_t s);
QModelIndex index(int row, int col, const QModelIndex& = {}) const override;
QModelIndex parent(const QModelIndex&) const override;
int rowCount(const QModelIndex& parent = {}) const override;
int columnCount(const QModelIndex& = {}) const override;
QVariant data(const QModelIndex& index, int role) const override;
QVariant headerData(int col, Qt::Orientation, int role) const;
void sort(int colIndex, Qt::SortOrder order = Qt::AscendingOrder);
void add(ConflictItem item);
void finished();
const ConflictItem* getItem(std::size_t row) const;
private:
QTreeView* m_tree;
std::vector<Column> m_columns;
std::vector<ConflictItem> m_items;
int m_sortColumn;
Qt::SortOrder m_sortOrder;
const ConflictItem* itemFromIndex(const QModelIndex& index) const;
QModelIndex indexFromItem(const ConflictItem* item, int col);
void doSort();
};
class OverwriteConflictListModel : public ConflictListModel
{
Q_OBJECT;
public:
OverwriteConflictListModel(QTreeView* tree);
};
class OverwrittenConflictListModel : public ConflictListModel
{
Q_OBJECT;
public:
OverwrittenConflictListModel(QTreeView* tree);
};
class NoConflictListModel : public ConflictListModel
{
Q_OBJECT;
public:
NoConflictListModel(QTreeView* tree);
};
class AdvancedConflictListModel : public ConflictListModel
{
Q_OBJECT;
public:
AdvancedConflictListModel(QTreeView* tree);
};
|