]> Shamusworld >> Repos - architektonas/blob - src/widgets/qg_listviewitem.cpp
Initial import
[architektonas] / src / widgets / qg_listviewitem.cpp
1 /****************************************************************************
2 ** $Id: qg_listviewitem.cpp 1385 2003-08-27 23:19:42Z andrew $
3 **
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5 **
6 ** This file is part of the qcadlib Library project.
7 **
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
12 **
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
16 **
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 **
20 ** See http://www.ribbonsoft.com for further details.
21 **
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
23 ** not clear to you.
24 **
25 **********************************************************************/
26
27 #include "qg_listviewitem.h"
28
29 #include <qpixmap.h>
30 /*#include "xpm/folderclosed.xpm"
31 #include "xpm/folderopen.xpm"*/
32
33 /**
34  * Constructor for root items.
35  */
36 //QG_ListViewItem::QG_ListViewItem(Q3ListView * par, const QString & label,
37 QG_ListViewItem::QG_ListViewItem(QListWidget * par, const QString & label,
38         bool open, int id): QListWidgetItem(par)
39 {
40         par = 0;
41         this->label = label;
42         this->id = id;
43
44 //      setPixmap(0, QPixmap((open ? folderopen_xpm : folderclosed_xpm)));
45 //      setIcon(QIcon((open ? folderopen_xpm : folderclosed_xpm)));
46         setIcon(QIcon((open ? ":/res/folderopen.xpm" : ":/res/folderclosed.xpm")));
47
48         setOpen(open);
49 }
50
51 /**
52  * Constructor for list view items with a folder icon.
53  */
54 QG_ListViewItem::QG_ListViewItem(QG_ListViewItem * par, const QString & label,
55         bool open, int id): QListWidgetItem((QListWidget *)par)
56 {
57         this->par = par;
58         this->label = label;
59         this->id = id;
60
61 //      setPixmap(0, QPixmap((open ? folderopen_xpm : folderclosed_xpm)));
62 //redundant:    setIcon(QIcon((open ? folderopen_xpm : folderclosed_xpm)));
63         setOpen(open);
64 }
65
66 /**
67  * Opens or closes the item.
68  */
69 void QG_ListViewItem::setOpen(bool open)
70 {
71         if (open == true)
72 //              setPixmap(0, QPixmap(folderopen_xpm));
73 //              setIcon(QIcon(folderopen_xpm));
74                 setIcon(QIcon(":/res/folderopen.xpm"));
75         else
76 //              setPixmap(0, QPixmap(folderclosed_xpm));
77 //              setIcon(QIcon(folderclosed_xpm));
78                 setIcon(QIcon(":/res/folderclosed.xpm"));
79
80 //      Q3ListViewItem::setOpen(open);
81 #warning "!!!"
82 //      QListWidgetItem::setOpen(open);
83 }
84
85 /**
86  * Called in the beginning.
87  */
88 void QG_ListViewItem::setup()
89 {
90 //      Q3ListViewItem::setup();
91 #warning "!!!"
92 //      QListWidgetItem::setup();
93 }
94
95 /**
96  * Returns the "path" of this item (like: "Project/Page1/Paragraph1/").
97  */
98 QString QG_ListViewItem::getFullPath()
99 {
100         QString s;
101
102         if (par != NULL)
103         {
104                 s = par->getFullPath();
105                 s.append(text(0));
106                 s.append("/");
107         }
108         else
109         {
110                 s = text(0);
111                 s.append("/");
112         }
113
114         return s;
115 }
116
117 /**
118  * Returns the text of the given column of this item.
119  */
120 QString QG_ListViewItem::text(int column) const
121 {
122         if (column == 0)
123                 return label;
124
125         return "Column1";
126 }
127
128 QString QG_ListViewItem::getLabel() const
129 {
130         return label;
131 }
132
133 void QG_ListViewItem::setId(int id)
134 {
135         this->id = id;
136 }
137
138 int QG_ListViewItem::getId()
139 {
140         return id;
141 }