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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
|
#ifndef LISTCAT_H
#define LISTCAT_H
/* listCat.h KPilot
**
** Copyright (C) 2000-2001 by Adriaan de Groot
** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
**
*/
/** @file
** This is a specialization of KListView to allow the user to
** DnD a fixed set of objects into a fixed set of categories
** (categories set at construction time). @em Deprecated, do not use.
*/
/*
** This program 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; either version 2 of the License, or
** (at your option) any later version.
**
** This program 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
** along with this program in a file called COPYING; if not, write to
** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
** MA 02110-1301, USA.
*/
/*
** Bug reports and questions can be sent to kde-pim@kde.org
*/
#include <klistview.h>
class TQStringList;
/**
* This Widget extends KListView for a particular purpose:
* sorting some items into some bins. This can be useful
* for putting items in an enabled / disabled state, or
* into categories, or configuring toolbars (putting
* icons onto toolbars).
*
* You can use all of the standard KListView signals and
* slots. You may in particular want to change the names
* of the columns, for example:
* @code
* ListCategorizer *lc = new ListCategorizer(this,colors);
* lc->setColumnText(0,i18n("Color"));
* lc->setColumnText(1,i18n("HTML"));
* TQListViewItem *stdKDE = lc->addCategory(i18n("Standard KDE"));
* (void) new TQListViewItem(stdKDE,i18n("red"),"#FF0000");
* @endcode
* to set sensible column headers for a list of colors
* and their HTML equivalents (although why you would want
* to categorize colors is beyond me).
*
* @version $Id$
*/
class ListCategorizer : public KListView
{
Q_OBJECT
public:
/**
* Constructor.
*
* This creates a new empty ListCategorizer with
* startOpen set to false. The parameters
* @p parent and @p name are the usual Qt ones.
*/
ListCategorizer(TQWidget *parent,
const char *name = 0);
/**
* Constructor.
*
* This creates a ListCategorizer with the given @p categories
* already inserted. In addition, this constructor lets you
* specify whether or not startOpen is set.
*/
ListCategorizer(const TQStringList& categories,
bool startOpen,
TQWidget *parent,
const char *name = 0);
/**
* Add a list of categories to the ListCategorizer.
* All the categories are added without descriptions;
* use addCategory on a per-category basis for that.
*/
void addCategories(const TQStringList&);
/**
* Add a category with name @p name and optional
* @p description. This can be useful if you want
* either a description for the category or want to
* refer to this category in the future without
* using findCategory().
*
* @return the TQListViewItem created for the category
*/
TQListViewItem *addCategory(const TQString& name,
const TQString& description = TQString::null);
/**
* Returns the list of names of the categories in
* the ListCategorizer.
*/
TQStringList categories() const
{
return listSiblings(firstChild());
} ;
/**
* Add a single item to the category named @p category,
* with name @p name and description set to @p description.
* This might be a convenience function, but it's probably
* more convenient to just use QListViewItem's
* constructor. That way you can also hide more data in
* the remaining columns.
*/
TQListViewItem *addItem(const TQString& category,
const TQString& name,
const TQString& description = TQString::null);
/**
* Returns the list of strings in column @p column under
* category @p category. You can do this to get, for example
* the names of all the items categorized under a given
* category, or, more usefully, set @p column to something
* other that 0 (name) or 1 (description) to return the
* TQStringList hidden in the non-visible columns.
*/
TQStringList items(const TQString& category,int column=0) const
{
return listSiblings(findCategory(category),column);
}
/**
* Given a category categoryName return the QListViewItem
* that represents that category. Probably a useless function,
* since just remembering the pointer addCategory gives
* you is faster and uses hardly any memory.
*/
TQListViewItem *findCategory(const TQString& categoryName) const;
/**
* Return the list of strings in column @p column of all siblings
* of the given item @p p. If you remembered a pointer to a
* category, you can use
* @code
* TQStringList l = lc->listSiblings(stdKDE->firstChild(),2);
* @endcode
* to get the list of strings in hidden column 2 under
* the category you remembered.
*/
TQStringList listSiblings(const TQListViewItem *p,int column=0) const;
/**
* @return whether new categories are inserted in an
* open state or not.
*
* @see setStartOpen
*/
bool startOpen() const { return fStartOpen; } ;
/**
* Enable categories being inserted in an open state.
* It is disabled by default but may be set from the
* constructor.
*/
void setStartOpen(bool b) { fStartOpen=b; } ;
protected:
/**
* Reimplemented to prevent categories from being dragged.
*/
virtual bool acceptDrag (TQDropEvent* event) const;
/**
* Reimplemented to prevent categories from being dragged.
*/
virtual void startDrag();
/**
* Reimplemented to prevent categories from being dragged.
*/
virtual void contentsDropEvent (TQDropEvent*);
private:
/**
* Call several KListView functions to set up useful
* behavior for this particular class.
*/
void setupWidget();
bool fStartOpen:1;
} ;
class RichListViewItem : public QListViewItem
{
public:
RichListViewItem(TQListViewItem *parent,
TQString,
int);
virtual ~RichListViewItem();
virtual void paintCell(TQPainter *,
const TQColorGroup &,
int column,
int width,
int alignment);
virtual void setup();
bool isRich(int c) const { return fIsRich[c]; } ;
void setRich(int c,bool b) { fIsRich[c]=b; } ;
protected:
void computeHeight(int c);
protected:
bool *fIsRich;
TQRect *fRect;
int fColumns;
} ;
#endif
|