summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp7
-rw-r--r--microkde/kapplication.cpp15
-rw-r--r--microkde/kapplication.h1
-rw-r--r--microkde/kresources/factory.cpp6
4 files changed, 25 insertions, 4 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index c60b566..029f14b 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -19,193 +19,193 @@
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#include "KDGanttMinimizeSplitter.h" 34#include "KDGanttMinimizeSplitter.h"
35#ifndef QT_NO_SPLITTER___ 35#ifndef QT_NO_SPLITTER___
36 36
37#include "qpainter.h" 37#include "qpainter.h"
38#include "qdrawutil.h" 38#include "qdrawutil.h"
39#include "qbitmap.h" 39#include "qbitmap.h"
40#if QT_VERSION >= 0x030000 40#if QT_VERSION >= 0x030000
41#include "qptrlist.h" 41#include "qptrlist.h"
42#include "qmemarray.h" 42#include "qmemarray.h"
43#else 43#else
44#include <qlist.h> 44#include <qlist.h>
45#include <qarray.h> 45#include <qarray.h>
46#define QPtrList QList 46#define QPtrList QList
47#define QMemArray QArray 47#define QMemArray QArray
48#endif 48#endif
49#include "qlayoutengine_p.h" 49#include "qlayoutengine_p.h"
50#include "qobjectlist.h" 50#include "qobjectlist.h"
51#include "qstyle.h" 51#include "qstyle.h"
52#include "qapplication.h" //sendPostedEvents 52#include "qapplication.h" //sendPostedEvents
53#include <qvaluelist.h> 53#include <qvaluelist.h>
54#include <qcursor.h> 54#include <qcursor.h>
55#ifndef KDGANTT_MASTER_CVS 55#ifndef KDGANTT_MASTER_CVS
56//#include "KDGanttMinimizeSplitter.moc" 56//#include "KDGanttMinimizeSplitter.moc"
57#endif 57#endif
58 58
59 59
60 60
61#ifndef DOXYGEN_SKIP_INTERNAL 61#ifndef DOXYGEN_SKIP_INTERNAL
62 62
63#if QT_VERSION >= 232 63#if QT_VERSION >= 232
64static int mouseOffset; 64static int mouseOffset;
65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky 65static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
66 66
67 67
68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, 68KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o,
69 KDGanttMinimizeSplitter *parent, const char * name ) 69 KDGanttMinimizeSplitter *parent, const char * name )
70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) 70 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false )
71{ 71{
72 72
73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { 73 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) {
74 mSizeHint = QSize(7,7); 74 mSizeHint = QSize(7,7);
75 mUseOffset = true; 75 mUseOffset = true;
76 } else { 76 } else {
77 mSizeHint = QSize(6,6); 77 mSizeHint = QSize(6,6);
78 mUseOffset = false; 78 mUseOffset = false;
79 } 79 }
80 s = parent; 80 s = parent;
81 setOrientation(o); 81 setOrientation(o);
82 setMouseTracking( true ); 82 setMouseTracking( true );
83 mMouseDown = false; 83 mMouseDown = false;
84 //setMaximumHeight( 5 ); // test only 84 //setMaximumHeight( 5 ); // test only
85} 85}
86 86
87QSize KDGanttSplitterHandle::sizeHint() const 87QSize KDGanttSplitterHandle::sizeHint() const
88{ 88{
89 return mSizeHint; 89 return mSizeHint;
90} 90}
91 91
92void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) 92void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
93{ 93{
94 orient = o; 94 orient = o;
95#ifndef QT_NO_CURSOR 95#ifndef QT_NO_CURSOR
96 if ( o == KDGanttMinimizeSplitter::Horizontal ) 96 if ( o == KDGanttMinimizeSplitter::Horizontal )
97 setCursor( splitHCursor ); 97 setCursor( splitHCursor );
98 else 98 else
99 setCursor( splitVCursor ); 99 setCursor( splitVCursor );
100#endif 100#endif
101} 101}
102 102
103 103
104void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 104void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
105{ 105{
106 updateCursor( e->pos() ); 106 updateCursor( e->pos() );
107 if ( !(e->state()&LeftButton) ) 107 if ( !(e->state()&LeftButton) )
108 return; 108 return;
109 109
110 if ( _activeButton != 0) 110 if ( _activeButton != 0)
111 return; 111 return;
112 112
113 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 113 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
114 - mouseOffset; 114 - mouseOffset;
115 if ( true /*opaque()*/ ) { 115 if ( opaque() ) {
116 s->moveSplitter( pos, id() ); 116 s->moveSplitter( pos, id() );
117 } else { 117 } else {
118 int min = pos; int max = pos; 118 int min = pos; int max = pos;
119 s->getRange( id(), &min, &max ); 119 s->getRange( id(), &min, &max );
120 s->setRubberband( QMAX( min, QMIN(max, pos ))); 120 s->setRubberband( QMAX( min, QMIN(max, pos )));
121 } 121 }
122 _collapsed = false; 122 _collapsed = false;
123} 123}
124 124
125void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) 125void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
126{ 126{
127 if ( e->button() == LeftButton ) { 127 if ( e->button() == LeftButton ) {
128 _activeButton = onButton( e->pos() ); 128 _activeButton = onButton( e->pos() );
129 mouseOffset = s->pick(e->pos()); 129 mouseOffset = s->pick(e->pos());
130 mMouseDown = true; 130 mMouseDown = true;
131 repaint(); 131 repaint();
132 updateCursor( e->pos() ); 132 updateCursor( e->pos() );
133 } 133 }
134} 134}
135 135
136void KDGanttSplitterHandle::updateCursor( const QPoint& p) 136void KDGanttSplitterHandle::updateCursor( const QPoint& p)
137{ 137{
138 if ( onButton( p ) != 0 ) { 138 if ( onButton( p ) != 0 ) {
139 setCursor( arrowCursor ); 139 setCursor( arrowCursor );
140 } 140 }
141 else { 141 else {
142 if ( orient == KDGanttMinimizeSplitter::Horizontal ) 142 if ( orient == KDGanttMinimizeSplitter::Horizontal )
143 setCursor( splitHCursor ); 143 setCursor( splitHCursor );
144 else 144 else
145 setCursor( splitVCursor ); 145 setCursor( splitVCursor );
146 } 146 }
147} 147}
148void KDGanttSplitterHandle::toggle() 148void KDGanttSplitterHandle::toggle()
149{ 149{
150 int pos; 150 int pos;
151 int min, max; 151 int min, max;
152 if ( !_collapsed ) { 152 if ( !_collapsed ) {
153 s->expandPos( id(), &min, &max ); 153 s->expandPos( id(), &min, &max );
154 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left 154 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
155 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 155 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
156 pos = min; 156 pos = min;
157 } 157 }
158 else { 158 else {
159 pos = max; 159 pos = max;
160 } 160 }
161 161
162 _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); 162 _origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
163 s->moveSplitter( pos, id() ); 163 s->moveSplitter( pos, id() );
164 _collapsed = true; 164 _collapsed = true;
165 } 165 }
166 else { 166 else {
167 s->moveSplitter( _origPos, id() ); 167 s->moveSplitter( _origPos, id() );
168 _collapsed = false; 168 _collapsed = false;
169 } 169 }
170 repaint(); 170 repaint();
171} 171}
172 172
173void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 173void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
174{ 174{
175 mMouseDown = false; 175 mMouseDown = false;
176 if ( _activeButton != 0 ) { 176 if ( _activeButton != 0 ) {
177 if ( onButton( e->pos() ) == _activeButton ) 177 if ( onButton( e->pos() ) == _activeButton )
178 { 178 {
179 toggle(); 179 toggle();
180 } 180 }
181 _activeButton = 0; 181 _activeButton = 0;
182 updateCursor( e->pos() ); 182 updateCursor( e->pos() );
183 } 183 }
184 else { 184 else {
185 if ( !opaque() && e->button() == LeftButton ) { 185 if ( !opaque() && e->button() == LeftButton ) {
186 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 186 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
187 - mouseOffset; 187 - mouseOffset;
188 s->setRubberband( -1 ); 188 s->setRubberband( -1 );
189 s->moveSplitter( pos, id() ); 189 s->moveSplitter( pos, id() );
190 } 190 }
191 } 191 }
192 repaint(); 192 repaint();
193} 193}
194 194
195int KDGanttSplitterHandle::onButton( const QPoint& p ) 195int KDGanttSplitterHandle::onButton( const QPoint& p )
196{ 196{
197 QValueList<QPointArray> list = buttonRegions(); 197 QValueList<QPointArray> list = buttonRegions();
198 int index = 1; 198 int index = 1;
199 int add = 12; 199 int add = 12;
200 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 200 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
201 QRect rect = (*it).boundingRect(); 201 QRect rect = (*it).boundingRect();
202 rect.setLeft( rect.left()- add ); 202 rect.setLeft( rect.left()- add );
203 rect.setRight( rect.right() + add); 203 rect.setRight( rect.right() + add);
204 rect.setTop( rect.top()- add ); 204 rect.setTop( rect.top()- add );
205 rect.setBottom( rect.bottom() + add); 205 rect.setBottom( rect.bottom() + add);
206 if ( rect.contains( p ) ) { 206 if ( rect.contains( p ) ) {
207 return index; 207 return index;
208 } 208 }
209 index++; 209 index++;
210 } 210 }
211 return 0; 211 return 0;
@@ -390,192 +390,197 @@ void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int
390 \endcode 390 \endcode
391 391
392 In KDGanttMinimizeSplitter, the boundary can be either horizontal or 392 In KDGanttMinimizeSplitter, the boundary can be either horizontal or
393 vertical. The default is horizontal (the children are side by side) 393 vertical. The default is horizontal (the children are side by side)
394 but you can use setOrientation( QSplitter::Vertical ) to set it to 394 but you can use setOrientation( QSplitter::Vertical ) to set it to
395 vertical. 395 vertical.
396 396
397 Use setResizeMode() to specify 397 Use setResizeMode() to specify
398 that a widget should keep its size when the splitter is resized. 398 that a widget should keep its size when the splitter is resized.
399 399
400 Although KDGanttMinimizeSplitter normally resizes the children only 400 Although KDGanttMinimizeSplitter normally resizes the children only
401 at the end of a resize operation, if you call setOpaqueResize( TRUE 401 at the end of a resize operation, if you call setOpaqueResize( TRUE
402 ) the widgets are resized as often as possible. 402 ) the widgets are resized as often as possible.
403 403
404 The initial distribution of size between the widgets is determined 404 The initial distribution of size between the widgets is determined
405 by the initial size of each widget. You can also use setSizes() to 405 by the initial size of each widget. You can also use setSizes() to
406 set the sizes of all the widgets. The function sizes() returns the 406 set the sizes of all the widgets. The function sizes() returns the
407 sizes set by the user. 407 sizes set by the user.
408 408
409 If you hide() a child, its space will be distributed among the other 409 If you hide() a child, its space will be distributed among the other
410 children. It will be reinstated when you show() it again. It is also 410 children. It will be reinstated when you show() it again. It is also
411 possible to reorder the widgets within the splitter using 411 possible to reorder the widgets within the splitter using
412 moveToFirst() and moveToLast(). 412 moveToFirst() and moveToLast().
413*/ 413*/
414 414
415 415
416 416
417static QSize minSize( const QWidget* /*w*/ ) 417static QSize minSize( const QWidget* /*w*/ )
418{ 418{
419 return QSize(0,0); 419 return QSize(0,0);
420} 420}
421 421
422// This is the original version of minSize 422// This is the original version of minSize
423static QSize minSizeHint( const QWidget* w ) 423static QSize minSizeHint( const QWidget* w )
424{ 424{
425 QSize min = w->minimumSize(); 425 QSize min = w->minimumSize();
426 QSize s; 426 QSize s;
427 if ( min.height() <= 0 || min.width() <= 0 ) 427 if ( min.height() <= 0 || min.width() <= 0 )
428 s = w->minimumSizeHint(); 428 s = w->minimumSizeHint();
429 if ( min.height() > 0 ) 429 if ( min.height() > 0 )
430 s.setHeight( min.height() ); 430 s.setHeight( min.height() );
431 if ( min.width() > 0 ) 431 if ( min.width() > 0 )
432 s.setWidth( min.width() ); 432 s.setWidth( min.width() );
433 return s.expandedTo(QSize(0,0)); 433 return s.expandedTo(QSize(0,0));
434} 434}
435 435
436 436
437 437
438/*! 438/*!
439 Constructs a horizontal splitter with the \a parent and \a 439 Constructs a horizontal splitter with the \a parent and \a
440 name arguments being passed on to the QFrame constructor. 440 name arguments being passed on to the QFrame constructor.
441*/ 441*/
442KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 442KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
443 :QFrame(parent,name,WPaintUnclipped) 443 :QFrame(parent,name,WPaintUnclipped)
444{ 444{
445 mFirstHandle = 0; 445 mFirstHandle = 0;
446#if QT_VERSION >= 232 446#if QT_VERSION >= 232
447 orient = Horizontal; 447 orient = Horizontal;
448 init(); 448 init();
449#endif 449#endif
450} 450}
451 451
452/*! 452/*!
453 Constructs a splitter with orientation \a o with the \a parent 453 Constructs a splitter with orientation \a o with the \a parent
454 and \a name arguments being passed on to the QFrame constructor. 454 and \a name arguments being passed on to the QFrame constructor.
455*/ 455*/
456KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 456KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name )
457 :QFrame(parent,name,WPaintUnclipped) 457 :QFrame(parent,name,WPaintUnclipped)
458{ 458{
459 mFirstHandle = 0; 459 mFirstHandle = 0;
460#if QT_VERSION >= 232 460#if QT_VERSION >= 232
461 orient = o; 461 orient = o;
462 init(); 462 init();
463#endif 463#endif
464} 464}
465 465
466/*! 466/*!
467 Destroys the splitter and any children. 467 Destroys the splitter and any children.
468*/ 468*/
469KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 469KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
470{ 470{
471#if QT_VERSION >= 232 471#if QT_VERSION >= 232
472 data->list.setAutoDelete( TRUE ); 472 data->list.setAutoDelete( TRUE );
473 delete data; 473 delete data;
474#endif 474#endif
475} 475}
476 476
477 477
478#if QT_VERSION >= 232 478#if QT_VERSION >= 232
479void KDGanttMinimizeSplitter::init() 479void KDGanttMinimizeSplitter::init()
480{ 480{
481 data = new QSplitterData; 481 data = new QSplitterData;
482 if ( orient == Horizontal ) 482 if ( orient == Horizontal )
483 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 483 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
484 else 484 else
485 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 485 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
486#ifndef DESKTOP_VERSION
487 setOpaqueResize( false );
488#else
489 setOpaqueResize( true );
490#endif
486} 491}
487#endif 492#endif
488 493
489 494
490void KDGanttMinimizeSplitter::toggle() 495void KDGanttMinimizeSplitter::toggle()
491{ 496{
492 if ( mFirstHandle ) 497 if ( mFirstHandle )
493 mFirstHandle->toggle(); 498 mFirstHandle->toggle();
494 else 499 else
495 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); 500 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available ");
496 501
497} 502}
498 503
499 504
500/*! 505/*!
501 \brief the orientation of the splitter 506 \brief the orientation of the splitter
502 507
503 By default the orientation is horizontal (the widgets are side by side). 508 By default the orientation is horizontal (the widgets are side by side).
504 The possible orientations are Qt:Vertical and Qt::Horizontal (the default). 509 The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
505*/ 510*/
506void KDGanttMinimizeSplitter::setOrientation( Orientation o ) 511void KDGanttMinimizeSplitter::setOrientation( Orientation o )
507{ 512{
508#if QT_VERSION >= 232 513#if QT_VERSION >= 232
509 if ( orient == o ) 514 if ( orient == o )
510 return; 515 return;
511 orient = o; 516 orient = o;
512 517
513 if ( orient == Horizontal ) 518 if ( orient == Horizontal )
514 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 519 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
515 else 520 else
516 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 521 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
517 522
518 QSplitterLayoutStruct *s = data->list.first(); 523 QSplitterLayoutStruct *s = data->list.first();
519 while ( s ) { 524 while ( s ) {
520 if ( s->isSplitter ) 525 if ( s->isSplitter )
521 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); 526 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
522 s = data->list.next(); // ### next at end of loop, no iterator 527 s = data->list.next(); // ### next at end of loop, no iterator
523 } 528 }
524 recalc( isVisible() ); 529 recalc( isVisible() );
525#endif 530#endif
526} 531}
527 532
528 533
529#if QT_VERSION >= 232 534#if QT_VERSION >= 232
530/*! 535/*!
531 \reimp 536 \reimp
532*/ 537*/
533void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) 538void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
534{ 539{
535 doResize(); 540 doResize();
536} 541}
537 542
538 543
539/* 544/*
540 Inserts the widget \a w at the end (or at the beginning if \a first 545 Inserts the widget \a w at the end (or at the beginning if \a first
541 is TRUE) of the splitter's list of widgets. 546 is TRUE) of the splitter's list of widgets.
542 547
543 It is the responsibility of the caller of this function to make sure 548 It is the responsibility of the caller of this function to make sure
544 that \a w is not already in the splitter and to call recalcId if 549 that \a w is not already in the splitter and to call recalcId if
545 needed. (If \a first is TRUE, then recalcId is very probably 550 needed. (If \a first is TRUE, then recalcId is very probably
546 needed.) 551 needed.)
547*/ 552*/
548QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) 553QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first )
549{ 554{
550 QSplitterLayoutStruct *s; 555 QSplitterLayoutStruct *s;
551 KDGanttSplitterHandle *newHandle = 0; 556 KDGanttSplitterHandle *newHandle = 0;
552 if ( data->list.count() > 0 ) { 557 if ( data->list.count() > 0 ) {
553 s = new QSplitterLayoutStruct; 558 s = new QSplitterLayoutStruct;
554 s->mode = KeepSize; 559 s->mode = KeepSize;
555 QString tmp = "qt_splithandle_"; 560 QString tmp = "qt_splithandle_";
556 tmp += w->name(); 561 tmp += w->name();
557 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); 562 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() );
558 if ( ! mFirstHandle ) 563 if ( ! mFirstHandle )
559 mFirstHandle = newHandle; 564 mFirstHandle = newHandle;
560 s->wid = newHandle; 565 s->wid = newHandle;
561 newHandle->setId(data->list.count()); 566 newHandle->setId(data->list.count());
562 s->isSplitter = TRUE; 567 s->isSplitter = TRUE;
563 s->sizer = pick( newHandle->sizeHint() ); 568 s->sizer = pick( newHandle->sizeHint() );
564 if ( first ) 569 if ( first )
565 data->list.insert( 0, s ); 570 data->list.insert( 0, s );
566 else 571 else
567 data->list.append( s ); 572 data->list.append( s );
568 } 573 }
569 s = new QSplitterLayoutStruct; 574 s = new QSplitterLayoutStruct;
570 s->mode = Stretch; 575 s->mode = Stretch;
571 s->wid = w; 576 s->wid = w;
572 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 577 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
573 s->sizer = pick( w->sizeHint() ); 578 s->sizer = pick( w->sizeHint() );
574 else 579 else
575 s->sizer = pick( w->size() ); 580 s->sizer = pick( w->size() );
576 s->isSplitter = FALSE; 581 s->isSplitter = FALSE;
577 if ( first ) 582 if ( first )
578 data->list.insert( 0, s ); 583 data->list.insert( 0, s );
579 else 584 else
580 data->list.append( s ); 585 data->list.append( s );
581 if ( newHandle && isVisible() ) 586 if ( newHandle && isVisible() )
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index f05b91b..80a83e0 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,111 +1,126 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3 3
4#include "kapplication.h" 4#include "kapplication.h"
5#include "ktextedit.h" 5#include "ktextedit.h"
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qstring.h> 7#include <qstring.h>
8#include <qfile.h> 8#include <qfile.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qdialog.h> 10#include <qdialog.h>
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qtextbrowser.h> 12#include <qtextbrowser.h>
13 13
14int KApplication::random() 14int KApplication::random()
15{ 15{
16 return rand(); 16 return rand();
17} 17}
18 18
19//US 19//US
20QString KApplication::randomString(int length) 20QString KApplication::randomString(int length)
21{ 21{
22 if (length <=0 ) return QString::null; 22 if (length <=0 ) return QString::null;
23 23
24 QString str; 24 QString str;
25 while (length--) 25 while (length--)
26 { 26 {
27 int r=random() % 62; 27 int r=random() % 62;
28 r+=48; 28 r+=48;
29 if (r>57) r+=7; 29 if (r>57) r+=7;
30 if (r>90) r+=6; 30 if (r>90) r+=6;
31 str += char(r); 31 str += char(r);
32 // so what if I work backwards? 32 // so what if I work backwards?
33 } 33 }
34 return str; 34 return str;
35} 35}
36int KApplication::execDialog( QDialog* d ) 36int KApplication::execDialog( QDialog* d )
37{ 37{
38 if (QApplication::desktop()->width() <= 640 ) 38 if (QApplication::desktop()->width() <= 640 )
39 d->showMaximized(); 39 d->showMaximized();
40 else 40 else
41 ;//d->resize( 800, 600 ); 41 ;//d->resize( 800, 600 );
42 return d->exec(); 42 return d->exec();
43} 43}
44void KApplication::showLicence() 44void KApplication::showLicence()
45{ 45{
46 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); 46 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" );
47} 47}
48 48
49void KApplication::testCoords( int* x, int* y, int* wid, int * hei )
50{
51 int dWid = QApplication::desktop()->width() ;
52 int dHei = QApplication::desktop()->height();
53 if ( *x + *wid > dWid ) {
54 *x = 0;
55 if ( *wid > dWid )
56 *wid = dWid;
57 }
58 if ( *y + *hei > dHei ) {
59 *y = 0;
60 if ( *hei > dHei )
61 *hei = dHei;
62 }
63}
49void KApplication::showFile(QString caption, QString fn) 64void KApplication::showFile(QString caption, QString fn)
50{ 65{
51 QString text; 66 QString text;
52 QString fileName; 67 QString fileName;
53#ifndef DESKTOP_VERSION 68#ifndef DESKTOP_VERSION
54 fileName = getenv("QPEDIR"); 69 fileName = getenv("QPEDIR");
55 fileName += "/pics/" + fn ; 70 fileName += "/pics/" + fn ;
56#else 71#else
57 fileName = qApp->applicationDirPath () + "/" + fn; 72 fileName = qApp->applicationDirPath () + "/" + fn;
58#endif 73#endif
59 QFile file( fileName ); 74 QFile file( fileName );
60 if (!file.open( IO_ReadOnly ) ) { 75 if (!file.open( IO_ReadOnly ) ) {
61 return ; 76 return ;
62 } 77 }
63 QTextStream ts( &file ); 78 QTextStream ts( &file );
64 text = ts.read(); 79 text = ts.read();
65 file.close(); 80 file.close();
66 KApplication::showText( caption, text ); 81 KApplication::showText( caption, text );
67 82
68} 83}
69 84
70bool KApplication::convert2latin1(QString fileName) 85bool KApplication::convert2latin1(QString fileName)
71{ 86{
72 QString text; 87 QString text;
73 QFile file( fileName ); 88 QFile file( fileName );
74 if (!file.open( IO_ReadOnly ) ) { 89 if (!file.open( IO_ReadOnly ) ) {
75 return false; 90 return false;
76 91
77 } 92 }
78 QTextStream ts( &file ); 93 QTextStream ts( &file );
79 ts.setEncoding( QTextStream::UnicodeUTF8 ); 94 ts.setEncoding( QTextStream::UnicodeUTF8 );
80 text = ts.read(); 95 text = ts.read();
81 file.close(); 96 file.close();
82 if (!file.open( IO_WriteOnly ) ) { 97 if (!file.open( IO_WriteOnly ) ) {
83 return false; 98 return false;
84 } 99 }
85 QTextStream tsIn( &file ); 100 QTextStream tsIn( &file );
86 tsIn.setEncoding( QTextStream::Latin1 ); 101 tsIn.setEncoding( QTextStream::Latin1 );
87 tsIn << text.latin1(); 102 tsIn << text.latin1();
88 file.close(); 103 file.close();
89 return true; 104 return true;
90 105
91 106
92} 107}
93void KApplication::showText(QString caption, QString text) 108void KApplication::showText(QString caption, QString text)
94{ 109{
95 QDialog dia( 0, "name", true ); ; 110 QDialog dia( 0, "name", true ); ;
96 dia.setCaption( caption ); 111 dia.setCaption( caption );
97 QVBoxLayout* lay = new QVBoxLayout( &dia ); 112 QVBoxLayout* lay = new QVBoxLayout( &dia );
98 lay->setSpacing( 3 ); 113 lay->setSpacing( 3 );
99 lay->setMargin( 3 ); 114 lay->setMargin( 3 );
100 KTextEdit tb ( &dia ); 115 KTextEdit tb ( &dia );
101 tb.setWordWrap( QMultiLineEdit::WidgetWidth ); 116 tb.setWordWrap( QMultiLineEdit::WidgetWidth );
102 lay->addWidget( &tb ); 117 lay->addWidget( &tb );
103 tb.setText( text ); 118 tb.setText( text );
104#ifdef DESKTOP_VERSION 119#ifdef DESKTOP_VERSION
105 dia.resize( 640, 480); 120 dia.resize( 640, 480);
106#else 121#else
107 dia.showMaximized(); 122 dia.showMaximized();
108#endif 123#endif
109 dia.exec(); 124 dia.exec();
110 125
111} 126}
diff --git a/microkde/kapplication.h b/microkde/kapplication.h
index 497ec2f..f7eb1ef 100644
--- a/microkde/kapplication.h
+++ b/microkde/kapplication.h
@@ -1,30 +1,31 @@
1#ifndef MINIKDE_KAPPLICATION_H 1#ifndef MINIKDE_KAPPLICATION_H
2#define MINIKDE_KAPPLICATION_H 2#define MINIKDE_KAPPLICATION_H
3 3
4#include "qstring.h" 4#include "qstring.h"
5#include <qdialog.h> 5#include <qdialog.h>
6#ifdef QDialog 6#ifdef QDialog
7#undef QDialog 7#undef QDialog
8#endif 8#endif
9 9
10class KApplication 10class KApplication
11{ 11{
12 public: 12 public:
13 static int random(); 13 static int random();
14 14
15//US 15//US
16 /** 16 /**
17 * Generates a random string. It operates in the range [A-Za-z0-9] 17 * Generates a random string. It operates in the range [A-Za-z0-9]
18 * @param length Generate a string of this length. 18 * @param length Generate a string of this length.
19 * @return the random string 19 * @return the random string
20 */ 20 */
21 static QString randomString(int length); 21 static QString randomString(int length);
22 static int execDialog( QDialog* ); 22 static int execDialog( QDialog* );
23 static void showLicence(); 23 static void showLicence();
24 static void testCoords( int* x, int* y, int* wid, int * hei );
24 static void showFile(QString caption, QString file); 25 static void showFile(QString caption, QString file);
25 static void showText(QString caption, QString text); 26 static void showText(QString caption, QString text);
26 static bool convert2latin1(QString file); 27 static bool convert2latin1(QString file);
27}; 28};
28 29
29 30
30#endif 31#endif
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 3d1889f..a3b7fff 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -1,191 +1,191 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <kdebug.h> 24#include <kdebug.h>
25#include <klocale.h> 25#include <klocale.h>
26#include <ksimpleconfig.h> 26#include <ksimpleconfig.h>
27#include <kstandarddirs.h> 27#include <kstandarddirs.h>
28#include <kstaticdeleter.h> 28#include <kstaticdeleter.h>
29//#ifndef DESKTOP_VERSION 29//#ifndef DESKTOP_VERSION
30#include <klibloader.h> 30#include <klibloader.h>
31//#endif 31//#endif
32#include <qfile.h> 32#include <qfile.h>
33 33
34#include "resource.h" 34#include "resource.h"
35#include "factory.h" 35#include "factory.h"
36 36
37using namespace KRES; 37using namespace KRES;
38 38
39QDict<Factory> *Factory::mSelves = 0; 39QDict<Factory> *Factory::mSelves = 0;
40static KStaticDeleter< QDict<Factory> > staticDeleter; 40static KStaticDeleter< QDict<Factory> > staticDeleter;
41 41
42Factory *Factory::self( const QString& resourceFamily) 42Factory *Factory::self( const QString& resourceFamily)
43{ 43{
44 44
45 45
46 Factory *factory = 0; 46 Factory *factory = 0;
47 if ( !mSelves ) 47 if ( !mSelves )
48 { 48 {
49 mSelves = staticDeleter.setObject( new QDict<Factory> ); 49 mSelves = staticDeleter.setObject( new QDict<Factory> );
50 } 50 }
51 51
52 factory = mSelves->find( resourceFamily ); 52 factory = mSelves->find( resourceFamily );
53 53
54 if ( !factory ) { 54 if ( !factory ) {
55 factory = new Factory( resourceFamily); 55 factory = new Factory( resourceFamily);
56 mSelves->insert( resourceFamily, factory ); 56 mSelves->insert( resourceFamily, factory );
57 } 57 }
58 58
59 return factory; 59 return factory;
60} 60}
61 61
62Factory::Factory( const QString& resourceFamily) : 62Factory::Factory( const QString& resourceFamily) :
63 mResourceFamily( resourceFamily ) 63 mResourceFamily( resourceFamily )
64{ 64{
65//US so far we have three types available for resourceFamily "contact" 65//US so far we have three types available for resourceFamily "contact"
66// and that are "file", "dir", "ldap" 66// and that are "file", "dir", "ldap"
67/*US 67/*US
68 68
69 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) 69 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
70 .arg( resourceFamily ) ); 70 .arg( resourceFamily ) );
71 KTrader::OfferList::ConstIterator it; 71 KTrader::OfferList::ConstIterator it;
72 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 72 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
73 QVariant type = (*it)->property( "X-KDE-ResourceType" ); 73 QVariant type = (*it)->property( "X-KDE-ResourceType" );
74 if ( !type.toString().isEmpty() ) 74 if ( !type.toString().isEmpty() )
75 mTypeMap.insert( type.toString(), *it ); 75 mTypeMap.insert( type.toString(), *it );
76 } 76 }
77*/ 77*/
78 78
79//US new 79//US new
80 PluginInfo* info = new PluginInfo; 80 PluginInfo* info = new PluginInfo;
81 info->library = "microkabc_file"; 81 info->library = "microkabc_file";
82 info->nameLabel = i18n( "file" ); 82 info->nameLabel = i18n( "file" );
83 info->descriptionLabel = i18n( "Choose one file" ); 83 info->descriptionLabel = i18n( "One file" );
84 mTypeMap.insert( "file", info ); 84 mTypeMap.insert( "file", info );
85 85
86 info = new PluginInfo; 86 info = new PluginInfo;
87 info->library = "microkabc_dir"; 87 info->library = "microkabc_dir";
88 info->nameLabel = i18n( "dir" ); 88 info->nameLabel = i18n( "dir" );
89 info->descriptionLabel = i18n( "Choose a directory with may files" ); 89 info->descriptionLabel = i18n( "A directory with many files" );
90 mTypeMap.insert( "dir", info ); 90 mTypeMap.insert( "dir", info );
91 91
92 info = new PluginInfo; 92 info = new PluginInfo;
93 info->library = "microkabc_ldap"; 93 info->library = "microkabc_ldap";
94 info->nameLabel = i18n( "ldap" ); 94 info->nameLabel = i18n( "ldap" );
95 info->descriptionLabel = i18n( "No description available" ); 95 info->descriptionLabel = i18n( "Connect to a directory server" );
96 mTypeMap.insert( "ldap", info ); 96 mTypeMap.insert( "ldap", info );
97 97
98 //US add opie plugin only, if the library exists. 98 //US add opie plugin only, if the library exists.
99 /*US 99 /*US
100 QString libname = "microkabc_opie"; 100 QString libname = "microkabc_opie";
101 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 101 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
102 if ( !path.isEmpty() ) 102 if ( !path.isEmpty() )
103 { 103 {
104 info = new PluginInfo; 104 info = new PluginInfo;
105 info->library = libname; 105 info->library = libname;
106 info->nameLabel = i18n( "opie" ); 106 info->nameLabel = i18n( "opie" );
107 info->descriptionLabel = i18n( "Opie PIM Addressbook." ); 107 info->descriptionLabel = i18n( "Opie PIM Addressbook." );
108 mTypeMap.insert( "opie", info ); 108 mTypeMap.insert( "opie", info );
109 } 109 }
110 */ 110 */
111 //US add qtopia plugin only, if the library exists. 111 //US add qtopia plugin only, if the library exists.
112 QString libname = "microkabc_qtopia"; 112 QString libname = "microkabc_qtopia";
113 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 113 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
114 if ( !path.isEmpty() ) 114 if ( !path.isEmpty() )
115 { 115 {
116 info = new PluginInfo; 116 info = new PluginInfo;
117 info->library = libname; 117 info->library = libname;
118 info->nameLabel = i18n( "qtopia" ); 118 info->nameLabel = i18n( "qtopia" );
119 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); 119 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." );
120 mTypeMap.insert( "qtopia", info ); 120 mTypeMap.insert( "qtopia", info );
121 } 121 }
122 122
123 //US add sharp plugin only, if the library exists. 123 //US add sharp plugin only, if the library exists.
124 libname = "microkabc_sharpdtm"; 124 libname = "microkabc_sharpdtm";
125 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 125 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
126 if ( !path.isEmpty() ) 126 if ( !path.isEmpty() )
127 { 127 {
128 info = new PluginInfo; 128 info = new PluginInfo;
129 info->library = libname; 129 info->library = libname;
130 info->nameLabel = i18n( "sharp" ); 130 info->nameLabel = i18n( "sharp" );
131 info->descriptionLabel = i18n( "Sharp DTM Addressbook." ); 131 info->descriptionLabel = i18n( "Sharp DTM Addressbook." );
132 mTypeMap.insert( "sharp", info ); 132 mTypeMap.insert( "sharp", info );
133 } 133 }
134 134
135 135
136} 136}
137 137
138Factory::~Factory() 138Factory::~Factory()
139{ 139{
140} 140}
141 141
142QStringList Factory::typeNames() const 142QStringList Factory::typeNames() const
143{ 143{
144//US method QMap::keys() not available yet. SO collect the data manually 144//US method QMap::keys() not available yet. SO collect the data manually
145//US return mTypeMap.keys(); 145//US return mTypeMap.keys();
146 146
147 QStringList result; 147 QStringList result;
148 148
149 QMap<QString, PluginInfo*>::ConstIterator it; 149 QMap<QString, PluginInfo*>::ConstIterator it;
150 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { 150 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) {
151 result << it.key().latin1(); 151 result << it.key().latin1();
152// qDebug("Factory::typeNames() : %s ", it.key().latin1()); 152// qDebug("Factory::typeNames() : %s ", it.key().latin1());
153 153
154 } 154 }
155 return result; 155 return result;
156} 156}
157 157
158ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) 158ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
159{ 159{
160 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 160 if ( type.isEmpty() || !mTypeMap.contains( type ) )
161 return 0; 161 return 0;
162 162
163//US KService::Ptr ptr = mTypeMap[ type ]; 163//US KService::Ptr ptr = mTypeMap[ type ];
164//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 164//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
165 PluginInfo* pi = mTypeMap[ type ]; 165 PluginInfo* pi = mTypeMap[ type ];
166 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 166 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
167 if ( !factory ) { 167 if ( !factory ) {
168 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); 168 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
169 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; 169 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
170 return 0; 170 return 0;
171 } 171 }
172 172
173 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 173 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
174 174
175 if ( !pluginFactory ) { 175 if ( !pluginFactory ) {
176 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); 176 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
177 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; 177 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
178 return 0; 178 return 0;
179 } 179 }
180 180
181 ConfigWidget *wdg = pluginFactory->configWidget( parent ); 181 ConfigWidget *wdg = pluginFactory->configWidget( parent );
182 if ( !wdg ) { 182 if ( !wdg ) {
183//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 183//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
184 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 184 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
185 return 0; 185 return 0;
186 } 186 }
187 return wdg; 187 return wdg;
188 188
189} 189}
190 190
191QString Factory::typeName( const QString &type ) const 191QString Factory::typeName( const QString &type ) const