-
Notifications
You must be signed in to change notification settings - Fork 0
/
intelmodel.cpp
53 lines (44 loc) · 1.39 KB
/
intelmodel.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
#include "intelmodel.h"
#include "intel.h"
#include <QDebug>
#include <QLabel>
#include <QPixmap>
IntelModel::IntelModel(QObject *parent)
: QAbstractListModel(parent)
{
//intel_ = intel;
}
int IntelModel::rowCount(const QModelIndex &parent) const
{
//if (!parent.isValid())
//return 0;
// FIXME: Implement me!
return intel_.size();
}
QVariant IntelModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid())
return QVariant();
if (index.row() >= intel_.size()) return QVariant();
if (role == Qt::DisplayRole) {
// Only returns something for the roles you support (DisplayRole is a minimum)
// Here we assume that the "Employee" class has a "lastName" method but of course any string can be returned
return QVariant(intel_.at(index.row())->getIntelTextLayout());
}
if(role == Qt::DecorationRole){
QPixmap pixmap = intel_.at(index.row())->getPortraitPixMap();
return pixmap;
}
else {
return QVariant();
}
// FIXME: Implement me!
//return QVariant();
}
void IntelModel::addIntel(Intel* intel)
{
beginInsertRows( QModelIndex(), 0, 0 ); //notify views and proxy models that a line will be inserted
//m_data.prepend( somedata ); // do the modification to the model data
intel_.push_back(intel);
endInsertRows(); //finish insertion, notify views/models
}