summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui
authorulf69 <ulf69>2004-10-22 03:17:57 (UTC)
committer ulf69 <ulf69>2004-10-22 03:17:57 (UTC)
commitd7ca0e5ca1346116145209b49ae62abeefebdb5f (patch) (unidiff)
tree29080282472aa29ebe3a8ebd4e47837e18e0b51b /microkde/kdeui
parente81c11b59475d934608c7253d2862933d497d1f8 (diff)
downloadkdepimpi-d7ca0e5ca1346116145209b49ae62abeefebdb5f.zip
kdepimpi-d7ca0e5ca1346116145209b49ae62abeefebdb5f.tar.gz
kdepimpi-d7ca0e5ca1346116145209b49ae62abeefebdb5f.tar.bz2
added include statement to make it buildable on all systems
Diffstat (limited to 'microkde/kdeui') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kjanuswidget.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/microkde/kdeui/kjanuswidget.cpp b/microkde/kdeui/kjanuswidget.cpp
index 7d25854..462c44f 100644
--- a/microkde/kdeui/kjanuswidget.cpp
+++ b/microkde/kdeui/kjanuswidget.cpp
@@ -1,129 +1,129 @@
1/* This file is part of the KDE Libraries 1/* This file is part of the KDE Libraries
2 * Copyright (C) 1999-2000 Espen Sand (espensa@online.no) 2 * Copyright (C) 1999-2000 Espen Sand (espensa@online.no)
3 * Copyright (C) 2003 Ravikiran Rajagopal (ravi@kde.org) 3 * Copyright (C) 2003 Ravikiran Rajagopal (ravi@kde.org)
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 as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA. 18 * Boston, MA 02111-1307, USA.
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 <qwidgetstack.h>
26#include <qtabwidget.h> 26#include <qtabwidget.h>
27#include <qlistview.h> 27#include <qlistview.h>
28#include <qhbox.h> 28#include <qhbox.h>
29#include <qvbox.h> 29#include <qvbox.h>
30#include <qgrid.h> 30#include <qgrid.h>
31#include <qpainter.h> 31#include <qpainter.h>
32#include <qobjectlist.h> 32#include <qobjectlist.h>
33 33#include <qstringlist.h>
34/*US 34/*US
35#include <qbitmap.h> 35#include <qbitmap.h>
36#include <qgrid.h> 36#include <qgrid.h>
37#include <qhbox.h> 37#include <qhbox.h>
38#include <qheader.h> 38#include <qheader.h>
39#include <qlabel.h> 39#include <qlabel.h>
40#include <qlayout.h> 40#include <qlayout.h>
41#include <qobjectlist.h> 41#include <qobjectlist.h>
42#include <qpixmap.h> 42#include <qpixmap.h>
43#include <qsplitter.h> 43#include <qsplitter.h>
44#include <qtabwidget.h> 44#include <qtabwidget.h>
45#include <qvbox.h> 45#include <qvbox.h>
46#include <qwidgetstack.h> 46#include <qwidgetstack.h>
47#include <qpainter.h> 47#include <qpainter.h>
48#include <qstyle.h> 48#include <qstyle.h>
49 49
50#include <kapplication.h> 50#include <kapplication.h>
51#include <klocale.h> 51#include <klocale.h>
52#include <kglobal.h> 52#include <kglobal.h>
53#include <kglobalsettings.h> 53#include <kglobalsettings.h>
54#include <kseparator.h> 54#include <kseparator.h>
55#include <kdebug.h> 55#include <kdebug.h>
56#include "kjanuswidget.h" 56#include "kjanuswidget.h"
57#include <klistview.h> 57#include <klistview.h>
58 58
59*/ 59*/
60 60
61#include <kseparator.h> 61#include <kseparator.h>
62#include <kdialog.h> // Access to some static members 62#include <kdialog.h> // Access to some static members
63#include <kdebug.h> 63#include <kdebug.h>
64#include <klistview.h> 64#include <klistview.h>
65 65
66#include "kjanuswidget.h" 66#include "kjanuswidget.h"
67 67
68class KJanusWidget::IconListItem : public QListBoxItem 68class KJanusWidget::IconListItem : public QListBoxItem
69{ 69{
70 public: 70 public:
71 IconListItem( QListBox *listbox, const QPixmap &pixmap, 71 IconListItem( QListBox *listbox, const QPixmap &pixmap,
72 const QString &text ); 72 const QString &text );
73 virtual int height( const QListBox *lb ) const; 73 virtual int height( const QListBox *lb ) const;
74 virtual int width( const QListBox *lb ) const; 74 virtual int width( const QListBox *lb ) const;
75 int expandMinimumWidth( int width ); 75 int expandMinimumWidth( int width );
76 76
77 protected: 77 protected:
78 const QPixmap &defaultPixmap(); 78 const QPixmap &defaultPixmap();
79 void paint( QPainter *painter ); 79 void paint( QPainter *painter );
80 80
81 private: 81 private:
82 QPixmap mPixmap; 82 QPixmap mPixmap;
83 int mMinimumWidth; 83 int mMinimumWidth;
84}; 84};
85 85
86class KJanusWidget::KJanusWidgetPrivate 86class KJanusWidget::KJanusWidgetPrivate
87{ 87{
88public: 88public:
89 KJanusWidgetPrivate() : mNextPageIndex(0) { } 89 KJanusWidgetPrivate() : mNextPageIndex(0) { }
90 90
91 int mNextPageIndex; // The next page index. 91 int mNextPageIndex; // The next page index.
92 92
93 // Dictionary for multipage modes. 93 // Dictionary for multipage modes.
94 QMap<int,QWidget*> mIntToPage; 94 QMap<int,QWidget*> mIntToPage;
95 // Reverse dictionary. Used because showPage() may be performance critical. 95 // Reverse dictionary. Used because showPage() may be performance critical.
96 QMap<QWidget*,int> mPageToInt; 96 QMap<QWidget*,int> mPageToInt;
97 // Dictionary of title string associated with page. 97 // Dictionary of title string associated with page.
98 QMap<int, QString> mIntToTitle; 98 QMap<int, QString> mIntToTitle;
99}; 99};
100 100
101template class QPtrList<QListViewItem>; 101template class QPtrList<QListViewItem>;
102 102
103 103
104KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) 104KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face )
105 : QWidget( parent, name ), 105 : QWidget( parent, name ),
106 mValid(false), mPageList(0), 106 mValid(false), mPageList(0),
107 mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0), 107 mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0),
108 mShowIconsInTreeList(false), d(0) 108 mShowIconsInTreeList(false), d(0)
109{ 109{
110 QVBoxLayout *topLayout = new QVBoxLayout( this ); 110 QVBoxLayout *topLayout = new QVBoxLayout( this );
111 if( mFace == TreeList || mFace == IconList ) 111 if( mFace == TreeList || mFace == IconList )
112 { 112 {
113 d = new KJanusWidgetPrivate; 113 d = new KJanusWidgetPrivate;
114 114
115 QFrame *page = 0; 115 QFrame *page = 0;
116 if( mFace == TreeList ) 116 if( mFace == TreeList )
117 { 117 {
118 //US 118 //US
119 qDebug("KJanusWidget::KJanusWidget TreeList not implemented yet"); 119 qDebug("KJanusWidget::KJanusWidget TreeList not implemented yet");
120/*US 120/*US
121 QSplitter *splitter = new QSplitter( this ); 121 QSplitter *splitter = new QSplitter( this );
122 topLayout->addWidget( splitter, 10 ); 122 topLayout->addWidget( splitter, 10 );
123 mTreeListResizeMode = QSplitter::KeepSize; 123 mTreeListResizeMode = QSplitter::KeepSize;
124 124
125 mTreeList = new KListView( splitter ); 125 mTreeList = new KListView( splitter );
126 mTreeList->addColumn( QString::null ); 126 mTreeList->addColumn( QString::null );
127 mTreeList->header()->hide(); 127 mTreeList->header()->hide();
128 mTreeList->setRootIsDecorated(true); 128 mTreeList->setRootIsDecorated(true);
129 mTreeList->setSorting( -1 ); 129 mTreeList->setSorting( -1 );
@@ -203,192 +203,193 @@ KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face )
203 topLayout->addWidget( mPlainPage, 10 ); 203 topLayout->addWidget( mPlainPage, 10 );
204 } 204 }
205/*US 205/*US
206 if ( kapp ) 206 if ( kapp )
207 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged())); 207 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
208*/ 208*/
209 mValid = true; 209 mValid = true;
210 setSwallowedWidget(0); // Set default size if 'mFace' is Swallow. 210 setSwallowedWidget(0); // Set default size if 'mFace' is Swallow.
211} 211}
212 212
213 213
214KJanusWidget::~KJanusWidget() 214KJanusWidget::~KJanusWidget()
215{ 215{
216 216
217/*US the destroyed signal caused a segmentation fault while closing the dialog and destructing 217/*US the destroyed signal caused a segmentation fault while closing the dialog and destructing
218 all pages. Why not just remove all pages in the destructor?? 218 all pages. Why not just remove all pages in the destructor??
219*/ 219*/
220// LR we have all subwidgets with parent-child relation 220// LR we have all subwidgets with parent-child relation
221// LR we do not need to delete here anything by the private class 221// LR we do not need to delete here anything by the private class
222/* 222/*
223 if( mFace == Tabbed ) 223 if( mFace == Tabbed )
224 { 224 {
225 QMap<QWidget*,int>::Iterator it; 225 QMap<QWidget*,int>::Iterator it;
226 for (it = d->mPageToInt.begin(); it != d->mPageToInt.end(); ++it) { 226 for (it = d->mPageToInt.begin(); it != d->mPageToInt.end(); ++it) {
227 QObject*page = (QObject*)it.key(); 227 QObject*page = (QObject*)it.key();
228 pageGone(page); 228 pageGone(page);
229 } 229 }
230 } 230 }
231 else 231 else
232 qDebug("KJanusWidget::~KJanusWidget so far "); 232 qDebug("KJanusWidget::~KJanusWidget so far ");
233*/ 233*/
234//US end 234//US end
235 235
236 delete d; 236 delete d;
237 237
238 238
239} 239}
240 240
241 241
242bool KJanusWidget::isValid() const 242bool KJanusWidget::isValid() const
243{ 243{
244 return( mValid ); 244 return( mValid );
245} 245}
246 246
247 247
248QFrame *KJanusWidget::plainPage() 248QFrame *KJanusWidget::plainPage()
249{ 249{
250 return( mPlainPage ); 250 return( mPlainPage );
251} 251}
252 252
253 253
254int KJanusWidget::face() const 254int KJanusWidget::face() const
255{ 255{
256 return( mFace ); 256 return( mFace );
257} 257}
258 258
259QWidget *KJanusWidget::FindParent() 259QWidget *KJanusWidget::FindParent()
260{ 260{
261 if( mFace == Tabbed ) { 261 if( mFace == Tabbed ) {
262 return mTabControl; 262 return mTabControl;
263 } 263 }
264 else { 264 else {
265 return this; 265 return this;
266 } 266 }
267} 267}
268 268
269QFrame *KJanusWidget::addPage( const QStringList &items, const QString &header, 269QFrame *KJanusWidget::addPage( const QStringList &items, const QString &header,
270 const QPixmap &pixmap ) 270 const QPixmap &pixmap )
271{ 271{
272 if( mValid == false ) 272 if( mValid == false )
273 { 273 {
274 kdDebug() << "addPage: Invalid object" << endl; 274 kdDebug() << "addPage: Invalid object" << endl;
275 return( 0 ); 275 return( 0 );
276 } 276 }
277 277
278 QFrame *page = new QFrame( FindParent(), "page" ); 278 QFrame *page = new QFrame( FindParent(), "page" );
279 addPageWidget( page, items, header, pixmap ); 279 addPageWidget( page, items, header, pixmap );
280 280
281 return page; 281 return page;
282} 282}
283 283
284void KJanusWidget::pageGone( QObject *obj ) 284void KJanusWidget::pageGone( QObject *obj )
285{ 285{
286// QObject* obj = (QObject*)sender(); 286// QObject* obj = (QObject*)sender();
287 removePage( static_cast<QWidget*>( obj ) ); 287 removePage( static_cast<QWidget*>( obj ) );
288} 288}
289 289
290void KJanusWidget::slotReopen( QListViewItem * item ) 290void KJanusWidget::slotReopen( QListViewItem * item )
291{ 291{
292 if( item ) 292 if( item )
293 item->setOpen( true ); 293 item->setOpen( true );
294} 294}
295 295
296QFrame *KJanusWidget::addPage( const QString &itemName, const QString &header, 296QFrame *KJanusWidget::addPage( const QString &itemName, const QString &header,
297 const QPixmap &pixmap ) 297 const QPixmap &pixmap )
298{ 298{
299
299 QStringList items; 300 QStringList items;
300 items << itemName; 301 items << itemName;
301 return addPage(items, header, pixmap); 302 return addPage(items, header, pixmap);
302} 303}
303 304
304 305
305 306
306QVBox *KJanusWidget::addVBoxPage( const QStringList &items, 307QVBox *KJanusWidget::addVBoxPage( const QStringList &items,
307 const QString &header, 308 const QString &header,
308 const QPixmap &pixmap ) 309 const QPixmap &pixmap )
309{ 310{
310 if( mValid == false ) 311 if( mValid == false )
311 { 312 {
312 qDebug("addPage: Invalid object "); 313 qDebug("addPage: Invalid object ");
313 314
314 return( 0 ); 315 return( 0 );
315 } 316 }
316 317
317 QVBox *page = new QVBox(FindParent() , "vbox_page" ); 318 QVBox *page = new QVBox(FindParent() , "vbox_page" );
318 page->setSpacing( KDialog::spacingHintSmall() ); 319 page->setSpacing( KDialog::spacingHintSmall() );
319 addPageWidget( page, items, header, pixmap ); 320 addPageWidget( page, items, header, pixmap );
320 321
321 return page; 322 return page;
322} 323}
323 324
324QVBox *KJanusWidget::addVBoxPage( const QString &itemName, 325QVBox *KJanusWidget::addVBoxPage( const QString &itemName,
325 const QString &header, 326 const QString &header,
326 const QPixmap &pixmap ) 327 const QPixmap &pixmap )
327{ 328{
328 QStringList items; 329 QStringList items;
329 items << itemName; 330 items << itemName;
330 return addVBoxPage(items, header, pixmap); 331 return addVBoxPage(items, header, pixmap);
331} 332}
332 333
333QHBox *KJanusWidget::addHBoxPage( const QStringList &items, 334QHBox *KJanusWidget::addHBoxPage( const QStringList &items,
334 const QString &header, 335 const QString &header,
335 const QPixmap &pixmap ) 336 const QPixmap &pixmap )
336{ 337{
337 if( mValid == false ) { 338 if( mValid == false ) {
338 kdDebug() << "addPage: Invalid object" << endl; 339 kdDebug() << "addPage: Invalid object" << endl;
339 return( 0 ); 340 return( 0 );
340 } 341 }
341 342
342 QHBox *page = new QHBox(FindParent(), "hbox_page"); 343 QHBox *page = new QHBox(FindParent(), "hbox_page");
343 page->setSpacing( KDialog::spacingHint() ); 344 page->setSpacing( KDialog::spacingHint() );
344 addPageWidget( page, items, header, pixmap ); 345 addPageWidget( page, items, header, pixmap );
345 346
346 return page; 347 return page;
347} 348}
348 349
349QHBox *KJanusWidget::addHBoxPage( const QString &itemName, 350QHBox *KJanusWidget::addHBoxPage( const QString &itemName,
350 const QString &header, 351 const QString &header,
351 const QPixmap &pixmap ) 352 const QPixmap &pixmap )
352{ 353{
353 QStringList items; 354 QStringList items;
354 items << itemName; 355 items << itemName;
355 return addHBoxPage(items, header, pixmap); 356 return addHBoxPage(items, header, pixmap);
356} 357}
357 358
358QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, 359QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir,
359 const QStringList &items, 360 const QStringList &items,
360 const QString &header, 361 const QString &header,
361 const QPixmap &pixmap ) 362 const QPixmap &pixmap )
362{ 363{
363 if( mValid == false ) 364 if( mValid == false )
364 { 365 {
365 kdDebug() << "addPage: Invalid object" << endl; 366 kdDebug() << "addPage: Invalid object" << endl;
366 return( 0 ); 367 return( 0 );
367 } 368 }
368 369
369 QGrid *page = new QGrid( n, dir, FindParent(), "page" ); 370 QGrid *page = new QGrid( n, dir, FindParent(), "page" );
370 page->setSpacing( KDialog::spacingHint() ); 371 page->setSpacing( KDialog::spacingHint() );
371 addPageWidget( page, items, header, pixmap ); 372 addPageWidget( page, items, header, pixmap );
372 373
373 return page; 374 return page;
374} 375}
375 376
376 377
377QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, 378QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir,
378 const QString &itemName, 379 const QString &itemName,
379 const QString &header, 380 const QString &header,
380 const QPixmap &pixmap ) 381 const QPixmap &pixmap )
381{ 382{
382 QStringList items; 383 QStringList items;
383 items << itemName; 384 items << itemName;
384 return addGridPage(n, dir, items, header, pixmap); 385 return addGridPage(n, dir, items, header, pixmap);
385} 386}
386 387
387void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page) 388void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page)
388{ 389{
389 bool isTop = true; 390 bool isTop = true;
390 QListViewItem *curTop = 0, *child, *last, *newChild; 391 QListViewItem *curTop = 0, *child, *last, *newChild;
391 unsigned int index = 1; 392 unsigned int index = 1;
392 QStringList curPath; 393 QStringList curPath;
393 394
394 for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it, index++ ) { 395 for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it, index++ ) {