-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodmodel.cpp
More file actions
110 lines (81 loc) · 2.2 KB
/
modmodel.cpp
File metadata and controls
110 lines (81 loc) · 2.2 KB
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
#include "modmodel.h"
ModModel::ModModel(const QString &path)
{
_mod_manager = new ModManager(path);
_mod_manager->update();
}
ModModel::~ModModel()
{
delete _mod_manager;
}
void ModModel::setPath(const QString &path)
{
beginResetModel();
_mod_manager->setPath(path);
_mod_manager->update();
endResetModel();
}
bool ModModel::append(const QString &path)
{
if (!_mod_manager->install(path))
return false;
insertRow(0);
return true;
}
bool ModModel::remove(const QModelIndex &index)
{
if (!_mod_manager->remove(index.row()))
return false;
removeRow(index.row());
return true;
}
QPixmap ModModel::logo(const QModelIndex &index)
{
return _mod_manager->logo(index.row());
}
int ModModel::rowCount(const QModelIndex &) const
{
return _mod_manager->count();
}
int ModModel::columnCount(const QModelIndex &) const
{
return 8;
}
QVariant ModModel::data(const QModelIndex &index, int role) const
{
if (role == Qt::DisplayRole)
{
switch(index.column())
{
case ModInfo::Name :
return _mod_manager->at(index.row(), "name");
case ModInfo::Description :
return _mod_manager->at(index.row(), "description");
case ModInfo::Version :
return _mod_manager->at(index.row(), "version");
case ModInfo::McVersion :
return _mod_manager->at(index.row(), "mcversion");
case ModInfo::Url :
return _mod_manager->at(index.row(), "url");
case ModInfo::AuthorList :
return _mod_manager->at(index.row(), "authorList");
case ModInfo::Credits :
return _mod_manager->at(index.row(), "credits");
case ModInfo::Path :
return _mod_manager->at(index.row(), "path");
}
}
return QVariant();
}
bool ModModel::insertRow(int row, const QModelIndex &parent)
{
beginInsertRows(parent, row, row);
endInsertRows();
return true;
}
bool ModModel::removeRow(int row, const QModelIndex &parent)
{
beginRemoveRows(parent, row, row);
endRemoveRows();
return true;
}