author | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-03-28 15:11:52 (UTC) |
commit | 11304d02942e9fa493e4e80943a828f9c65f6772 (patch) (unidiff) | |
tree | a0223c10c067e1afc70d15c2b82be3f3c15e41ae /libopie2/opieui/olistview.h | |
parent | b271d575fa05cf570a1a829136517761bd47e69b (diff) | |
download | opie-11304d02942e9fa493e4e80943a828f9c65f6772.zip opie-11304d02942e9fa493e4e80943a828f9c65f6772.tar.gz opie-11304d02942e9fa493e4e80943a828f9c65f6772.tar.bz2 |
skeleton and the start of libopie2, please read README, ROADMAP and STATUS and comment...
-rw-r--r-- | libopie2/opieui/olistview.h | 235 |
1 files changed, 235 insertions, 0 deletions
diff --git a/libopie2/opieui/olistview.h b/libopie2/opieui/olistview.h new file mode 100644 index 0000000..bafc67c --- a/dev/null +++ b/libopie2/opieui/olistview.h | |||
@@ -0,0 +1,235 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | =. (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
5 | .=l. | ||
6 | .>+-= | ||
7 | _;:, .> :=|. This program is free software; you can | ||
8 | .> <`_, > . <= redistribute it and/or modify it under | ||
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
10 | .="- .-=="i, .._ License as published by the Free Software | ||
11 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
12 | ._= =} : or (at your option) any later version. | ||
13 | .%`+i> _;_. | ||
14 | .i_,=:_. -<s. This program is distributed in the hope that | ||
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
16 | : .. .:, . . . without even the implied warranty of | ||
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
19 | ..}^=.= = ; Library General Public License for more | ||
20 | ++= -. .` .: details. | ||
21 | : = ...= . :.=- | ||
22 | -. .:....=;==+<; You should have received a copy of the GNU | ||
23 | -_. . . )=. = Library General Public License along with | ||
24 | -- :-=` this library; see the file COPYING.LIB. | ||
25 | If not, write to the Free Software Foundation, | ||
26 | Inc., 59 Temple Place - Suite 330, | ||
27 | Boston, MA 02111-1307, USA. | ||
28 | |||
29 | */ | ||
30 | |||
31 | #ifndef OLISTVIEW_H | ||
32 | #define OLISTVIEW_H | ||
33 | |||
34 | #include <qcolor.h> | ||
35 | #include <qlistview.h> | ||
36 | #include <qpen.h> | ||
37 | #include <qdatastream.h> | ||
38 | |||
39 | class OListViewItem; | ||
40 | |||
41 | /** | ||
42 | * A @ref QListView variant featuring visual and functional enhancements | ||
43 | * like an alternate background for odd rows, an autostretch mode | ||
44 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. | ||
45 | * | ||
46 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | ||
47 | * @short OListView list/tree widget. | ||
48 | */ | ||
49 | class OListView: public QListView | ||
50 | { | ||
51 | public: | ||
52 | /** | ||
53 | * Constructor. | ||
54 | * | ||
55 | * The parameters @p parent and @p name are handled by | ||
56 | * @ref QListView, as usual. | ||
57 | */ | ||
58 | OListView ( QWidget *parent = 0, const char *name = 0 ); | ||
59 | |||
60 | /** | ||
61 | * Destructor. | ||
62 | */ | ||
63 | virtual ~OListView(); | ||
64 | |||
65 | /** | ||
66 | * Let the last column fit exactly all the available width. | ||
67 | */ | ||
68 | void setFullWidth( bool fullWidth ); | ||
69 | |||
70 | /** | ||
71 | * Returns whether the last column is set to fit the available width. | ||
72 | */ | ||
73 | bool fullWidth() const; | ||
74 | |||
75 | /** | ||
76 | * Reimplemented for full width support | ||
77 | */ | ||
78 | virtual int addColumn( const QString& label, int width = -1 ); | ||
79 | |||
80 | /** | ||
81 | * Reimplemented for full width support | ||
82 | */ | ||
83 | virtual int addColumn( const QIconSet& iconset, const QString& label, int width = -1 ); | ||
84 | |||
85 | /** | ||
86 | * Reimplemented for full width support | ||
87 | */ | ||
88 | virtual void removeColumn(int index); | ||
89 | |||
90 | /** | ||
91 | * sets the alternate background background color. | ||
92 | * This only has an effect if the items are OListViewItems | ||
93 | * | ||
94 | * @param c the color to use for every other item. Set to an invalid | ||
95 | * color to disable alternate colors. | ||
96 | */ | ||
97 | void setAlternateBackground( const QColor &c ); | ||
98 | |||
99 | /** | ||
100 | * sets the column separator pen. | ||
101 | * | ||
102 | * @param p the pen used to draw the column separator. | ||
103 | */ | ||
104 | void setColumnSeparator( const QPen &p ); | ||
105 | |||
106 | /** | ||
107 | * @return the alternate background color | ||
108 | */ | ||
109 | const QColor& alternateBackground() const; | ||
110 | |||
111 | /** | ||
112 | * @return the column separator pen | ||
113 | */ | ||
114 | const QPen& columnSeparator() const; | ||
115 | |||
116 | /** | ||
117 | * create a list view item as child of this object | ||
118 | * @return the new object | ||
119 | */ | ||
120 | virtual OListViewItem* childFactory(); | ||
121 | |||
122 | #ifndef QT_NO_DATASTREAM | ||
123 | /** | ||
124 | * serialize this object to a @ref QDataStream | ||
125 | * @param s the stream used to serialize this object. | ||
126 | */ | ||
127 | virtual void serializeTo( QDataStream& s ) const; | ||
128 | |||
129 | /** | ||
130 | * serialize this object from a @ref QDataStream | ||
131 | * @param s the stream used to serialize this object. | ||
132 | */ | ||
133 | virtual void serializeFrom( QDataStream& s ); | ||
134 | #endif | ||
135 | |||
136 | private: | ||
137 | QColor m_alternateBackground; | ||
138 | bool m_fullWidth; | ||
139 | QPen m_columnSeparator; | ||
140 | }; | ||
141 | |||
142 | #ifndef QT_NO_DATASTREAM | ||
143 | /** | ||
144 | * \relates QListView | ||
145 | * Writes a listview to the stream and returns a reference to the stream. | ||
146 | */ | ||
147 | QDataStream& operator<<( QDataStream& s, const OListView& lv ); | ||
148 | /** | ||
149 | * \relates QListView | ||
150 | * Reads a listview from the stream and returns a reference to the stream. | ||
151 | */ | ||
152 | QDataStream& operator>>( QDataStream& s, OListView& lv ); | ||
153 | #endif // QT_NO_DATASTREAM | ||
154 | |||
155 | //****************************** OListViewItem ****************************************************************** | ||
156 | |||
157 | class OListViewItem: public QListViewItem | ||
158 | { | ||
159 | public: | ||
160 | OListViewItem( QListView * parent ); | ||
161 | OListViewItem( QListViewItem * parent ); | ||
162 | OListViewItem( QListView * parent, QListViewItem * after ); | ||
163 | OListViewItem( QListViewItem * parent, QListViewItem * after ); | ||
164 | |||
165 | OListViewItem( QListView * parent, | ||
166 | QString, QString = QString::null, | ||
167 | QString = QString::null, QString = QString::null, | ||
168 | QString = QString::null, QString = QString::null, | ||
169 | QString = QString::null, QString = QString::null ); | ||
170 | |||
171 | OListViewItem( QListViewItem * parent, | ||
172 | QString, QString = QString::null, | ||
173 | QString = QString::null, QString = QString::null, | ||
174 | QString = QString::null, QString = QString::null, | ||
175 | QString = QString::null, QString = QString::null ); | ||
176 | |||
177 | OListViewItem( QListView * parent, QListViewItem * after, | ||
178 | QString, QString = QString::null, | ||
179 | QString = QString::null, QString = QString::null, | ||
180 | QString = QString::null, QString = QString::null, | ||
181 | QString = QString::null, QString = QString::null ); | ||
182 | |||
183 | OListViewItem( QListViewItem * parent, QListViewItem * after, | ||
184 | QString, QString = QString::null, | ||
185 | QString = QString::null, QString = QString::null, | ||
186 | QString = QString::null, QString = QString::null, | ||
187 | QString = QString::null, QString = QString::null ); | ||
188 | |||
189 | virtual ~OListViewItem(); | ||
190 | |||
191 | const QColor& backgroundColor(); | ||
192 | bool isAlternate(); | ||
193 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | ||
194 | void init(); | ||
195 | |||
196 | /** | ||
197 | * create a list view item as child of this object | ||
198 | * @return the new object | ||
199 | */ | ||
200 | virtual OListViewItem* childFactory(); | ||
201 | |||
202 | #ifndef QT_NO_DATASTREAM | ||
203 | /** | ||
204 | * serialize this object to or from a @ref QDataStream | ||
205 | * @param s the stream used to serialize this object. | ||
206 | */ | ||
207 | virtual void serializeTo( QDataStream& s ) const; | ||
208 | |||
209 | /** | ||
210 | * serialize this object to or from a @ref QDataStream | ||
211 | * @param s the stream used to serialize this object. | ||
212 | */ | ||
213 | virtual void serializeFrom( QDataStream& s ); | ||
214 | #endif | ||
215 | |||
216 | private: | ||
217 | bool m_known; | ||
218 | bool m_odd; | ||
219 | }; | ||
220 | |||
221 | #ifndef QT_NO_DATASTREAM | ||
222 | /** | ||
223 | * \relates QListViewItem | ||
224 | * Writes a listview item and all subitems recursively to the stream | ||
225 | * and returns a reference to the stream. | ||
226 | */ | ||
227 | QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); | ||
228 | /** | ||
229 | * \relates QListViewItem | ||
230 | * Reads a listview item from the stream and returns a reference to the stream. | ||
231 | */ | ||
232 | QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); | ||
233 | #endif // QT_NO_DATASTREAM | ||
234 | |||
235 | #endif // OLISTVIEW_H | ||