summaryrefslogtreecommitdiffstats
path: root/src/SessionTreeItem.cpp
blob: ed7ead79edb609774e113c4695b7505a0f64b23e (plain) (blame)
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
58
59
60
61
62
63
64
65
/*
 * Copyright (c) 2010,2011 - RZ Uni Freiburg
 * Copyright (c) 2010,2011 - OpenSLX Project
 *
 * This program/file is free software distributed under the GPL version 2.
 * See http://gpl.openslx.org/
 *
 * If you have any feedback please consult http://feedback.openslx.org/ and
 * send your feedback to feedback@openslx.org
 *
 * General information about OpenSLX - libChooser can be found under
 * http://openslx.org
 *
 */

#include "SessionTreeItem.h"

SessionTreeItem::SessionTreeItem(const Session* session,
                                 SessionTreeItem *parent)
    : parent_(parent), session_(session) {
}

SessionTreeItem::SessionTreeItem(const QString& text, SessionTreeItem *parent)
    : parent_(parent), session_(NULL), text_(text) {
}

SessionTreeItem::~SessionTreeItem() {
    qDeleteAll(children_);
}

void SessionTreeItem::appendChild(SessionTreeItem *item) {
    children_.append(item);
}

SessionTreeItem *SessionTreeItem::child(int row) {
    return children_.value(row);
}

int SessionTreeItem::childCount() const {
    return children_.count();
}

int SessionTreeItem::columnCount() const {
    return 1;
}

SessionTreeItem *SessionTreeItem::parent() {
    return parent_;
}

int SessionTreeItem::row() const {
    if (parent_) {
        return parent_->children_.indexOf(const_cast<SessionTreeItem*>(this));
    }

    return 0;
}

const Session* SessionTreeItem::session() const {
    return session_;
}

const QString SessionTreeItem::text() const {
    return text_;
}