Diffstat (limited to 'noncore/net/wellenreiter/cornucopia') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/net/wellenreiter/cornucopia/README | 127 | ||||
-rw-r--r-- | noncore/net/wellenreiter/cornucopia/olistview.cpp | 147 | ||||
-rw-r--r-- | noncore/net/wellenreiter/cornucopia/olistview.h | 81 |
3 files changed, 345 insertions, 10 deletions
diff --git a/noncore/net/wellenreiter/cornucopia/README b/noncore/net/wellenreiter/cornucopia/README index 36a6954..486dc67 100644 --- a/noncore/net/wellenreiter/cornucopia/README +++ b/noncore/net/wellenreiter/cornucopia/README | |||
@@ -1,3 +1,124 @@ | |||
1 | --------------------------------------------------------------- | 1 | /******************************************************************** |
2 | Dies ist ein Testballon für opielibs1.2 - Codename: Cornucopia | 2 | /* This is an overview of the opielibs 1.2 project |
3 | --------------------------------------------------------------- | 3 | /********************************************************************/ |
4 | |||
5 | Origin: opielibs is about creating classes to | ||
6 | * optimize Qt classes for the embedded environment | ||
7 | * provide sophisticated abstractions for developers | ||
8 | * provide complete documentation and working examples | ||
9 | * provide end users with a common look and feel | ||
10 | * reduce memory footprint through sharing code | ||
11 | * reduce possible bugs through reusing tested code | ||
12 | |||
13 | -------------------------------------------------------- | ||
14 | 1. General Overview | ||
15 | -------------------------------------------------------- | ||
16 | |||
17 | Separation into the following libraries: | ||
18 | - libopiecore | ||
19 | - libopieui | ||
20 | - libopiepim | ||
21 | - libopienet | ||
22 | |||
23 | 1.1 Contents of libopiecore [ opiecore ] | ||
24 | -------------------------------------------------------- | ||
25 | |||
26 | - oprocctrl | ||
27 | - oprocess | ||
28 | - odevice | ||
29 | - odevicebutton | ||
30 | |||
31 | - oconfig | ||
32 | - oconfiggroupsaver | ||
33 | - ocompletionbase | ||
34 | - ocompletion | ||
35 | - ocomptreenodelist | ||
36 | - ocomptreenode | ||
37 | - ocompletionwrapper | ||
38 | - oglobal | ||
39 | - oglobalsettings | ||
40 | - osortableitem | ||
41 | - osortablevaluelist | ||
42 | |||
43 | 1.2 Contents of libopieui [ opieui ] | ||
44 | -------------------------------------------------------- | ||
45 | |||
46 | - oapplication | ||
47 | |||
48 | - ofiledialog | ||
49 | - colordialog | ||
50 | - oclickablelabel | ||
51 | - ocolorbutton | ||
52 | - colorpopupmenu | ||
53 | - otabinfo | ||
54 | - otabbar | ||
55 | - otabwidget | ||
56 | - ofontmenu | ||
57 | - ofontselector | ||
58 | - ofileview | ||
59 | - oticker | ||
60 | |||
61 | - olistview | ||
62 | - olistviewitem | ||
63 | - oversatileview | ||
64 | - oversatileviewitem | ||
65 | - ocompletionbox | ||
66 | - olineedit | ||
67 | - ocombobox | ||
68 | - ohistorycombo | ||
69 | |||
70 | - omessagebox | ||
71 | - odialogbase | ||
72 | |||
73 | - todayconfigwidget (rather into opiepim?) | ||
74 | - orecurrancewidget (rather into opiepim?) | ||
75 | - otimepicker (rather into opiepim?) | ||
76 | |||
77 | 1.3 Contents of libopiepim [ opiepim ] | ||
78 | -------------------------------------------------------- | ||
79 | |||
80 | - ocheckitem | ||
81 | - todoevent | ||
82 | - todoresource | ||
83 | - todayplugininterface | ||
84 | - todovcalresource | ||
85 | |||
86 | 1.4 Contents of libopiedb [ opiedb ] | ||
87 | -------------------------------------------------------- | ||
88 | |||
89 | - tododb | ||
90 | - xmltree | ||
91 | |||
92 | 1.5 Contents of libopienet [ opienet ] | ||
93 | -------------------------------------------------------- | ||
94 | |||
95 | <libmail stuff> | ||
96 | <libbend stuff> | ||
97 | <libftp stuff> | ||
98 | |||
99 | -------------------------------------------------------- | ||
100 | 2.0 Feature Description | ||
101 | -------------------------------------------------------- | ||
102 | |||
103 | 2.1 libopiecore | ||
104 | |||
105 | ... | ||
106 | |||
107 | 2.2 libopieui | ||
108 | |||
109 | ... | ||
110 | |||
111 | 2.2.x OListView, OListViewItem, OListViewFactory | ||
112 | |||
113 | ... | ||
114 | |||
115 | 2.3 libopiepim | ||
116 | |||
117 | ... | ||
118 | |||
119 | 2.4 libopiedb | ||
120 | |||
121 | ... | ||
122 | |||
123 | 2.5 libopienet | ||
124 | |||
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.cpp b/noncore/net/wellenreiter/cornucopia/olistview.cpp index 8bc59de..f2d3730 100644 --- a/noncore/net/wellenreiter/cornucopia/olistview.cpp +++ b/noncore/net/wellenreiter/cornucopia/olistview.cpp | |||
@@ -114,24 +114,100 @@ void OListView::setAlternateBackground( const QColor &c ) | |||
114 | 114 | ||
115 | const QPen& OListView::columnSeparator() const | 115 | const QPen& OListView::columnSeparator() const |
116 | { | 116 | { |
117 | return m_columnSeparator; | 117 | return m_columnSeparator; |
118 | } | 118 | } |
119 | 119 | ||
120 | void OListView::setColumnSeparator( const QPen& p ) | 120 | void OListView::setColumnSeparator( const QPen& p ) |
121 | { | 121 | { |
122 | m_columnSeparator = p; | 122 | m_columnSeparator = p; |
123 | repaint(); | 123 | repaint(); |
124 | } | 124 | } |
125 | 125 | ||
126 | #ifndef QT_NO_DATASTREAM | ||
127 | void OListView::serializeTo( QDataStream& s ) const | ||
128 | { | ||
129 | #warning Caution... the binary format is still under construction... | ||
130 | qDebug( "storing OListView..." ); | ||
131 | |||
132 | // store number of columns and the labels | ||
133 | s << columns(); | ||
134 | for ( int i = 0; i < columns(); ++i ) | ||
135 | s << columnText( i ); | ||
136 | |||
137 | // calculate the number of top-level items to serialize | ||
138 | int items = 0; | ||
139 | QListViewItem* item = firstChild(); | ||
140 | while ( item ) | ||
141 | { | ||
142 | item = item->nextSibling(); | ||
143 | items++; | ||
144 | } | ||
145 | |||
146 | // store number of items and the items itself | ||
147 | s << items; | ||
148 | item = firstChild(); | ||
149 | for ( int i = 0; i < items; ++i ) | ||
150 | { | ||
151 | s << *static_cast<OListViewItem*>( item ); | ||
152 | item = item->nextSibling(); | ||
153 | } | ||
154 | |||
155 | qDebug( "OListview stored." ); | ||
156 | } | ||
157 | |||
158 | void OListView::serializeFrom( QDataStream& s ) | ||
159 | { | ||
160 | #warning Caution... the binary format is still under construction... | ||
161 | qDebug( "loading OListView..." ); | ||
162 | |||
163 | int cols; | ||
164 | s >> cols; | ||
165 | qDebug( "read number of columns = %d", cols ); | ||
166 | |||
167 | while ( columns() < cols ) addColumn( QString::null ); | ||
168 | |||
169 | for ( int i = 0; i < cols; ++i ) | ||
170 | { | ||
171 | QString coltext; | ||
172 | s >> coltext; | ||
173 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | ||
174 | setColumnText( i, coltext ); | ||
175 | } | ||
176 | |||
177 | int items; | ||
178 | s >> items; | ||
179 | qDebug( "read number of items = %d", items ); | ||
180 | |||
181 | for ( int i = 0; i < items; ++i ) | ||
182 | { | ||
183 | OListViewItem* item = new OListViewItem( this ); | ||
184 | s >> *item; | ||
185 | } | ||
186 | |||
187 | qDebug( "OListView loaded." ); | ||
188 | |||
189 | } | ||
190 | |||
191 | QDataStream& operator<<( QDataStream& s, const OListView& lv ) | ||
192 | { | ||
193 | lv.serializeTo( s ); | ||
194 | } | ||
195 | |||
196 | QDataStream& operator>>( QDataStream& s, OListView& lv ) | ||
197 | { | ||
198 | lv.serializeFrom( s ); | ||
199 | } | ||
200 | #endif // QT_NO_DATASTREAM | ||
201 | |||
126 | //****************************** OListViewItem *********************************************************************** | 202 | //****************************** OListViewItem *********************************************************************** |
127 | 203 | ||
128 | OListViewItem::OListViewItem(QListView *parent) | 204 | OListViewItem::OListViewItem(QListView *parent) |
129 | : QListViewItem(parent) | 205 | : QListViewItem(parent) |
130 | { | 206 | { |
131 | init(); | 207 | init(); |
132 | } | 208 | } |
133 | 209 | ||
134 | OListViewItem::OListViewItem(QListViewItem *parent) | 210 | OListViewItem::OListViewItem(QListViewItem *parent) |
135 | : QListViewItem(parent) | 211 | : QListViewItem(parent) |
136 | { | 212 | { |
137 | init(); | 213 | init(); |
@@ -245,18 +321,87 @@ void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, in | |||
245 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); | 321 | const QPixmap *pm = listView()->viewport()->backgroundPixmap(); |
246 | if (pm && !pm->isNull()) | 322 | if (pm && !pm->isNull()) |
247 | { | 323 | { |
248 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); | 324 | _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); |
249 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); | 325 | p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); |
250 | } | 326 | } |
251 | else if ( isAlternate() ) | 327 | else if ( isAlternate() ) |
252 | { | 328 | { |
253 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); | 329 | _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); |
254 | } | 330 | } |
255 | QListViewItem::paintCell(p, _cg, column, width, alignment); | 331 | QListViewItem::paintCell(p, _cg, column, width, alignment); |
256 | 332 | ||
257 | //FIXME: Use styling here? | 333 | //FIXME: Use styling here! |
258 | 334 | ||
259 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); | 335 | const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); |
260 | p->setPen( pen ); | 336 | p->setPen( pen ); |
261 | p->drawLine( width-1, 0, width-1, height() ); | 337 | p->drawLine( width-1, 0, width-1, height() ); |
262 | } | 338 | } |
339 | |||
340 | #ifndef QT_NO_DATASTREAM | ||
341 | void OListViewItem::serializeTo( QDataStream& s ) const | ||
342 | { | ||
343 | #warning Caution... the binary format is still under construction... | ||
344 | qDebug( "storing OListViewItem..." ); | ||
345 | |||
346 | // store item text | ||
347 | for ( int i = 0; i < listView()->columns(); ++i ) | ||
348 | { | ||
349 | s << text( i ); | ||
350 | } | ||
351 | |||
352 | // calculate the number of children to serialize | ||
353 | int items = 0; | ||
354 | QListViewItem* item = firstChild(); | ||
355 | while ( item ) | ||
356 | { | ||
357 | item = item->nextSibling(); | ||
358 | items++; | ||
359 | } | ||
360 | |||
361 | // store number of items and the items itself | ||
362 | s << items; | ||
363 | item = firstChild(); | ||
364 | for ( int i = 0; i < items; ++i ) | ||
365 | { | ||
366 | s << *static_cast<OListViewItem*>( item ); | ||
367 | item = item->nextSibling(); | ||
368 | } | ||
369 | |||
370 | qDebug( "OListviewItem stored." ); | ||
371 | } | ||
372 | void OListViewItem::serializeFrom( QDataStream& s ) | ||
373 | { | ||
374 | #warning Caution... the binary format is still under construction... | ||
375 | qDebug( "loading OListViewItem..." ); | ||
376 | |||
377 | for ( int i = 0; i < listView()->columns(); ++i ) | ||
378 | { | ||
379 | QString coltext; | ||
380 | s >> coltext; | ||
381 | qDebug( "read text '%s' for column %d", (const char*) coltext, i ); | ||
382 | setText( i, coltext ); | ||
383 | } | ||
384 | |||
385 | int items; | ||
386 | s >> items; | ||
387 | qDebug( "read number of items = %d", items ); | ||
388 | |||
389 | for ( int i = 0; i < items; ++i ) | ||
390 | { | ||
391 | OListViewItem* item = new OListViewItem( this ); | ||
392 | s >> (*item); | ||
393 | } | ||
394 | |||
395 | qDebug( "OListViewItem loaded." ); | ||
396 | } | ||
397 | |||
398 | QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) | ||
399 | { | ||
400 | lvi.serializeTo( s ); | ||
401 | } | ||
402 | |||
403 | QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) | ||
404 | { | ||
405 | lvi.serializeFrom( s ); | ||
406 | } | ||
407 | #endif // QT_NO_DATASTREAM | ||
diff --git a/noncore/net/wellenreiter/cornucopia/olistview.h b/noncore/net/wellenreiter/cornucopia/olistview.h index 4b9e4b0..9df5500 100644 --- a/noncore/net/wellenreiter/cornucopia/olistview.h +++ b/noncore/net/wellenreiter/cornucopia/olistview.h | |||
@@ -24,32 +24,35 @@ | |||
24 | -. .:....=;==+<; You should have received a copy of the GNU | 24 | -. .:....=;==+<; You should have received a copy of the GNU |
25 | -_. . . )=. = Library General Public License along with | 25 | -_. . . )=. = Library General Public License along with |
26 | -- :-=` this library; see the file COPYING.LIB. | 26 | -- :-=` this library; see the file COPYING.LIB. |
27 | If not, write to the Free Software Foundation, | 27 | If not, write to the Free Software Foundation, |
28 | Inc., 59 Temple Place - Suite 330, | 28 | Inc., 59 Temple Place - Suite 330, |
29 | Boston, MA 02111-1307, USA. | 29 | Boston, MA 02111-1307, USA. |
30 | 30 | ||
31 | */ | 31 | */ |
32 | 32 | ||
33 | #ifndef OLISTVIEW_H | 33 | #ifndef OLISTVIEW_H |
34 | #define OLISTVIEW_H | 34 | #define OLISTVIEW_H |
35 | 35 | ||
36 | #include <qlistview.h> | ||
37 | #include <qcolor.h> | 36 | #include <qcolor.h> |
37 | #include <qlistview.h> | ||
38 | #include <qpen.h> | 38 | #include <qpen.h> |
39 | #include <qdatastream.h> | ||
40 | |||
41 | class OListViewFactory; | ||
39 | 42 | ||
40 | /** | 43 | /** |
41 | * A @ref QListView variant featuring visual enhancements | 44 | * A @ref QListView variant featuring visual and functional enhancements |
42 | * like an alternate background for odd rows and an autostretch | 45 | * like an alternate background for odd rows, an autostretch mode |
43 | * mode for the width of the widget. | 46 | * for the width of the widget ( >= Qt 3 only ) and persistence capabilities. |
44 | * | 47 | * |
45 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> | 48 | * @author Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> |
46 | * @short OListView list/tree widget. | 49 | * @short OListView list/tree widget. |
47 | */ | 50 | */ |
48 | class OListView: public QListView | 51 | class OListView: public QListView |
49 | { | 52 | { |
50 | public: | 53 | public: |
51 | /** | 54 | /** |
52 | * Constructor. | 55 | * Constructor. |
53 | * | 56 | * |
54 | * The parameters @p parent and @p name are handled by | 57 | * The parameters @p parent and @p name are handled by |
55 | * @ref QListView, as usual. | 58 | * @ref QListView, as usual. |
@@ -103,31 +106,69 @@ | |||
103 | void setColumnSeparator( const QPen &p ); | 106 | void setColumnSeparator( const QPen &p ); |
104 | 107 | ||
105 | /** | 108 | /** |
106 | * @return the alternate background color | 109 | * @return the alternate background color |
107 | */ | 110 | */ |
108 | const QColor& alternateBackground() const; | 111 | const QColor& alternateBackground() const; |
109 | 112 | ||
110 | /** | 113 | /** |
111 | * @return the column separator pen | 114 | * @return the column separator pen |
112 | */ | 115 | */ |
113 | const QPen& columnSeparator() const; | 116 | const QPen& columnSeparator() const; |
114 | 117 | ||
118 | #ifndef QT_NO_DATASTREAM | ||
119 | /** | ||
120 | * serialize this object to a @ref QDataStream | ||
121 | * @param s the stream used to serialize this object. | ||
122 | */ | ||
123 | virtual void serializeTo( QDataStream& s ) const; | ||
124 | |||
125 | /** | ||
126 | * serialize this object from a @ref QDataStream | ||
127 | * @param s the stream used to serialize this object. | ||
128 | */ | ||
129 | virtual void serializeFrom( QDataStream& s ); | ||
130 | #endif | ||
131 | |||
132 | /** | ||
133 | * returns a factory for OListView classes | ||
134 | * creates one on the fly if it doesn't exist | ||
135 | * @return the XML Factory | ||
136 | */ | ||
137 | #ifndef QT_NO_XML | ||
138 | //OListViewFactory* Factory(); | ||
139 | #endif | ||
140 | |||
115 | private: | 141 | private: |
116 | QColor m_alternateBackground; | 142 | QColor m_alternateBackground; |
117 | bool m_fullWidth; | 143 | bool m_fullWidth; |
118 | QPen m_columnSeparator; | 144 | QPen m_columnSeparator; |
119 | 145 | #ifndef QT_NO_XML | |
146 | //OListViewFactory* m_Factory; | ||
147 | #endif | ||
120 | }; | 148 | }; |
121 | 149 | ||
150 | #ifndef QT_NO_DATASTREAM | ||
151 | /** | ||
152 | * \relates QListView | ||
153 | * Writes a listview to the stream and returns a reference to the stream. | ||
154 | */ | ||
155 | QDataStream& operator<<( QDataStream& s, const OListView& lv ); | ||
156 | /** | ||
157 | * \relates QListView | ||
158 | * Reads a listview from the stream and returns a reference to the stream. | ||
159 | */ | ||
160 | QDataStream& operator>>( QDataStream& s, OListView& lv ); | ||
161 | #endif // QT_NO_DATASTREAM | ||
162 | |||
122 | //****************************** OListViewItem ****************************************************************** | 163 | //****************************** OListViewItem ****************************************************************** |
123 | 164 | ||
124 | class OListViewItem: public QListViewItem | 165 | class OListViewItem: public QListViewItem |
125 | { | 166 | { |
126 | public: | 167 | public: |
127 | OListViewItem( QListView * parent ); | 168 | OListViewItem( QListView * parent ); |
128 | OListViewItem( QListViewItem * parent ); | 169 | OListViewItem( QListViewItem * parent ); |
129 | OListViewItem( QListView * parent, QListViewItem * after ); | 170 | OListViewItem( QListView * parent, QListViewItem * after ); |
130 | OListViewItem( QListViewItem * parent, QListViewItem * after ); | 171 | OListViewItem( QListViewItem * parent, QListViewItem * after ); |
131 | 172 | ||
132 | OListViewItem( QListView * parent, | 173 | OListViewItem( QListView * parent, |
133 | QString, QString = QString::null, | 174 | QString, QString = QString::null, |
@@ -151,18 +192,46 @@ class OListViewItem: public QListViewItem | |||
151 | QString, QString = QString::null, | 192 | QString, QString = QString::null, |
152 | QString = QString::null, QString = QString::null, | 193 | QString = QString::null, QString = QString::null, |
153 | QString = QString::null, QString = QString::null, | 194 | QString = QString::null, QString = QString::null, |
154 | QString = QString::null, QString = QString::null ); | 195 | QString = QString::null, QString = QString::null ); |
155 | 196 | ||
156 | virtual ~OListViewItem(); | 197 | virtual ~OListViewItem(); |
157 | 198 | ||
158 | const QColor& backgroundColor(); | 199 | const QColor& backgroundColor(); |
159 | bool isAlternate(); | 200 | bool isAlternate(); |
160 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); | 201 | void paintCell( QPainter *p, const QColorGroup &cg, int column, int width, int alignment ); |
161 | void init(); | 202 | void init(); |
162 | 203 | ||
204 | #ifndef QT_NO_DATASTREAM | ||
205 | /** | ||
206 | * serialize this object to or from a @ref QDataStream | ||
207 | * @param s the stream used to serialize this object. | ||
208 | */ | ||
209 | virtual void serializeTo( QDataStream& s ) const; | ||
210 | |||
211 | /** | ||
212 | * serialize this object to or from a @ref QDataStream | ||
213 | * @param s the stream used to serialize this object. | ||
214 | */ | ||
215 | virtual void serializeFrom( QDataStream& s ); | ||
216 | #endif | ||
217 | |||
163 | private: | 218 | private: |
164 | bool m_known; | 219 | bool m_known; |
165 | bool m_odd; | 220 | bool m_odd; |
166 | }; | 221 | }; |
167 | 222 | ||
168 | #endif | 223 | #ifndef QT_NO_DATASTREAM |
224 | /** | ||
225 | * \relates QListViewItem | ||
226 | * Writes a listview item and all subitems recursively to the stream | ||
227 | * and returns a reference to the stream. | ||
228 | */ | ||
229 | QDataStream& operator<<( QDataStream &s, const OListViewItem& lvi ); | ||
230 | /** | ||
231 | * \relates QListViewItem | ||
232 | * Reads a listview item from the stream and returns a reference to the stream. | ||
233 | */ | ||
234 | QDataStream& operator>>( QDataStream &s, OListViewItem& lvi ); | ||
235 | #endif // QT_NO_DATASTREAM | ||
236 | |||
237 | #endif // OLISTVIEW_H | ||