]> Shamusworld >> Repos - architektonas/blob - src/widgets/listviewitem.cpp
Removed useless *Listener class and references.
[architektonas] / src / widgets / listviewitem.cpp
1 // listviewitem.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  08/03/2010  Added this text. :-)
15 //
16
17 #include "listviewitem.h"
18
19 #include <qpixmap.h>
20
21 /**
22  * Constructor for root items.
23  */
24 QG_ListViewItem::QG_ListViewItem(QListWidget * par, const QString & label,
25         bool open, int id): QListWidgetItem(par)
26 {
27         par = 0;
28         this->label = label;
29         this->id = id;
30
31         setIcon(QIcon((open ? ":/res/folderopen.xpm" : ":/res/folderclosed.xpm")));
32         setOpen(open);
33 }
34
35 /**
36  * Constructor for list view items with a folder icon.
37  */
38 QG_ListViewItem::QG_ListViewItem(QG_ListViewItem * par, const QString & label,
39         bool open, int id): QListWidgetItem((QListWidget *)par)
40 {
41         this->par = par;
42         this->label = label;
43         this->id = id;
44
45 //      setPixmap(0, QPixmap((open ? folderopen_xpm : folderclosed_xpm)));
46 //redundant:    setIcon(QIcon((open ? folderopen_xpm : folderclosed_xpm)));
47         setOpen(open);
48 }
49
50 /**
51  * Opens or closes the item.
52  */
53 void QG_ListViewItem::setOpen(bool open)
54 {
55         if (open == true)
56 //              setPixmap(0, QPixmap(folderopen_xpm));
57 //              setIcon(QIcon(folderopen_xpm));
58                 setIcon(QIcon(":/res/folderopen.xpm"));
59         else
60 //              setPixmap(0, QPixmap(folderclosed_xpm));
61 //              setIcon(QIcon(folderclosed_xpm));
62                 setIcon(QIcon(":/res/folderclosed.xpm"));
63
64 //      Q3ListViewItem::setOpen(open);
65 #warning "!!!"
66 //      QListWidgetItem::setOpen(open);
67 }
68
69 /**
70  * Called in the beginning.
71  */
72 void QG_ListViewItem::setup()
73 {
74 //      Q3ListViewItem::setup();
75 #warning "!!!"
76 //      QListWidgetItem::setup();
77 }
78
79 /**
80  * Returns the "path" of this item (like: "Project/Page1/Paragraph1/").
81  */
82 QString QG_ListViewItem::getFullPath()
83 {
84         QString s;
85
86         if (par != NULL)
87         {
88                 s = par->getFullPath();
89                 s.append(text(0));
90                 s.append("/");
91         }
92         else
93         {
94                 s = text(0);
95                 s.append("/");
96         }
97
98         return s;
99 }
100
101 /**
102  * Returns the text of the given column of this item.
103  */
104 QString QG_ListViewItem::text(int column) const
105 {
106         if (column == 0)
107                 return label;
108
109         return "Column1";
110 }
111
112 QString QG_ListViewItem::getLabel() const
113 {
114         return label;
115 }
116
117 void QG_ListViewItem::setId(int id)
118 {
119         this->id = id;
120 }
121
122 int QG_ListViewItem::getId()
123 {
124         return id;
125 }