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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
|
#include "AuxConflictModel.h"
#include <utility>
namespace BSPluginInfo
{
AuxConflictModel::AuxConflictModel(const TESData::PluginList* pluginList,
QObject* parent)
: QAbstractItemModel(parent), m_PluginList{pluginList}
{}
void AuxConflictModel::appendItem(const QString& name,
QList<TESData::TESFileHandle>&& handles)
{
m_Items.append({name, std::move(handles)});
}
QModelIndex AuxConflictModel::index(int row, int column,
const QModelIndex& parent) const
{
if (parent.isValid()) {
return QModelIndex();
}
return createIndex(row, column, row);
}
QModelIndex AuxConflictModel::parent([[maybe_unused]] const QModelIndex& index) const
{
return QModelIndex();
}
int AuxConflictModel::rowCount(const QModelIndex& parent) const
{
return !parent.isValid() ? m_Items.length() : 0;
}
int AuxWinnerModel::columnCount([[maybe_unused]] const QModelIndex& parent) const
{
return COL_COUNT;
}
int AuxLoserModel::columnCount([[maybe_unused]] const QModelIndex& parent) const
{
return COL_COUNT;
}
int AuxNonConflictModel::columnCount([[maybe_unused]] const QModelIndex& parent) const
{
return COL_COUNT;
}
QVariant AuxWinnerModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole) {
switch (index.column()) {
case COL_NAME:
return m_Items[index.row()].name;
case COL_LOSERS: {
QStringList names;
const auto& handles = m_Items[index.row()].sortedHandles;
for (int i = 0, count = handles.length() - 1; i < count; ++i) {
const auto handle = handles[i];
const auto entry = m_PluginList->findEntryByHandle(handle);
if (entry) {
names.append(QString::fromStdString(entry->name()));
}
}
return names.join(QStringLiteral(", "));
}
}
}
return QVariant();
}
QVariant AuxLoserModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole) {
switch (index.column()) {
case COL_NAME:
return m_Items[index.row()].name;
case COL_WINNER: {
const auto& handles = m_Items[index.row()].sortedHandles;
const auto entry = m_PluginList->findEntryByHandle(handles.last());
return entry ? QString::fromStdString(entry->name()) : QString();
}
}
}
return QVariant();
}
QVariant AuxNonConflictModel::data(const QModelIndex& index, int role) const
{
if (role == Qt::DisplayRole) {
switch (index.column()) {
case COL_NAME:
return m_Items[index.row()].name;
}
}
return QVariant();
}
QVariant AuxWinnerModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation != Qt::Horizontal || role != Qt::DisplayRole) {
return QVariant();
}
switch (section) {
case COL_NAME:
return tr("File");
case COL_LOSERS:
return tr("Overwritten Mods");
default:
return QVariant();
}
}
QVariant AuxLoserModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation != Qt::Horizontal || role != Qt::DisplayRole) {
return QVariant();
}
switch (section) {
case COL_NAME:
return tr("File");
case COL_WINNER:
return tr("Providing Mod");
default:
return QVariant();
}
}
QVariant AuxNonConflictModel::headerData(int section, Qt::Orientation orientation,
int role) const
{
if (orientation != Qt::Horizontal || role != Qt::DisplayRole) {
return QVariant();
}
switch (section) {
case COL_NAME:
return tr("File");
default:
return QVariant();
}
}
} // namespace BSPluginInfo
|