-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCvor.cpp
50 lines (35 loc) · 1.11 KB
/
Cvor.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
#include "Cvor.h"
CvorModel::CvorModel(QObject *parent) : QAbstractTableModel(parent) {}
void CvorModel::populateData(QList<Cvor> _cvorovi){
cvorovi.clear();
cvorovi = _cvorovi;
}
int CvorModel::rowCount(const QModelIndex &parent) const {
Q_UNUSED(parent);
return cvorovi.length();
}
int CvorModel::columnCount(const QModelIndex &parent) const {
Q_UNUSED(parent);
return 1;
}
QVariant CvorModel::data(const QModelIndex &index, int role) const{
if(!index.isValid() || role != Qt::DisplayRole)
return QVariant();
if(index.column() == 0)
return cvorovi[index.row()].MAC_Adresa;
return QVariant();
}
QVariant CvorModel::headerData(int section, Qt::Orientation orientation, int role) const {
if(role != Qt::DisplayRole || orientation != Qt::Horizontal)
return QVariant();
if(section == 0)
return QString("Čvor");
return QVariant();
}
bool CvorModel::dodajCvor(Cvor cvor, const QModelIndex &parent)
{
beginInsertRows(parent, cvorovi.count(), cvorovi.count());
cvorovi.append(cvor);
endInsertRows();
return true;
}