summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kjanuswidget.cpp
Unidiff
Diffstat (limited to 'microkde/kdeui/kjanuswidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kjanuswidget.cpp140
1 files changed, 74 insertions, 66 deletions
diff --git a/microkde/kdeui/kjanuswidget.cpp b/microkde/kdeui/kjanuswidget.cpp
index 462c44f..3d9173d 100644
--- a/microkde/kdeui/kjanuswidget.cpp
+++ b/microkde/kdeui/kjanuswidget.cpp
@@ -19,21 +19,29 @@
19 */ 19 */
20 20
21#include <qpixmap.h> 21#include <qpixmap.h>
22#include <qbitmap.h> 22#include <qbitmap.h>
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qwidgetstack.h> 25#include <q3widgetstack.h>
26#include <qtabwidget.h> 26#include <qtabwidget.h>
27#include <qlistview.h> 27#include <q3listview.h>
28#include <qhbox.h> 28#include <q3hbox.h>
29#include <qvbox.h> 29#include <q3vbox.h>
30#include <qgrid.h> 30#include <q3grid.h>
31#include <qpainter.h> 31#include <qpainter.h>
32#include <qobjectlist.h> 32#include <qobject.h>
33#include <qstringlist.h> 33#include <qstringlist.h>
34//Added by qt3to4:
35#include <Q3HBoxLayout>
36#include <Q3GridLayout>
37#include <Q3PtrList>
38#include <Q3Frame>
39#include <QEvent>
40#include <Q3VBoxLayout>
41#include <QShowEvent>
34/*US 42/*US
35#include <qbitmap.h> 43#include <qbitmap.h>
36#include <qgrid.h> 44#include <qgrid.h>
37#include <qhbox.h> 45#include <qhbox.h>
38#include <qheader.h> 46#include <qheader.h>
39#include <qlabel.h> 47#include <qlabel.h>
@@ -62,19 +70,19 @@
62#include <kdialog.h> // Access to some static members 70#include <kdialog.h> // Access to some static members
63#include <kdebug.h> 71#include <kdebug.h>
64#include <klistview.h> 72#include <klistview.h>
65 73
66#include "kjanuswidget.h" 74#include "kjanuswidget.h"
67 75
68class KJanusWidget::IconListItem : public QListBoxItem 76class KJanusWidget::IconListItem : public Q3ListBoxItem
69{ 77{
70 public: 78 public:
71 IconListItem( QListBox *listbox, const QPixmap &pixmap, 79 IconListItem( Q3ListBox *listbox, const QPixmap &pixmap,
72 const QString &text ); 80 const QString &text );
73 virtual int height( const QListBox *lb ) const; 81 virtual int height( const Q3ListBox *lb ) const;
74 virtual int width( const QListBox *lb ) const; 82 virtual int width( const Q3ListBox *lb ) const;
75 int expandMinimumWidth( int width ); 83 int expandMinimumWidth( int width );
76 84
77 protected: 85 protected:
78 const QPixmap &defaultPixmap(); 86 const QPixmap &defaultPixmap();
79 void paint( QPainter *painter ); 87 void paint( QPainter *painter );
80 88
@@ -95,27 +103,27 @@ public:
95 // Reverse dictionary. Used because showPage() may be performance critical. 103 // Reverse dictionary. Used because showPage() may be performance critical.
96 QMap<QWidget*,int> mPageToInt; 104 QMap<QWidget*,int> mPageToInt;
97 // Dictionary of title string associated with page. 105 // Dictionary of title string associated with page.
98 QMap<int, QString> mIntToTitle; 106 QMap<int, QString> mIntToTitle;
99}; 107};
100 108
101template class QPtrList<QListViewItem>; 109template class Q3PtrList<Q3ListViewItem>;
102 110
103 111
104KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) 112KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face )
105 : QWidget( parent, name ), 113 : QWidget( parent, name ),
106 mValid(false), mPageList(0), 114 mValid(false), mPageList(0),
107 mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0), 115 mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0),
108 mShowIconsInTreeList(false), d(0) 116 mShowIconsInTreeList(false), d(0)
109{ 117{
110 QVBoxLayout *topLayout = new QVBoxLayout( this ); 118 Q3VBoxLayout *topLayout = new Q3VBoxLayout( this );
111 if( mFace == TreeList || mFace == IconList ) 119 if( mFace == TreeList || mFace == IconList )
112 { 120 {
113 d = new KJanusWidgetPrivate; 121 d = new KJanusWidgetPrivate;
114 122
115 QFrame *page = 0; 123 Q3Frame *page = 0;
116 if( mFace == TreeList ) 124 if( mFace == TreeList )
117 { 125 {
118 //US 126 //US
119 qDebug("KJanusWidget::KJanusWidget TreeList not implemented yet"); 127 qDebug("KJanusWidget::KJanusWidget TreeList not implemented yet");
120/*US 128/*US
121 QSplitter *splitter = new QSplitter( this ); 129 QSplitter *splitter = new QSplitter( this );
@@ -142,46 +150,46 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face )
142 page = new QFrame( p ); 150 page = new QFrame( p );
143 hbox->addWidget( page, 10 ); 151 hbox->addWidget( page, 10 );
144*/ 152*/
145 } 153 }
146 else 154 else
147 { 155 {
148 QHBoxLayout *hbox = new QHBoxLayout( topLayout ); 156 Q3HBoxLayout *hbox = new Q3HBoxLayout( topLayout );
149 mIconList = new IconListBox( this ); 157 mIconList = new IconListBox( this );
150 158
151 QFont listFont( mIconList->font() ); 159 QFont listFont( mIconList->font() );
152 listFont.setBold( true ); 160 listFont.setBold( true );
153 mIconList->setFont( listFont ); 161 mIconList->setFont( listFont );
154 162
155 mIconList->verticalScrollBar()->installEventFilter( this ); 163 mIconList->verticalScrollBar()->installEventFilter( this );
156 hbox->addWidget( mIconList ); 164 hbox->addWidget( mIconList );
157 connect( mIconList, SIGNAL(selectionChanged()), SLOT(slotShowPage())); 165 connect( mIconList, SIGNAL(selectionChanged()), SLOT(slotShowPage()));
158 hbox->addSpacing( KDialog::marginHint() ); 166 hbox->addSpacing( KDialog::marginHint() );
159 page = new QFrame( this ); 167 page = new Q3Frame( this );
160 hbox->addWidget( page, 10 ); 168 hbox->addWidget( page, 10 );
161 } 169 }
162 170
163 // 171 //
164 // Rest of page area. Title at top with a separator below and a 172 // Rest of page area. Title at top with a separator below and a
165 // pagestack using all available space at bottom. 173 // pagestack using all available space at bottom.
166 // 174 //
167 175
168 QVBoxLayout *vbox = new QVBoxLayout( page, 0, KDialog::spacingHint() ); 176 Q3VBoxLayout *vbox = new Q3VBoxLayout( page, 0, KDialog::spacingHint() );
169 177
170 mTitleLabel = new QLabel( QString::fromLatin1("Empty page"), page, "KJanusWidgetTitleLabel" ); 178 mTitleLabel = new QLabel( QString::fromLatin1("Empty page"), page, "KJanusWidgetTitleLabel" );
171 vbox->addWidget( mTitleLabel ); 179 vbox->addWidget( mTitleLabel );
172 180
173 QFont titleFont( mTitleLabel->font() ); 181 QFont titleFont( mTitleLabel->font() );
174 titleFont.setBold( true ); 182 titleFont.setBold( true );
175 mTitleLabel->setFont( titleFont ); 183 mTitleLabel->setFont( titleFont );
176 184
177 mTitleSep = new KSeparator( page ); 185 mTitleSep = new KSeparator( page );
178 mTitleSep->setFrameStyle( QFrame::HLine|QFrame::Plain ); 186 mTitleSep->setFrameStyle( Q3Frame::HLine|Q3Frame::Plain );
179 vbox->addWidget( mTitleSep ); 187 vbox->addWidget( mTitleSep );
180 188
181 mPageStack = new QWidgetStack( page ); 189 mPageStack = new Q3WidgetStack( page );
182 connect(mPageStack, SIGNAL(aboutToShow(QWidget *)), 190 connect(mPageStack, SIGNAL(aboutToShow(QWidget *)),
183 SIGNAL(aboutToShowPage(QWidget *))); 191 SIGNAL(aboutToShowPage(QWidget *)));
184 vbox->addWidget( mPageStack, 10 ); 192 vbox->addWidget( mPageStack, 10 );
185 } 193 }
186 else if( mFace == Tabbed ) 194 else if( mFace == Tabbed )
187 { 195 {
@@ -196,13 +204,13 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face )
196 mSwallowPage = new QWidget( this ); 204 mSwallowPage = new QWidget( this );
197 topLayout->addWidget( mSwallowPage, 10 ); 205 topLayout->addWidget( mSwallowPage, 10 );
198 } 206 }
199 else 207 else
200 { 208 {
201 mFace = Plain; 209 mFace = Plain;
202 mPlainPage = new QFrame( this ); 210 mPlainPage = new Q3Frame( this );
203 topLayout->addWidget( mPlainPage, 10 ); 211 topLayout->addWidget( mPlainPage, 10 );
204 } 212 }
205/*US 213/*US
206 if ( kapp ) 214 if ( kapp )
207 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged())); 215 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
208*/ 216*/
@@ -242,13 +250,13 @@ KJanusWidget::~KJanusWidget()
242bool KJanusWidget::isValid() const 250bool KJanusWidget::isValid() const
243{ 251{
244 return( mValid ); 252 return( mValid );
245} 253}
246 254
247 255
248QFrame *KJanusWidget::plainPage() 256Q3Frame *KJanusWidget::plainPage()
249{ 257{
250 return( mPlainPage ); 258 return( mPlainPage );
251} 259}
252 260
253 261
254int KJanusWidget::face() const 262int KJanusWidget::face() const
@@ -263,135 +271,135 @@ QWidget *KJanusWidget::FindParent()
263 } 271 }
264 else { 272 else {
265 return this; 273 return this;
266 } 274 }
267} 275}
268 276
269QFrame *KJanusWidget::addPage( const QStringList &items, const QString &header, 277Q3Frame *KJanusWidget::addPage( const QStringList &items, const QString &header,
270 const QPixmap &pixmap ) 278 const QPixmap &pixmap )
271{ 279{
272 if( mValid == false ) 280 if( mValid == false )
273 { 281 {
274 kdDebug() << "addPage: Invalid object" << endl; 282 kdDebug() << "addPage: Invalid object" << endl;
275 return( 0 ); 283 return( 0 );
276 } 284 }
277 285
278 QFrame *page = new QFrame( FindParent(), "page" ); 286 Q3Frame *page = new Q3Frame( FindParent(), "page" );
279 addPageWidget( page, items, header, pixmap ); 287 addPageWidget( page, items, header, pixmap );
280 288
281 return page; 289 return page;
282} 290}
283 291
284void KJanusWidget::pageGone( QObject *obj ) 292void KJanusWidget::pageGone( QObject *obj )
285{ 293{
286// QObject* obj = (QObject*)sender(); 294// QObject* obj = (QObject*)sender();
287 removePage( static_cast<QWidget*>( obj ) ); 295 removePage( static_cast<QWidget*>( obj ) );
288} 296}
289 297
290void KJanusWidget::slotReopen( QListViewItem * item ) 298void KJanusWidget::slotReopen( Q3ListViewItem * item )
291{ 299{
292 if( item ) 300 if( item )
293 item->setOpen( true ); 301 item->setOpen( true );
294} 302}
295 303
296QFrame *KJanusWidget::addPage( const QString &itemName, const QString &header, 304Q3Frame *KJanusWidget::addPage( const QString &itemName, const QString &header,
297 const QPixmap &pixmap ) 305 const QPixmap &pixmap )
298{ 306{
299 307
300 QStringList items; 308 QStringList items;
301 items << itemName; 309 items << itemName;
302 return addPage(items, header, pixmap); 310 return addPage(items, header, pixmap);
303} 311}
304 312
305 313
306 314
307QVBox *KJanusWidget::addVBoxPage( const QStringList &items, 315Q3VBox *KJanusWidget::addVBoxPage( const QStringList &items,
308 const QString &header, 316 const QString &header,
309 const QPixmap &pixmap ) 317 const QPixmap &pixmap )
310{ 318{
311 if( mValid == false ) 319 if( mValid == false )
312 { 320 {
313 qDebug("addPage: Invalid object "); 321 qDebug("addPage: Invalid object ");
314 322
315 return( 0 ); 323 return( 0 );
316 } 324 }
317 325
318 QVBox *page = new QVBox(FindParent() , "vbox_page" ); 326 Q3VBox *page = new Q3VBox(FindParent() , "vbox_page" );
319 page->setSpacing( KDialog::spacingHintSmall() ); 327 page->setSpacing( KDialog::spacingHintSmall() );
320 addPageWidget( page, items, header, pixmap ); 328 addPageWidget( page, items, header, pixmap );
321 329
322 return page; 330 return page;
323} 331}
324 332
325QVBox *KJanusWidget::addVBoxPage( const QString &itemName, 333Q3VBox *KJanusWidget::addVBoxPage( const QString &itemName,
326 const QString &header, 334 const QString &header,
327 const QPixmap &pixmap ) 335 const QPixmap &pixmap )
328{ 336{
329 QStringList items; 337 QStringList items;
330 items << itemName; 338 items << itemName;
331 return addVBoxPage(items, header, pixmap); 339 return addVBoxPage(items, header, pixmap);
332} 340}
333 341
334QHBox *KJanusWidget::addHBoxPage( const QStringList &items, 342Q3HBox *KJanusWidget::addHBoxPage( const QStringList &items,
335 const QString &header, 343 const QString &header,
336 const QPixmap &pixmap ) 344 const QPixmap &pixmap )
337{ 345{
338 if( mValid == false ) { 346 if( mValid == false ) {
339 kdDebug() << "addPage: Invalid object" << endl; 347 kdDebug() << "addPage: Invalid object" << endl;
340 return( 0 ); 348 return( 0 );
341 } 349 }
342 350
343 QHBox *page = new QHBox(FindParent(), "hbox_page"); 351 Q3HBox *page = new Q3HBox(FindParent(), "hbox_page");
344 page->setSpacing( KDialog::spacingHint() ); 352 page->setSpacing( KDialog::spacingHint() );
345 addPageWidget( page, items, header, pixmap ); 353 addPageWidget( page, items, header, pixmap );
346 354
347 return page; 355 return page;
348} 356}
349 357
350QHBox *KJanusWidget::addHBoxPage( const QString &itemName, 358Q3HBox *KJanusWidget::addHBoxPage( const QString &itemName,
351 const QString &header, 359 const QString &header,
352 const QPixmap &pixmap ) 360 const QPixmap &pixmap )
353{ 361{
354 QStringList items; 362 QStringList items;
355 items << itemName; 363 items << itemName;
356 return addHBoxPage(items, header, pixmap); 364 return addHBoxPage(items, header, pixmap);
357} 365}
358 366
359QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, 367Q3Grid *KJanusWidget::addGridPage( int n, Qt::Orientation dir,
360 const QStringList &items, 368 const QStringList &items,
361 const QString &header, 369 const QString &header,
362 const QPixmap &pixmap ) 370 const QPixmap &pixmap )
363{ 371{
364 if( mValid == false ) 372 if( mValid == false )
365 { 373 {
366 kdDebug() << "addPage: Invalid object" << endl; 374 kdDebug() << "addPage: Invalid object" << endl;
367 return( 0 ); 375 return( 0 );
368 } 376 }
369 377
370 QGrid *page = new QGrid( n, dir, FindParent(), "page" ); 378 Q3Grid *page = new Q3Grid( n, dir, FindParent(), "page" );
371 page->setSpacing( KDialog::spacingHint() ); 379 page->setSpacing( KDialog::spacingHint() );
372 addPageWidget( page, items, header, pixmap ); 380 addPageWidget( page, items, header, pixmap );
373 381
374 return page; 382 return page;
375} 383}
376 384
377 385
378QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, 386Q3Grid *KJanusWidget::addGridPage( int n, Qt::Orientation dir,
379 const QString &itemName, 387 const QString &itemName,
380 const QString &header, 388 const QString &header,
381 const QPixmap &pixmap ) 389 const QPixmap &pixmap )
382{ 390{
383 QStringList items; 391 QStringList items;
384 items << itemName; 392 items << itemName;
385 return addGridPage(n, dir, items, header, pixmap); 393 return addGridPage(n, dir, items, header, pixmap);
386} 394}
387 395
388void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page) 396void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, Q3Frame *page)
389{ 397{
390 bool isTop = true; 398 bool isTop = true;
391 QListViewItem *curTop = 0, *child, *last, *newChild; 399 Q3ListViewItem *curTop = 0, *child, *last, *newChild;
392 unsigned int index = 1; 400 unsigned int index = 1;
393 QStringList curPath; 401 QStringList curPath;
394 402
395 for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it, index++ ) { 403 for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it, index++ ) {
396 QString name = (*it); 404 QString name = (*it);
397 bool isPath = ( index != items.count() ); 405 bool isPath = ( index != items.count() );
@@ -409,15 +417,15 @@ void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &p
409 for (last = 0; child && child->text(0) != name ; last = child, child = child->nextSibling()); 417 for (last = 0; child && child->text(0) != name ; last = child, child = child->nextSibling());
410 418
411 if (last == 0 && child == 0) { 419 if (last == 0 && child == 0) {
412 // This node didn't have any children at all, lets just insert the 420 // This node didn't have any children at all, lets just insert the
413 // new child. 421 // new child.
414 if (isTop) 422 if (isTop)
415 newChild = new QListViewItem(mTreeList, name); 423 newChild = new Q3ListViewItem(mTreeList, name);
416 else 424 else
417 newChild = new QListViewItem(curTop, name); 425 newChild = new Q3ListViewItem(curTop, name);
418 426
419 } 427 }
420 else if (child != 0) { 428 else if (child != 0) {
421 // we found the given name in this child. 429 // we found the given name in this child.
422 if (!isPath) { 430 if (!isPath) {
423 kdDebug() << "The element inserted was already in the TreeList box!" << endl; 431 kdDebug() << "The element inserted was already in the TreeList box!" << endl;
@@ -428,15 +436,15 @@ void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &p
428 newChild = child; 436 newChild = child;
429 } 437 }
430 } 438 }
431 else { 439 else {
432 // the node had some children, but we didn't find the given name 440 // the node had some children, but we didn't find the given name
433 if (isTop) 441 if (isTop)
434 newChild = new QListViewItem(mTreeList, last, name); 442 newChild = new Q3ListViewItem(mTreeList, last, name);
435 else 443 else
436 newChild = new QListViewItem(curTop, last, name); 444 newChild = new Q3ListViewItem(curTop, last, name);
437 } 445 }
438 446
439 // Now make the element expandable if it is a path component, and make 447 // Now make the element expandable if it is a path component, and make
440 // ready for next loop 448 // ready for next loop
441 if (isPath) { 449 if (isPath) {
442 newChild->setExpandable(true); 450 newChild->setExpandable(true);
@@ -456,13 +464,13 @@ void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &p
456 } 464 }
457 mTreeListToPageStack.insert(newChild, page); 465 mTreeListToPageStack.insert(newChild, page);
458 } 466 }
459 } 467 }
460} 468}
461 469
462void KJanusWidget::addPageWidget( QFrame *page, const QStringList &items, 470void KJanusWidget::addPageWidget( Q3Frame *page, const QStringList &items,
463 const QString &header,const QPixmap &pixmap ) 471 const QString &header,const QPixmap &pixmap )
464{ 472{
465/*US the following signal causes a segmentation fault while closing the dialog. 473/*US the following signal causes a segmentation fault while closing the dialog.
466 Why not just remove all pages in the destructor?? 474 Why not just remove all pages in the destructor??
467*/ 475*/
468//US connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*))); 476//US connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*)));
@@ -547,21 +555,21 @@ bool KJanusWidget::setSwallowedWidget( QWidget *widget )
547 // Remove current layout and make a new. 555 // Remove current layout and make a new.
548 // 556 //
549 if( mSwallowPage->layout() != 0 ) 557 if( mSwallowPage->layout() != 0 )
550 { 558 {
551 delete mSwallowPage->layout(); 559 delete mSwallowPage->layout();
552 } 560 }
553 QGridLayout *gbox = new QGridLayout( mSwallowPage, 1, 1, 0 ); 561 Q3GridLayout *gbox = new Q3GridLayout( mSwallowPage, 1, 1, 0 );
554 562
555 // 563 //
556 // Hide old children 564 // Hide old children
557 // 565 //
558 QObjectList *l = (QObjectList*)mSwallowPage->children(); // silence please 566 QObjectList l = mSwallowPage->children(); // silence please
559 for( uint i=0; i < l->count(); i++ ) 567 for( uint i=0; i < l.count(); i++ )
560 { 568 {
561 QObject *o = l->at(i); 569 QObject *o = l.at(i);
562 if( o->isWidgetType() ) 570 if( o->isWidgetType() )
563 { 571 {
564 ((QWidget*)o)->hide(); 572 ((QWidget*)o)->hide();
565 } 573 }
566 } 574 }
567 575
@@ -594,22 +602,22 @@ bool KJanusWidget::slotShowPage()
594 { 602 {
595 return( false ); 603 return( false );
596 } 604 }
597 605
598 if( mFace == TreeList ) 606 if( mFace == TreeList )
599 { 607 {
600 QListViewItem *node = mTreeList->selectedItem(); 608 Q3ListViewItem *node = mTreeList->selectedItem();
601 if( node == 0 ) { return( false ); } 609 if( node == 0 ) { return( false ); }
602 610
603 QWidget *stackItem = mTreeListToPageStack[node]; 611 QWidget *stackItem = mTreeListToPageStack[node];
604 // Make sure to call through the virtual function showPage(int) 612 // Make sure to call through the virtual function showPage(int)
605 return showPage(d->mPageToInt[stackItem]); 613 return showPage(d->mPageToInt[stackItem]);
606 } 614 }
607 else if( mFace == IconList ) 615 else if( mFace == IconList )
608 { 616 {
609 QListBoxItem *node = mIconList->item( mIconList->currentItem() ); 617 Q3ListBoxItem *node = mIconList->item( mIconList->currentItem() );
610 if( node == 0 ) { return( false ); } 618 if( node == 0 ) { return( false ); }
611 QWidget *stackItem = mIconListToPageStack[node]; 619 QWidget *stackItem = mIconListToPageStack[node];
612 // Make sure to call through the virtual function showPage(int) 620 // Make sure to call through the virtual function showPage(int)
613 return showPage(d->mPageToInt[stackItem]); 621 return showPage(d->mPageToInt[stackItem]);
614 } 622 }
615 623
@@ -643,27 +651,27 @@ bool KJanusWidget::showPage( QWidget *w )
643 mActivePageWidget = w; 651 mActivePageWidget = w;
644 652
645 int index = d->mPageToInt[w]; 653 int index = d->mPageToInt[w];
646 mTitleLabel->setText( d->mIntToTitle[index] ); 654 mTitleLabel->setText( d->mIntToTitle[index] );
647 if( mFace == TreeList ) 655 if( mFace == TreeList )
648 { 656 {
649 QMap<QListViewItem *, QWidget *>::Iterator it; 657 QMap<Q3ListViewItem *, QWidget *>::Iterator it;
650 for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){ 658 for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){
651 QListViewItem *key = it.key(); 659 Q3ListViewItem *key = it.key();
652 QWidget *val = it.data(); 660 QWidget *val = it.data();
653 if (val == w) { 661 if (val == w) {
654 mTreeList->setSelected(key, true ); 662 mTreeList->setSelected(key, true );
655 break; 663 break;
656 } 664 }
657 } 665 }
658 } 666 }
659 else 667 else
660 { 668 {
661 QMap<QListBoxItem *, QWidget *>::Iterator it; 669 QMap<Q3ListBoxItem *, QWidget *>::Iterator it;
662 for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){ 670 for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){
663 QListBoxItem *key = it.key(); 671 Q3ListBoxItem *key = it.key();
664 QWidget *val = it.data(); 672 QWidget *val = it.data();
665 if (val == w) { 673 if (val == w) {
666 mIconList->setSelected( key, true ); 674 mIconList->setSelected( key, true );
667 break; 675 break;
668 } 676 }
669 } 677 }
@@ -683,19 +691,19 @@ bool KJanusWidget::showPage( QWidget *w )
683} 691}
684 692
685 693
686int KJanusWidget::activePageIndex() const 694int KJanusWidget::activePageIndex() const
687{ 695{
688 if( mFace == TreeList) { 696 if( mFace == TreeList) {
689 QListViewItem *node = mTreeList->selectedItem(); 697 Q3ListViewItem *node = mTreeList->selectedItem();
690 if( node == 0 ) { return -1; } 698 if( node == 0 ) { return -1; }
691 QWidget *stackItem = mTreeListToPageStack[node]; 699 QWidget *stackItem = mTreeListToPageStack[node];
692 return d->mPageToInt[stackItem]; 700 return d->mPageToInt[stackItem];
693 } 701 }
694 else if (mFace == IconList) { 702 else if (mFace == IconList) {
695 QListBoxItem *node = mIconList->item( mIconList->currentItem() ); 703 Q3ListBoxItem *node = mIconList->item( mIconList->currentItem() );
696 if( node == 0 ) { return( false ); } 704 if( node == 0 ) { return( false ); }
697 QWidget *stackItem = mIconListToPageStack[node]; 705 QWidget *stackItem = mIconListToPageStack[node];
698 return d->mPageToInt[stackItem]; 706 return d->mPageToInt[stackItem];
699 } 707 }
700 else if( mFace == Tabbed ) { 708 else if( mFace == Tabbed ) {
701 QWidget *widget = mTabControl->currentPage(); 709 QWidget *widget = mTabControl->currentPage();
@@ -758,13 +766,13 @@ void KJanusWidget::slotFontChanged()
758 mIconList->invalidateWidth(); 766 mIconList->invalidateWidth();
759 } 767 }
760} 768}
761*/ 769*/
762 770
763// makes the treelist behave like the list of kcontrol 771// makes the treelist behave like the list of kcontrol
764void KJanusWidget::slotItemClicked(QListViewItem *it) 772void KJanusWidget::slotItemClicked(Q3ListViewItem *it)
765{ 773{
766 if(it && (it->childCount()>0)) 774 if(it && (it->childCount()>0))
767 it->setOpen(!it->isOpen()); 775 it->setOpen(!it->isOpen());
768} 776}
769 777
770void KJanusWidget::setFocus() 778void KJanusWidget::setFocus()
@@ -892,17 +900,17 @@ void KJanusWidget::setRootIsDecorated( bool state )
892 900
893void KJanusWidget::unfoldTreeList( bool persist ) 901void KJanusWidget::unfoldTreeList( bool persist )
894{ 902{
895 if( mFace == TreeList ) 903 if( mFace == TreeList )
896 { 904 {
897 if( persist ) 905 if( persist )
898 connect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); 906 connect( mTreeList, SIGNAL( collapsed( Q3ListViewItem * ) ), this, SLOT( slotReopen( Q3ListViewItem * ) ) );
899 else 907 else
900 disconnect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); 908 disconnect( mTreeList, SIGNAL( collapsed( Q3ListViewItem * ) ), this, SLOT( slotReopen( Q3ListViewItem * ) ) );
901 909
902 for( QListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() ) 910 for( Q3ListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() )
903 item->setOpen( true ); 911 item->setOpen( true );
904 } 912 }
905} 913}
906 914
907void KJanusWidget::showEvent( QShowEvent * ) 915void KJanusWidget::showEvent( QShowEvent * )
908{ 916{
@@ -950,25 +958,25 @@ bool KJanusWidget::eventFilter( QObject *o, QEvent *e )
950// 958//
951// Code for the icon list box 959// Code for the icon list box
952// 960//
953 961
954 962
955KJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name, 963KJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name,
956 WFlags f ) 964 Qt::WFlags f )
957 :KListBox( parent, name, f ), mShowAll(false), mHeightValid(false), 965 :KListBox( parent, name, f ), mShowAll(false), mHeightValid(false),
958 mWidthValid(false) 966 mWidthValid(false)
959{ 967{
960} 968}
961 969
962 970
963void KJanusWidget::IconListBox::updateMinimumHeight() 971void KJanusWidget::IconListBox::updateMinimumHeight()
964{ 972{
965 if( mShowAll == true && mHeightValid == false ) 973 if( mShowAll == true && mHeightValid == false )
966 { 974 {
967 int h = frameWidth()*2; 975 int h = frameWidth()*2;
968 for( QListBoxItem *i = item(0); i != 0; i = i->next() ) 976 for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() )
969 { 977 {
970 h += i->height( this ); 978 h += i->height( this );
971 } 979 }
972 setMinimumHeight( h ); 980 setMinimumHeight( h );
973 mHeightValid = true; 981 mHeightValid = true;
974 } 982 }
@@ -977,19 +985,19 @@ void KJanusWidget::IconListBox::updateMinimumHeight()
977 985
978void KJanusWidget::IconListBox::updateWidth() 986void KJanusWidget::IconListBox::updateWidth()
979{ 987{
980 if( mWidthValid == false ) 988 if( mWidthValid == false )
981 { 989 {
982 int maxWidth = 10; 990 int maxWidth = 10;
983 for( QListBoxItem *i = item(0); i != 0; i = i->next() ) 991 for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() )
984 { 992 {
985 int w = ((IconListItem *)i)->width(this); 993 int w = ((IconListItem *)i)->width(this);
986 maxWidth = QMAX( w, maxWidth ); 994 maxWidth = QMAX( w, maxWidth );
987 } 995 }
988 996
989 for( QListBoxItem *i = item(0); i != 0; i = i->next() ) 997 for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() )
990 { 998 {
991 ((IconListItem *)i)->expandMinimumWidth( maxWidth ); 999 ((IconListItem *)i)->expandMinimumWidth( maxWidth );
992 } 1000 }
993 1001
994 if( verticalScrollBar()->isVisible() ) 1002 if( verticalScrollBar()->isVisible() )
995 { 1003 {
@@ -1019,15 +1027,15 @@ void KJanusWidget::IconListBox::setShowAll( bool showAll )
1019 mShowAll = showAll; 1027 mShowAll = showAll;
1020 mHeightValid = false; 1028 mHeightValid = false;
1021} 1029}
1022 1030
1023 1031
1024 1032
1025KJanusWidget::IconListItem::IconListItem( QListBox *listbox, const QPixmap &pixmap, 1033KJanusWidget::IconListItem::IconListItem( Q3ListBox *listbox, const QPixmap &pixmap,
1026 const QString &text ) 1034 const QString &text )
1027 : QListBoxItem( listbox ) 1035 : Q3ListBoxItem( listbox )
1028{ 1036{
1029 mPixmap = pixmap; 1037 mPixmap = pixmap;
1030 if( mPixmap.isNull() == true ) 1038 if( mPixmap.isNull() == true )
1031 { 1039 {
1032 mPixmap = defaultPixmap(); 1040 mPixmap = defaultPixmap();
1033 } 1041 }
@@ -1080,26 +1088,26 @@ void KJanusWidget::IconListItem::paint( QPainter *painter )
1080 if( text().isEmpty() == false ) 1088 if( text().isEmpty() == false )
1081 { 1089 {
1082 painter->drawText( 0, hp+7, mMinimumWidth, ht, Qt::AlignCenter, text() ); 1090 painter->drawText( 0, hp+7, mMinimumWidth, ht, Qt::AlignCenter, text() );
1083 } 1091 }
1084} 1092}
1085 1093
1086int KJanusWidget::IconListItem::height( const QListBox *lb ) const 1094int KJanusWidget::IconListItem::height( const Q3ListBox *lb ) const
1087{ 1095{
1088 if( text().isEmpty() == true ) 1096 if( text().isEmpty() == true )
1089 { 1097 {
1090 return( mPixmap.height() ); 1098 return( mPixmap.height() );
1091 } 1099 }
1092 else 1100 else
1093 { 1101 {
1094 return( mPixmap.height() + lb->fontMetrics().lineSpacing()+10 ); 1102 return( mPixmap.height() + lb->fontMetrics().lineSpacing()+10 );
1095 } 1103 }
1096} 1104}
1097 1105
1098 1106
1099int KJanusWidget::IconListItem::width( const QListBox *lb ) const 1107int KJanusWidget::IconListItem::width( const Q3ListBox *lb ) const
1100{ 1108{
1101 int wt = lb->fontMetrics().boundingRect(text()).width()+10; 1109 int wt = lb->fontMetrics().boundingRect(text()).width()+10;
1102 int wp = mPixmap.width() + 10; 1110 int wp = mPixmap.width() + 10;
1103 int w = QMAX( wt, wp ); 1111 int w = QMAX( wt, wp );
1104 return( QMAX( w, mMinimumWidth ) ); 1112 return( QMAX( w, mMinimumWidth ) );
1105} 1113}
@@ -1119,13 +1127,13 @@ void KJanusWidget::removePage( QWidget *page )
1119 } 1127 }
1120 1128
1121 int index = d->mPageToInt[page]; 1129 int index = d->mPageToInt[page];
1122 1130
1123 if ( mFace == TreeList ) 1131 if ( mFace == TreeList )
1124 { 1132 {
1125 QMap<QListViewItem*, QWidget *>::Iterator i; 1133 QMap<Q3ListViewItem*, QWidget *>::Iterator i;
1126 for( i = mTreeListToPageStack.begin(); i != mTreeListToPageStack.end(); ++i ) 1134 for( i = mTreeListToPageStack.begin(); i != mTreeListToPageStack.end(); ++i )
1127 if (i.data()==page) 1135 if (i.data()==page)
1128 { 1136 {
1129 delete i.key(); 1137 delete i.key();
1130 mPageStack->removeWidget(page); 1138 mPageStack->removeWidget(page);
1131 mTreeListToPageStack.remove(i); 1139 mTreeListToPageStack.remove(i);
@@ -1134,13 +1142,13 @@ void KJanusWidget::removePage( QWidget *page )
1134 d->mIntToPage.remove(index); 1142 d->mIntToPage.remove(index);
1135 break; 1143 break;
1136 } 1144 }
1137 } 1145 }
1138 else if ( mFace == IconList ) 1146 else if ( mFace == IconList )
1139 { 1147 {
1140 QMap<QListBoxItem*, QWidget *>::Iterator i; 1148 QMap<Q3ListBoxItem*, QWidget *>::Iterator i;
1141 for( i = mIconListToPageStack.begin(); i != mIconListToPageStack.end(); ++i ) 1149 for( i = mIconListToPageStack.begin(); i != mIconListToPageStack.end(); ++i )
1142 if (i.data()==page) 1150 if (i.data()==page)
1143 { 1151 {
1144 delete i.key(); 1152 delete i.key();
1145 mPageStack->removeWidget(page); 1153 mPageStack->removeWidget(page);
1146 mIconListToPageStack.remove(i); 1154 mIconListToPageStack.remove(i);