summaryrefslogtreecommitdiff
path: root/libopie2
authorzecke <zecke>2004-09-10 11:06:50 (UTC)
committer zecke <zecke>2004-09-10 11:06:50 (UTC)
commit00b7879d0d886b642b1f1102e3a811e67f928df7 (patch) (unidiff)
tree15a9a6b1ba3ddf64a94265556cd9140916a47811 /libopie2
parentd416ff23ea50303173d07ea243498a163f5995b5 (diff)
downloadopie-00b7879d0d886b642b1f1102e3a811e67f928df7.zip
opie-00b7879d0d886b642b1f1102e3a811e67f928df7.tar.gz
opie-00b7879d0d886b642b1f1102e3a811e67f928df7.tar.bz2
Fix warnings about unused parameters and no newline at the end of file
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/big-screen/owidgetstack.cpp2
-rw-r--r--libopie2/opieui/ofontselector.cpp1
-rw-r--r--libopie2/opieui/olistview.cpp20
-rw-r--r--libopie2/opieui/oselector.cpp2
-rw-r--r--libopie2/opieui/owait.cpp1
5 files changed, 17 insertions, 9 deletions
diff --git a/libopie2/opieui/big-screen/owidgetstack.cpp b/libopie2/opieui/big-screen/owidgetstack.cpp
index de7f83f..9c9f7ec 100644
--- a/libopie2/opieui/big-screen/owidgetstack.cpp
+++ b/libopie2/opieui/big-screen/owidgetstack.cpp
@@ -345,97 +345,97 @@ void OWidgetStack::resizeEvent( QResizeEvent* ev ) {
345 * If in BigScreen mode the current mainwindow will be reparented 345 * If in BigScreen mode the current mainwindow will be reparented
346 * and hidden. The position will be taken by the new one. 346 * and hidden. The position will be taken by the new one.
347 * If the old MainWindow was hidden the new window will 347 * If the old MainWindow was hidden the new window will
348 * also be hidden. If the window was visible the new mainwindow 348 * also be hidden. If the window was visible the new mainwindow
349 * will be made visible too and the old one hidden. If there 349 * will be made visible too and the old one hidden. If there
350 * was no mainwindow it will be hidden as well. 350 * was no mainwindow it will be hidden as well.
351 * 351 *
352 * @param wid The new mainwindow 352 * @param wid The new mainwindow
353 */ 353 */
354void OWidgetStack::setMainWindow( QWidget* wid ) { 354void OWidgetStack::setMainWindow( QWidget* wid ) {
355 if (m_mode == BigScreen ) { 355 if (m_mode == BigScreen ) {
356 bool wasVisible = false; 356 bool wasVisible = false;
357 if (m_mWidget ) { 357 if (m_mWidget ) {
358 wasVisible = !m_mWidget->isHidden(); 358 wasVisible = !m_mWidget->isHidden();
359 /* hidden by default */ 359 /* hidden by default */
360 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) ); 360 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) );
361 } 361 }
362 wid->reparent(this, 0, frameRect().topLeft() ); 362 wid->reparent(this, 0, frameRect().topLeft() );
363 363
364 if (wasVisible) 364 if (wasVisible)
365 wid->show(); 365 wid->show();
366 } 366 }
367 367
368 m_mWidget = wid; 368 m_mWidget = wid;
369} 369}
370 370
371/** 371/**
372 * this is an overloaded member and only differs 372 * this is an overloaded member and only differs
373 * in the type of arguments. 373 * in the type of arguments.
374 * @see setMainWindow(QWidget*) 374 * @see setMainWindow(QWidget*)
375 */ 375 */
376void OWidgetStack::setMainWindow( int id) { 376void OWidgetStack::setMainWindow( int id) {
377 setMainWindow( widget( id ) ); 377 setMainWindow( widget( id ) );
378} 378}
379 379
380 380
381/* 381/*
382 * this function switches to a stack ;) 382 * this function switches to a stack ;)
383 */ 383 */
384void OWidgetStack::switchStack() { 384void OWidgetStack::switchStack() {
385 if (m_stack ) { 385 if (m_stack ) {
386 m_stack->setGeometry( frameRect() ); 386 m_stack->setGeometry( frameRect() );
387 return; 387 return;
388 } 388 }
389 389
390 m_mode = SmallScreen; 390 m_mode = SmallScreen;
391 m_stack = new QWidgetStack(this); 391 m_stack = new QWidgetStack(this);
392 392
393 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ), 393 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ),
394 this, SIGNAL(aboutToShow(QWidget*) ) ); 394 this, SIGNAL(aboutToShow(QWidget*) ) );
395 connect(m_stack, SIGNAL(aboutToShow(int) ), 395 connect(m_stack, SIGNAL(aboutToShow(int) ),
396 this, SIGNAL(aboutToShow(int) ) ); 396 this, SIGNAL(aboutToShow(int) ) );
397 397
398 /* now reparent the widgets... luckily QWidgetSatck does most of the work */ 398 /* now reparent the widgets... luckily QWidgetSatck does most of the work */
399 if (m_list.isEmpty() ) 399 if (m_list.isEmpty() )
400 return; 400 return;
401 401
402 QMap<int, QWidget*>::Iterator it = m_list.begin(); 402 QMap<int, QWidget*>::Iterator it = m_list.begin();
403 for ( ; it != m_list.end(); ++it ) 403 for ( ; it != m_list.end(); ++it )
404 m_stack->addWidget( it.data(), it.key() ); 404 m_stack->addWidget( it.data(), it.key() );
405 405
406 406
407} 407}
408 408
409/* 409/*
410 * we will switch to top level mode 410 * we will switch to top level mode
411 * reparent the list of widgets and then delete the stack 411 * reparent the list of widgets and then delete the stack
412 */ 412 */
413void OWidgetStack::switchTop() { 413void OWidgetStack::switchTop() {
414 m_mode = BigScreen; 414 m_mode = BigScreen;
415 /* this works because it is guaranteed that switchStack was called at least once*/ 415 /* this works because it is guaranteed that switchStack was called at least once*/
416 if (!m_stack && m_mWidget) { 416 if (!m_stack && m_mWidget) {
417 m_mWidget->setGeometry( frameRect() ); 417 m_mWidget->setGeometry( frameRect() );
418 return; 418 return;
419 }else if (!m_stack) 419 }else if (!m_stack)
420 return; 420 return;
421 421
422 if (!m_list.isEmpty() ) { 422 if (!m_list.isEmpty() ) {
423 QMap<int, QWidget*>::Iterator it = m_list.begin(); 423 QMap<int, QWidget*>::Iterator it = m_list.begin();
424 for ( ; it != m_list.end(); ++it ) { 424 for ( ; it != m_list.end(); ++it ) {
425 /* better than reparenting twice */ 425 /* better than reparenting twice */
426 if ( it.data() == m_mWidget ) { 426 if ( it.data() == m_mWidget ) {
427 m_mWidget->reparent(this, 0, frameRect().topLeft() ); 427 m_mWidget->reparent(this, 0, frameRect().topLeft() );
428 m_mWidget->setGeometry( frameRect() ); 428 m_mWidget->setGeometry( frameRect() );
429 m_mWidget->show(); 429 m_mWidget->show();
430 }else 430 }else
431 /* ### FIXME we need to place the widget better */ 431 /* ### FIXME we need to place the widget better */
432 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) ); 432 it.data()->reparent(0, WType_TopLevel, QPoint(10, 10) );
433 } 433 }
434 } 434 }
435 435
436 delete m_stack; 436 delete m_stack;
437 m_stack = 0; 437 m_stack = 0;
438} 438}
439 439
440} 440}
441} \ No newline at end of file 441}
diff --git a/libopie2/opieui/ofontselector.cpp b/libopie2/opieui/ofontselector.cpp
index 6763ee6..4870cd9 100644
--- a/libopie2/opieui/ofontselector.cpp
+++ b/libopie2/opieui/ofontselector.cpp
@@ -100,192 +100,193 @@ using namespace Opie::Ui::Internal;
100 100
101static int findItemCB( QComboBox *box, const QString &str ) 101static int findItemCB( QComboBox *box, const QString &str )
102{ 102{
103 for ( int i = 0; i < box->count(); i++ ) 103 for ( int i = 0; i < box->count(); i++ )
104 { 104 {
105 if ( box->text ( i ) == str ) 105 if ( box->text ( i ) == str )
106 return i; 106 return i;
107 } 107 }
108 return -1; 108 return -1;
109} 109}
110 110
111/* static same as anon. namespace */ 111/* static same as anon. namespace */
112static int qt_version() 112static int qt_version()
113{ 113{
114 const char *qver = qVersion(); 114 const char *qver = qVersion();
115 115
116 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' ); 116 return ( qver [0] - '0' ) * 100 + ( qver [2] - '0' ) * 10 + ( qver [4] - '0' );
117} 117}
118 118
119/** 119/**
120 * Constructs the Selector object 120 * Constructs the Selector object
121 * @param withpreview If a font preview should be given 121 * @param withpreview If a font preview should be given
122 * @param parent The parent of the Font Selector 122 * @param parent The parent of the Font Selector
123 * @param name The name of the object 123 * @param name The name of the object
124 * @param fl WidgetFlags 124 * @param fl WidgetFlags
125 */ 125 */
126OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl ) 126OFontSelector::OFontSelector( bool withpreview, QWidget *parent, const char *name, WFlags fl ) : QWidget ( parent, name, fl )
127{ 127{
128 d = new OFontSelectorPrivate(); 128 d = new OFontSelectorPrivate();
129 129
130 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 ); 130 QGridLayout *gridLayout = new QGridLayout( this, 0, 0, 4, 4 );
131 gridLayout->setRowStretch( 4, 10 ); 131 gridLayout->setRowStretch( 4, 10 );
132 132
133 d->m_font_family_list = new QListBox( this, "FontListBox" ); 133 d->m_font_family_list = new QListBox( this, "FontListBox" );
134 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 ); 134 gridLayout->addMultiCellWidget( d->m_font_family_list, 0, 4, 0, 0 );
135 connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) ); 135 connect( d->m_font_family_list, SIGNAL( highlighted(int) ), this, SLOT( fontFamilyClicked(int) ) );
136 136
137 QLabel *label = new QLabel( tr( "Style" ), this ); 137 QLabel *label = new QLabel( tr( "Style" ), this );
138 gridLayout->addWidget( label, 0, 1 ); 138 gridLayout->addWidget( label, 0, 1 );
139 139
140 d->m_font_style_list = new QComboBox( this, "StyleListBox" ); 140 d->m_font_style_list = new QComboBox( this, "StyleListBox" );
141 connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) ); 141 connect( d->m_font_style_list, SIGNAL( activated(int) ), this, SLOT( fontStyleClicked(int) ) );
142 gridLayout->addWidget( d->m_font_style_list, 1, 1 ); 142 gridLayout->addWidget( d->m_font_style_list, 1, 1 );
143 143
144 label = new QLabel( tr( "Size" ), this ); 144 label = new QLabel( tr( "Size" ), this );
145 gridLayout->addWidget( label, 2, 1 ); 145 gridLayout->addWidget( label, 2, 1 );
146 146
147 d->m_font_size_list = new QComboBox( this, "SizeListBox" ); 147 d->m_font_size_list = new QComboBox( this, "SizeListBox" );
148 connect( d->m_font_size_list, SIGNAL( activated(int) ), 148 connect( d->m_font_size_list, SIGNAL( activated(int) ),
149 this, SLOT( fontSizeClicked(int) ) ); 149 this, SLOT( fontSizeClicked(int) ) );
150 gridLayout->addWidget( d->m_font_size_list, 3, 1 ); 150 gridLayout->addWidget( d->m_font_size_list, 3, 1 );
151 151
152 d->m_pointbug = ( qt_version() <= 233 ); 152 d->m_pointbug = ( qt_version() <= 233 );
153 153
154 if ( withpreview ) 154 if ( withpreview )
155 { 155 {
156 d->m_preview = new QMultiLineEdit ( this, "Preview" ); 156 d->m_preview = new QMultiLineEdit ( this, "Preview" );
157 d->m_preview->setAlignment ( AlignCenter ); 157 d->m_preview->setAlignment ( AlignCenter );
158 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth ); 158 d->m_preview->setWordWrap ( QMultiLineEdit::WidgetWidth );
159 d->m_preview->setMargin ( 3 ); 159 d->m_preview->setMargin ( 3 );
160 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" )); 160 d->m_preview->setText ( tr( "The Quick Brown Fox Jumps Over The Lazy Dog" ));
161 gridLayout->addRowSpacing ( 5, 4 ); 161 gridLayout->addRowSpacing ( 5, 4 );
162 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 ); 162 gridLayout->addMultiCellWidget ( d->m_preview, 6, 6, 0, 1 );
163 gridLayout->setRowStretch ( 6, 5 ); 163 gridLayout->setRowStretch ( 6, 5 );
164 } 164 }
165 else 165 else
166 d->m_preview = 0; 166 d->m_preview = 0;
167 167
168 loadFonts ( d->m_font_family_list ); 168 loadFonts ( d->m_font_family_list );
169} 169}
170 170
171OFontSelector::~OFontSelector() 171OFontSelector::~OFontSelector()
172{ 172{
173 delete d; 173 delete d;
174} 174}
175 175
176/** 176/**
177 * This methods tries to set the font 177 * This methods tries to set the font
178 * @param f The wishes font 178 * @param f The wishes font
179 * @return success or failure 179 * @return success or failure
180 */ 180 */
181bool OFontSelector::setSelectedFont ( const QFont &f ) 181bool OFontSelector::setSelectedFont ( const QFont &f )
182{ 182{
183 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet())); 183 return setSelectedFont ( f. family(), d->m_fdb. styleString ( f ), f. pointSize(), QFont::encodingName ( f. charSet()));
184} 184}
185 185
186 186
187/** 187/**
188 * This is an overloaded method @see setSelectedFont 188 * This is an overloaded method @see setSelectedFont
189 * @param familyStr The family of the font 189 * @param familyStr The family of the font
190 * @param styleStr The style of the font 190 * @param styleStr The style of the font
191 * @param sizeVal The size of font 191 * @param sizeVal The size of font
192 * @param charset The charset to be used. Will be deprecated by QT3 192 * @param charset The charset to be used. Will be deprecated by QT3
193 */ 193 */
194bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset ) 194bool OFontSelector::setSelectedFont( const QString &familyStr, const QString &styleStr, int sizeVal, const QString & charset )
195{ 195{
196 Q_CONST_UNUSED( charset )
196 QString sizeStr = QString::number ( sizeVal ); 197 QString sizeStr = QString::number ( sizeVal );
197 198
198 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr ); 199 QListBoxItem *family = d->m_font_family_list->findItem ( familyStr );
199 if ( !family ) 200 if ( !family )
200 family = d->m_font_family_list->findItem ( "Helvetica" ); 201 family = d->m_font_family_list->findItem ( "Helvetica" );
201 if ( !family ) 202 if ( !family )
202 family = d->m_font_family_list->firstItem(); 203 family = d->m_font_family_list->firstItem();
203 d->m_font_family_list->setCurrentItem ( family ); 204 d->m_font_family_list->setCurrentItem ( family );
204 fontFamilyClicked ( d->m_font_family_list->index ( family )); 205 fontFamilyClicked ( d->m_font_family_list->index ( family ));
205 206
206 int style = findItemCB ( d->m_font_style_list, styleStr ); 207 int style = findItemCB ( d->m_font_style_list, styleStr );
207 if ( style < 0 ) 208 if ( style < 0 )
208 style = findItemCB ( d->m_font_style_list, "Regular" ); 209 style = findItemCB ( d->m_font_style_list, "Regular" );
209 if ( style < 0 && d->m_font_style_list->count() > 0 ) 210 if ( style < 0 && d->m_font_style_list->count() > 0 )
210 style = 0; 211 style = 0;
211 d->m_font_style_list->setCurrentItem ( style ); 212 d->m_font_style_list->setCurrentItem ( style );
212 fontStyleClicked ( style ); 213 fontStyleClicked ( style );
213 214
214 int size = findItemCB ( d->m_font_size_list, sizeStr ); 215 int size = findItemCB ( d->m_font_size_list, sizeStr );
215 if ( size < 0 ) 216 if ( size < 0 )
216 size = findItemCB ( d->m_font_size_list, "10" ); 217 size = findItemCB ( d->m_font_size_list, "10" );
217 if ( size < 0 && d->m_font_size_list->count() > 0 ) 218 if ( size < 0 && d->m_font_size_list->count() > 0 )
218 size = 0; 219 size = 0;
219 d->m_font_size_list->setCurrentItem ( size ); 220 d->m_font_size_list->setCurrentItem ( size );
220 fontSizeClicked ( size ); 221 fontSizeClicked ( size );
221 222
222 return (( family ) && ( style >= 0 ) && ( size >= 0 )); 223 return (( family ) && ( style >= 0 ) && ( size >= 0 ));
223} 224}
224 225
225/** 226/**
226 * This method returns the name, style and size of the currently selected 227 * This method returns the name, style and size of the currently selected
227 * font or false if no font is selected 228 * font or false if no font is selected
228 * @param family The font family will be written there 229 * @param family The font family will be written there
229 * @param style The style will be written there 230 * @param style The style will be written there
230 * @param size The size will be written there 231 * @param size The size will be written there
231 * @return success or failure 232 * @return success or failure
232 */ 233 */
233bool OFontSelector::selectedFont ( QString &family, QString &style, int &size ) 234bool OFontSelector::selectedFont ( QString &family, QString &style, int &size )
234{ 235{
235 QString dummy; 236 QString dummy;
236 return selectedFont ( family, style, size, dummy ); 237 return selectedFont ( family, style, size, dummy );
237} 238}
238 239
239 240
240/** 241/**
241 * This method does return the font family or QString::null if there is 242 * This method does return the font family or QString::null if there is
242 * no font item selected 243 * no font item selected
243 * @return the font family 244 * @return the font family
244 */ 245 */
245QString OFontSelector::fontFamily() const 246QString OFontSelector::fontFamily() const
246{ 247{
247 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 248 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
248 249
249 return fli ? fli->family() : QString::null; 250 return fli ? fli->family() : QString::null;
250} 251}
251 252
252/** 253/**
253 * This method will return the style of the font or QString::null 254 * This method will return the style of the font or QString::null
254 * @return the style of the font 255 * @return the style of the font
255 */ 256 */
256QString OFontSelector::fontStyle() const 257QString OFontSelector::fontStyle() const
257{ 258{
258 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 259 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
259 int fst = d->m_font_style_list->currentItem(); 260 int fst = d->m_font_style_list->currentItem();
260 261
261 return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null; 262 return ( fli && fst >= 0 ) ? fli->styles() [fst] : QString::null;
262} 263}
263 264
264/** 265/**
265 * This method will return the font size or 10 if no font size is available 266 * This method will return the font size or 10 if no font size is available
266 */ 267 */
267int OFontSelector::fontSize() const 268int OFontSelector::fontSize() const
268{ 269{
269 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 270 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
270 int fsi = d->m_font_size_list->currentItem(); 271 int fsi = d->m_font_size_list->currentItem();
271 272
272 return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10; 273 return ( fli && fsi >= 0 ) ? fli->sizes() [fsi] : 10;
273} 274}
274 275
275/** 276/**
276 * returns the charset of the font or QString::null 277 * returns the charset of the font or QString::null
277 */ 278 */
278QString OFontSelector::fontCharSet() const 279QString OFontSelector::fontCharSet() const
279{ 280{
280 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem()); 281 FontListItem *fli = (FontListItem *) d->m_font_family_list->item ( d->m_font_family_list->currentItem());
281 282
282 return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null; 283 return fli ? d->m_fdb. charSets ( fli->family()) [0] : QString::null;
283} 284}
284 285
285/** 286/**
286 * Overloaded member function see above 287 * Overloaded member function see above
287 * @see selectedFont 288 * @see selectedFont
288 */ 289 */
289bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset ) 290bool OFontSelector::selectedFont ( QString &family, QString &style, int &size, QString &charset )
290{ 291{
291 int ffa = d->m_font_family_list->currentItem(); 292 int ffa = d->m_font_family_list->currentItem();
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp
index b90c786..67b4b83 100644
--- a/libopie2/opieui/olistview.cpp
+++ b/libopie2/opieui/olistview.cpp
@@ -94,242 +94,244 @@ int OListView::addColumn( const QIconSet& iconset, const QString& label, int wid
94 header()->setStretchEnabled( true, columns()-1 ); 94 header()->setStretchEnabled( true, columns()-1 );
95 } 95 }
96 #endif 96 #endif
97 return result; 97 return result;
98} 98}
99 99
100void OListView::removeColumn( int index ) 100void OListView::removeColumn( int index )
101{ 101{
102 QListView::removeColumn(index); 102 QListView::removeColumn(index);
103 #if QT_VERSION > 290 103 #if QT_VERSION > 290
104 if ( m_fullWidth && index == columns() ) 104 if ( m_fullWidth && index == columns() )
105 { 105 {
106 header()->setStretchEnabled( true, columns()-1 ); 106 header()->setStretchEnabled( true, columns()-1 );
107 } 107 }
108 #endif 108 #endif
109} 109}
110 110
111const QColor& OListView::alternateBackground() const 111const QColor& OListView::alternateBackground() const
112{ 112{
113 return m_alternateBackground; 113 return m_alternateBackground;
114} 114}
115 115
116void OListView::setAlternateBackground( const QColor &c ) 116void OListView::setAlternateBackground( const QColor &c )
117{ 117{
118 m_alternateBackground = c; 118 m_alternateBackground = c;
119 repaint(); 119 repaint();
120} 120}
121 121
122const QPen& OListView::columnSeparator() const 122const QPen& OListView::columnSeparator() const
123{ 123{
124 return m_columnSeparator; 124 return m_columnSeparator;
125} 125}
126 126
127void OListView::setColumnSeparator( const QPen& p ) 127void OListView::setColumnSeparator( const QPen& p )
128{ 128{
129 m_columnSeparator = p; 129 m_columnSeparator = p;
130 repaint(); 130 repaint();
131} 131}
132 132
133void OListView::expand(QListViewItem *item) 133void OListView::expand(QListViewItem *item)
134{ 134{
135 ((OListViewItem*)item)->expand(); 135 ((OListViewItem*)item)->expand();
136} 136}
137 137
138OListViewItem* OListView::childFactory() 138OListViewItem* OListView::childFactory()
139{ 139{
140 return new OListViewItem( this ); 140 return new OListViewItem( this );
141} 141}
142 142
143#ifndef QT_NO_DATASTREAM 143#ifndef QT_NO_DATASTREAM
144void OListView::serializeTo( QDataStream& s ) const 144void OListView::serializeTo( QDataStream& s ) const
145{ 145{
146 #warning Caution... the binary format is still under construction... 146 #warning Caution... the binary format is still under construction...
147 odebug << "storing OListView..." << oendl; 147 odebug << "storing OListView..." << oendl;
148 148
149 // store number of columns and the labels 149 // store number of columns and the labels
150 s << columns(); 150 s << columns();
151 for ( int i = 0; i < columns(); ++i ) 151 for ( int i = 0; i < columns(); ++i )
152 s << columnText( i ); 152 s << columnText( i );
153 153
154 // calculate the number of top-level items to serialize 154 // calculate the number of top-level items to serialize
155 int items = 0; 155 int items = 0;
156 QListViewItem* item = firstChild(); 156 QListViewItem* item = firstChild();
157 while ( item ) 157 while ( item )
158 { 158 {
159 item = item->nextSibling(); 159 item = item->nextSibling();
160 items++; 160 items++;
161 } 161 }
162 162
163 // store number of items and the items itself 163 // store number of items and the items itself
164 s << items; 164 s << items;
165 item = firstChild(); 165 item = firstChild();
166 for ( int i = 0; i < items; ++i ) 166 for ( int i = 0; i < items; ++i )
167 { 167 {
168 s << *static_cast<OListViewItem*>( item ); 168 s << *static_cast<OListViewItem*>( item );
169 item = item->nextSibling(); 169 item = item->nextSibling();
170 } 170 }
171 171
172 odebug << "OListview stored." << oendl; 172 odebug << "OListview stored." << oendl;
173} 173}
174 174
175void OListView::serializeFrom( QDataStream& s ) 175void OListView::serializeFrom( QDataStream& s )
176{ 176{
177 #warning Caution... the binary format is still under construction... 177 #warning Caution... the binary format is still under construction...
178 odebug << "loading OListView..." << oendl; 178 odebug << "loading OListView..." << oendl;
179 179
180 int cols; 180 int cols;
181 s >> cols; 181 s >> cols;
182 odebug << "read number of columns = " << cols << oendl; 182 odebug << "read number of columns = " << cols << oendl;
183 183
184 while ( columns() < cols ) addColumn( QString::null ); 184 while ( columns() < cols ) addColumn( QString::null );
185 185
186 for ( int i = 0; i < cols; ++i ) 186 for ( int i = 0; i < cols; ++i )
187 { 187 {
188 QString coltext; 188 QString coltext;
189 s >> coltext; 189 s >> coltext;
190 odebug << "read text '" << coltext << "' for column " << i << "" << oendl; 190 odebug << "read text '" << coltext << "' for column " << i << "" << oendl;
191 setColumnText( i, coltext ); 191 setColumnText( i, coltext );
192 } 192 }
193 193
194 int items; 194 int items;
195 s >> items; 195 s >> items;
196 odebug << "read number of items = " << items << oendl; 196 odebug << "read number of items = " << items << oendl;
197 197
198 for ( int i = 0; i < items; ++i ) 198 for ( int i = 0; i < items; ++i )
199 { 199 {
200 OListViewItem* item = childFactory(); 200 OListViewItem* item = childFactory();
201 s >> *item; 201 s >> *item;
202 } 202 }
203 203
204 odebug << "OListView loaded." << oendl; 204 odebug << "OListView loaded." << oendl;
205 205
206} 206}
207 207
208 208
209void OListView::expand() 209void OListView::expand()
210{ 210{
211 odebug << "OListView::expand" << oendl; 211 odebug << "OListView::expand" << oendl;
212 212
213 QListViewItemIterator it( this ); 213 QListViewItemIterator it( this );
214 while ( it.current() ) { 214 while ( it.current() ) {
215 it.current()->setOpen( true ); 215 it.current()->setOpen( true );
216 ++it; 216 ++it;
217 } 217 }
218} 218}
219 219
220 220
221void OListView::collapse() 221void OListView::collapse()
222{ 222{
223 odebug << "OListView::collapse" << oendl; 223 odebug << "OListView::collapse" << oendl;
224 QListViewItemIterator it( this ); 224 QListViewItemIterator it( this );
225 while ( it.current() ) { 225 while ( it.current() ) {
226 it.current()->setOpen( false ); 226 it.current()->setOpen( false );
227 ++it; 227 ++it;
228 } 228 }
229} 229}
230 230
231 231
232QDataStream& operator<<( QDataStream& s, const OListView& lv ) 232QDataStream& operator<<( QDataStream& s, const OListView& lv )
233{ 233{
234 lv.serializeTo( s ); 234 lv.serializeTo( s );
235 return s;
235} 236}
236 237
237QDataStream& operator>>( QDataStream& s, OListView& lv ) 238QDataStream& operator>>( QDataStream& s, OListView& lv )
238{ 239{
239 lv.serializeFrom( s ); 240 lv.serializeFrom( s );
241 return s;
240} 242}
241#endif // QT_NO_DATASTREAM 243#endif // QT_NO_DATASTREAM
242 244
243/*====================================================================================== 245/*======================================================================================
244 * OListViewItem 246 * OListViewItem
245 *======================================================================================*/ 247 *======================================================================================*/
246 248
247OListViewItem::OListViewItem(QListView *parent) 249OListViewItem::OListViewItem(QListView *parent)
248 : QListViewItem(parent) 250 : QListViewItem(parent)
249{ 251{
250 init(); 252 init();
251} 253}
252 254
253 255
254OListViewItem::OListViewItem(QListViewItem *parent) 256OListViewItem::OListViewItem(QListViewItem *parent)
255 : QListViewItem(parent) 257 : QListViewItem(parent)
256{ 258{
257 init(); 259 init();
258} 260}
259 261
260 262
261OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) 263OListViewItem::OListViewItem(QListView *parent, QListViewItem *after)
262 : QListViewItem(parent, after) 264 : QListViewItem(parent, after)
263{ 265{
264 init(); 266 init();
265} 267}
266 268
267 269
268OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) 270OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after)
269 : QListViewItem(parent, after) 271 : QListViewItem(parent, after)
270{ 272{
271 init(); 273 init();
272} 274}
273 275
274 276
275OListViewItem::OListViewItem(QListView *parent, 277OListViewItem::OListViewItem(QListView *parent,
276 QString label1, QString label2, QString label3, QString label4, 278 QString label1, QString label2, QString label3, QString label4,
277 QString label5, QString label6, QString label7, QString label8) 279 QString label5, QString label6, QString label7, QString label8)
278 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 280 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
279{ 281{
280 init(); 282 init();
281} 283}
282 284
283 285
284OListViewItem::OListViewItem(QListViewItem *parent, 286OListViewItem::OListViewItem(QListViewItem *parent,
285 QString label1, QString label2, QString label3, QString label4, 287 QString label1, QString label2, QString label3, QString label4,
286 QString label5, QString label6, QString label7, QString label8) 288 QString label5, QString label6, QString label7, QString label8)
287 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 289 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
288{ 290{
289 init(); 291 init();
290} 292}
291 293
292 294
293OListViewItem::OListViewItem(QListView *parent, QListViewItem *after, 295OListViewItem::OListViewItem(QListView *parent, QListViewItem *after,
294 QString label1, QString label2, QString label3, QString label4, 296 QString label1, QString label2, QString label3, QString label4,
295 QString label5, QString label6, QString label7, QString label8) 297 QString label5, QString label6, QString label7, QString label8)
296 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 298 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
297{ 299{
298 init(); 300 init();
299} 301}
300 302
301 303
302OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after, 304OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after,
303 QString label1, QString label2, QString label3, QString label4, 305 QString label1, QString label2, QString label3, QString label4,
304 QString label5, QString label6, QString label7, QString label8) 306 QString label5, QString label6, QString label7, QString label8)
305 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 307 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
306{ 308{
307 init(); 309 init();
308} 310}
309 311
310 312
311OListViewItem::~OListViewItem() 313OListViewItem::~OListViewItem()
312{ 314{
313} 315}
314 316
315 317
316void OListViewItem::init() 318void OListViewItem::init()
317{ 319{
318 m_known = false; 320 m_known = false;
319} 321}
320 322
321 323
322const QColor &OListViewItem::backgroundColor() 324const QColor &OListViewItem::backgroundColor()
323{ 325{
324 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : 326 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() :
325 listView()->viewport()->colorGroup().base(); 327 listView()->viewport()->colorGroup().base();
326} 328}
327 329
328 330
329bool OListViewItem::isAlternate() 331bool OListViewItem::isAlternate()
330{ 332{
331 OListView *lv = static_cast<OListView*>( listView() ); 333 OListView *lv = static_cast<OListView*>( listView() );
332 334
333 // check if the item above is an OListViewItem 335 // check if the item above is an OListViewItem
334 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() ); 336 OListViewItem *above = static_cast<OListViewItem*>( itemAbove() );
335 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/ 337 /*if (! itemAbove()->inherits( "OListViewItem" )) return false;*/
@@ -349,416 +351,418 @@ bool OListViewItem::isAlternate()
349 if (parent()) 351 if (parent())
350 { 352 {
351 item = static_cast<OListViewItem *>(parent()); 353 item = static_cast<OListViewItem *>(parent());
352 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; 354 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd;
353 item = static_cast<OListViewItem *>(parent()->firstChild()); 355 item = static_cast<OListViewItem *>(parent()->firstChild());
354 /* if ( !item.inherits( "OListViewItem" ) item = 0; */ 356 /* if ( !item.inherits( "OListViewItem" ) item = 0; */
355 } 357 }
356 else 358 else
357 { 359 {
358 item = static_cast<OListViewItem *>(lv->firstChild()); 360 item = static_cast<OListViewItem *>(lv->firstChild());
359 } 361 }
360 362
361 while(item) 363 while(item)
362 { 364 {
363 item->m_odd = previous = !previous; 365 item->m_odd = previous = !previous;
364 item->m_known = true; 366 item->m_known = true;
365 item = static_cast<OListViewItem *>(item->nextSibling()); 367 item = static_cast<OListViewItem *>(item->nextSibling());
366 /* if (!item.inherits( "OListViewItem" ) ) break; */ 368 /* if (!item.inherits( "OListViewItem" ) ) break; */
367 } 369 }
368 } 370 }
369 return m_odd; 371 return m_odd;
370} 372}
371 373
372 374
373void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 375void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
374{ 376{
375 QColorGroup _cg = cg; 377 QColorGroup _cg = cg;
376 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 378 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
377 if (pm && !pm->isNull()) 379 if (pm && !pm->isNull())
378 { 380 {
379 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); 381 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) );
380 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 382 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
381 } 383 }
382 else if ( isAlternate() ) 384 else if ( isAlternate() )
383 { 385 {
384 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); 386 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
385 } 387 }
386 QListViewItem::paintCell( p, _cg, column, width, alignment ); 388 QListViewItem::paintCell( p, _cg, column, width, alignment );
387 389
388 //FIXME: Use styling here! 390 //FIXME: Use styling here!
389 391
390 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); 392 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
391 p->setPen( pen ); 393 p->setPen( pen );
392 p->drawLine( width-1, 0, width-1, height() ); 394 p->drawLine( width-1, 0, width-1, height() );
393} 395}
394 396
395 397
396OListViewItem* OListViewItem::childFactory() 398OListViewItem* OListViewItem::childFactory()
397{ 399{
398 return new OListViewItem( this ); 400 return new OListViewItem( this );
399} 401}
400 402
401 403
402#ifndef QT_NO_DATASTREAM 404#ifndef QT_NO_DATASTREAM
403void OListViewItem::serializeTo( QDataStream& s ) const 405void OListViewItem::serializeTo( QDataStream& s ) const
404{ 406{
405 #warning Caution... the binary format is still under construction... 407 #warning Caution... the binary format is still under construction...
406 odebug << "storing OListViewItem..." << oendl; 408 odebug << "storing OListViewItem..." << oendl;
407 409
408 // store item text 410 // store item text
409 for ( int i = 0; i < listView()->columns(); ++i ) 411 for ( int i = 0; i < listView()->columns(); ++i )
410 { 412 {
411 s << text( i ); 413 s << text( i );
412 } 414 }
413 415
414 // calculate the number of children to serialize 416 // calculate the number of children to serialize
415 int items = 0; 417 int items = 0;
416 QListViewItem* item = firstChild(); 418 QListViewItem* item = firstChild();
417 while ( item ) 419 while ( item )
418 { 420 {
419 item = item->nextSibling(); 421 item = item->nextSibling();
420 items++; 422 items++;
421 } 423 }
422 424
423 // store number of items and the items itself 425 // store number of items and the items itself
424 s << items; 426 s << items;
425 item = firstChild(); 427 item = firstChild();
426 for ( int i = 0; i < items; ++i ) 428 for ( int i = 0; i < items; ++i )
427 { 429 {
428 s << *static_cast<OListViewItem*>( item ); 430 s << *static_cast<OListViewItem*>( item );
429 item = item->nextSibling(); 431 item = item->nextSibling();
430 } 432 }
431 433
432 odebug << "OListviewItem stored." << oendl; 434 odebug << "OListviewItem stored." << oendl;
433} 435}
434 436
435 437
436void OListViewItem::serializeFrom( QDataStream& s ) 438void OListViewItem::serializeFrom( QDataStream& s )
437{ 439{
438 #warning Caution... the binary format is still under construction... 440 #warning Caution... the binary format is still under construction...
439 odebug << "loading OListViewItem..." << oendl; 441 odebug << "loading OListViewItem..." << oendl;
440 442
441 for ( int i = 0; i < listView()->columns(); ++i ) 443 for ( int i = 0; i < listView()->columns(); ++i )
442 { 444 {
443 QString coltext; 445 QString coltext;
444 s >> coltext; 446 s >> coltext;
445 odebug << "read text '" << coltext << "' for column " << i << "" << oendl; 447 odebug << "read text '" << coltext << "' for column " << i << "" << oendl;
446 setText( i, coltext ); 448 setText( i, coltext );
447 } 449 }
448 450
449 int items; 451 int items;
450 s >> items; 452 s >> items;
451 odebug << "read number of items = " << items << "" << oendl; 453 odebug << "read number of items = " << items << "" << oendl;
452 454
453 for ( int i = 0; i < items; ++i ) 455 for ( int i = 0; i < items; ++i )
454 { 456 {
455 OListViewItem* item = childFactory(); 457 OListViewItem* item = childFactory();
456 s >> (*item); 458 s >> (*item);
457 } 459 }
458 460
459 odebug << "OListViewItem loaded." << oendl; 461 odebug << "OListViewItem loaded." << oendl;
460} 462}
461 463
462 464
463QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) 465QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi )
464{ 466{
465 lvi.serializeTo( s ); 467 lvi.serializeTo( s );
468 return s;
466} 469}
467 470
468 471
469QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) 472QDataStream& operator>>( QDataStream& s, OListViewItem& lvi )
470{ 473{
471 lvi.serializeFrom( s ); 474 lvi.serializeFrom( s );
475 return s;
472} 476}
473#endif // QT_NO_DATASTREAM 477#endif // QT_NO_DATASTREAM
474 478
475 479
476/*====================================================================================== 480/*======================================================================================
477 * OCheckListItem 481 * OCheckListItem
478 *======================================================================================*/ 482 *======================================================================================*/
479 483
480OCheckListItem::OCheckListItem( QCheckListItem* parent, const QString& text, Type t ) 484OCheckListItem::OCheckListItem( QCheckListItem* parent, const QString& text, Type t )
481 :QCheckListItem( parent, text, t ) 485 :QCheckListItem( parent, text, t )
482{ 486{
483 init(); 487 init();
484} 488}
485 489
486 490
487OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, Type t) 491OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, Type t)
488 :QCheckListItem( parent, text, t ) 492 :QCheckListItem( parent, text, t )
489{ 493{
490 init(); 494 init();
491} 495}
492 496
493 497
494OCheckListItem::OCheckListItem( QListView* parent, const QString& text, Type t ) 498OCheckListItem::OCheckListItem( QListView* parent, const QString& text, Type t )
495 :QCheckListItem( parent, text, t ) 499 :QCheckListItem( parent, text, t )
496{ 500{
497 init(); 501 init();
498} 502}
499 503
500 504
501OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, const QPixmap& p ) 505OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, const QPixmap& p )
502 :QCheckListItem( parent, text, p ) 506 :QCheckListItem( parent, text, p )
503{ 507{
504 init(); 508 init();
505} 509}
506 510
507 511
508OCheckListItem::OCheckListItem( QListView* parent, const QString& text, const QPixmap& p ) 512OCheckListItem::OCheckListItem( QListView* parent, const QString& text, const QPixmap& p )
509 :QCheckListItem( parent, text, p ) 513 :QCheckListItem( parent, text, p )
510{ 514{
511 init(); 515 init();
512} 516}
513 517
514 518
515OCheckListItem::~OCheckListItem() 519OCheckListItem::~OCheckListItem()
516{ 520{
517} 521}
518 522
519void OCheckListItem::init() 523void OCheckListItem::init()
520{ 524{
521 m_known = false; 525 m_known = false;
522} 526}
523 527
524 528
525const QColor &OCheckListItem::backgroundColor() 529const QColor &OCheckListItem::backgroundColor()
526{ 530{
527 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : 531 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() :
528 listView()->viewport()->colorGroup().base(); 532 listView()->viewport()->colorGroup().base();
529} 533}
530 534
531 535
532bool OCheckListItem::isAlternate() 536bool OCheckListItem::isAlternate()
533{ 537{
534 OListView *lv = static_cast<OListView*>( listView() ); 538 OListView *lv = static_cast<OListView*>( listView() );
535 539
536 // check if the item above is an OCheckListItem 540 // check if the item above is an OCheckListItem
537 OCheckListItem *above = static_cast<OCheckListItem*>( itemAbove() ); 541 OCheckListItem *above = static_cast<OCheckListItem*>( itemAbove() );
538 /*if (! itemAbove()->inherits( "OCheckListItem" )) return false;*/ 542 /*if (! itemAbove()->inherits( "OCheckListItem" )) return false;*/
539 543
540 // check if we have a valid alternate background color 544 // check if we have a valid alternate background color
541 if (!(lv && lv->alternateBackground().isValid())) return false; 545 if (!(lv && lv->alternateBackground().isValid())) return false;
542 546
543 m_known = above ? above->m_known : true; 547 m_known = above ? above->m_known : true;
544 if (m_known) 548 if (m_known)
545 { 549 {
546 m_odd = above ? !above->m_odd : false; 550 m_odd = above ? !above->m_odd : false;
547 } 551 }
548 else 552 else
549 { 553 {
550 OCheckListItem *item; 554 OCheckListItem *item;
551 bool previous = true; 555 bool previous = true;
552 if (parent()) 556 if (parent())
553 { 557 {
554 item = static_cast<OCheckListItem *>(parent()); 558 item = static_cast<OCheckListItem *>(parent());
555 if ( item /*&& item->inherits( "OCheckListItem" )*/ ) previous = item->m_odd; 559 if ( item /*&& item->inherits( "OCheckListItem" )*/ ) previous = item->m_odd;
556 item = static_cast<OCheckListItem *>(parent()->firstChild()); 560 item = static_cast<OCheckListItem *>(parent()->firstChild());
557 /* if ( !item.inherits( "OCheckListItem" ) item = 0; */ 561 /* if ( !item.inherits( "OCheckListItem" ) item = 0; */
558 } 562 }
559 else 563 else
560 { 564 {
561 item = static_cast<OCheckListItem *>(lv->firstChild()); 565 item = static_cast<OCheckListItem *>(lv->firstChild());
562 } 566 }
563 567
564 while(item) 568 while(item)
565 { 569 {
566 item->m_odd = previous = !previous; 570 item->m_odd = previous = !previous;
567 item->m_known = true; 571 item->m_known = true;
568 item = static_cast<OCheckListItem *>(item->nextSibling()); 572 item = static_cast<OCheckListItem *>(item->nextSibling());
569 /* if (!item.inherits( "OCheckListItem" ) ) break; */ 573 /* if (!item.inherits( "OCheckListItem" ) ) break; */
570 } 574 }
571 } 575 }
572 return m_odd; 576 return m_odd;
573} 577}
574 578
575 579
576void OCheckListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 580void OCheckListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
577{ 581{
578 QColorGroup _cg = cg; 582 QColorGroup _cg = cg;
579 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 583 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
580 if (pm && !pm->isNull()) 584 if (pm && !pm->isNull())
581 { 585 {
582 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); 586 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) );
583 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 587 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
584 } 588 }
585 else if ( isAlternate() ) 589 else if ( isAlternate() )
586 { 590 {
587 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); 591 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
588 } 592 }
589 QCheckListItem::paintCell( p, _cg, column, width, alignment ); 593 QCheckListItem::paintCell( p, _cg, column, width, alignment );
590 594
591 //FIXME: Use styling here! 595 //FIXME: Use styling here!
592 596
593 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); 597 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
594 p->setPen( pen ); 598 p->setPen( pen );
595 p->drawLine( width-1, 0, width-1, height() ); 599 p->drawLine( width-1, 0, width-1, height() );
596} 600}
597 601
598 602
599/*====================================================================================== 603/*======================================================================================
600 * ONamedListView 604 * ONamedListView
601 *======================================================================================*/ 605 *======================================================================================*/
602 606
603ONamedListView::ONamedListView( QWidget *parent, const char *name ) 607ONamedListView::ONamedListView( QWidget *parent, const char *name )
604 :OListView( parent, name ) 608 :OListView( parent, name )
605{ 609{
606} 610}
607 611
608 612
609ONamedListView::~ONamedListView() 613ONamedListView::~ONamedListView()
610{ 614{
611} 615}
612 616
613 617
614void ONamedListView::addColumns( const QStringList& columns ) 618void ONamedListView::addColumns( const QStringList& columns )
615{ 619{
616 for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it ) 620 for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it )
617 { 621 {
618 odebug << "adding column " << *it << "" << oendl; 622 odebug << "adding column " << *it << "" << oendl;
619 addColumn( *it ); 623 addColumn( *it );
620 } 624 }
621} 625}
622 626
623 627
624int ONamedListView::findColumn( const QString& text ) const 628int ONamedListView::findColumn( const QString& text ) const
625{ 629{
626 //FIXME: If used excessively, this will slow down performance of updates 630 //FIXME: If used excessively, this will slow down performance of updates
627 //FIXME: because of the linear search over all column texts. 631 //FIXME: because of the linear search over all column texts.
628 //FIXME: I will optimize later by using a hash map. 632 //FIXME: I will optimize later by using a hash map.
629 for ( int i = 0; i < columns(); ++i ) 633 for ( int i = 0; i < columns(); ++i )
630 if ( columnText( i ) == text ) 634 if ( columnText( i ) == text )
631 return i; 635 return i;
632 return -1; 636 return -1;
633} 637}
634 638
635 639
636ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const 640ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const
637{ 641{
638 return find( (ONamedListViewItem*) firstChild(), column, text, recurse ); 642 return find( (ONamedListViewItem*) firstChild(), column, text, recurse );
639} 643}
640 644
641 645
642ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const 646ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const
643{ 647{
644 ONamedListViewItem* result; 648 ONamedListViewItem* result;
645 while ( item && item->text( column ) != text ) 649 while ( item && item->text( column ) != text )
646 { 650 {
647 odebug << "checked " << item->text( column ) << "" << oendl; 651 odebug << "checked " << item->text( column ) << "" << oendl;
648 652
649 if ( recurse < 0 || recurse > 0 ) 653 if ( recurse < 0 || recurse > 0 )
650 { 654 {
651 odebug << "recursion is " << recurse << " - recursing into..." << oendl; 655 odebug << "recursion is " << recurse << " - recursing into..." << oendl;
652 result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 ); 656 result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 );
653 if ( result ) return result; 657 if ( result ) return result;
654 } 658 }
655 659
656 660
657 item = (ONamedListViewItem*) item->itemBelow(); 661 item = (ONamedListViewItem*) item->itemBelow();
658 } 662 }
659 if ( item && item->text( column ) == text ) 663 if ( item && item->text( column ) == text )
660 return item; 664 return item;
661 else 665 else
662 return 0; 666 return 0;
663} 667}
664 668
665 669
666ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const 670ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const
667{ 671{
668 int col = findColumn( column ); 672 int col = findColumn( column );
669 if ( col != -1 ) 673 if ( col != -1 )
670 return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); 674 return find( (ONamedListViewItem*) firstChild(), col, text, recurse );
671 else 675 else
672 return 0; 676 return 0;
673} 677}
674 678
675 679
676ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const 680ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const
677{ 681{
678 int col = findColumn( column ); 682 int col = findColumn( column );
679 if ( col != -1 ) 683 if ( col != -1 )
680 return find( item, col, text, recurse ); 684 return find( item, col, text, recurse );
681 else 685 else
682 return 0; 686 return 0;
683} 687}
684 688
685 689
686/*====================================================================================== 690/*======================================================================================
687 * ONamedListViewItem 691 * ONamedListViewItem
688 *======================================================================================*/ 692 *======================================================================================*/
689 693
690ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) 694ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts )
691 :OListViewItem( parent ) 695 :OListViewItem( parent )
692{ 696{
693 setText( texts ); 697 setText( texts );
694} 698}
695 699
696 700
697ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) 701ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts )
698 :OListViewItem( parent ) 702 :OListViewItem( parent )
699{ 703{
700 setText( texts ); 704 setText( texts );
701} 705}
702 706
703 707
704ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) 708ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts )
705 :OListViewItem( parent, after ) 709 :OListViewItem( parent, after )
706{ 710{
707 setText( texts ); 711 setText( texts );
708} 712}
709 713
710 714
711ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) 715ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts )
712 :OListViewItem( parent, after ) 716 :OListViewItem( parent, after )
713{ 717{
714 setText( texts ); 718 setText( texts );
715} 719}
716 720
717 721
718ONamedListViewItem::~ONamedListViewItem() 722ONamedListViewItem::~ONamedListViewItem()
719{ 723{
720} 724}
721 725
722 726
723void ONamedListViewItem::setText( const QStringList& texts ) 727void ONamedListViewItem::setText( const QStringList& texts )
724{ 728{
725 int col = 0; 729 int col = 0;
726 for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) 730 for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it )
727 { 731 {
728 odebug << "setting column " << col << " = text " << *it << "" << oendl; 732 odebug << "setting column " << col << " = text " << *it << "" << oendl;
729 OListViewItem::setText( col++, *it ); 733 OListViewItem::setText( col++, *it );
730 } 734 }
731 735
732} 736}
733 737
734 738
735void ONamedListViewItem::setText( const QString& column, const QString& text ) 739void ONamedListViewItem::setText( const QString& column, const QString& text )
736{ 740{
737 //FIXME: If used excessively, this will slow down performance of updates 741 //FIXME: If used excessively, this will slow down performance of updates
738 //FIXME: because of the linear search over all column texts. 742 //FIXME: because of the linear search over all column texts.
739 //FIXME: I will optimize later by using a hash map. 743 //FIXME: I will optimize later by using a hash map.
740 int col = ( (ONamedListView*) listView() )->findColumn( column ); 744 int col = ( (ONamedListView*) listView() )->findColumn( column );
741 if ( col != -1 ) 745 if ( col != -1 )
742 OListViewItem::setText( col, text ); 746 OListViewItem::setText( col, text );
743 else 747 else
744 owarn << "ONamedListViewItem::setText(): Warning! Columntext '" << column << "' not found." << oendl; 748 owarn << "ONamedListViewItem::setText(): Warning! Columntext '" << column << "' not found." << oendl;
745} 749}
746 750
747 751
748ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const 752ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const
749{ 753{
750 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); 754 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse );
751} 755}
752 756
753 757
754ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const 758ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const
755{ 759{
756 int col = ( (ONamedListView*) listView() )->findColumn( column ); 760 int col = ( (ONamedListView*) listView() )->findColumn( column );
757 if ( col != -1 ) 761 if ( col != -1 )
758 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); 762 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse );
759 else 763 else
760 return 0; 764 return 0;
761} 765}
762 766
763} 767}
764} 768}
diff --git a/libopie2/opieui/oselector.cpp b/libopie2/opieui/oselector.cpp
index 5f6f10f..05543c5 100644
--- a/libopie2/opieui/oselector.cpp
+++ b/libopie2/opieui/oselector.cpp
@@ -53,192 +53,194 @@ OXYSelector::OXYSelector( QWidget *parent, const char *name )
53 53
54 54
55OXYSelector::~OXYSelector() 55OXYSelector::~OXYSelector()
56{} 56{}
57 57
58 58
59void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY ) 59void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY )
60{ 60{
61 px = 2; 61 px = 2;
62 py = 2; 62 py = 2;
63 minX = _minX; 63 minX = _minX;
64 minY = _minY; 64 minY = _minY;
65 maxX = _maxX; 65 maxX = _maxX;
66 maxY = _maxY; 66 maxY = _maxY;
67} 67}
68 68
69void OXYSelector::setValues( int _xPos, int _yPos ) 69void OXYSelector::setValues( int _xPos, int _yPos )
70{ 70{
71 xPos = _xPos; 71 xPos = _xPos;
72 yPos = _yPos; 72 yPos = _yPos;
73 73
74 if ( xPos > maxX ) 74 if ( xPos > maxX )
75 xPos = maxX; 75 xPos = maxX;
76 else if ( xPos < minX ) 76 else if ( xPos < minX )
77 xPos = minX; 77 xPos = minX;
78 78
79 if ( yPos > maxY ) 79 if ( yPos > maxY )
80 yPos = maxY; 80 yPos = maxY;
81 else if ( yPos < minY ) 81 else if ( yPos < minY )
82 yPos = minY; 82 yPos = minY;
83 83
84 int xp = 2 + (width() - 4) * xPos / (maxX - minX); 84 int xp = 2 + (width() - 4) * xPos / (maxX - minX);
85 int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY); 85 int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY);
86 86
87 setPosition( xp, yp ); 87 setPosition( xp, yp );
88} 88}
89 89
90QRect OXYSelector::contentsRect() const 90QRect OXYSelector::contentsRect() const
91{ 91{
92 return QRect( 2, 2, width()-4, height()-4 ); 92 return QRect( 2, 2, width()-4, height()-4 );
93} 93}
94 94
95void OXYSelector::paintEvent( QPaintEvent *ev ) 95void OXYSelector::paintEvent( QPaintEvent *ev )
96{ 96{
97 QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2); 97 QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2);
98 QRect paintRect = ev->rect(); 98 QRect paintRect = ev->rect();
99 99
100 QPainter painter; 100 QPainter painter;
101 painter.begin( this ); 101 painter.begin( this );
102 102
103 QBrush brush; 103 QBrush brush;
104 qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(), 104 qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(),
105 TRUE, 2, &brush ); 105 TRUE, 2, &brush );
106 106
107 drawContents( &painter ); 107 drawContents( &painter );
108 if (paintRect.contains(cursorRect)) 108 if (paintRect.contains(cursorRect))
109 { 109 {
110 bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W, 110 bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W,
111 STORE_W2, STORE_W2, CopyROP ); 111 STORE_W2, STORE_W2, CopyROP );
112 drawCursor( &painter, px, py ); 112 drawCursor( &painter, px, py );
113 } 113 }
114 else if (paintRect.intersects(cursorRect)) 114 else if (paintRect.intersects(cursorRect))
115 { 115 {
116 repaint( cursorRect, false); 116 repaint( cursorRect, false);
117 } 117 }
118 118
119 painter.end(); 119 painter.end();
120} 120}
121 121
122void OXYSelector::mousePressEvent( QMouseEvent *e ) 122void OXYSelector::mousePressEvent( QMouseEvent *e )
123{ 123{
124 int xVal, yVal; 124 int xVal, yVal;
125 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); 125 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal );
126 setValues( xVal, yVal ); 126 setValues( xVal, yVal );
127 127
128 emit valueChanged( xPos, yPos ); 128 emit valueChanged( xPos, yPos );
129} 129}
130 130
131void OXYSelector::mouseMoveEvent( QMouseEvent *e ) 131void OXYSelector::mouseMoveEvent( QMouseEvent *e )
132{ 132{
133 int xVal, yVal; 133 int xVal, yVal;
134 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); 134 valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal );
135 setValues( xVal, yVal ); 135 setValues( xVal, yVal );
136 136
137 emit valueChanged( xPos, yPos ); 137 emit valueChanged( xPos, yPos );
138} 138}
139 139
140void OXYSelector::wheelEvent( QWheelEvent *e ) 140void OXYSelector::wheelEvent( QWheelEvent *e )
141{ 141{
142 #if QT_VERSION > 290 142 #if QT_VERSION > 290
143 if ( e->orientation() == Qt::Horizontal ) 143 if ( e->orientation() == Qt::Horizontal )
144 setValues( xValue() + e->delta()/120, yValue() ); 144 setValues( xValue() + e->delta()/120, yValue() );
145 else 145 else
146 setValues( xValue(), yValue() + e->delta()/120 ); 146 setValues( xValue(), yValue() + e->delta()/120 );
147 147
148 emit valueChanged( xPos, yPos ); 148 emit valueChanged( xPos, yPos );
149 #else
150 Q_UNUSED( e )
149 #endif 151 #endif
150} 152}
151 153
152void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const 154void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const
153{ 155{
154 xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 ); 156 xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 );
155 yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) ); 157 yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) );
156 158
157 if ( xVal > maxX ) 159 if ( xVal > maxX )
158 xVal = maxX; 160 xVal = maxX;
159 else if ( xVal < minX ) 161 else if ( xVal < minX )
160 xVal = minX; 162 xVal = minX;
161 163
162 if ( yVal > maxY ) 164 if ( yVal > maxY )
163 yVal = maxY; 165 yVal = maxY;
164 else if ( yVal < minY ) 166 else if ( yVal < minY )
165 yVal = minY; 167 yVal = minY;
166} 168}
167 169
168void OXYSelector::setPosition( int xp, int yp ) 170void OXYSelector::setPosition( int xp, int yp )
169{ 171{
170 if ( xp < 2 ) 172 if ( xp < 2 )
171 xp = 2; 173 xp = 2;
172 else if ( xp > width() - 2 ) 174 else if ( xp > width() - 2 )
173 xp = width() - 2; 175 xp = width() - 2;
174 176
175 if ( yp < 2 ) 177 if ( yp < 2 )
176 yp = 2; 178 yp = 2;
177 else if ( yp > height() - 2 ) 179 else if ( yp > height() - 2 )
178 yp = height() - 2; 180 yp = height() - 2;
179 181
180 QPainter painter; 182 QPainter painter;
181 painter.begin( this ); 183 painter.begin( this );
182 184
183 bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0, 185 bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0,
184 STORE_W2, STORE_W2, CopyROP ); 186 STORE_W2, STORE_W2, CopyROP );
185 bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W, 187 bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W,
186 STORE_W2, STORE_W2, CopyROP ); 188 STORE_W2, STORE_W2, CopyROP );
187 drawCursor( &painter, xp, yp ); 189 drawCursor( &painter, xp, yp );
188 px = xp; 190 px = xp;
189 py = yp; 191 py = yp;
190 192
191 painter.end(); 193 painter.end();
192} 194}
193 195
194void OXYSelector::drawContents( QPainter * ) 196void OXYSelector::drawContents( QPainter * )
195{} 197{}
196 198
197 199
198void OXYSelector::drawCursor( QPainter *p, int xp, int yp ) 200void OXYSelector::drawCursor( QPainter *p, int xp, int yp )
199{ 201{
200 p->setPen( QPen( white ) ); 202 p->setPen( QPen( white ) );
201 203
202 p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 ); 204 p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 );
203 p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 ); 205 p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 );
204 p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 ); 206 p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 );
205 p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 ); 207 p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 );
206} 208}
207 209
208//----------------------------------------------------------------------------- 210//-----------------------------------------------------------------------------
209/* 211/*
210 * 1D value selector with contents drawn by derived class. 212 * 1D value selector with contents drawn by derived class.
211 * See OColorDialog for example. 213 * See OColorDialog for example.
212 */ 214 */
213 215
214 216
215OSelector::OSelector( QWidget *parent, const char *name ) 217OSelector::OSelector( QWidget *parent, const char *name )
216 : QWidget( parent, name ), QRangeControl() 218 : QWidget( parent, name ), QRangeControl()
217{ 219{
218 _orientation = Horizontal; 220 _orientation = Horizontal;
219 _indent = TRUE; 221 _indent = TRUE;
220} 222}
221 223
222OSelector::OSelector( Orientation o, QWidget *parent, const char *name ) 224OSelector::OSelector( Orientation o, QWidget *parent, const char *name )
223 : QWidget( parent, name ), QRangeControl() 225 : QWidget( parent, name ), QRangeControl()
224{ 226{
225 _orientation = o; 227 _orientation = o;
226 _indent = TRUE; 228 _indent = TRUE;
227} 229}
228 230
229 231
230OSelector::~OSelector() 232OSelector::~OSelector()
231{} 233{}
232 234
233 235
234QRect OSelector::contentsRect() const 236QRect OSelector::contentsRect() const
235{ 237{
236 if ( orientation() == Vertical ) 238 if ( orientation() == Vertical )
237 return QRect( 2, 5, width()-9, height()-10 ); 239 return QRect( 2, 5, width()-9, height()-10 );
238 else 240 else
239 return QRect( 5, 2, width()-10, height()-9 ); 241 return QRect( 5, 2, width()-10, height()-9 );
240} 242}
241 243
242void OSelector::paintEvent( QPaintEvent * ) 244void OSelector::paintEvent( QPaintEvent * )
243{ 245{
244 QPainter painter; 246 QPainter painter;
diff --git a/libopie2/opieui/owait.cpp b/libopie2/opieui/owait.cpp
index 9519888..ec1f25a 100644
--- a/libopie2/opieui/owait.cpp
+++ b/libopie2/opieui/owait.cpp
@@ -1,112 +1,113 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3              Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org> 3              Copyright (C) 2003 Maximilian Reiss <harlekin@handhelds.org>
4 =. 4 =.
5 .=l. 5 .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7 _;:,     .>    :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14    .i_,=:_.      -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.=       =       ; Library General Public License for more
20++=   -.     .`     .: details. 20++=   -.     .`     .: details.
21 :     =  ...= . :.=- 21 :     =  ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22 -.   .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23  -_. . .   )=.  = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24    --        :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28 28
29*/ 29*/
30 30
31#include "owait.h" 31#include "owait.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
35#include <qpe/resource.h> 35#include <qpe/resource.h>
36 36
37/* QT */ 37/* QT */
38#include <qlayout.h> 38#include <qlayout.h>
39#include <qpainter.h> 39#include <qpainter.h>
40 40
41using namespace Opie::Ui; 41using namespace Opie::Ui;
42 42
43static int frame = 0; 43static int frame = 0;
44 44
45/** 45/**
46 * This will construct a modal dialog. 46 * This will construct a modal dialog.
47 * 47 *
48 * The default timer length is 10. 48 * The default timer length is 10.
49 * 49 *
50 * @param parent The parent of the widget 50 * @param parent The parent of the widget
51 * @param msg The name of the object 51 * @param msg The name of the object
52 * @param dispIcon Display Icon? 52 * @param dispIcon Display Icon?
53 */ 53 */
54OWait::OWait( QWidget *parent, const char* msg, bool dispIcon ) 54OWait::OWait( QWidget *parent, const char* msg, bool dispIcon )
55 :QDialog( parent, msg, TRUE, WStyle_Customize ) 55 :QDialog( parent, msg, TRUE, WStyle_Customize )
56{ 56{
57 57
58 Q_UNUSED( dispIcon )
58 59
59 QHBoxLayout * hbox = new QHBoxLayout( this ); 60 QHBoxLayout * hbox = new QHBoxLayout( this );
60 61
61 m_lb = new QLabel( this ); 62 m_lb = new QLabel( this );
62 m_lb->setBackgroundMode ( NoBackground ); 63 m_lb->setBackgroundMode ( NoBackground );
63 64
64 hbox->addWidget( m_lb ); 65 hbox->addWidget( m_lb );
65 hbox->activate(); 66 hbox->activate();
66 67
67 m_pix = Resource::loadPixmap( "BigBusy" ); 68 m_pix = Resource::loadPixmap( "BigBusy" );
68 m_aniSize = m_pix.height(); 69 m_aniSize = m_pix.height();
69 resize( m_aniSize, m_aniSize ); 70 resize( m_aniSize, m_aniSize );
70 71
71 m_timerLength = 10; 72 m_timerLength = 10;
72 73
73 m_waitTimer = new QTimer( this ); 74 m_waitTimer = new QTimer( this );
74 connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) ); 75 connect( m_waitTimer, SIGNAL( timeout() ), this, SLOT( hide() ) );
75} 76}
76 77
77void OWait::timerEvent( QTimerEvent * ) 78void OWait::timerEvent( QTimerEvent * )
78{ 79{
79 frame = ( ++frame ) % 4; 80 frame = ( ++frame ) % 4;
80 repaint(); 81 repaint();
81} 82}
82 83
83void OWait::paintEvent( QPaintEvent * ) 84void OWait::paintEvent( QPaintEvent * )
84{ 85{
85 QPainter p( m_lb ); 86 QPainter p( m_lb );
86 p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize ); 87 p.drawPixmap( 0, 0, m_pix, m_aniSize * frame, 0, m_aniSize, m_aniSize );
87} 88}
88 89
89void OWait::show() 90void OWait::show()
90{ 91{
91 92
92 move( ( ( qApp->desktop() ->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop() ->height() ) / 2 ) - ( m_aniSize / 2 ) ); 93 move( ( ( qApp->desktop() ->width() ) / 2 ) - ( m_aniSize / 2 ), ( ( qApp->desktop() ->height() ) / 2 ) - ( m_aniSize / 2 ) );
93 startTimer( 300 ); 94 startTimer( 300 );
94 m_waitTimer->start( m_timerLength * 1000, true ); 95 m_waitTimer->start( m_timerLength * 1000, true );
95 QDialog::show(); 96 QDialog::show();
96} 97}
97 98
98void OWait::hide() 99void OWait::hide()
99{ 100{
100 killTimers(); 101 killTimers();
101 m_waitTimer->stop(); 102 m_waitTimer->stop();
102 frame = 0; 103 frame = 0;
103 QDialog::hide(); 104 QDialog::hide();
104} 105}
105 106
106void OWait::setTimerLength( int length ) 107void OWait::setTimerLength( int length )
107{ 108{
108 m_timerLength = length; 109 m_timerLength = length;
109} 110}
110 111
111OWait::~OWait() 112OWait::~OWait()
112{} 113{}