summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opieui/big-screen/osplitter.cpp25
-rw-r--r--libopie2/opieui/big-screen/owidgetstack.cpp5
-rw-r--r--libopie2/opieui/fileselector/ofileselector.cpp5
-rw-r--r--libopie2/opieui/olistview.cpp16
-rw-r--r--libopie2/opieui/opopupmenu.cpp30
-rw-r--r--libopie2/opieui/otaskbarapplet.h10
-rw-r--r--libqtaux/oticker.cpp10
7 files changed, 56 insertions, 45 deletions
diff --git a/libopie2/opieui/big-screen/osplitter.cpp b/libopie2/opieui/big-screen/osplitter.cpp
index f0287ed..f50e7f0 100644
--- a/libopie2/opieui/big-screen/osplitter.cpp
+++ b/libopie2/opieui/big-screen/osplitter.cpp
@@ -1,639 +1,640 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "osplitter.h" 29#include "osplitter.h"
30 30
31/* OPIE */ 31/* OPIE */
32#include <opie2/otabwidget.h> 32#include <opie2/otabwidget.h>
33#include <opie2/odebug.h>
33 34
34/* QT */ 35/* QT */
35#include <qvaluelist.h> 36#include <qvaluelist.h>
36#include <qvbox.h> 37#include <qvbox.h>
37 38
38using namespace Opie::Ui; 39using namespace Opie::Ui;
39using namespace Opie::Ui::Internal; 40using namespace Opie::Ui::Internal;
40 41
41/** 42/**
42 * 43 *
43 * This is the constructor of OSplitter 44 * This is the constructor of OSplitter
44 * You might want to call setSizeChange to tell 45 * You might want to call setSizeChange to tell
45 * OSplitter to change its layout when a specefic 46 * OSplitter to change its layout when a specefic
46 * mark was crossed. OSplitter sets a default value. 47 * mark was crossed. OSplitter sets a default value.
47 * 48 *
48 * You cann add widget with addWidget to the OSplitter. 49 * You cann add widget with addWidget to the OSplitter.
49 * OSplitter supports also grouping of Splitters where they 50 * OSplitter supports also grouping of Splitters where they
50 * can share one OTabBar in small screen mode. This can be used 51 * can share one OTabBar in small screen mode. This can be used
51 * for email clients like vies but see the example. 52 * for email clients like vies but see the example.
52 * 53 *
53 * @param orient The orientation wether to layout horizontal or vertical 54 * @param orient The orientation wether to layout horizontal or vertical
54 * @param parent The parent of this widget 55 * @param parent The parent of this widget
55 * @param name The name passed on to QObject 56 * @param name The name passed on to QObject
56 * @param fl Additional widgets flags passed to QWidget 57 * @param fl Additional widgets flags passed to QWidget
57 * 58 *
58 * @short single c'tor of the OSplitter 59 * @short single c'tor of the OSplitter
59 */ 60 */
60OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl ) 61OSplitter::OSplitter( Orientation orient, QWidget* parent, const char* name, WFlags fl )
61 : QFrame( parent, name, fl ) 62 : QFrame( parent, name, fl )
62{ 63{
63 m_orient = orient; 64 m_orient = orient;
64 m_hbox = 0; 65 m_hbox = 0;
65 m_size_policy = 330; 66 m_size_policy = 330;
66 setFontPropagation( AllChildren ); 67 setFontPropagation( AllChildren );
67 setPalettePropagation( AllChildren ); 68 setPalettePropagation( AllChildren );
68 69
69 /* start by default with the tab widget */ 70 /* start by default with the tab widget */
70 m_tabWidget = 0; 71 m_tabWidget = 0;
71 m_parentTab = 0; 72 m_parentTab = 0;
72 changeTab(); 73 changeTab();
73 74
74} 75}
75 76
76 77
77/** 78/**
78 * Destructor destructs this object and cleans up. All child 79 * Destructor destructs this object and cleans up. All child
79 * widgets will be deleted 80 * widgets will be deleted
80 * @see addWidget 81 * @see addWidget
81 */ 82 */
82OSplitter::~OSplitter() 83OSplitter::~OSplitter()
83{ 84{
84 qWarning("Deleted Splitter"); 85 owarn << "Deleted Splitter" << oendl;
85 m_splitter.setAutoDelete( true ); 86 m_splitter.setAutoDelete( true );
86 m_splitter.clear(); 87 m_splitter.clear();
87 88
88 delete m_hbox; 89 delete m_hbox;
89 delete m_tabWidget; 90 delete m_tabWidget;
90} 91}
91 92
92 93
93/** 94/**
94 * Sets the label for the Splitter. This label will be used 95 * Sets the label for the Splitter. This label will be used
95 * if a parent splitter is arranged as TabWidget but 96 * if a parent splitter is arranged as TabWidget but
96 * this splitter is in fullscreen mode. Then a tab with OSplitter::label() 97 * this splitter is in fullscreen mode. Then a tab with OSplitter::label()
97 * and iconName() gets added. 98 * and iconName() gets added.
98 * 99 *
99 * @param name The name of the Label 100 * @param name The name of the Label
100 */ 101 */
101void OSplitter::setLabel( const QString& name ) 102void OSplitter::setLabel( const QString& name )
102{ 103{
103 m_name = name; 104 m_name = name;
104} 105}
105 106
106/** 107/**
107 * @see setLabel but this is for the icon retrieved by Resource 108 * @see setLabel but this is for the icon retrieved by Resource
108 * 109 *
109 * @param name The name of the icon in example ( "zoom" ) 110 * @param name The name of the icon in example ( "zoom" )
110 */ 111 */
111void OSplitter::setIconName( const QString& name ) 112void OSplitter::setIconName( const QString& name )
112{ 113{
113 m_icon = name; 114 m_icon = name;
114} 115}
115 116
116 117
117/** 118/**
118 * returns the iconName 119 * returns the iconName
119 * @see setIconName 120 * @see setIconName
120 */ 121 */
121QString OSplitter::iconName()const 122QString OSplitter::iconName()const
122{ 123{
123 return m_icon; 124 return m_icon;
124} 125}
125 126
126/** 127/**
127 * returns the label set with setLabel 128 * returns the label set with setLabel
128 * @see setLabel 129 * @see setLabel
129 */ 130 */
130QString OSplitter::label()const 131QString OSplitter::label()const
131{ 132{
132 return m_name; 133 return m_name;
133} 134}
134 135
135/** 136/**
136 * This function sets the size change policy of the splitter. 137 * This function sets the size change policy of the splitter.
137 * If this size marked is crossed the splitter will relayout. 138 * If this size marked is crossed the splitter will relayout.
138 * Note: that depending on the set Orientation it'll either look 139 * Note: that depending on the set Orientation it'll either look
139 * at the width or height. 140 * at the width or height.
140 * Note: If you want to from side to side view to tabbed view you need 141 * Note: If you want to from side to side view to tabbed view you need
141 * to make sure that the size you supply is not smaller than the minimum 142 * to make sure that the size you supply is not smaller than the minimum
142 * size of your added widgets. Note that if you use widgets like QComboBoxes 143 * size of your added widgets. Note that if you use widgets like QComboBoxes
143 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy 144 * you need to teach them to accept smaller sizes as well @see QWidget::setSizePolicy
144 * 145 *
145 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter. 146 * @param width_height The mark that will be watched. Interpreted depending on the Orientation of the Splitter.
146 * @return void 147 * @return void
147 */ 148 */
148void OSplitter::setSizeChange( int width_height ) 149void OSplitter::setSizeChange( int width_height )
149{ 150{
150 m_size_policy = width_height; 151 m_size_policy = width_height;
151 QSize sz(width(), height() ); 152 QSize sz(width(), height() );
152 QResizeEvent ev(sz, sz ); 153 QResizeEvent ev(sz, sz );
153 resizeEvent(&ev); 154 resizeEvent(&ev);
154} 155}
155 156
156/** 157/**
157 * This functions allows to add another OSplitter and to share 158 * This functions allows to add another OSplitter and to share
158 * the OTabBar in small screen mode. The ownerships gets transfered. 159 * the OTabBar in small screen mode. The ownerships gets transfered.
159 * OSplitters are always added after normal widget items 160 * OSplitters are always added after normal widget items
160 */ 161 */
161void OSplitter::addWidget( OSplitter* split ) 162void OSplitter::addWidget( OSplitter* split )
162{ 163{
163 m_splitter.append( split ); 164 m_splitter.append( split );
164 165
165 /* 166 /*
166 * set tab widget 167 * set tab widget
167 */ 168 */
168 if (m_tabWidget ) 169 if (m_tabWidget )
169 setTabWidget( m_parentTab ); 170 setTabWidget( m_parentTab );
170 else 171 else
171 { 172 {
172 OSplitterContainer con; 173 OSplitterContainer con;
173 con.widget =split; 174 con.widget =split;
174 addToBox( con ); 175 addToBox( con );
175 } 176 }
176} 177}
177 178
178/* 179/*
179 * If in a tab it should be removed 180 * If in a tab it should be removed
180 * and if in a hbox the reparent kills it too 181 * and if in a hbox the reparent kills it too
181 */ 182 */
182/** 183/**
183 * This removes the splitter again. You currently need to call this 184 * This removes the splitter again. You currently need to call this
184 * before you delete or otherwise you can get mem corruption 185 * before you delete or otherwise you can get mem corruption
185 * or other weird behaviour. 186 * or other weird behaviour.
186 * Owner ship gets transfered back to you it's current parent 187 * Owner ship gets transfered back to you it's current parent
187 * is 0 188 * is 0
188 */ 189 */
189void OSplitter::removeWidget( OSplitter* split) 190void OSplitter::removeWidget( OSplitter* split)
190{ 191{
191 split->setTabWidget( 0 ); 192 split->setTabWidget( 0 );
192 split->reparent( 0, 0, QPoint(0, 0) ); 193 split->reparent( 0, 0, QPoint(0, 0) );
193} 194}
194 195
195/** 196/**
196 * Adds a widget to the Splitter. The widgets gets inserted 197 * Adds a widget to the Splitter. The widgets gets inserted
197 * at the end of either the Box or TabWidget. 198 * at the end of either the Box or TabWidget.
198 * Ownership gets transfered and the widgets gets reparented. 199 * Ownership gets transfered and the widgets gets reparented.
199 * Note: icon and label is only available on small screensizes 200 * Note: icon and label is only available on small screensizes
200 * if size is smaller than the mark 201 * if size is smaller than the mark
201 * Warning: No null checking of the widget is done. Only on debug 202 * Warning: No null checking of the widget is done. Only on debug
202 * a message will be outputtet 203 * a message will be outputtet
203 * 204 *
204 * @param wid The widget which will be added 205 * @param wid The widget which will be added
205 * @param icon The icon of the possible Tab 206 * @param icon The icon of the possible Tab
206 * @param label The label of the possible Tab 207 * @param label The label of the possible Tab
207 */ 208 */
208void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label ) 209void OSplitter::addWidget( QWidget* wid, const QString& icon, const QString& label )
209{ 210{
210#ifdef DEBUG 211#ifdef DEBUG
211 if (!wid ) 212 if (!wid )
212 { 213 {
213 qWarning("Widget is not valid!"); 214 owarn << "Widget is not valid!" << oendl;
214 return; 215 return;
215 } 216 }
216#endif 217#endif
217 OSplitterContainer cont; 218 OSplitterContainer cont;
218 cont.widget = wid; 219 cont.widget = wid;
219 cont.icon =icon; 220 cont.icon =icon;
220 cont.name = label; 221 cont.name = label;
221 222
222 m_container.append( cont ); 223 m_container.append( cont );
223 224
224 /* 225 /*
225 * 226 *
226 */ 227 */
227 if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) ) 228 if (!m_splitter.isEmpty() && (m_tabWidget || m_parentTab ) )
228 setTabWidget( m_parentTab ); 229 setTabWidget( m_parentTab );
229 else 230 else
230 { 231 {
231 if (m_hbox ) 232 if (m_hbox )
232 addToBox( cont ); 233 addToBox( cont );
233 else 234 else
234 addToTab( cont ); 235 addToTab( cont );
235 } 236 }
236} 237}
237 238
238 239
239/** 240/**
240 * Removes the widget from the tab widgets if necessary. 241 * Removes the widget from the tab widgets if necessary.
241 * OSplitter drops ownership of this widget and the widget 242 * OSplitter drops ownership of this widget and the widget
242 * will be reparented i tto 0. 243 * will be reparented i tto 0.
243 * The widget will not be deleted. 244 * The widget will not be deleted.
244 * 245 *
245 * @param w The widget to be removed 246 * @param w The widget to be removed
246 */ 247 */
247void OSplitter::removeWidget( QWidget* w) 248void OSplitter::removeWidget( QWidget* w)
248{ 249{
249 ContainerList::Iterator it; 250 ContainerList::Iterator it;
250 for ( it = m_container.begin(); it != m_container.end(); ++it ) 251 for ( it = m_container.begin(); it != m_container.end(); ++it )
251 if ( (*it).widget == w ) 252 if ( (*it).widget == w )
252 break; 253 break;
253 254
254 if (it == m_container.end() ) 255 if (it == m_container.end() )
255 return; 256 return;
256 257
257 258
258 /* only tab needs to be removed.. box recognizes it */ 259 /* only tab needs to be removed.. box recognizes it */
259 if ( !m_hbox ) 260 if ( !m_hbox )
260 removeFromTab( w ); 261 removeFromTab( w );
261 262
262 263
263 /* Find reparent it and remove it from our list */ 264 /* Find reparent it and remove it from our list */
264 265
265 w->reparent( 0, 0, QPoint(0, 0)); 266 w->reparent( 0, 0, QPoint(0, 0));
266 it = m_container.remove( it ); 267 it = m_container.remove( it );
267 268
268} 269}
269 270
270 271
271/** 272/**
272 * This method will give focus to the widget. If in a tabwidget 273 * This method will give focus to the widget. If in a tabwidget
273 * the tabbar will be changed 274 * the tabbar will be changed
274 * 275 *
275 * @param w The widget which will be set the current one 276 * @param w The widget which will be set the current one
276 */ 277 */
277void OSplitter::setCurrentWidget( QWidget* w) 278void OSplitter::setCurrentWidget( QWidget* w)
278{ 279{
279 if (m_tabWidget ) 280 if (m_tabWidget )
280 m_tabWidget->setCurrentTab( w ); 281 m_tabWidget->setCurrentTab( w );
281 // else 282 // else
282 // m_hbox->setFocus( w ); 283 // m_hbox->setFocus( w );
283 284
284} 285}
285 286
286/** 287/**
287 * This is an overloaded member function and only differs in the 288 * This is an overloaded member function and only differs in the
288 * argument it takes. 289 * argument it takes.
289 * Searches list of widgets for label. It'll pick the first label it finds 290 * Searches list of widgets for label. It'll pick the first label it finds
290 * 291 *
291 * @param label Label to look for. First match will be taken 292 * @param label Label to look for. First match will be taken
292 */ 293 */
293void OSplitter::setCurrentWidget( const QString& label ) 294void OSplitter::setCurrentWidget( const QString& label )
294{ 295{
295 ContainerList::Iterator it; 296 ContainerList::Iterator it;
296 for (it = m_container.begin(); it != m_container.end(); ++it ) 297 for (it = m_container.begin(); it != m_container.end(); ++it )
297 { 298 {
298 if ( (*it).name == label ) 299 if ( (*it).name == label )
299 { 300 {
300 setCurrentWidget( (*it).widget ); 301 setCurrentWidget( (*it).widget );
301 break; 302 break;
302 } 303 }
303 } 304 }
304} 305}
305 306
306/** 307/**
307 * This will only work when the TabWidget is active 308 * This will only work when the TabWidget is active
308 * If everything is visible this signal is kindly ignored 309 * If everything is visible this signal is kindly ignored
309 * @see OTabWidget::setCurrentTab(int) 310 * @see OTabWidget::setCurrentTab(int)
310 * 311 *
311 * @param tab The tab to make current 312 * @param tab The tab to make current
312 */ 313 */
313void OSplitter::setCurrentWidget( int tab ) 314void OSplitter::setCurrentWidget( int tab )
314{ 315{
315 if (m_tabWidget ) 316 if (m_tabWidget )
316 m_tabWidget->setCurrentTab( tab ); 317 m_tabWidget->setCurrentTab( tab );
317} 318}
318 319
319/** 320/**
320 * return the currently activated widget if in tab widget mode 321 * return the currently activated widget if in tab widget mode
321 * or null because all widgets are visible 322 * or null because all widgets are visible
322 */ 323 */
323QWidget* OSplitter::currentWidget() const 324QWidget* OSplitter::currentWidget() const
324{ 325{
325 if (m_tabWidget) 326 if (m_tabWidget)
326 return m_tabWidget->currentWidget(); 327 return m_tabWidget->currentWidget();
327 else if (m_parentTab ) 328 else if (m_parentTab )
328 return m_parentTab->currentWidget(); 329 return m_parentTab->currentWidget();
329 330
330 return 0l; 331 return 0l;
331} 332}
332/* wrong */ 333/* wrong */
333#if 0 334#if 0
334/** 335/**
335 * @reimplented for internal reasons 336 * @reimplented for internal reasons
336 * returns the sizeHint of one of its sub widgets 337 * returns the sizeHint of one of its sub widgets
337 */ 338 */
338QSize OSplitter::sizeHint()const 339QSize OSplitter::sizeHint()const
339{ 340{
340 if (m_parentTab ) 341 if (m_parentTab )
341 return QFrame::sizeHint(); 342 return QFrame::sizeHint();
342 343
343 if (m_hbox ) 344 if (m_hbox )
344 return m_hbox->sizeHint(); 345 return m_hbox->sizeHint();
345 else 346 else
346 return m_tabWidget->sizeHint(); 347 return m_tabWidget->sizeHint();
347} 348}
348 349
349QSize OSplitter::minimumSizeHint()const 350QSize OSplitter::minimumSizeHint()const
350{ 351{
351 if (m_parentTab ) 352 if (m_parentTab )
352 return QFrame::minimumSizeHint(); 353 return QFrame::minimumSizeHint();
353 if (m_hbox) 354 if (m_hbox)
354 return m_hbox->sizeHint(); 355 return m_hbox->sizeHint();
355 else 356 else
356 return m_tabWidget->sizeHint(); 357 return m_tabWidget->sizeHint();
357} 358}
358#endif 359#endif
359 360
360/** 361/**
361 * @reimplemented for internal reasons 362 * @reimplemented for internal reasons
362 */ 363 */
363void OSplitter::resizeEvent( QResizeEvent* res ) 364void OSplitter::resizeEvent( QResizeEvent* res )
364{ 365{
365 QFrame::resizeEvent( res ); 366 QFrame::resizeEvent( res );
366 /* 367 /*
367 * 368 *
368 */ 369 */
369 // qWarning("Old size was width = %d height = %d", res->oldSize().width(), res->oldSize().height() ); 370 // owarn << "Old size was width = " << res->oldSize().width() << " height = " << res->oldSize().height() << "" << oendl;
370 bool mode = true; 371 bool mode = true;
371 qWarning("New size is width = %d height = %d %s", res->size().width(), res->size().height(), name() ); 372 owarn << "New size is width = " << res->size().width() << " height = " << res->size().height() << " " << name() << "" << oendl;
372 if ( res->size().width() > m_size_policy && 373 if ( res->size().width() > m_size_policy &&
373 m_orient == Horizontal ) 374 m_orient == Horizontal )
374 { 375 {
375 changeHBox(); 376 changeHBox();
376 mode = false; 377 mode = false;
377 } 378 }
378 else if ( (res->size().width() <= m_size_policy && 379 else if ( (res->size().width() <= m_size_policy &&
379 m_orient == Horizontal ) || 380 m_orient == Horizontal ) ||
380 (res->size().height() <= m_size_policy && 381 (res->size().height() <= m_size_policy &&
381 m_orient == Vertical ) ) 382 m_orient == Vertical ) )
382 { 383 {
383 changeTab(); 384 changeTab();
384 } 385 }
385 else if ( res->size().height() > m_size_policy && 386 else if ( res->size().height() > m_size_policy &&
386 m_orient == Vertical ) 387 m_orient == Vertical )
387 { 388 {
388 qWarning("Changng to vbox %s", name() ); 389 owarn << "Changng to vbox " << name() << "" << oendl;
389 changeVBox(); 390 changeVBox();
390 mode = false; 391 mode = false;
391 } 392 }
392 393
393 emit sizeChanged(mode, m_orient ); 394 emit sizeChanged(mode, m_orient );
394} 395}
395 396
396/* 397/*
397 * Adds a container to a tab either the parent tab 398 * Adds a container to a tab either the parent tab
398 * or our own 399 * or our own
399 */ 400 */
400void OSplitter::addToTab( const Opie::Ui::Internal::OSplitterContainer& con ) 401void OSplitter::addToTab( const Opie::Ui::Internal::OSplitterContainer& con )
401{ 402{
402 QWidget *wid = con.widget; 403 QWidget *wid = con.widget;
403 // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) ); 404 // not needed widgetstack will reparent as well wid.reparent(m_tabWidget, wid->getWFlags(), QPoint(0, 0) );
404 if (m_parentTab ) 405 if (m_parentTab )
405 m_parentTab->addTab( wid, con.icon, con.name ); 406 m_parentTab->addTab( wid, con.icon, con.name );
406 else 407 else
407 m_tabWidget->addTab( wid, con.icon, con.name ); 408 m_tabWidget->addTab( wid, con.icon, con.name );
408} 409}
409 410
410 411
411/* 412/*
412 * adds a container to the box 413 * adds a container to the box
413 */ 414 */
414void OSplitter::addToBox( const Opie::Ui::Internal::OSplitterContainer& con ) 415void OSplitter::addToBox( const Opie::Ui::Internal::OSplitterContainer& con )
415{ 416{
416 QWidget* wid = con.widget; 417 QWidget* wid = con.widget;
417 wid->reparent(m_hbox, 0, QPoint(0, 0) ); 418 wid->reparent(m_hbox, 0, QPoint(0, 0) );
418} 419}
419 420
420 421
421/* 422/*
422 * Removes a widget from the tab 423 * Removes a widget from the tab
423 */ 424 */
424void OSplitter::removeFromTab( QWidget* wid ) 425void OSplitter::removeFromTab( QWidget* wid )
425{ 426{
426 if (m_parentTab ) 427 if (m_parentTab )
427 m_parentTab->removePage( wid ); 428 m_parentTab->removePage( wid );
428 else 429 else
429 m_tabWidget->removePage( wid ); 430 m_tabWidget->removePage( wid );
430} 431}
431 432
432/* 433/*
433 * switches over to a OTabWidget layout 434 * switches over to a OTabWidget layout
434 * it is recursive 435 * it is recursive
435 */ 436 */
436void OSplitter::changeTab() 437void OSplitter::changeTab()
437{ 438{
438 /* if we're the owner of the tab widget */ 439 /* if we're the owner of the tab widget */
439 if (m_tabWidget ) 440 if (m_tabWidget )
440 { 441 {
441 raise(); 442 raise();
442 show(); 443 show();
443 m_tabWidget->setGeometry( frameRect() ); 444 m_tabWidget->setGeometry( frameRect() );
444 return; 445 return;
445 } 446 }
446 447
447 qWarning(" New Tab Widget %s", name() ); 448 owarn << " New Tab Widget " << name() << "" << oendl;
448 /* 449 /*
449 * and add all widgets this will reparent them 450 * and add all widgets this will reparent them
450 * delete m_hbox set it to 0 451 * delete m_hbox set it to 0
451 * 452 *
452 */ 453 */
453 OTabWidget *tab; 454 OTabWidget *tab;
454 if ( m_parentTab ) 455 if ( m_parentTab )
455 { 456 {
456 hide(); 457 hide();
457 tab = m_parentTab; 458 tab = m_parentTab;
458 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/ 459 /* expensive but needed cause we're called from setTabWidget and resizeEvent*/
459 if (!m_container.isEmpty() ) 460 if (!m_container.isEmpty() )
460 { 461 {
461 ContainerList::Iterator it = m_container.begin(); 462 ContainerList::Iterator it = m_container.begin();
462 for (; it != m_container.end(); ++it ) 463 for (; it != m_container.end(); ++it )
463 m_parentTab->removePage( (*it).widget ); 464 m_parentTab->removePage( (*it).widget );
464 } 465 }
465 } 466 }
466 else 467 else
467 tab = m_tabWidget = new OTabWidget( this ); 468 tab = m_tabWidget = new OTabWidget( this );
468 469
469 connect(tab, SIGNAL(currentChanged(QWidget*) ), 470 connect(tab, SIGNAL(currentChanged(QWidget*) ),
470 this, SIGNAL(currentChanged(QWidget*) ) ); 471 this, SIGNAL(currentChanged(QWidget*) ) );
471 472
472 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) 473 for ( ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it )
473 { 474 {
474 qWarning("Widget is %s", (*it).name.latin1() ); 475 owarn << "Widget is " << (*it).name << "" << oendl;
475 addToTab( (*it) ); 476 addToTab( (*it) );
476 } 477 }
477 478
478 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) 479 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() )
479 { 480 {
480 split->reparent(this, 0, QPoint(0, 0) ); 481 split->reparent(this, 0, QPoint(0, 0) );
481 split->setTabWidget( tab ); 482 split->setTabWidget( tab );
482 } 483 }
483 484
484 485
485 delete m_hbox; 486 delete m_hbox;
486 m_hbox = 0; 487 m_hbox = 0;
487 if (!m_tabWidget ) 488 if (!m_tabWidget )
488 return; 489 return;
489 490
490 m_tabWidget->setGeometry( frameRect() ); 491 m_tabWidget->setGeometry( frameRect() );
491 m_tabWidget->show(); 492 m_tabWidget->show();
492 493
493} 494}
494 495
495/* 496/*
496 * changes over to a box 497 * changes over to a box
497 * this is recursive as well 498 * this is recursive as well
498 */ 499 */
499void OSplitter::changeHBox() 500void OSplitter::changeHBox()
500{ 501{
501 if (m_hbox ) 502 if (m_hbox )
502 { 503 {
503 m_hbox->setGeometry( frameRect() ); 504 m_hbox->setGeometry( frameRect() );
504 return; 505 return;
505 } 506 }
506 507
507 qWarning("new HBox %s", name() ); 508 owarn << "new HBox " << name() << "" << oendl;
508 m_hbox = new QHBox( this ); 509 m_hbox = new QHBox( this );
509 commonChangeBox(); 510 commonChangeBox();
510} 511}
511 512
512void OSplitter::changeVBox() 513void OSplitter::changeVBox()
513{ 514{
514 if (m_hbox ) 515 if (m_hbox )
515 { 516 {
516 m_hbox->setGeometry( frameRect() ); 517 m_hbox->setGeometry( frameRect() );
517 return; 518 return;
518 } 519 }
519 520
520 qWarning("New VBOX %s", name() ); 521 owarn << "New VBOX " << name() << "" << oendl;
521 m_hbox = new QVBox( this ); 522 m_hbox = new QVBox( this );
522 523
523 commonChangeBox(); 524 commonChangeBox();
524 525
525} 526}
526 527
527/* 528/*
528 * common box code 529 * common box code
529 * first remove and add children 530 * first remove and add children
530 * the other splitters 531 * the other splitters
531 * it is recursive as well due the call to setTabWidget 532 * it is recursive as well due the call to setTabWidget
532 */ 533 */
533void OSplitter::commonChangeBox() 534void OSplitter::commonChangeBox()
534{ 535{
535 qWarning(" Name of Splitters is %s", name() ); 536 owarn << " Name of Splitters is " << name() << "" << oendl;
536 537
537 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it ) 538 for (ContainerList::Iterator it = m_container.begin(); it != m_container.end(); ++it )
538 { 539 {
539 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */ 540 /* only if parent tab.. m_tabWidgets gets deleted and would do that as well */
540 if (m_parentTab ) 541 if (m_parentTab )
541 removeFromTab( (*it).widget ); 542 removeFromTab( (*it).widget );
542 qWarning("Adding to box %s", (*it).name.latin1() ); 543 owarn << "Adding to box " << (*it).name << "" << oendl;
543 addToBox( (*it) ); 544 addToBox( (*it) );
544 } 545 }
545 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() ) 546 for ( OSplitter* split = m_splitter.first(); split; split = m_splitter.next() )
546 { 547 {
547 /* tell them the world had changed */ 548 /* tell them the world had changed */
548 split->setTabWidget( 0 ); 549 split->setTabWidget( 0 );
549 OSplitterContainer con; 550 OSplitterContainer con;
550 con.widget = split; 551 con.widget = split;
551 // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget) 552 // con.widget = split->m_tabWidget ? static_cast<QWidget*>(split->m_tabWidget)
552 // : static_cast<QWidget*>(split->m_hbox); 553 // : static_cast<QWidget*>(split->m_hbox);
553 addToBox( con ); 554 addToBox( con );
554 } 555 }
555 556
556 557
557 558
558 if (m_parentTab ) 559 if (m_parentTab )
559 m_parentTab->addTab(m_hbox, iconName(), label() ); 560 m_parentTab->addTab(m_hbox, iconName(), label() );
560 else 561 else
561 { 562 {
562 qWarning(" setting Box geometry for %s", name() ); 563 owarn << " setting Box geometry for " << name() << "" << oendl;
563 m_hbox->setGeometry( frameRect() ); 564 m_hbox->setGeometry( frameRect() );
564 m_hbox->show(); 565 m_hbox->show();
565 delete m_tabWidget; 566 delete m_tabWidget;
566 m_tabWidget = 0; 567 m_tabWidget = 0;
567 show(); // also show this widget 568 show(); // also show this widget
568 } 569 }
569} 570}
570 571
571/* 572/*
572 * sets the tabwidget, removes tabs, and relayouts the widget 573 * sets the tabwidget, removes tabs, and relayouts the widget
573 */ 574 */
574void OSplitter::setTabWidget( OTabWidget* wid) 575void OSplitter::setTabWidget( OTabWidget* wid)
575{ 576{
576 /* clean up cause m_parentTab will not be available for us */ 577 /* clean up cause m_parentTab will not be available for us */
577 if ( m_parentTab ) 578 if ( m_parentTab )
578 { 579 {
579 if (m_hbox ) 580 if (m_hbox )
580 m_parentTab->removePage( m_hbox ); 581 m_parentTab->removePage( m_hbox );
581 else if (!m_container.isEmpty() ) 582 else if (!m_container.isEmpty() )
582 { 583 {
583 ContainerList::Iterator it = m_container.begin(); 584 ContainerList::Iterator it = m_container.begin();
584 for ( ; it != m_container.end(); ++it ) 585 for ( ; it != m_container.end(); ++it )
585 m_parentTab->removePage( (*it).widget ); 586 m_parentTab->removePage( (*it).widget );
586 } 587 }
587 } 588 }
588 /* the parent Splitter changed so either make us indepent or dep */ 589 /* the parent Splitter changed so either make us indepent or dep */
589 590
590 m_parentTab = wid; 591 m_parentTab = wid;
591 592
592 QWidget *tab = m_tabWidget; 593 QWidget *tab = m_tabWidget;
593 QWidget *box = m_hbox; 594 QWidget *box = m_hbox;
594 m_hbox = 0; m_tabWidget = 0; 595 m_hbox = 0; m_tabWidget = 0;
595 596
596 if ( layoutMode() ) 597 if ( layoutMode() )
597 changeTab(); 598 changeTab();
598 else if (m_orient == Horizontal ) 599 else if (m_orient == Horizontal )
599 changeHBox(); 600 changeHBox();
600 else 601 else
601 changeVBox(); 602 changeVBox();
602 603
603 /* our own crap is added and children from change* */ 604 /* our own crap is added and children from change* */
604 delete tab; 605 delete tab;
605 delete box; 606 delete box;
606} 607}
607 608
608#if 0 609#if 0
609void OSplitter::reparentAll() 610void OSplitter::reparentAll()
610{ 611{
611 if (m_container.isEmpty() ) 612 if (m_container.isEmpty() )
612 return; 613 return;
613 614
614 ContainerList::Iterator it = m_container.begin(); 615 ContainerList::Iterator it = m_container.begin();
615 for ( ; it != m_container.end(); ++it ) 616 for ( ; it != m_container.end(); ++it )
616 (*it).wid->reparent(0, 0, QPoint(0, 0) ); 617 (*it).wid->reparent(0, 0, QPoint(0, 0) );
617 618
618 619
619} 620}
620#endif 621#endif
621 622
622/** 623/**
623 * @internal 624 * @internal
624 */ 625 */
625bool OSplitter::layoutMode()const 626bool OSplitter::layoutMode()const
626{ 627{
627 if ( size().width() > m_size_policy && 628 if ( size().width() > m_size_policy &&
628 m_orient == Horizontal ) 629 m_orient == Horizontal )
629 { 630 {
630 return false; 631 return false;
631 } 632 }
632 else if ( size().height() > m_size_policy && 633 else if ( size().height() > m_size_policy &&
633 m_orient == Vertical ) 634 m_orient == Vertical )
634 { 635 {
635 return false; 636 return false;
636 } 637 }
637 638
638 return true; 639 return true;
639} 640}
diff --git a/libopie2/opieui/big-screen/owidgetstack.cpp b/libopie2/opieui/big-screen/owidgetstack.cpp
index a0a6355..de7f83f 100644
--- a/libopie2/opieui/big-screen/owidgetstack.cpp
+++ b/libopie2/opieui/big-screen/owidgetstack.cpp
@@ -1,126 +1,129 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org> 3             .=l. Copyright (c) 2003 hOlgAr <zecke@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under 6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%`+i>       _;_. 11    .%`+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .`     .: details. 18++=   -.     .`     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-=` this library; see the file COPYING.LIB. 22    --        :-=` this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29#include "owidgetstack.h" 29#include "owidgetstack.h"
30 30
31/* OPIE */
32#include <opie2/odebug.h>
33
31/* QT */ 34/* QT */
32#include <qapplication.h> 35#include <qapplication.h>
33#include <qwidgetstack.h> 36#include <qwidgetstack.h>
34 37
35namespace Opie { 38namespace Opie {
36namespace Ui { 39namespace Ui {
37 const int mode_size = 330; 40 const int mode_size = 330;
38 41
39 42
40 43
41/** 44/**
42 * This is the standard widget. For simple usage see the example. Normally this widget 45 * This is the standard widget. For simple usage see the example. Normally this widget
43 * is the central widget of a QMainWindow. 46 * is the central widget of a QMainWindow.
44 * Use removeWidget before you delete a widget yourself. OWidgetStack does not 47 * Use removeWidget before you delete a widget yourself. OWidgetStack does not
45 * yet recognize removal of children. 48 * yet recognize removal of children.
46 * 49 *
47 * @param parent The parent widget. It maybe 0 but then you need to take care of deletion. 50 * @param parent The parent widget. It maybe 0 but then you need to take care of deletion.
48 * Or you use QPEApplication::showMainWidget(). 51 * Or you use QPEApplication::showMainWidget().
49 * @param name Name will be passed on to QObject 52 * @param name Name will be passed on to QObject
50 * @param fl Additional window flags passed to QFrame. see @Qt::WFlags 53 * @param fl Additional window flags passed to QFrame. see @Qt::WFlags
51 */ 54 */
52OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl) 55OWidgetStack::OWidgetStack( QWidget* parent, const char* name, WFlags fl)
53 : QFrame( parent, name, fl ) 56 : QFrame( parent, name, fl )
54{ 57{
55 m_last = m_mWidget = 0; 58 m_last = m_mWidget = 0;
56 m_forced = false; 59 m_forced = false;
57 60
58 QApplication::desktop()->installEventFilter( this ); 61 QApplication::desktop()->installEventFilter( this );
59 setFontPropagation ( AllChildren ); 62 setFontPropagation ( AllChildren );
60 setPalettePropagation( AllChildren ); 63 setPalettePropagation( AllChildren );
61 64
62 /* sets m_mode and initializes more */ 65 /* sets m_mode and initializes more */
63 /* if you change this call change switchTop as well */ 66 /* if you change this call change switchTop as well */
64 m_stack = 0; 67 m_stack = 0;
65 switchStack(); 68 switchStack();
66} 69}
67 70
68/** 71/**
69 * The destructor. It deletes also all added widgets. 72 * The destructor. It deletes also all added widgets.
70 * 73 *
71 */ 74 */
72OWidgetStack::~OWidgetStack() { 75OWidgetStack::~OWidgetStack() {
73 if (m_mode == BigScreen && !m_list.isEmpty() ) { 76 if (m_mode == BigScreen && !m_list.isEmpty() ) {
74 QMap<int, QWidget*>::Iterator it = m_list.begin(); 77 QMap<int, QWidget*>::Iterator it = m_list.begin();
75 for ( ; it != m_list.end(); ++it ) 78 for ( ; it != m_list.end(); ++it )
76 delete it.data(); 79 delete it.data();
77 } 80 }
78 m_list.clear(); 81 m_list.clear();
79 82
80} 83}
81 84
82/** 85/**
83 * return the mode of the desktop. There are currently two modes. SmallScreen 86 * return the mode of the desktop. There are currently two modes. SmallScreen
84 * with a normal PDA resolution and BigScreen with resolutions greater than 87 * with a normal PDA resolution and BigScreen with resolutions greater than
85 * 330 for width and height. 88 * 330 for width and height.
86 * You can also force the mode this widget is in with forceMode() 89 * You can also force the mode this widget is in with forceMode()
87 * Note that NoForce will be never returned from here 90 * Note that NoForce will be never returned from here
88 */ 91 */
89enum OWidgetStack::Mode OWidgetStack::mode()const { 92enum OWidgetStack::Mode OWidgetStack::mode()const {
90 return m_mode; 93 return m_mode;
91} 94}
92 95
93/** 96/**
94 * You can also force one of the modes and then 97 * You can also force one of the modes and then
95 * this widget stops on listening to size changes. You 98 * this widget stops on listening to size changes. You
96 * can revert to the scanning behaviour by setting mode 99 * can revert to the scanning behaviour by setting mode
97 * to NoForce 100 * to NoForce
98 */ 101 */
99void OWidgetStack::forceMode( enum Mode mode) { 102void OWidgetStack::forceMode( enum Mode mode) {
100 m_forced = mode != NoForce; 103 m_forced = mode != NoForce;
101 104
102 /* we need to see which mode we're in */ 105 /* we need to see which mode we're in */
103 if (!m_forced ) { 106 if (!m_forced ) {
104 if ( QApplication::desktop()->width() >= 107 if ( QApplication::desktop()->width() >=
105 mode_size ) 108 mode_size )
106 mode = BigScreen; 109 mode = BigScreen;
107 else 110 else
108 mode = SmallScreen; 111 mode = SmallScreen;
109 } 112 }
110 switch( mode ) { 113 switch( mode ) {
111 case NoForce: 114 case NoForce:
112 case SmallScreen: 115 case SmallScreen:
113 switchStack(); 116 switchStack();
114 break; 117 break;
115 case BigScreen: 118 case BigScreen:
116 switchTop(); 119 switchTop();
117 break; 120 break;
118 121
119 } 122 }
120 123
121 m_mode = mode; 124 m_mode = mode;
122} 125}
123 126
124/** 127/**
125 * Adds a widget to the stack. The first widget added is considered 128 * Adds a widget to the stack. The first widget added is considered
126 * to be the mainwindow. This is important because if Opie is in 129 * to be the mainwindow. This is important because if Opie is in
@@ -214,193 +217,193 @@ QSizeHint OWidgetStack::minimumSizeHint()const {
214QWidget* OWidgetStack::widget( int id) const { 217QWidget* OWidgetStack::widget( int id) const {
215 return m_list[id]; 218 return m_list[id];
216} 219}
217 220
218/** 221/**
219 * Tries to find the assigned id for the widget 222 * Tries to find the assigned id for the widget
220 * or returns -1 if no widget could be found 223 * or returns -1 if no widget could be found
221 * @param wid The widget to look for 224 * @param wid The widget to look for
222 */ 225 */
223int OWidgetStack::id( QWidget* wid)const{ 226int OWidgetStack::id( QWidget* wid)const{
224 if (m_list.isEmpty() ) 227 if (m_list.isEmpty() )
225 return -1; 228 return -1;
226 229
227 QMap<int, QWidget*>::ConstIterator it = m_list.begin(); 230 QMap<int, QWidget*>::ConstIterator it = m_list.begin();
228 for ( ; it != m_list.end(); ++it ) 231 for ( ; it != m_list.end(); ++it )
229 if ( it.data() == wid ) 232 if ( it.data() == wid )
230 break; 233 break;
231 234
232 /* if not at the end return the key */ 235 /* if not at the end return the key */
233 return it == m_list.end() ? -1 : it.key(); 236 return it == m_list.end() ? -1 : it.key();
234} 237}
235 238
236 239
237/** 240/**
238 * This function returns the currently visible 241 * This function returns the currently visible
239 * widget. In BigScreen mode the mainwindow 242 * widget. In BigScreen mode the mainwindow
240 * is returned 243 * is returned
241 */ 244 */
242QWidget* OWidgetStack::visibleWidget()const { 245QWidget* OWidgetStack::visibleWidget()const {
243 if (m_mode == SmallScreen ) 246 if (m_mode == SmallScreen )
244 return m_stack->visibleWidget(); 247 return m_stack->visibleWidget();
245 else 248 else
246 return m_mWidget; 249 return m_mWidget;
247 250
248} 251}
249 252
250/** 253/**
251 * This method raises the widget wit the specefic id. 254 * This method raises the widget wit the specefic id.
252 * Note that in BigScreen mode the widget is made visible 255 * Note that in BigScreen mode the widget is made visible
253 * but the other ( previous) visible widget(s) will not 256 * but the other ( previous) visible widget(s) will not
254 * be made invisible. If you need this use hideWidget(). 257 * be made invisible. If you need this use hideWidget().
255 * 258 *
256 * @param id Raise the widget with id 259 * @param id Raise the widget with id
257 */ 260 */
258void OWidgetStack::raiseWidget( int id) { 261void OWidgetStack::raiseWidget( int id) {
259 return raiseWidget( widget( id ) ); 262 return raiseWidget( widget( id ) );
260} 263}
261 264
262/** 265/**
263 * This is an overloaded function and only differs in its parameters. 266 * This is an overloaded function and only differs in its parameters.
264 * @see raiseWidget( int ) 267 * @see raiseWidget( int )
265 */ 268 */
266void OWidgetStack::raiseWidget( QWidget* wid) { 269void OWidgetStack::raiseWidget( QWidget* wid) {
267 m_last = wid; 270 m_last = wid;
268 if (m_mode == SmallScreen ) 271 if (m_mode == SmallScreen )
269 m_stack->raiseWidget( wid ); 272 m_stack->raiseWidget( wid );
270 else { 273 else {
271 int ide; 274 int ide;
272 emit aboutToShow( wid ); 275 emit aboutToShow( wid );
273 /* if someone is connected and the widget is actually available */ 276 /* if someone is connected and the widget is actually available */
274 if ( receivers( SIGNAL(aboutToShow(int) ) ) && 277 if ( receivers( SIGNAL(aboutToShow(int) ) ) &&
275 ( (ide = id( wid ) ) != -1 ) ) 278 ( (ide = id( wid ) ) != -1 ) )
276 emit aboutToShow( ide ); 279 emit aboutToShow( ide );
277 280
278 /* ### FIXME PLACE THE WIDGET right */ 281 /* ### FIXME PLACE THE WIDGET right */
279 wid->show(); 282 wid->show();
280 } 283 }
281} 284}
282 285
283/** 286/**
284 * This will hide the currently visible widget 287 * This will hide the currently visible widget
285 * and raise the widget specified by the parameter. 288 * and raise the widget specified by the parameter.
286 * Note that this method does not use visibleWIdget but remembers 289 * Note that this method does not use visibleWIdget but remembers
287 * the last raisedWidget 290 * the last raisedWidget
288 */ 291 */
289void OWidgetStack::hideWidget( int id) { 292void OWidgetStack::hideWidget( int id) {
290 /* hiding our main widget wouldn't be smart */ 293 /* hiding our main widget wouldn't be smart */
291 if ( m_mode == BigScreen && m_last != m_mWidget ) 294 if ( m_mode == BigScreen && m_last != m_mWidget )
292 m_last->hide(); 295 m_last->hide();
293 raiseWidget( id ); 296 raiseWidget( id );
294} 297}
295 298
296/** 299/**
297 * This is overloaded and only differs in the parameters 300 * This is overloaded and only differs in the parameters
298 * it takes. 301 * it takes.
299 */ 302 */
300void OWidgetStack::hideWidget( QWidget* wid) { 303void OWidgetStack::hideWidget( QWidget* wid) {
301 /* still not smart */ 304 /* still not smart */
302 if ( m_mode == BigScreen && m_last != m_mWidget ) 305 if ( m_mode == BigScreen && m_last != m_mWidget )
303 m_last->hide(); 306 m_last->hide();
304 307
305 raiseWidget( wid ); 308 raiseWidget( wid );
306} 309}
307 310
308 311
309bool OWidgetStack::eventFilter( QObject* obj, QEvent* e) { 312bool OWidgetStack::eventFilter( QObject* obj, QEvent* e) {
310 qWarning(" %s %s", obj->name(), obj->className() ); 313 owarn << " " << obj->name() << " " << obj->className() << "" << oendl;
311 if ( e->type() == QEvent::Resize ) { 314 if ( e->type() == QEvent::Resize ) {
312 QResizeEvent *res = static_cast<QResizeEvent*>( e ); 315 QResizeEvent *res = static_cast<QResizeEvent*>( e );
313 QSize size = res->size(); 316 QSize size = res->size();
314 if ( size.width() >= mode_size ) 317 if ( size.width() >= mode_size )
315 switchTop(); 318 switchTop();
316 else 319 else
317 switchStack(); 320 switchStack();
318 } 321 }
319 return false; 322 return false;
320} 323}
321 324
322 325
323/** 326/**
324 * @internal_resons 327 * @internal_resons
325 */ 328 */
326void OWidgetStack::resizeEvent( QResizeEvent* ev ) { 329void OWidgetStack::resizeEvent( QResizeEvent* ev ) {
327 QFrame::resizeEvent( ev ); 330 QFrame::resizeEvent( ev );
328 if (m_mode == SmallScreen ) 331 if (m_mode == SmallScreen )
329 m_stack->setGeometry( frameRect() ); 332 m_stack->setGeometry( frameRect() );
330 else 333 else
331 if (m_mWidget ) 334 if (m_mWidget )
332 m_mWidget->setGeometry( frameRect() ); 335 m_mWidget->setGeometry( frameRect() );
333 336
334} 337}
335 338
336/** 339/**
337 * setMainWindow gives the OWidgetStack a hint which 340 * setMainWindow gives the OWidgetStack a hint which
338 * window should always stay inside the stack. 341 * window should always stay inside the stack.
339 * Normally the first added widget is considered to be 342 * Normally the first added widget is considered to be
340 * the mainwindow but you can change this with this 343 * the mainwindow but you can change this with this
341 * function. 344 * function.
342 * If in BigScreen mode the current mainwindow will be reparented 345 * If in BigScreen mode the current mainwindow will be reparented
343 * and hidden. The position will be taken by the new one. 346 * and hidden. The position will be taken by the new one.
344 * If the old MainWindow was hidden the new window will 347 * If the old MainWindow was hidden the new window will
345 * also be hidden. If the window was visible the new mainwindow 348 * also be hidden. If the window was visible the new mainwindow
346 * 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
347 * was no mainwindow it will be hidden as well. 350 * was no mainwindow it will be hidden as well.
348 * 351 *
349 * @param wid The new mainwindow 352 * @param wid The new mainwindow
350 */ 353 */
351void OWidgetStack::setMainWindow( QWidget* wid ) { 354void OWidgetStack::setMainWindow( QWidget* wid ) {
352 if (m_mode == BigScreen ) { 355 if (m_mode == BigScreen ) {
353 bool wasVisible = false; 356 bool wasVisible = false;
354 if (m_mWidget ) { 357 if (m_mWidget ) {
355 wasVisible = !m_mWidget->isHidden(); 358 wasVisible = !m_mWidget->isHidden();
356 /* hidden by default */ 359 /* hidden by default */
357 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) ); 360 m_mWidget->reparent(0, WType_TopLevel, QPoint(10, 10) );
358 } 361 }
359 wid->reparent(this, 0, frameRect().topLeft() ); 362 wid->reparent(this, 0, frameRect().topLeft() );
360 363
361 if (wasVisible) 364 if (wasVisible)
362 wid->show(); 365 wid->show();
363 } 366 }
364 367
365 m_mWidget = wid; 368 m_mWidget = wid;
366} 369}
367 370
368/** 371/**
369 * this is an overloaded member and only differs 372 * this is an overloaded member and only differs
370 * in the type of arguments. 373 * in the type of arguments.
371 * @see setMainWindow(QWidget*) 374 * @see setMainWindow(QWidget*)
372 */ 375 */
373void OWidgetStack::setMainWindow( int id) { 376void OWidgetStack::setMainWindow( int id) {
374 setMainWindow( widget( id ) ); 377 setMainWindow( widget( id ) );
375} 378}
376 379
377 380
378/* 381/*
379 * this function switches to a stack ;) 382 * this function switches to a stack ;)
380 */ 383 */
381void OWidgetStack::switchStack() { 384void OWidgetStack::switchStack() {
382 if (m_stack ) { 385 if (m_stack ) {
383 m_stack->setGeometry( frameRect() ); 386 m_stack->setGeometry( frameRect() );
384 return; 387 return;
385 } 388 }
386 389
387 m_mode = SmallScreen; 390 m_mode = SmallScreen;
388 m_stack = new QWidgetStack(this); 391 m_stack = new QWidgetStack(this);
389 392
390 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ), 393 connect(m_stack, SIGNAL(aboutToShow(QWidget*) ),
391 this, SIGNAL(aboutToShow(QWidget*) ) ); 394 this, SIGNAL(aboutToShow(QWidget*) ) );
392 connect(m_stack, SIGNAL(aboutToShow(int) ), 395 connect(m_stack, SIGNAL(aboutToShow(int) ),
393 this, SIGNAL(aboutToShow(int) ) ); 396 this, SIGNAL(aboutToShow(int) ) );
394 397
395 /* now reparent the widgets... luckily QWidgetSatck does most of the work */ 398 /* now reparent the widgets... luckily QWidgetSatck does most of the work */
396 if (m_list.isEmpty() ) 399 if (m_list.isEmpty() )
397 return; 400 return;
398 401
399 QMap<int, QWidget*>::Iterator it = m_list.begin(); 402 QMap<int, QWidget*>::Iterator it = m_list.begin();
400 for ( ; it != m_list.end(); ++it ) 403 for ( ; it != m_list.end(); ++it )
401 m_stack->addWidget( it.data(), it.key() ); 404 m_stack->addWidget( it.data(), it.key() );
402 405
403 406
404} 407}
405 408
406/* 409/*
diff --git a/libopie2/opieui/fileselector/ofileselector.cpp b/libopie2/opieui/fileselector/ofileselector.cpp
index a9ec8c4..1f6ca05 100644
--- a/libopie2/opieui/fileselector/ofileselector.cpp
+++ b/libopie2/opieui/fileselector/ofileselector.cpp
@@ -1,134 +1,135 @@
1 1
2/* 2/*
3               =. This file is part of the OPIE Project 3               =. This file is part of the OPIE Project
4             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org> 4             .=l. Copyright (C) 2002,2003 Holger Freyther <zecke@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This library is free software; you can 6 _;:,     .>    :=|. This library is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License, 10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version. 11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This library is distributed in the hope that 13    .i_,=:_.      -<s. This library is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of 15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30/* hacky but we need to get FileSelector::filter */ 30/* hacky but we need to get FileSelector::filter */
31#define private public 31#define private public
32#include <qpe/fileselector.h> 32#include <qpe/fileselector.h>
33#undef private 33#undef private
34 34
35#include "ofileselector_p.h" 35#include "ofileselector_p.h"
36 36
37/* OPIE */ 37/* OPIE */
38#include <opie2/ofileselector.h> 38#include <opie2/ofileselector.h>
39#include <opie2/odebug.h>
39 40
40#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
41#include <qpe/mimetype.h> 42#include <qpe/mimetype.h>
42#include <qpe/resource.h> 43#include <qpe/resource.h>
43#include <qpe/storage.h> 44#include <qpe/storage.h>
44 45
45/* QT */ 46/* QT */
46#include <qcombobox.h> 47#include <qcombobox.h>
47#include <qdir.h> 48#include <qdir.h>
48#include <qhbox.h> 49#include <qhbox.h>
49#include <qheader.h> 50#include <qheader.h>
50#include <qlabel.h> 51#include <qlabel.h>
51#include <qlayout.h> 52#include <qlayout.h>
52#include <qlineedit.h> 53#include <qlineedit.h>
53#include <qlistview.h> 54#include <qlistview.h>
54#include <qpopupmenu.h> 55#include <qpopupmenu.h>
55#include <qwidgetstack.h> 56#include <qwidgetstack.h>
56#include <qregexp.h> 57#include <qregexp.h>
57#include <qobjectlist.h> 58#include <qobjectlist.h>
58 59
59using namespace Opie::Ui::Internal; 60using namespace Opie::Ui::Internal;
60 61
61namespace Opie { 62namespace Opie {
62namespace Ui { 63namespace Ui {
63namespace Internal { 64namespace Internal {
64OFileViewInterface::OFileViewInterface( OFileSelector* selector ) 65OFileViewInterface::OFileViewInterface( OFileSelector* selector )
65 : m_selector( selector ) 66 : m_selector( selector )
66{} 67{}
67 68
68OFileViewInterface::~OFileViewInterface() 69OFileViewInterface::~OFileViewInterface()
69{} 70{}
70 71
71QString OFileViewInterface::name()const 72QString OFileViewInterface::name()const
72{ 73{
73 return m_name; 74 return m_name;
74} 75}
75 76
76void OFileViewInterface::setName( const QString& name ) 77void OFileViewInterface::setName( const QString& name )
77{ 78{
78 m_name = name; 79 m_name = name;
79} 80}
80 81
81OFileSelector* OFileViewInterface::selector()const 82OFileSelector* OFileViewInterface::selector()const
82{ 83{
83 return m_selector; 84 return m_selector;
84} 85}
85 86
86DocLnk OFileViewInterface::selectedDocument()const 87DocLnk OFileViewInterface::selectedDocument()const
87{ 88{
88 return DocLnk( selectedName() ); 89 return DocLnk( selectedName() );
89} 90}
90 91
91bool OFileViewInterface::showNew()const 92bool OFileViewInterface::showNew()const
92{ 93{
93 return selector()->showNew(); 94 return selector()->showNew();
94} 95}
95 96
96bool OFileViewInterface::showClose()const 97bool OFileViewInterface::showClose()const
97{ 98{
98 return selector()->showClose(); 99 return selector()->showClose();
99} 100}
100 101
101MimeTypes OFileViewInterface::mimeTypes()const 102MimeTypes OFileViewInterface::mimeTypes()const
102{ 103{
103 return selector()->mimeTypes(); 104 return selector()->mimeTypes();
104} 105}
105 106
106QStringList OFileViewInterface::currentMimeType()const 107QStringList OFileViewInterface::currentMimeType()const
107{ 108{
108 return selector()->currentMimeType(); 109 return selector()->currentMimeType();
109} 110}
110 111
111void OFileViewInterface::activate( const QString& ) 112void OFileViewInterface::activate( const QString& )
112{ 113{
113 // not implemented here 114 // not implemented here
114} 115}
115 116
116void OFileViewInterface::ok() 117void OFileViewInterface::ok()
117{ 118{
118 emit selector()->ok(); 119 emit selector()->ok();
119} 120}
120 121
121void OFileViewInterface::cancel() 122void OFileViewInterface::cancel()
122{ 123{
123 emit selector()->cancel(); 124 emit selector()->cancel();
124} 125}
125 126
126void OFileViewInterface::closeMe() 127void OFileViewInterface::closeMe()
127{ 128{
128 emit selector()->closeMe(); 129 emit selector()->closeMe();
129} 130}
130 131
131void OFileViewInterface::fileSelected( const QString& str) 132void OFileViewInterface::fileSelected( const QString& str)
132{ 133{
133 emit selector()->fileSelected( str); 134 emit selector()->fileSelected( str);
134} 135}
@@ -453,221 +454,221 @@ void OFileViewFileListView::reread( bool all )
453 * It is a symlink we try to resolve it now but don't let us attack by DOS 454 * It is a symlink we try to resolve it now but don't let us attack by DOS
454 * 455 *
455 */ 456 */
456 if( fi->isSymLink() ) 457 if( fi->isSymLink() )
457 { 458 {
458 QString file = fi->dirPath( true ) + "/" + fi->readLink(); 459 QString file = fi->dirPath( true ) + "/" + fi->readLink();
459 for( int i = 0; i<=4; i++) 460 for( int i = 0; i<=4; i++)
460 { // 5 tries to prevent dos 461 { // 5 tries to prevent dos
461 QFileInfo info( file ); 462 QFileInfo info( file );
462 if( !info.exists() ) 463 if( !info.exists() )
463 { 464 {
464 addSymlink( fi, TRUE ); 465 addSymlink( fi, TRUE );
465 break; 466 break;
466 } 467 }
467 else if( info.isDir() ) 468 else if( info.isDir() )
468 { 469 {
469 addDir( fi, TRUE ); 470 addDir( fi, TRUE );
470 break; 471 break;
471 } 472 }
472 else if( info.isFile() ) 473 else if( info.isFile() )
473 { 474 {
474 addFile( fi, TRUE ); 475 addFile( fi, TRUE );
475 break; 476 break;
476 } 477 }
477 else if( info.isSymLink() ) 478 else if( info.isSymLink() )
478 { 479 {
479 file = info.dirPath(true ) + "/" + info.readLink() ; 480 file = info.dirPath(true ) + "/" + info.readLink() ;
480 break; 481 break;
481 } 482 }
482 else if( i == 4) 483 else if( i == 4)
483 { // couldn't resolve symlink add it as symlink 484 { // couldn't resolve symlink add it as symlink
484 addSymlink( fi ); 485 addSymlink( fi );
485 } 486 }
486 } // off for loop for symlink resolving 487 } // off for loop for symlink resolving
487 } 488 }
488 else if( fi->isDir() ) 489 else if( fi->isDir() )
489 addDir( fi ); 490 addDir( fi );
490 else if( fi->isFile() ) 491 else if( fi->isFile() )
491 addFile( fi ); 492 addFile( fi );
492 493
493 ++it; 494 ++it;
494 } // of while loop 495 } // of while loop
495 m_view->sort(); 496 m_view->sort();
496 497
497} 498}
498int OFileViewFileListView::fileCount()const 499int OFileViewFileListView::fileCount()const
499{ 500{
500 return m_view->childCount(); 501 return m_view->childCount();
501} 502}
502 503
503QString OFileViewFileListView::currentDir()const 504QString OFileViewFileListView::currentDir()const
504{ 505{
505 return m_currentDir; 506 return m_currentDir;
506} 507}
507 508
508OFileSelector* OFileViewFileListView::selector() 509OFileSelector* OFileViewFileListView::selector()
509{ 510{
510 return m_sel; 511 return m_sel;
511} 512}
512 513
513bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) 514bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e)
514{ 515{
515 if ( e->type() == QEvent::KeyPress ) 516 if ( e->type() == QEvent::KeyPress )
516 { 517 {
517 QKeyEvent *k = (QKeyEvent *)e; 518 QKeyEvent *k = (QKeyEvent *)e;
518 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) 519 if ( (k->key()==Key_Enter) || (k->key()==Key_Return))
519 { 520 {
520 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 521 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
521 return true; 522 return true;
522 } 523 }
523 } 524 }
524 return false; 525 return false;
525} 526}
526 527
527void OFileViewFileListView::connectSlots() 528void OFileViewFileListView::connectSlots()
528{ 529{
529 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 530 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
530 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 531 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
531 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ), 532 connect(m_view, SIGNAL(mouseButtonClicked(int,QListViewItem*,const QPoint&,int) ),
532 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) ); 533 this, SLOT(slotClicked(int,QListViewItem*,const QPoint&,int) ) );
533} 534}
534 535
535void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) 536void OFileViewFileListView::slotCurrentChanged( QListViewItem* item)
536{ 537{
537 if (!item) 538 if (!item)
538 return; 539 return;
539#if 0 540#if 0
540 541
541 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 542 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
542 543
543 if (!sel->isDir() ) 544 if (!sel->isDir() )
544 { 545 {
545 selector()->m_lneEdit->setText( sel->text(1) ); 546 selector()->m_lneEdit->setText( sel->text(1) );
546 // if in fileselector mode we will emit selected 547 // if in fileselector mode we will emit selected
547 if ( selector()->mode() == OFileSelector::FileSelector ) 548 if ( selector()->mode() == OFileSelector::FileSelector )
548 { 549 {
549 qWarning("slot Current Changed"); 550 owarn << "slot Current Changed" << oendl;
550 QStringList str = QStringList::split("->", sel->text(1) ); 551 QStringList str = QStringList::split("->", sel->text(1) );
551 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 552 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
552 emit selector()->fileSelected( path ); 553 emit selector()->fileSelected( path );
553 DocLnk lnk( path ); 554 DocLnk lnk( path );
554 emit selector()->fileSelected( lnk ); 555 emit selector()->fileSelected( lnk );
555 } 556 }
556 } 557 }
557#endif 558#endif
558} 559}
559 560
560void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) 561void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int )
561{ 562{
562 if (!item || ( button != Qt::LeftButton) ) 563 if (!item || ( button != Qt::LeftButton) )
563 return; 564 return;
564 565
565 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 566 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
566 if (!sel->isLocked() ) 567 if (!sel->isLocked() )
567 { 568 {
568 QStringList str = QStringList::split("->", sel->text(1) ); 569 QStringList str = QStringList::split("->", sel->text(1) );
569 if (sel->isDir() ) 570 if (sel->isDir() )
570 { 571 {
571 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 572 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
572 emit selector()->dirSelected( m_currentDir ); 573 emit selector()->dirSelected( m_currentDir );
573 reread( m_all ); 574 reread( m_all );
574 } 575 }
575 else 576 else
576 { // file 577 { // file
577 qWarning("slot Clicked"); 578 owarn << "slot Clicked" << oendl;
578 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 579 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
579 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 580 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
580 emit selector()->fileSelected( path ); 581 emit selector()->fileSelected( path );
581 DocLnk lnk( path ); 582 DocLnk lnk( path );
582 emit selector()->fileSelected( lnk ); 583 emit selector()->fileSelected( lnk );
583 } 584 }
584 } // not locked 585 } // not locked
585} 586}
586 587
587void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) 588void OFileViewFileListView::addFile( QFileInfo* info, bool symlink )
588{ 589{
589 MimeType type( info->absFilePath() ); 590 MimeType type( info->absFilePath() );
590 if (!compliesMime( type.id() ) ) 591 if (!compliesMime( type.id() ) )
591 return; 592 return;
592 593
593 QPixmap pix = type.pixmap(); 594 QPixmap pix = type.pixmap();
594 QString dir, name; bool locked; 595 QString dir, name; bool locked;
595 if ( pix.isNull() ) 596 if ( pix.isNull() )
596 { 597 {
597 QWMatrix matrix; 598 QWMatrix matrix;
598 QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); 599 QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
599 matrix.scale( .4, .4 ); 600 matrix.scale( .4, .4 );
600 pix = pixer.xForm( matrix ); 601 pix = pixer.xForm( matrix );
601 } 602 }
602 dir = info->dirPath( true ); 603 dir = info->dirPath( true );
603 locked = false; 604 locked = false;
604 if ( symlink ) 605 if ( symlink )
605 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink(); 606 name = info->fileName() + " -> " + info->dirPath() + "/" + info->readLink();
606 else 607 else
607 { 608 {
608 name = info->fileName(); 609 name = info->fileName();
609 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || 610 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
610 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) 611 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) )
611 { 612 {
612 locked = true; pix = Resource::loadPixmap("locked"); 613 locked = true; pix = Resource::loadPixmap("locked");
613 } 614 }
614 } 615 }
615 (void)new OFileSelectorItem( m_view, pix, name, 616 (void)new OFileSelectorItem( m_view, pix, name,
616 info->lastModified().toString(), QString::number( info->size() ), 617 info->lastModified().toString(), QString::number( info->size() ),
617 dir, locked ); 618 dir, locked );
618} 619}
619 620
620void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) 621void OFileViewFileListView::addDir( QFileInfo* info, bool symlink )
621{ 622{
622 bool locked = false; QString name; QPixmap pix; 623 bool locked = false; QString name; QPixmap pix;
623 624
624 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || 625 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
625 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) 626 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) )
626 { 627 {
627 locked = true; 628 locked = true;
628 if ( symlink ) 629 if ( symlink )
629 pix = Resource::loadPixmap( "opie/symlink" ); 630 pix = Resource::loadPixmap( "opie/symlink" );
630 else 631 else
631 pix = Resource::loadPixmap( "lockedfolder" ); 632 pix = Resource::loadPixmap( "lockedfolder" );
632 } 633 }
633 else 634 else
634 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder"); 635 pix = symlink ? Resource::loadPixmap( "opie/symlink") : Resource::loadPixmap("folder");
635 636
636 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() : 637 name = symlink ? info->fileName() + " -> " + info->dirPath(true) + "/" + info->readLink() :
637 info->fileName(); 638 info->fileName();
638 639
639 (void)new OFileSelectorItem( m_view, pix, name, 640 (void)new OFileSelectorItem( m_view, pix, name,
640 info->lastModified().toString(), 641 info->lastModified().toString(),
641 QString::number( info->size() ), 642 QString::number( info->size() ),
642 info->dirPath( true ), locked, true ); 643 info->dirPath( true ), locked, true );
643 644
644 645
645} 646}
646 647
647void OFileViewFileListView::addSymlink( QFileInfo* , bool ) 648void OFileViewFileListView::addSymlink( QFileInfo* , bool )
648{ 649{
649} 650}
650 651
651void OFileViewFileListView::cdUP() 652void OFileViewFileListView::cdUP()
652{ 653{
653 QDir dir( m_currentDir ); 654 QDir dir( m_currentDir );
654 dir.cdUp(); 655 dir.cdUp();
655 656
656 if (!dir.exists() ) 657 if (!dir.exists() )
657 m_currentDir = "/"; 658 m_currentDir = "/";
658 else 659 else
659 m_currentDir = dir.absPath(); 660 m_currentDir = dir.absPath();
660 661
661 emit selector()->dirSelected( m_currentDir ); 662 emit selector()->dirSelected( m_currentDir );
662 reread( m_all ); 663 reread( m_all );
663} 664}
664 665
665void OFileViewFileListView::cdHome() 666void OFileViewFileListView::cdHome()
666{ 667{
667 m_currentDir = QDir::homeDirPath(); 668 m_currentDir = QDir::homeDirPath();
668 emit selector()->dirSelected( m_currentDir ); 669 emit selector()->dirSelected( m_currentDir );
669 reread( m_all ); 670 reread( m_all );
670} 671}
671 672
672void OFileViewFileListView::cdDoc() 673void OFileViewFileListView::cdDoc()
673{ 674{
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp
index d7c92fd..0b3bdea 100644
--- a/libopie2/opieui/olistview.cpp
+++ b/libopie2/opieui/olistview.cpp
@@ -94,193 +94,193 @@ 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 qDebug( "read text '%s' for column %d", (const char*) coltext, i ); 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} 235}
236 236
237QDataStream& operator>>( QDataStream& s, OListView& lv ) 237QDataStream& operator>>( QDataStream& s, OListView& lv )
238{ 238{
239 lv.serializeFrom( s ); 239 lv.serializeFrom( s );
240} 240}
241#endif // QT_NO_DATASTREAM 241#endif // QT_NO_DATASTREAM
242 242
243/*====================================================================================== 243/*======================================================================================
244 * OListViewItem 244 * OListViewItem
245 *======================================================================================*/ 245 *======================================================================================*/
246 246
247OListViewItem::OListViewItem(QListView *parent) 247OListViewItem::OListViewItem(QListView *parent)
248 : QListViewItem(parent) 248 : QListViewItem(parent)
249{ 249{
250 init(); 250 init();
251} 251}
252 252
253 253
254OListViewItem::OListViewItem(QListViewItem *parent) 254OListViewItem::OListViewItem(QListViewItem *parent)
255 : QListViewItem(parent) 255 : QListViewItem(parent)
256{ 256{
257 init(); 257 init();
258} 258}
259 259
260 260
261OListViewItem::OListViewItem(QListView *parent, QListViewItem *after) 261OListViewItem::OListViewItem(QListView *parent, QListViewItem *after)
262 : QListViewItem(parent, after) 262 : QListViewItem(parent, after)
263{ 263{
264 init(); 264 init();
265} 265}
266 266
267 267
268OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after) 268OListViewItem::OListViewItem(QListViewItem *parent, QListViewItem *after)
269 : QListViewItem(parent, after) 269 : QListViewItem(parent, after)
270{ 270{
271 init(); 271 init();
272} 272}
273 273
274 274
275OListViewItem::OListViewItem(QListView *parent, 275OListViewItem::OListViewItem(QListView *parent,
276 QString label1, QString label2, QString label3, QString label4, 276 QString label1, QString label2, QString label3, QString label4,
277 QString label5, QString label6, QString label7, QString label8) 277 QString label5, QString label6, QString label7, QString label8)
278 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 278 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
279{ 279{
280 init(); 280 init();
281} 281}
282 282
283 283
284OListViewItem::OListViewItem(QListViewItem *parent, 284OListViewItem::OListViewItem(QListViewItem *parent,
285 QString label1, QString label2, QString label3, QString label4, 285 QString label1, QString label2, QString label3, QString label4,
286 QString label5, QString label6, QString label7, QString label8) 286 QString label5, QString label6, QString label7, QString label8)
@@ -349,416 +349,416 @@ bool OListViewItem::isAlternate()
349 if (parent()) 349 if (parent())
350 { 350 {
351 item = static_cast<OListViewItem *>(parent()); 351 item = static_cast<OListViewItem *>(parent());
352 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd; 352 if ( item /*&& item->inherits( "OListViewItem" )*/ ) previous = item->m_odd;
353 item = static_cast<OListViewItem *>(parent()->firstChild()); 353 item = static_cast<OListViewItem *>(parent()->firstChild());
354 /* if ( !item.inherits( "OListViewItem" ) item = 0; */ 354 /* if ( !item.inherits( "OListViewItem" ) item = 0; */
355 } 355 }
356 else 356 else
357 { 357 {
358 item = static_cast<OListViewItem *>(lv->firstChild()); 358 item = static_cast<OListViewItem *>(lv->firstChild());
359 } 359 }
360 360
361 while(item) 361 while(item)
362 { 362 {
363 item->m_odd = previous = !previous; 363 item->m_odd = previous = !previous;
364 item->m_known = true; 364 item->m_known = true;
365 item = static_cast<OListViewItem *>(item->nextSibling()); 365 item = static_cast<OListViewItem *>(item->nextSibling());
366 /* if (!item.inherits( "OListViewItem" ) ) break; */ 366 /* if (!item.inherits( "OListViewItem" ) ) break; */
367 } 367 }
368 } 368 }
369 return m_odd; 369 return m_odd;
370} 370}
371 371
372 372
373void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 373void OListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
374{ 374{
375 QColorGroup _cg = cg; 375 QColorGroup _cg = cg;
376 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 376 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
377 if (pm && !pm->isNull()) 377 if (pm && !pm->isNull())
378 { 378 {
379 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); 379 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) );
380 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 380 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
381 } 381 }
382 else if ( isAlternate() ) 382 else if ( isAlternate() )
383 { 383 {
384 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); 384 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
385 } 385 }
386 QListViewItem::paintCell( p, _cg, column, width, alignment ); 386 QListViewItem::paintCell( p, _cg, column, width, alignment );
387 387
388 //FIXME: Use styling here! 388 //FIXME: Use styling here!
389 389
390 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); 390 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
391 p->setPen( pen ); 391 p->setPen( pen );
392 p->drawLine( width-1, 0, width-1, height() ); 392 p->drawLine( width-1, 0, width-1, height() );
393} 393}
394 394
395 395
396OListViewItem* OListViewItem::childFactory() 396OListViewItem* OListViewItem::childFactory()
397{ 397{
398 return new OListViewItem( this ); 398 return new OListViewItem( this );
399} 399}
400 400
401 401
402#ifndef QT_NO_DATASTREAM 402#ifndef QT_NO_DATASTREAM
403void OListViewItem::serializeTo( QDataStream& s ) const 403void OListViewItem::serializeTo( QDataStream& s ) const
404{ 404{
405 #warning Caution... the binary format is still under construction... 405 #warning Caution... the binary format is still under construction...
406 odebug << "storing OListViewItem..." << oendl; 406 odebug << "storing OListViewItem..." << oendl;
407 407
408 // store item text 408 // store item text
409 for ( int i = 0; i < listView()->columns(); ++i ) 409 for ( int i = 0; i < listView()->columns(); ++i )
410 { 410 {
411 s << text( i ); 411 s << text( i );
412 } 412 }
413 413
414 // calculate the number of children to serialize 414 // calculate the number of children to serialize
415 int items = 0; 415 int items = 0;
416 QListViewItem* item = firstChild(); 416 QListViewItem* item = firstChild();
417 while ( item ) 417 while ( item )
418 { 418 {
419 item = item->nextSibling(); 419 item = item->nextSibling();
420 items++; 420 items++;
421 } 421 }
422 422
423 // store number of items and the items itself 423 // store number of items and the items itself
424 s << items; 424 s << items;
425 item = firstChild(); 425 item = firstChild();
426 for ( int i = 0; i < items; ++i ) 426 for ( int i = 0; i < items; ++i )
427 { 427 {
428 s << *static_cast<OListViewItem*>( item ); 428 s << *static_cast<OListViewItem*>( item );
429 item = item->nextSibling(); 429 item = item->nextSibling();
430 } 430 }
431 431
432 odebug << "OListviewItem stored." << oendl; 432 odebug << "OListviewItem stored." << oendl;
433} 433}
434 434
435 435
436void OListViewItem::serializeFrom( QDataStream& s ) 436void OListViewItem::serializeFrom( QDataStream& s )
437{ 437{
438 #warning Caution... the binary format is still under construction... 438 #warning Caution... the binary format is still under construction...
439 odebug << "loading OListViewItem..." << oendl; 439 odebug << "loading OListViewItem..." << oendl;
440 440
441 for ( int i = 0; i < listView()->columns(); ++i ) 441 for ( int i = 0; i < listView()->columns(); ++i )
442 { 442 {
443 QString coltext; 443 QString coltext;
444 s >> coltext; 444 s >> coltext;
445 qDebug( "read text '%s' for column %d", (const char*) coltext, i ); 445 odebug << "read text '" << coltext << "' for column " << i << "" << oendl;
446 setText( i, coltext ); 446 setText( i, coltext );
447 } 447 }
448 448
449 int items; 449 int items;
450 s >> items; 450 s >> items;
451 qDebug( "read number of items = %d", items ); 451 odebug << "read number of items = " << items << "" << oendl;
452 452
453 for ( int i = 0; i < items; ++i ) 453 for ( int i = 0; i < items; ++i )
454 { 454 {
455 OListViewItem* item = childFactory(); 455 OListViewItem* item = childFactory();
456 s >> (*item); 456 s >> (*item);
457 } 457 }
458 458
459 odebug << "OListViewItem loaded." << oendl; 459 odebug << "OListViewItem loaded." << oendl;
460} 460}
461 461
462 462
463QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi ) 463QDataStream& operator<<( QDataStream& s, const OListViewItem& lvi )
464{ 464{
465 lvi.serializeTo( s ); 465 lvi.serializeTo( s );
466} 466}
467 467
468 468
469QDataStream& operator>>( QDataStream& s, OListViewItem& lvi ) 469QDataStream& operator>>( QDataStream& s, OListViewItem& lvi )
470{ 470{
471 lvi.serializeFrom( s ); 471 lvi.serializeFrom( s );
472} 472}
473#endif // QT_NO_DATASTREAM 473#endif // QT_NO_DATASTREAM
474 474
475 475
476/*====================================================================================== 476/*======================================================================================
477 * OCheckListItem 477 * OCheckListItem
478 *======================================================================================*/ 478 *======================================================================================*/
479 479
480OCheckListItem::OCheckListItem( QCheckListItem* parent, const QString& text, Type t ) 480OCheckListItem::OCheckListItem( QCheckListItem* parent, const QString& text, Type t )
481 :QCheckListItem( parent, text, t ) 481 :QCheckListItem( parent, text, t )
482{ 482{
483 init(); 483 init();
484} 484}
485 485
486 486
487OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, Type t) 487OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, Type t)
488 :QCheckListItem( parent, text, t ) 488 :QCheckListItem( parent, text, t )
489{ 489{
490 init(); 490 init();
491} 491}
492 492
493 493
494OCheckListItem::OCheckListItem( QListView* parent, const QString& text, Type t ) 494OCheckListItem::OCheckListItem( QListView* parent, const QString& text, Type t )
495 :QCheckListItem( parent, text, t ) 495 :QCheckListItem( parent, text, t )
496{ 496{
497 init(); 497 init();
498} 498}
499 499
500 500
501OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, const QPixmap& p ) 501OCheckListItem::OCheckListItem( QListViewItem* parent, const QString& text, const QPixmap& p )
502 :QCheckListItem( parent, text, p ) 502 :QCheckListItem( parent, text, p )
503{ 503{
504 init(); 504 init();
505} 505}
506 506
507 507
508OCheckListItem::OCheckListItem( QListView* parent, const QString& text, const QPixmap& p ) 508OCheckListItem::OCheckListItem( QListView* parent, const QString& text, const QPixmap& p )
509 :QCheckListItem( parent, text, p ) 509 :QCheckListItem( parent, text, p )
510{ 510{
511 init(); 511 init();
512} 512}
513 513
514 514
515OCheckListItem::~OCheckListItem() 515OCheckListItem::~OCheckListItem()
516{ 516{
517} 517}
518 518
519void OCheckListItem::init() 519void OCheckListItem::init()
520{ 520{
521 m_known = false; 521 m_known = false;
522} 522}
523 523
524 524
525const QColor &OCheckListItem::backgroundColor() 525const QColor &OCheckListItem::backgroundColor()
526{ 526{
527 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() : 527 return isAlternate() ? static_cast<OListView*>(listView())->alternateBackground() :
528 listView()->viewport()->colorGroup().base(); 528 listView()->viewport()->colorGroup().base();
529} 529}
530 530
531 531
532bool OCheckListItem::isAlternate() 532bool OCheckListItem::isAlternate()
533{ 533{
534 OListView *lv = static_cast<OListView*>( listView() ); 534 OListView *lv = static_cast<OListView*>( listView() );
535 535
536 // check if the item above is an OCheckListItem 536 // check if the item above is an OCheckListItem
537 OCheckListItem *above = static_cast<OCheckListItem*>( itemAbove() ); 537 OCheckListItem *above = static_cast<OCheckListItem*>( itemAbove() );
538 /*if (! itemAbove()->inherits( "OCheckListItem" )) return false;*/ 538 /*if (! itemAbove()->inherits( "OCheckListItem" )) return false;*/
539 539
540 // check if we have a valid alternate background color 540 // check if we have a valid alternate background color
541 if (!(lv && lv->alternateBackground().isValid())) return false; 541 if (!(lv && lv->alternateBackground().isValid())) return false;
542 542
543 m_known = above ? above->m_known : true; 543 m_known = above ? above->m_known : true;
544 if (m_known) 544 if (m_known)
545 { 545 {
546 m_odd = above ? !above->m_odd : false; 546 m_odd = above ? !above->m_odd : false;
547 } 547 }
548 else 548 else
549 { 549 {
550 OCheckListItem *item; 550 OCheckListItem *item;
551 bool previous = true; 551 bool previous = true;
552 if (parent()) 552 if (parent())
553 { 553 {
554 item = static_cast<OCheckListItem *>(parent()); 554 item = static_cast<OCheckListItem *>(parent());
555 if ( item /*&& item->inherits( "OCheckListItem" )*/ ) previous = item->m_odd; 555 if ( item /*&& item->inherits( "OCheckListItem" )*/ ) previous = item->m_odd;
556 item = static_cast<OCheckListItem *>(parent()->firstChild()); 556 item = static_cast<OCheckListItem *>(parent()->firstChild());
557 /* if ( !item.inherits( "OCheckListItem" ) item = 0; */ 557 /* if ( !item.inherits( "OCheckListItem" ) item = 0; */
558 } 558 }
559 else 559 else
560 { 560 {
561 item = static_cast<OCheckListItem *>(lv->firstChild()); 561 item = static_cast<OCheckListItem *>(lv->firstChild());
562 } 562 }
563 563
564 while(item) 564 while(item)
565 { 565 {
566 item->m_odd = previous = !previous; 566 item->m_odd = previous = !previous;
567 item->m_known = true; 567 item->m_known = true;
568 item = static_cast<OCheckListItem *>(item->nextSibling()); 568 item = static_cast<OCheckListItem *>(item->nextSibling());
569 /* if (!item.inherits( "OCheckListItem" ) ) break; */ 569 /* if (!item.inherits( "OCheckListItem" ) ) break; */
570 } 570 }
571 } 571 }
572 return m_odd; 572 return m_odd;
573} 573}
574 574
575 575
576void OCheckListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 576void OCheckListItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
577{ 577{
578 QColorGroup _cg = cg; 578 QColorGroup _cg = cg;
579 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 579 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
580 if (pm && !pm->isNull()) 580 if (pm && !pm->isNull())
581 { 581 {
582 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) ); 582 _cg.setBrush( QColorGroup::Base, QBrush(backgroundColor(), *pm) );
583 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() ); 583 p->setBrushOrigin( -listView()->contentsX(), -listView()->contentsY() );
584 } 584 }
585 else if ( isAlternate() ) 585 else if ( isAlternate() )
586 { 586 {
587 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() ); 587 _cg.setColor( QColorGroup::Base, static_cast<OListView*>( listView() )->alternateBackground() );
588 } 588 }
589 QCheckListItem::paintCell( p, _cg, column, width, alignment ); 589 QCheckListItem::paintCell( p, _cg, column, width, alignment );
590 590
591 //FIXME: Use styling here! 591 //FIXME: Use styling here!
592 592
593 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator(); 593 const QPen& pen = static_cast<OListView*>( listView() )->columnSeparator();
594 p->setPen( pen ); 594 p->setPen( pen );
595 p->drawLine( width-1, 0, width-1, height() ); 595 p->drawLine( width-1, 0, width-1, height() );
596} 596}
597 597
598 598
599/*====================================================================================== 599/*======================================================================================
600 * ONamedListView 600 * ONamedListView
601 *======================================================================================*/ 601 *======================================================================================*/
602 602
603ONamedListView::ONamedListView( QWidget *parent, const char *name ) 603ONamedListView::ONamedListView( QWidget *parent, const char *name )
604 :OListView( parent, name ) 604 :OListView( parent, name )
605{ 605{
606} 606}
607 607
608 608
609ONamedListView::~ONamedListView() 609ONamedListView::~ONamedListView()
610{ 610{
611} 611}
612 612
613 613
614void ONamedListView::addColumns( const QStringList& columns ) 614void ONamedListView::addColumns( const QStringList& columns )
615{ 615{
616 for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it ) 616 for ( QStringList::ConstIterator it = columns.begin(); it != columns.end(); ++it )
617 { 617 {
618 qDebug( "adding column %s", (const char*) *it ); 618 odebug << "adding column " << *it << "" << oendl;
619 addColumn( *it ); 619 addColumn( *it );
620 } 620 }
621} 621}
622 622
623 623
624int ONamedListView::findColumn( const QString& text ) const 624int ONamedListView::findColumn( const QString& text ) const
625{ 625{
626 //FIXME: If used excessively, this will slow down performance of updates 626 //FIXME: If used excessively, this will slow down performance of updates
627 //FIXME: because of the linear search over all column texts. 627 //FIXME: because of the linear search over all column texts.
628 //FIXME: I will optimize later by using a hash map. 628 //FIXME: I will optimize later by using a hash map.
629 for ( int i = 0; i < columns(); ++i ) 629 for ( int i = 0; i < columns(); ++i )
630 if ( columnText( i ) == text ) 630 if ( columnText( i ) == text )
631 return i; 631 return i;
632 return -1; 632 return -1;
633} 633}
634 634
635 635
636ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const 636ONamedListViewItem* ONamedListView::find( int column, const QString& text, int recurse ) const
637{ 637{
638 return find( (ONamedListViewItem*) firstChild(), column, text, recurse ); 638 return find( (ONamedListViewItem*) firstChild(), column, text, recurse );
639} 639}
640 640
641 641
642ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const 642ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, int column, const QString& text, int recurse ) const
643{ 643{
644 ONamedListViewItem* result; 644 ONamedListViewItem* result;
645 while ( item && item->text( column ) != text ) 645 while ( item && item->text( column ) != text )
646 { 646 {
647 qDebug( "checked %s", (const char*) item->text( column ) ); 647 odebug << "checked " << item->text( column ) << "" << oendl;
648 648
649 if ( recurse < 0 || recurse > 0 ) 649 if ( recurse < 0 || recurse > 0 )
650 { 650 {
651 qDebug( "recursion is %d - recursing into...", recurse ); 651 odebug << "recursion is " << recurse << " - recursing into..." << oendl;
652 result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 ); 652 result = find( (ONamedListViewItem*) item->firstChild(), column, text, recurse-1 );
653 if ( result ) return result; 653 if ( result ) return result;
654 } 654 }
655 655
656 656
657 item = (ONamedListViewItem*) item->itemBelow(); 657 item = (ONamedListViewItem*) item->itemBelow();
658 } 658 }
659 if ( item && item->text( column ) == text ) 659 if ( item && item->text( column ) == text )
660 return item; 660 return item;
661 else 661 else
662 return 0; 662 return 0;
663} 663}
664 664
665 665
666ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const 666ONamedListViewItem* ONamedListView::find( const QString& column, const QString& text, int recurse ) const
667{ 667{
668 int col = findColumn( column ); 668 int col = findColumn( column );
669 if ( col != -1 ) 669 if ( col != -1 )
670 return find( (ONamedListViewItem*) firstChild(), col, text, recurse ); 670 return find( (ONamedListViewItem*) firstChild(), col, text, recurse );
671 else 671 else
672 return 0; 672 return 0;
673} 673}
674 674
675 675
676ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const 676ONamedListViewItem* ONamedListView::find( ONamedListViewItem* item, const QString& column, const QString& text, int recurse ) const
677{ 677{
678 int col = findColumn( column ); 678 int col = findColumn( column );
679 if ( col != -1 ) 679 if ( col != -1 )
680 return find( item, col, text, recurse ); 680 return find( item, col, text, recurse );
681 else 681 else
682 return 0; 682 return 0;
683} 683}
684 684
685 685
686/*====================================================================================== 686/*======================================================================================
687 * ONamedListViewItem 687 * ONamedListViewItem
688 *======================================================================================*/ 688 *======================================================================================*/
689 689
690ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts ) 690ONamedListViewItem::ONamedListViewItem( QListView* parent, const QStringList& texts )
691 :OListViewItem( parent ) 691 :OListViewItem( parent )
692{ 692{
693 setText( texts ); 693 setText( texts );
694} 694}
695 695
696 696
697ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts ) 697ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, const QStringList& texts )
698 :OListViewItem( parent ) 698 :OListViewItem( parent )
699{ 699{
700 setText( texts ); 700 setText( texts );
701} 701}
702 702
703 703
704ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts ) 704ONamedListViewItem::ONamedListViewItem( QListView* parent, QListViewItem* after, const QStringList& texts )
705 :OListViewItem( parent, after ) 705 :OListViewItem( parent, after )
706{ 706{
707 setText( texts ); 707 setText( texts );
708} 708}
709 709
710 710
711ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts ) 711ONamedListViewItem::ONamedListViewItem( QListViewItem* parent, QListViewItem* after, const QStringList& texts )
712 :OListViewItem( parent, after ) 712 :OListViewItem( parent, after )
713{ 713{
714 setText( texts ); 714 setText( texts );
715} 715}
716 716
717 717
718ONamedListViewItem::~ONamedListViewItem() 718ONamedListViewItem::~ONamedListViewItem()
719{ 719{
720} 720}
721 721
722 722
723void ONamedListViewItem::setText( const QStringList& texts ) 723void ONamedListViewItem::setText( const QStringList& texts )
724{ 724{
725 int col = 0; 725 int col = 0;
726 for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it ) 726 for ( QStringList::ConstIterator it = texts.begin(); it != texts.end(); ++it )
727 { 727 {
728 qDebug( "setting column %d = text %s", col, (const char*) *it ); 728 odebug << "setting column " << col << " = text " << *it << "" << oendl;
729 OListViewItem::setText( col++, *it ); 729 OListViewItem::setText( col++, *it );
730 } 730 }
731 731
732} 732}
733 733
734 734
735void ONamedListViewItem::setText( const QString& column, const QString& text ) 735void ONamedListViewItem::setText( const QString& column, const QString& text )
736{ 736{
737 //FIXME: If used excessively, this will slow down performance of updates 737 //FIXME: If used excessively, this will slow down performance of updates
738 //FIXME: because of the linear search over all column texts. 738 //FIXME: because of the linear search over all column texts.
739 //FIXME: I will optimize later by using a hash map. 739 //FIXME: I will optimize later by using a hash map.
740 int col = ( (ONamedListView*) listView() )->findColumn( column ); 740 int col = ( (ONamedListView*) listView() )->findColumn( column );
741 if ( col != -1 ) 741 if ( col != -1 )
742 OListViewItem::setText( col, text ); 742 OListViewItem::setText( col, text );
743 else 743 else
744 qWarning( "ONamedListViewItem::setText(): Warning! Columntext '%s' not found.", (const char*) column ); 744 owarn << "ONamedListViewItem::setText(): Warning! Columntext '" << column << "' not found." << oendl;
745} 745}
746 746
747 747
748ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const 748ONamedListViewItem* ONamedListViewItem::find( int column, const QString& text, int recurse ) const
749{ 749{
750 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse ); 750 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), column, text, recurse );
751} 751}
752 752
753 753
754ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const 754ONamedListViewItem* ONamedListViewItem::find( const QString& column, const QString& text, int recurse ) const
755{ 755{
756 int col = ( (ONamedListView*) listView() )->findColumn( column ); 756 int col = ( (ONamedListView*) listView() )->findColumn( column );
757 if ( col != -1 ) 757 if ( col != -1 )
758 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse ); 758 return ( (ONamedListView*) listView() )->find( (ONamedListViewItem*) firstChild(), col, text, recurse );
759 else 759 else
760 return 0; 760 return 0;
761} 761}
762 762
763} 763}
764} 764}
diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp
index 3ab8490..50c613f 100644
--- a/libopie2/opieui/opopupmenu.cpp
+++ b/libopie2/opieui/opopupmenu.cpp
@@ -1,360 +1,360 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> 2 Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org>
3 Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au> 3 Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20/* QT */ 20/* OPIE */
21#include <opie2/opopupmenu.h>
22#include <opie2/oconfig.h>
23#include <opie2/odebug.h>
21 24
25/* QT */
22#include <qdrawutil.h> 26#include <qdrawutil.h>
23#include <qtimer.h> 27#include <qtimer.h>
24 28
25/* OPIE */
26
27#include <opie2/opopupmenu.h>
28#include <opie2/oconfig.h>
29 29
30using namespace Opie::Core; 30using namespace Opie::Core;
31using namespace Opie::Ui; 31using namespace Opie::Ui;
32 32
33OPopupTitle::OPopupTitle(QWidget *parent, const char *name) 33OPopupTitle::OPopupTitle(QWidget *parent, const char *name)
34 : QWidget(parent, name) 34 : QWidget(parent, name)
35{ 35{
36 setMinimumSize(16, fontMetrics().height()+8); 36 setMinimumSize(16, fontMetrics().height()+8);
37} 37}
38 38
39OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, 39OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */,
40 const QColor &/* color */, const QColor &/* textColor */, 40 const QColor &/* color */, const QColor &/* textColor */,
41 QWidget *parent, const char *name) 41 QWidget *parent, const char *name)
42 : QWidget(parent, name) 42 : QWidget(parent, name)
43{ 43{
44 setMinimumSize(16, fontMetrics().height()+8); 44 setMinimumSize(16, fontMetrics().height()+8);
45} 45}
46 46
47OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, 47OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */,
48 const QColor &/* textColor */, QWidget *parent, 48 const QColor &/* textColor */, QWidget *parent,
49 const char *name) 49 const char *name)
50 : QWidget(parent, name) 50 : QWidget(parent, name)
51{ 51{
52 setMinimumSize(16, fontMetrics().height()+8); 52 setMinimumSize(16, fontMetrics().height()+8);
53} 53}
54 54
55void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) 55void OPopupTitle::setTitle(const QString &text, const QPixmap *icon)
56{ 56{
57 titleStr = text; 57 titleStr = text;
58 if (icon) 58 if (icon)
59 miniicon = *icon; 59 miniicon = *icon;
60 else 60 else
61 miniicon.resize(0, 0); 61 miniicon.resize(0, 0);
62 62
63 int w = miniicon.width()+fontMetrics().width(titleStr); 63 int w = miniicon.width()+fontMetrics().width(titleStr);
64 int h = QMAX( fontMetrics().height(), miniicon.height() ); 64 int h = QMAX( fontMetrics().height(), miniicon.height() );
65 setMinimumSize( w+16, h+8 ); 65 setMinimumSize( w+16, h+8 );
66} 66}
67 67
68void OPopupTitle::setText( const QString &text ) 68void OPopupTitle::setText( const QString &text )
69{ 69{
70 titleStr = text; 70 titleStr = text;
71 int w = miniicon.width()+fontMetrics().width(titleStr); 71 int w = miniicon.width()+fontMetrics().width(titleStr);
72 int h = QMAX( fontMetrics().height(), miniicon.height() ); 72 int h = QMAX( fontMetrics().height(), miniicon.height() );
73 setMinimumSize( w+16, h+8 ); 73 setMinimumSize( w+16, h+8 );
74} 74}
75 75
76void OPopupTitle::setIcon( const QPixmap &pix ) 76void OPopupTitle::setIcon( const QPixmap &pix )
77{ 77{
78 miniicon = pix; 78 miniicon = pix;
79 int w = miniicon.width()+fontMetrics().width(titleStr); 79 int w = miniicon.width()+fontMetrics().width(titleStr);
80 int h = QMAX( fontMetrics().height(), miniicon.height() ); 80 int h = QMAX( fontMetrics().height(), miniicon.height() );
81 setMinimumSize( w+16, h+8 ); 81 setMinimumSize( w+16, h+8 );
82} 82}
83 83
84void OPopupTitle::paintEvent(QPaintEvent *) 84void OPopupTitle::paintEvent(QPaintEvent *)
85{ 85{
86 QRect r(rect()); 86 QRect r(rect());
87 QPainter p(this); 87 QPainter p(this);
88 #if QT_VERSION > 290 88 #if QT_VERSION > 290
89 qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active()); 89 qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active());
90 #else 90 #else
91 #warning OPopupMenu is not fully functional on Qt2 91 #warning OPopupMenu is not fully functional on Qt2
92 #endif 92 #endif
93 93
94 if (!miniicon.isNull()) 94 if (!miniicon.isNull())
95 p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon); 95 p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon);
96 96
97 if (!titleStr.isNull()) 97 if (!titleStr.isNull())
98 { 98 {
99 p.setPen(palette().active().text()); 99 p.setPen(palette().active().text());
100 QFont f = p.font(); 100 QFont f = p.font();
101 f.setBold(true); 101 f.setBold(true);
102 p.setFont(f); 102 p.setFont(f);
103 if(!miniicon.isNull()) 103 if(!miniicon.isNull())
104 { 104 {
105 p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8), 105 p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8),
106 height(), AlignLeft | AlignVCenter | SingleLine, 106 height(), AlignLeft | AlignVCenter | SingleLine,
107 titleStr); 107 titleStr);
108 } 108 }
109 else 109 else
110 { 110 {
111 p.drawText(0, 0, width(), height(), 111 p.drawText(0, 0, width(), height(),
112 AlignCenter | SingleLine, titleStr); 112 AlignCenter | SingleLine, titleStr);
113 } 113 }
114 } 114 }
115 115
116 p.setPen(palette().active().highlight()); 116 p.setPen(palette().active().highlight());
117 p.drawLine(0, 0, r.right(), 0); 117 p.drawLine(0, 0, r.right(), 0);
118} 118}
119 119
120QSize OPopupTitle::sizeHint() const 120QSize OPopupTitle::sizeHint() const
121{ 121{
122 return(minimumSize()); 122 return(minimumSize());
123} 123}
124 124
125class OPopupMenu::OPopupMenuPrivate 125class OPopupMenu::OPopupMenuPrivate
126{ 126{
127public: 127public:
128 OPopupMenuPrivate () 128 OPopupMenuPrivate ()
129 : noMatches(false) 129 : noMatches(false)
130 , shortcuts(false) 130 , shortcuts(false)
131 , autoExec(false) 131 , autoExec(false)
132 , lastHitIndex(-1) 132 , lastHitIndex(-1)
133 , m_ctxMenu(0) 133 , m_ctxMenu(0)
134 {} 134 {}
135 135
136 ~OPopupMenuPrivate () 136 ~OPopupMenuPrivate ()
137 { 137 {
138 delete m_ctxMenu; 138 delete m_ctxMenu;
139 } 139 }
140 140
141 QString m_lastTitle; 141 QString m_lastTitle;
142 142
143 // variables for keyboard navigation 143 // variables for keyboard navigation
144 QTimer clearTimer; 144 QTimer clearTimer;
145 145
146 bool noMatches : 1; 146 bool noMatches : 1;
147 bool shortcuts : 1; 147 bool shortcuts : 1;
148 bool autoExec : 1; 148 bool autoExec : 1;
149 149
150 QString keySeq; 150 QString keySeq;
151 QString originalText; 151 QString originalText;
152 152
153 int lastHitIndex; 153 int lastHitIndex;
154 154
155 // support for RMB menus on menus 155 // support for RMB menus on menus
156 QPopupMenu* m_ctxMenu; 156 QPopupMenu* m_ctxMenu;
157 static bool s_continueCtxMenuShow; 157 static bool s_continueCtxMenuShow;
158 static int s_highlightedItem; 158 static int s_highlightedItem;
159 static OPopupMenu* s_contextedMenu; 159 static OPopupMenu* s_contextedMenu;
160}; 160};
161 161
162int OPopupMenu::OPopupMenuPrivate::s_highlightedItem(-1); 162int OPopupMenu::OPopupMenuPrivate::s_highlightedItem(-1);
163OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0); 163OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0);
164bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true); 164bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true);
165 165
166OPopupMenu::OPopupMenu(QWidget *parent, const char *name) 166OPopupMenu::OPopupMenu(QWidget *parent, const char *name)
167 : QPopupMenu(parent, name) 167 : QPopupMenu(parent, name)
168{ 168{
169 d = new OPopupMenuPrivate; 169 d = new OPopupMenuPrivate;
170 resetKeyboardVars(); 170 resetKeyboardVars();
171 connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars())); 171 connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars()));
172} 172}
173 173
174OPopupMenu::~OPopupMenu() 174OPopupMenu::~OPopupMenu()
175{ 175{
176 if (OPopupMenuPrivate::s_contextedMenu == this) 176 if (OPopupMenuPrivate::s_contextedMenu == this)
177 { 177 {
178 OPopupMenuPrivate::s_contextedMenu = 0; 178 OPopupMenuPrivate::s_contextedMenu = 0;
179 OPopupMenuPrivate::s_highlightedItem = -1; 179 OPopupMenuPrivate::s_highlightedItem = -1;
180 } 180 }
181 181
182 delete d; 182 delete d;
183} 183}
184 184
185int OPopupMenu::insertTitle(const QString &text, int id, int index) 185int OPopupMenu::insertTitle(const QString &text, int id, int index)
186{ 186{
187 OPopupTitle *titleItem = new OPopupTitle(); 187 OPopupTitle *titleItem = new OPopupTitle();
188 titleItem->setTitle(text); 188 titleItem->setTitle(text);
189 int ret = insertItem(titleItem, id, index); 189 int ret = insertItem(titleItem, id, index);
190 setItemEnabled(id, false); 190 setItemEnabled(id, false);
191 return ret; 191 return ret;
192} 192}
193 193
194int OPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id, 194int OPopupMenu::insertTitle(const QPixmap &icon, const QString &text, int id,
195 int index) 195 int index)
196{ 196{
197 OPopupTitle *titleItem = new OPopupTitle(); 197 OPopupTitle *titleItem = new OPopupTitle();
198 titleItem->setTitle(text, &icon); 198 titleItem->setTitle(text, &icon);
199 int ret = insertItem(titleItem, id, index); 199 int ret = insertItem(titleItem, id, index);
200 setItemEnabled(id, false); 200 setItemEnabled(id, false);
201 return ret; 201 return ret;
202} 202}
203 203
204void OPopupMenu::changeTitle(int id, const QString &text) 204void OPopupMenu::changeTitle(int id, const QString &text)
205{ 205{
206 QMenuItem *item = findItem(id); 206 QMenuItem *item = findItem(id);
207 if(item){ 207 if(item){
208 if(item->widget()) 208 if(item->widget())
209 ((OPopupTitle *)item->widget())->setTitle(text); 209 ((OPopupTitle *)item->widget())->setTitle(text);
210#ifndef NDEBUG 210#ifndef NDEBUG
211 else 211 else
212 qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); 212 owarn << "KPopupMenu: changeTitle() called with non-title id " << id << "" << oendl;
213#endif 213#endif
214 } 214 }
215#ifndef NDEBUG 215#ifndef NDEBUG
216 else 216 else
217 qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); 217 owarn << "KPopupMenu: changeTitle() called with invalid id " << id << "" << oendl;
218#endif 218#endif
219} 219}
220 220
221void OPopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text) 221void OPopupMenu::changeTitle(int id, const QPixmap &icon, const QString &text)
222{ 222{
223 QMenuItem *item = findItem(id); 223 QMenuItem *item = findItem(id);
224 if(item){ 224 if(item){
225 if(item->widget()) 225 if(item->widget())
226 ((OPopupTitle *)item->widget())->setTitle(text, &icon); 226 ((OPopupTitle *)item->widget())->setTitle(text, &icon);
227#ifndef NDEBUG 227#ifndef NDEBUG
228 else 228 else
229 qWarning( "KPopupMenu: changeTitle() called with non-title id %d", id ); 229 owarn << "KPopupMenu: changeTitle() called with non-title id " << id << "" << oendl;
230#endif 230#endif
231 } 231 }
232#ifndef NDEBUG 232#ifndef NDEBUG
233 else 233 else
234 qWarning( "KPopupMenu: changeTitle() called with invalid id %d", id ); 234 owarn << "KPopupMenu: changeTitle() called with invalid id " << id << "" << oendl;
235#endif 235#endif
236} 236}
237 237
238QString OPopupMenu::title(int id) const 238QString OPopupMenu::title(int id) const
239{ 239{
240 if(id == -1) // obsolete 240 if(id == -1) // obsolete
241 return(d->m_lastTitle); 241 return(d->m_lastTitle);
242 QMenuItem *item = findItem(id); 242 QMenuItem *item = findItem(id);
243 if(item){ 243 if(item){
244 if(item->widget()) 244 if(item->widget())
245 return(((OPopupTitle *)item->widget())->title()); 245 return(((OPopupTitle *)item->widget())->title());
246 else 246 else
247 qWarning("OPopupMenu: title() called with non-title id %d.", id); 247 owarn << "OPopupMenu: title() called with non-title id " << id << "." << oendl;
248 } 248 }
249 else 249 else
250 qWarning("OPopupMenu: title() called with invalid id %d.", id); 250 owarn << "OPopupMenu: title() called with invalid id " << id << "." << oendl;
251 return(QString::null); 251 return(QString::null);
252} 252}
253 253
254QPixmap OPopupMenu::titlePixmap(int id) const 254QPixmap OPopupMenu::titlePixmap(int id) const
255{ 255{
256 QMenuItem *item = findItem(id); 256 QMenuItem *item = findItem(id);
257 if(item){ 257 if(item){
258 if(item->widget()) 258 if(item->widget())
259 return(((OPopupTitle *)item->widget())->icon()); 259 return(((OPopupTitle *)item->widget())->icon());
260 else 260 else
261 qWarning("KPopupMenu: titlePixmap() called with non-title id %d.", id); 261 owarn << "KPopupMenu: titlePixmap() called with non-title id " << id << "." << oendl;
262 } 262 }
263 else 263 else
264 qWarning("KPopupMenu: titlePixmap() called with invalid id %d.", id); 264 owarn << "KPopupMenu: titlePixmap() called with invalid id " << id << "." << oendl;
265 QPixmap tmp; 265 QPixmap tmp;
266 return(tmp); 266 return(tmp);
267} 267}
268 268
269/** 269/**
270 * This is re-implemented for keyboard navigation. 270 * This is re-implemented for keyboard navigation.
271 */ 271 */
272void OPopupMenu::closeEvent(QCloseEvent*e) 272void OPopupMenu::closeEvent(QCloseEvent*e)
273{ 273{
274 if (d->shortcuts) 274 if (d->shortcuts)
275 resetKeyboardVars(); 275 resetKeyboardVars();
276 QPopupMenu::closeEvent(e); 276 QPopupMenu::closeEvent(e);
277} 277}
278 278
279void OPopupMenu::keyPressEvent(QKeyEvent* e) 279void OPopupMenu::keyPressEvent(QKeyEvent* e)
280{ 280{
281 if (!d->shortcuts) { 281 if (!d->shortcuts) {
282 // continue event processing by Qpopup 282 // continue event processing by Qpopup
283 //e->ignore(); 283 //e->ignore();
284 QPopupMenu::keyPressEvent(e); 284 QPopupMenu::keyPressEvent(e);
285 return; 285 return;
286 } 286 }
287 287
288 int i = 0; 288 int i = 0;
289 bool firstpass = true; 289 bool firstpass = true;
290 QString keyString = e->text(); 290 QString keyString = e->text();
291 291
292 // check for common commands dealt with by QPopup 292 // check for common commands dealt with by QPopup
293 int key = e->key(); 293 int key = e->key();
294 if (key == Key_Escape || key == Key_Return || key == Key_Enter 294 if (key == Key_Escape || key == Key_Return || key == Key_Enter
295 || key == Key_Up || key == Key_Down || key == Key_Left 295 || key == Key_Up || key == Key_Down || key == Key_Left
296 || key == Key_Right || key == Key_F1) { 296 || key == Key_Right || key == Key_F1) {
297 297
298 resetKeyboardVars(); 298 resetKeyboardVars();
299 // continue event processing by Qpopup 299 // continue event processing by Qpopup
300 //e->ignore(); 300 //e->ignore();
301 QPopupMenu::keyPressEvent(e); 301 QPopupMenu::keyPressEvent(e);
302 return; 302 return;
303 } 303 }
304 304
305 // check to see if the user wants to remove a key from the sequence (backspace) 305 // check to see if the user wants to remove a key from the sequence (backspace)
306 // or clear the sequence (delete) 306 // or clear the sequence (delete)
307 if (!d->keySeq.isNull()) { 307 if (!d->keySeq.isNull()) {
308 308
309 if (key == Key_Backspace) { 309 if (key == Key_Backspace) {
310 310
311 if (d->keySeq.length() == 1) { 311 if (d->keySeq.length() == 1) {
312 resetKeyboardVars(); 312 resetKeyboardVars();
313 return; 313 return;
314 } 314 }
315 315
316 // keep the last sequence in keyString 316 // keep the last sequence in keyString
317 keyString = d->keySeq.left(d->keySeq.length() - 1); 317 keyString = d->keySeq.left(d->keySeq.length() - 1);
318 318
319 // allow sequence matching to be tried again 319 // allow sequence matching to be tried again
320 resetKeyboardVars(); 320 resetKeyboardVars();
321 321
322 } else if (key == Key_Delete) { 322 } else if (key == Key_Delete) {
323 resetKeyboardVars(); 323 resetKeyboardVars();
324 324
325 // clear active item 325 // clear active item
326 setActiveItem(0); 326 setActiveItem(0);
327 return; 327 return;
328 328
329 } else if (d->noMatches) { 329 } else if (d->noMatches) {
330 // clear if there are no matches 330 // clear if there are no matches
331 resetKeyboardVars(); 331 resetKeyboardVars();
332 332
333 // clear active item 333 // clear active item
334 setActiveItem(0); 334 setActiveItem(0);
335 335
336 } else { 336 } else {
337 // the key sequence is not a null string 337 // the key sequence is not a null string
338 // therefore the lastHitIndex is valid 338 // therefore the lastHitIndex is valid
339 i = d->lastHitIndex; 339 i = d->lastHitIndex;
340 } 340 }
341 } else if (key == Key_Backspace && parentMenu) { 341 } else if (key == Key_Backspace && parentMenu) {
342 // backspace with no chars in the buffer... go back a menu. 342 // backspace with no chars in the buffer... go back a menu.
343 hide(); 343 hide();
344 resetKeyboardVars(); 344 resetKeyboardVars();
345 return; 345 return;
346 } 346 }
347 347
348 d->keySeq += keyString; 348 d->keySeq += keyString;
349 int seqLen = d->keySeq.length(); 349 int seqLen = d->keySeq.length();
350 350
351 for (; i < (int)count(); i++) { 351 for (; i < (int)count(); i++) {
352 // compare typed text with text of this entry 352 // compare typed text with text of this entry
353 int j = idAt(i); 353 int j = idAt(i);
354 354
355 // don't search disabled entries 355 // don't search disabled entries
356 if (!isItemEnabled(j)) 356 if (!isItemEnabled(j))
357 continue; 357 continue;
358 358
359 QString thisText; 359 QString thisText;
360 360
diff --git a/libopie2/opieui/otaskbarapplet.h b/libopie2/opieui/otaskbarapplet.h
index 77cc461..75c07d1 100644
--- a/libopie2/opieui/otaskbarapplet.h
+++ b/libopie2/opieui/otaskbarapplet.h
@@ -1,130 +1,134 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 3
4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de> 4              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OTASKBARAPPLET_H 32#ifndef OTASKBARAPPLET_H
33#define OTASKBARAPPLET_H 33#define OTASKBARAPPLET_H
34 34
35/* OPIE */
36#include <opie2/odebug.h>
37
35#include <qpe/taskbarappletinterface.h> 38#include <qpe/taskbarappletinterface.h>
36#include <qpe/qcom.h> 39#include <qpe/qcom.h>
37 40
41/* QT */
38#include <qwidget.h> 42#include <qwidget.h>
39 43
40class QMouseEvent; 44class QMouseEvent;
41 45
42namespace Opie { 46namespace Opie {
43namespace Ui { 47namespace Ui {
44namespace Internal { 48namespace Internal {
45/*====================================================================================== 49/*======================================================================================
46 * OTaskbarAppletWrapper 50 * OTaskbarAppletWrapper
47 *======================================================================================*/ 51 *======================================================================================*/
48 52
49class OTaskbarAppletWrapperPrivate; 53class OTaskbarAppletWrapperPrivate;
50template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface 54template<class T> class OTaskbarAppletWrapper : public TaskbarAppletInterface
51{ 55{
52 public: 56 public:
53 OTaskbarAppletWrapper():_applet( 0 ) 57 OTaskbarAppletWrapper():_applet( 0 )
54 { 58 {
55 } 59 }
56 60
57 virtual ~OTaskbarAppletWrapper() 61 virtual ~OTaskbarAppletWrapper()
58 { 62 {
59 delete _applet; 63 delete _applet;
60 } 64 }
61 65
62 QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface ) 66 QRESULT queryInterface( const QUuid& uuid, QUnknownInterface** iface )
63 { 67 {
64 qDebug( "OTaskbarAppletWrapper::queryInterface()" ); 68 odebug << "OTaskbarAppletWrapper::queryInterface()" << oendl;
65 *iface = 0; 69 *iface = 0;
66 if ( uuid == IID_QUnknown ) 70 if ( uuid == IID_QUnknown )
67 *iface = this; 71 *iface = this;
68 else if ( uuid == IID_TaskbarApplet ) 72 else if ( uuid == IID_TaskbarApplet )
69 *iface = this; 73 *iface = this;
70 else 74 else
71 return QS_FALSE; 75 return QS_FALSE;
72 76
73 if ( *iface ) (*iface)->addRef(); 77 if ( *iface ) (*iface)->addRef();
74 return QS_OK; 78 return QS_OK;
75 } 79 }
76 80
77 Q_REFCOUNT 81 Q_REFCOUNT
78 82
79 virtual T* applet( QWidget* parent ) 83 virtual T* applet( QWidget* parent )
80 { 84 {
81 if ( !_applet ) _applet = new T( parent ); 85 if ( !_applet ) _applet = new T( parent );
82 return _applet; 86 return _applet;
83 } 87 }
84 88
85 virtual int position() const 89 virtual int position() const
86 { 90 {
87 return T::position(); 91 return T::position();
88 } 92 }
89 93
90 private: 94 private:
91 T* _applet; 95 T* _applet;
92 OTaskbarAppletWrapperPrivate *d; 96 OTaskbarAppletWrapperPrivate *d;
93}; 97};
94 98
95} 99}
96/*====================================================================================== 100/*======================================================================================
97 * OTaskbarApplet 101 * OTaskbarApplet
98 *======================================================================================*/ 102 *======================================================================================*/
99 103
100// Must be inline until after we shipped Opie 1.0 104// Must be inline until after we shipped Opie 1.0
101 105
102// Having OTaskBarApplet reside in libopieui2 is not possible 106// Having OTaskBarApplet reside in libopieui2 is not possible
103// until we link the launcher binary against libopieui2 - 107// until we link the launcher binary against libopieui2 -
104// otherwise the necessary symbols are not present, when 108// otherwise the necessary symbols are not present, when
105// the dynamic loader [dlopen] tries to resolve an applet which 109// the dynamic loader [dlopen] tries to resolve an applet which
106// inherits OTaskbarApplet 110// inherits OTaskbarApplet
107 111
108class OTaskbarApplet : public QWidget 112class OTaskbarApplet : public QWidget
109{ 113{
110 public: 114 public:
111 OTaskbarApplet( QWidget* parent, const char* name = 0 ); 115 OTaskbarApplet( QWidget* parent, const char* name = 0 );
112 virtual ~OTaskbarApplet(); 116 virtual ~OTaskbarApplet();
113 117
114 118
115 protected: 119 protected:
116 virtual void popup( QWidget* widget ); 120 virtual void popup( QWidget* widget );
117private: 121private:
118 class Private; 122 class Private;
119 Private *d; 123 Private *d;
120}; 124};
121} 125}
122} 126}
123 127
124#define EXPORT_OPIE_APPLET_v1( AppLet ) \ 128#define EXPORT_OPIE_APPLET_v1( AppLet ) \
125 Q_EXPORT_INTERFACE() { \ 129 Q_EXPORT_INTERFACE() { \
126 Q_CREATE_INSTANCE( Opie::Ui::Internal::OTaskbarAppletWrapper<AppLet> ) \ 130 Q_CREATE_INSTANCE( Opie::Ui::Internal::OTaskbarAppletWrapper<AppLet> ) \
127 } 131 }
128 132
129#endif 133#endif
130 134
diff --git a/libqtaux/oticker.cpp b/libqtaux/oticker.cpp
index e954cc8..29478fd 100644
--- a/libqtaux/oticker.cpp
+++ b/libqtaux/oticker.cpp
@@ -1,139 +1,141 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com> 3 Copyright (c) 2002 L. Potter <ljp@llornkcor.com>
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 General Public 9:`=1 )Y*s>-.--   : the terms of the GNU 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 "oticker.h" 31#include "oticker.h"
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odebug.h>
35
34#include <qpe/config.h> 36#include <qpe/config.h>
35 37
36using namespace Opie::Ui; 38using namespace Opie::Ui;
37 39
38OTicker::OTicker( QWidget* parent ) 40OTicker::OTicker( QWidget* parent )
39 : QLabel( parent ) 41 : QLabel( parent )
40{ 42{
41 setTextFormat( Qt::RichText ); 43 setTextFormat( Qt::RichText );
42 Config cfg( "qpe" ); 44 Config cfg( "qpe" );
43 cfg.setGroup( "Appearance" ); 45 cfg.setGroup( "Appearance" );
44 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) ); 46 backgroundcolor = QColor( cfg.readEntry( "Background", "#E5E1D5" ) );
45 foregroundcolor = Qt::black; 47 foregroundcolor = Qt::black;
46 updateTimerTime = 50; 48 updateTimerTime = 50;
47 scrollLength = 1; 49 scrollLength = 1;
48} 50}
49 51
50OTicker::~OTicker() 52OTicker::~OTicker()
51{} 53{}
52 54
53void OTicker::setBackgroundColor( const QColor& backcolor ) 55void OTicker::setBackgroundColor( const QColor& backcolor )
54{ 56{
55 backgroundcolor = backcolor; 57 backgroundcolor = backcolor;
56 update(); 58 update();
57} 59}
58 60
59void OTicker::setForegroundColor( const QColor& backcolor ) 61void OTicker::setForegroundColor( const QColor& backcolor )
60{ 62{
61 foregroundcolor = backcolor; 63 foregroundcolor = backcolor;
62 update(); 64 update();
63} 65}
64 66
65void OTicker::setFrame( int frameStyle ) 67void OTicker::setFrame( int frameStyle )
66{ 68{
67 setFrameStyle( frameStyle /*WinPanel | Sunken */ ); 69 setFrameStyle( frameStyle /*WinPanel | Sunken */ );
68 update(); 70 update();
69} 71}
70 72
71void OTicker::setText( const QString& text ) 73void OTicker::setText( const QString& text )
72{ 74{
73 pos = 0; // reset it everytime the text is changed 75 pos = 0; // reset it everytime the text is changed
74 scrollText = text; 76 scrollText = text;
75 qDebug( scrollText ); 77 odebug << scrollText << oendl;
76 78
77 int pixelLen = 0; 79 int pixelLen = 0;
78 bool bigger = false; 80 bool bigger = false;
79 int contWidth = contentsRect().width(); 81 int contWidth = contentsRect().width();
80 int contHeight = contentsRect().height(); 82 int contHeight = contentsRect().height();
81 int pixelTextLen = fontMetrics().width( text ); 83 int pixelTextLen = fontMetrics().width( text );
82 qDebug( "<<<<<<<height %d, width %d, text width %d %d\n", contHeight, contWidth, pixelTextLen, scrollText.length() ); 84 odebug << "<<<<<<<height " << contHeight << ", width " << contWidth << ", text width " << pixelTextLen << " " << scrollText.length() << "\n" << oendl;
83 if ( pixelTextLen < contWidth ) 85 if ( pixelTextLen < contWidth )
84 { 86 {
85 pixelLen = contWidth; 87 pixelLen = contWidth;
86 } 88 }
87 else 89 else
88 { 90 {
89 bigger = true; 91 bigger = true;
90 pixelLen = pixelTextLen; 92 pixelLen = pixelTextLen;
91 } 93 }
92 QPixmap pm( pixelLen, contHeight ); 94 QPixmap pm( pixelLen, contHeight );
93 // pm.fill( QColor( 167, 212, 167 )); 95 // pm.fill( QColor( 167, 212, 167 ));
94 96
95 pm.fill( backgroundcolor ); 97 pm.fill( backgroundcolor );
96 QPainter pmp( &pm ); 98 QPainter pmp( &pm );
97 pmp.setPen( foregroundcolor ); 99 pmp.setPen( foregroundcolor );
98 pmp.drawText( 0, 0, pixelTextLen, contHeight, AlignVCenter, scrollText ); 100 pmp.drawText( 0, 0, pixelTextLen, contHeight, AlignVCenter, scrollText );
99 pmp.end(); 101 pmp.end();
100 scrollTextPixmap = pm; 102 scrollTextPixmap = pm;
101 103
102 killTimers(); 104 killTimers();
103 // qDebug("Scrollupdate %d", updateTimerTime); 105 // odebug << "Scrollupdate " << updateTimerTime << "" << oendl;
104 if ( bigger /*pixelTextLen > contWidth*/ ) 106 if ( bigger /*pixelTextLen > contWidth*/ )
105 startTimer( updateTimerTime ); 107 startTimer( updateTimerTime );
106 update(); 108 update();
107} 109}
108 110
109 111
110void OTicker::timerEvent( QTimerEvent * ) 112void OTicker::timerEvent( QTimerEvent * )
111{ 113{
112 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength; //1; 114 pos = ( pos <= 0 ) ? scrollTextPixmap.width() : pos - scrollLength; //1;
113 repaint( FALSE ); 115 repaint( FALSE );
114} 116}
115 117
116void OTicker::drawContents( QPainter *p ) 118void OTicker::drawContents( QPainter *p )
117{ 119{
118 int pixelLen = scrollTextPixmap.width(); 120 int pixelLen = scrollTextPixmap.width();
119 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap ); 121 p->drawPixmap( pos, contentsRect().y(), scrollTextPixmap );
120 if ( pixelLen > contentsRect().width() ) // Scrolling 122 if ( pixelLen > contentsRect().width() ) // Scrolling
121 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap ); 123 p->drawPixmap( pos - pixelLen, contentsRect().y(), scrollTextPixmap );
122} 124}
123 125
124void OTicker::mouseReleaseEvent( QMouseEvent * ) 126void OTicker::mouseReleaseEvent( QMouseEvent * )
125{ 127{
126 // qDebug("<<<<<<<>>>>>>>>>"); 128 // odebug << "<<<<<<<>>>>>>>>>" << oendl;
127 emit mousePressed(); 129 emit mousePressed();
128} 130}
129 131
130void OTicker::setUpdateTime( int time ) 132void OTicker::setUpdateTime( int time )
131{ 133{
132 updateTimerTime = time; 134 updateTimerTime = time;
133} 135}
134 136
135void OTicker::setScrollLength( int len ) 137void OTicker::setScrollLength( int len )
136{ 138{
137 scrollLength = len; 139 scrollLength = len;
138} 140}
139 141