-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableModel.cpp
More file actions
54 lines (44 loc) · 1.21 KB
/
Copy pathTableModel.cpp
File metadata and controls
54 lines (44 loc) · 1.21 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
#include "TableModel.h"
TableModel::TableModel(BlocElementBase *bloc, QObject *parent) :
QAbstractTableModel(parent)
{
listeElement=bloc;
}
Qt::ItemFlags TableModel::flags(const QModelIndex &index) const
{
Q_UNUSED(index);
return Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled;
}
int TableModel::rowCount(const QModelIndex &parent) const
{
return parent.isValid() ? 0 : listeElement->getNbElement();
}
void TableModel::addElement(elementBase *element)
{
const int count = listeElement->getNbElement();
beginInsertRows(QModelIndex(), count, count);
listeElement->addElement(element);
endInsertRows();
}
void TableModel::removeElement(int i)
{
beginRemoveRows(QModelIndex(),i,i);
listeElement->removeElement(i);
endRemoveRows();
}
QVariant TableModel::headerData(int section, Qt::Orientation orientation, int role) const
{
if (orientation == Qt::Horizontal && role == Qt::DisplayRole)
{
return headers.at(section);
}
return QAbstractTableModel::headerData(section, orientation, role);
}
void TableModel::initHeaders(const QStringList l)
{
headers=l;
}
elementBase *TableModel::getElement(int row)
{
return listeElement->getElement(row);
}