-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPortListModel.cpp
More file actions
36 lines (29 loc) · 843 Bytes
/
PortListModel.cpp
File metadata and controls
36 lines (29 loc) · 843 Bytes
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
#include "factories/ToolTipFactory.h"
#include "model/Port.h"
#include "PortListModel.h"
using namespace q2d::util;
PortListModel::PortListModel(QObject* parent) :
QAbstractListModel(parent) {}
PortListModel::~PortListModel() {
delete m_list;
}
int
PortListModel::rowCount(const QModelIndex &parent) const {
Q_UNUSED(parent);
return m_list->count();
}
QVariant
PortListModel::data(const QModelIndex &index, int role) const {
if (index.row() < 0 ||
index.row() >= m_list->count()) {
return QVariant();
}
switch (role) {
case Qt::DisplayRole :
return m_list->value(index.row())->relatedEntry()->localId();
case Qt::ToolTipRole:
return factories::ToolTipFactory::toHtmlTable(m_list->value(index.row())->propertyMap());
default:
return QVariant();
}
}