-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstringlistmodel.cpp
49 lines (35 loc) · 1.09 KB
/
stringlistmodel.cpp
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
#include "stringlistmodel.h"
int StringListModel::rowCount(const QModelIndex &parent) const {
return archivedFileNames.count();
}
QVariant StringListModel::data(const QModelIndex &index, int role) const {
if (!index.isValid()) {
return QVariant();
}
if (index.row() >= archivedFileNames.size()) {
return QVariant();
}
if (role == Qt::DisplayRole) {
return archivedFileNames.at(index.row());
}
else
return QVariant();
}
QVariant StringListModel::headerData(int section, Qt::Orientation orientation, int role) const {
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
return QVariant(archivePath);
} else
return QVariant();
}
void StringListModel::setAcrhivedFileNames(const QStringList &strings) {
archivedFileNames = strings;
}
void StringListModel::setArchivePath(const QString &path) {
archivePath = path;
}
QString StringListModel::getArchivePath() const {
return archivePath;
}
void StringListModel::removeFileName(const QString &string) {
archivedFileNames.removeOne(string);
}