blob: b39a47c6f033d4efe04747177dfc9b5a33582a1a (
plain)
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
|
#include "RosterItem.h"
#include <qdebug.h>
namespace Swift {
RosterItem::RosterItem(RosterItem* parent) : QObject() {
parent_ = parent;
}
RosterItem::~RosterItem() {
qDeleteAll(children_);
}
RosterItem* RosterItem::getParentItem() {
return parent_;
}
void RosterItem::addChild(RosterItem* child) {
printf("Boing\n");
children_.append(child);
connect(child, SIGNAL(changed()), this, SIGNAL(changed()));
emit changed();
}
int RosterItem::rowCount() {
qDebug() << "Returning size of " << children_.size() << " for item " << name_;
return children_.size();
}
int RosterItem::rowOf(RosterItem* item) {
return children_.indexOf(item);;
}
int RosterItem::row() {
return parent_ ? parent_->rowOf(this) : 0;
}
RosterItem* RosterItem::getItem(int row) {
qDebug() << "Returning row " << row << " from item " << name_;
return children_[row];
}
QVariant RosterItem::data(int role) {
if (role != Qt::DisplayRole) {
return QVariant();
}
qDebug() << "Returning name " << name_ << " for role " << role;
return name_;
}
void RosterItem::setName(QString name) {
name_ = name;
qDebug() << "Name changed to " << name;
changed();
}
}
|