File: treeitem.cpp

package info (click to toggle)
listaller 0.5.9-4
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,096 kB
  • ctags: 1,611
  • sloc: xml: 11,195; ansic: 2,298; sh: 1,648; perl: 1,452; cpp: 1,289; java: 157; makefile: 134; cs: 48; python: 24
file content (101 lines) | stat: -rw-r--r-- 2,098 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
* Copyright (C) 2010 Matthias Klumpp
*
* Authors:
*  Matthias Klumpp
*
* This unit is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, version 3.
*
* This unit is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License v3
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#include "treeitem.h"
#include <iostream>

TreeItem::TreeItem(const QString name, const QString dir, TreeItem *parent)
{
    parentItem = parent;
    d_soname = name;
    d_dir = dir;
    //Paint all items light blue...
    entryColor = QColor(152,245,255);
    //..except they're essential system libs
    if (name.indexOf(QRegExp("libc.*")) > -1)
        entryColor = QColor(209,238,238);
    if (name.indexOf(QRegExp("ld-linux*")) > -1)
        entryColor = QColor(188,210,238);
}

TreeItem::~TreeItem()
{
    qDeleteAll(childItems);
}

void TreeItem::appendChild(TreeItem *item)
{
    item->setParent(this);
    childItems.append(item);
}

TreeItem *TreeItem::child(int row)
{
    return childItems.value(row);
}

void TreeItem::setParent(TreeItem *item)
{
    parentItem = item;
}

int TreeItem::childCount() const
{
    return childItems.count();
}

int TreeItem::columnCount() const
{
    return 2;
}

QColor TreeItem::getColor() const
{
    return entryColor;
}

QVariant TreeItem::data(int column) const
{
    switch (column)
    {
    case 0: return d_soname;
    case 1: return d_dir;
    default: return "<?>";
    }
}

QString TreeItem::getData_Dir() const
{
    return d_dir;
}

QString TreeItem::getData_SOName() const
{
    return d_soname;
}

TreeItem *TreeItem::parent()
{
    return parentItem;
}

int TreeItem::row() const
{
    if (parentItem)
        return parentItem->childItems.indexOf(const_cast<TreeItem*>(this));
    return 0;
}