summaryrefslogtreecommitdiff
path: root/browse-item.c
blob: 79126629e09c5c8faf1a5694c112714d56bf6d78 (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
58
59
60
61
62
63
64
65
66
67
68
69
/*
 * browse-item.c
 */

#include "browse-item.h"

#include <string>


using namespace std;

/* --- cBrowseItem ---------------------------------------------------------- */

cBrowseItem::cBrowseItem(cBrowseItem *_main_item, const cTrackInfo *_track,
        int _column, eItemType _type)
:cOsdItem()
{
        main_item = _main_item;
        if (main_item)
                main_item->increase_items();

        track = _track;
        column = _column;
        type = _type;

        items = 0;
}


void cBrowseItem::increase_items(void)
{
        ++items;

        if (main_item)
                main_item->increase_items();
}


void cBrowseItem::delete_items(int del_items)
{
        items -= del_items;

        if (main_item)
                main_item->delete_items(del_items);

        if (items < 0)
                items = 0;
}


void cBrowseItem::toggle_node(void)
{
    string txt = Text();

        if (type == itemNodeOpen) {
                type = itemNodeClose;
                string::size_type f = txt.find_first_of("-");
                if (f != string::npos)
                        txt.replace(f, 1, "+");
    }
        else if (type == itemNodeClose) {
                type = itemNodeOpen;
                string::size_type f = txt.find_first_of("+");
                if (f != string::npos)
                        txt.replace(f, 1, "-");
    }

    SetText(txt.c_str());
}