-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilestablemodel.cpp
72 lines (65 loc) · 1.71 KB
/
filestablemodel.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "filestablemodel.h"
FilesTableModel::FilesTableModel(QObject* parent):
QAbstractTableModel(parent)
{
}
QVariant FilesTableModel::data(const QModelIndex &index, int role) const
{
if(role == Qt::DisplayRole || role == Qt::EditRole)
{
switch (index.column())
{
case 0:
return QString::fromStdWString(filesList.at(index.row()).getName());
break;
case 1:
return SystemTimeToQDateTime(filesList.at(index.row()).getDate()).toString();
break;
case 2:
return filesList.at(index.row()).getSize();
break;
case 3:
return QString::fromStdWString(filesList.at(index.row()).getPath());
break;
default:
break;
}
}
return QVariant();
}
int FilesTableModel::rowCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return filesList.size();
}
int FilesTableModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
return 4;
}
QVariant FilesTableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if(role == Qt::DisplayRole)
{
if(orientation == Qt::Horizontal)
{
switch (section) {
case 0:
return QString("Name");
break;
case 1:
return QString("Date");
break;
case 2:
return QString("Size");
break;
case 3:
return QString("Path");
break;
default:
break;
}
}
}
return QVariant();
}