-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 7 | ||||
-rw-r--r-- | microkde/kapplication.cpp | 15 | ||||
-rw-r--r-- | microkde/kapplication.h | 1 | ||||
-rw-r--r-- | microkde/kresources/factory.cpp | 6 |
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 | |||
@@ -1,677 +1,682 @@ | |||
1 | /* -*- Mode: C++ -*- | 1 | /* -*- Mode: C++ -*- |
2 | $Id$ | 2 | $Id$ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /**************************************************************************** | 5 | /**************************************************************************** |
6 | ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. | 6 | ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. |
7 | ** | 7 | ** |
8 | ** This file is part of the KDGantt library. | 8 | ** This file is part of the KDGantt library. |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ** This file may be distributed and/or modified under the terms of the |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | ** GNU General Public License version 2 as published by the Free Software |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** Licensees holding valid commercial KDGantt licenses may use this file in | 15 | ** Licensees holding valid commercial KDGantt licenses may use this file in |
16 | ** accordance with the KDGantt Commercial License Agreement provided with | 16 | ** accordance with the KDGantt Commercial License Agreement provided with |
17 | ** the Software. | 17 | ** the Software. |
18 | ** | 18 | ** |
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 |
64 | static int mouseOffset; | 64 | static int mouseOffset; |
65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky | 65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky |
66 | 66 | ||
67 | 67 | ||
68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | 68 | KDGanttSplitterHandle::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 | ||
87 | QSize KDGanttSplitterHandle::sizeHint() const | 87 | QSize KDGanttSplitterHandle::sizeHint() const |
88 | { | 88 | { |
89 | return mSizeHint; | 89 | return mSizeHint; |
90 | } | 90 | } |
91 | 91 | ||
92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 92 | void 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 | ||
104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 104 | void 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 | ||
125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 125 | void 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 | ||
136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 136 | void 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 | } |
148 | void KDGanttSplitterHandle::toggle() | 148 | void 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 | ||
173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 173 | void 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 | ||
195 | int KDGanttSplitterHandle::onButton( const QPoint& p ) | 195 | int 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; |
212 | } | 212 | } |
213 | 213 | ||
214 | 214 | ||
215 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() | 215 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() |
216 | { | 216 | { |
217 | QValueList<QPointArray> list; | 217 | QValueList<QPointArray> list; |
218 | 218 | ||
219 | int sw = 8; | 219 | int sw = 8; |
220 | int yyy = 1; | 220 | int yyy = 1; |
221 | int xxx = 1; | 221 | int xxx = 1; |
222 | int voffset[] = { (int) -sw*3, (int) sw*3 }; | 222 | int voffset[] = { (int) -sw*3, (int) sw*3 }; |
223 | for ( int i = 0; i < 2; i++ ) { | 223 | for ( int i = 0; i < 2; i++ ) { |
224 | QPointArray arr; | 224 | QPointArray arr; |
225 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || | 225 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || |
226 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { | 226 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { |
227 | int mid = height()/2 + voffset[i]; | 227 | int mid = height()/2 + voffset[i]; |
228 | arr.setPoints( 3, | 228 | arr.setPoints( 3, |
229 | 1-xxx, mid - sw + 4, | 229 | 1-xxx, mid - sw + 4, |
230 | sw-3-xxx, mid, | 230 | sw-3-xxx, mid, |
231 | 1-xxx, mid + sw -4); | 231 | 1-xxx, mid + sw -4); |
232 | } | 232 | } |
233 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 233 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
234 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 234 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
235 | int mid = height()/2 + voffset[i]; | 235 | int mid = height()/2 + voffset[i]; |
236 | arr.setPoints( 3, | 236 | arr.setPoints( 3, |
237 | sw-4, mid - sw + 4, | 237 | sw-4, mid - sw + 4, |
238 | 0, mid, | 238 | 0, mid, |
239 | sw-4, mid + sw - 4); | 239 | sw-4, mid + sw - 4); |
240 | } | 240 | } |
241 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 241 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
242 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { | 242 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { |
243 | int mid = width()/2 + voffset[i]; | 243 | int mid = width()/2 + voffset[i]; |
244 | arr.setPoints( 3, | 244 | arr.setPoints( 3, |
245 | mid - sw + 4, sw-4, | 245 | mid - sw + 4, sw-4, |
246 | mid, 0, | 246 | mid, 0, |
247 | mid + sw - 4, sw-4 ); | 247 | mid + sw - 4, sw-4 ); |
248 | } | 248 | } |
249 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || | 249 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || |
250 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 250 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
251 | int mid = width()/2 + voffset[i]; | 251 | int mid = width()/2 + voffset[i]; |
252 | arr.setPoints( 3, | 252 | arr.setPoints( 3, |
253 | mid - sw + 4, 1-yyy, | 253 | mid - sw + 4, 1-yyy, |
254 | mid, sw-3-yyy, | 254 | mid, sw-3-yyy, |
255 | mid + sw -4, 1-yyy); | 255 | mid + sw -4, 1-yyy); |
256 | } | 256 | } |
257 | list.append( arr ); | 257 | list.append( arr ); |
258 | } | 258 | } |
259 | return list; | 259 | return list; |
260 | } | 260 | } |
261 | 261 | ||
262 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) | 262 | void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) |
263 | { | 263 | { |
264 | QPixmap buffer( size() ); | 264 | QPixmap buffer( size() ); |
265 | QPainter p( &buffer ); | 265 | QPainter p( &buffer ); |
266 | 266 | ||
267 | //LR | 267 | //LR |
268 | // Draw the splitter rectangle | 268 | // Draw the splitter rectangle |
269 | p.setBrush( colorGroup().background() ); | 269 | p.setBrush( colorGroup().background() ); |
270 | p.setPen( colorGroup().foreground() ); | 270 | p.setPen( colorGroup().foreground() ); |
271 | //p.drawRect( rect() ); | 271 | //p.drawRect( rect() ); |
272 | buffer.fill( colorGroup().background() ); | 272 | buffer.fill( colorGroup().background() ); |
273 | //buffer.fill( backgroundColor() ); | 273 | //buffer.fill( backgroundColor() ); |
274 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); | 274 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); |
275 | 275 | ||
276 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size | 276 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size |
277 | 277 | ||
278 | // arrow color | 278 | // arrow color |
279 | QColor col; | 279 | QColor col; |
280 | if ( _activeButton ) | 280 | if ( _activeButton ) |
281 | col = colorGroup().background().dark( 250 ); | 281 | col = colorGroup().background().dark( 250 ); |
282 | else { | 282 | else { |
283 | if ( mMouseDown ) | 283 | if ( mMouseDown ) |
284 | col = Qt::white; | 284 | col = Qt::white; |
285 | else | 285 | else |
286 | col = colorGroup().background().dark( 150 ); | 286 | col = colorGroup().background().dark( 150 ); |
287 | } | 287 | } |
288 | //QColor col = backgroundColor().dark( 130 ); | 288 | //QColor col = backgroundColor().dark( 130 ); |
289 | p.setBrush( col ); | 289 | p.setBrush( col ); |
290 | p.setPen( col ); | 290 | p.setPen( col ); |
291 | 291 | ||
292 | QValueList<QPointArray> list = buttonRegions(); | 292 | QValueList<QPointArray> list = buttonRegions(); |
293 | int index = 1; | 293 | int index = 1; |
294 | if ( mUseOffset ) | 294 | if ( mUseOffset ) |
295 | p.translate( 0, 1 ); | 295 | p.translate( 0, 1 ); |
296 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 296 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
297 | if ( index == _activeButton ) { | 297 | if ( index == _activeButton ) { |
298 | 298 | ||
299 | /* | 299 | /* |
300 | if ( ! _collapsed ) { | 300 | if ( ! _collapsed ) { |
301 | p.save(); | 301 | p.save(); |
302 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), | 302 | // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), |
303 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); | 303 | // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); |
304 | p.translate( -1, 0 ); | 304 | p.translate( -1, 0 ); |
305 | p.drawPolygon( *it, true ); | 305 | p.drawPolygon( *it, true ); |
306 | p.restore(); } else | 306 | p.restore(); } else |
307 | */ | 307 | */ |
308 | p.drawPolygon( *it, true ); | 308 | p.drawPolygon( *it, true ); |
309 | 309 | ||
310 | } | 310 | } |
311 | else { | 311 | else { |
312 | /* | 312 | /* |
313 | if ( ! _collapsed ) { | 313 | if ( ! _collapsed ) { |
314 | p.save(); | 314 | p.save(); |
315 | p.translate( -1, 0 ); | 315 | p.translate( -1, 0 ); |
316 | p.drawPolygon( *it, true ); | 316 | p.drawPolygon( *it, true ); |
317 | p.restore(); | 317 | p.restore(); |
318 | } else | 318 | } else |
319 | */ | 319 | */ |
320 | p.drawPolygon( *it, true ); | 320 | p.drawPolygon( *it, true ); |
321 | 321 | ||
322 | } | 322 | } |
323 | index++; | 323 | index++; |
324 | } | 324 | } |
325 | 325 | ||
326 | // Draw the lines between the arrows | 326 | // Draw the lines between the arrows |
327 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 327 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
328 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 328 | s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
329 | int mid = height()/2; | 329 | int mid = height()/2; |
330 | p.drawLine ( 1, mid - sw, 1, mid + sw ); | 330 | p.drawLine ( 1, mid - sw, 1, mid + sw ); |
331 | p.drawLine ( 3, mid - sw, 3, mid + sw ); | 331 | p.drawLine ( 3, mid - sw, 3, mid + sw ); |
332 | } | 332 | } |
333 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || | 333 | else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || |
334 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { | 334 | s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { |
335 | int mid = width()/2; | 335 | int mid = width()/2; |
336 | p.drawLine( mid -sw, 1, mid +sw, 1 ); | 336 | p.drawLine( mid -sw, 1, mid +sw, 1 ); |
337 | p.drawLine( mid -sw, 3, mid +sw, 3 ); | 337 | p.drawLine( mid -sw, 3, mid +sw, 3 ); |
338 | } | 338 | } |
339 | bitBlt( this, 0, 0, &buffer ); | 339 | bitBlt( this, 0, 0, &buffer ); |
340 | 340 | ||
341 | } | 341 | } |
342 | #endif | 342 | #endif |
343 | 343 | ||
344 | class QSplitterLayoutStruct | 344 | class QSplitterLayoutStruct |
345 | { | 345 | { |
346 | public: | 346 | public: |
347 | KDGanttMinimizeSplitter::ResizeMode mode; | 347 | KDGanttMinimizeSplitter::ResizeMode mode; |
348 | QCOORD sizer; | 348 | QCOORD sizer; |
349 | bool isSplitter; | 349 | bool isSplitter; |
350 | QWidget *wid; | 350 | QWidget *wid; |
351 | }; | 351 | }; |
352 | 352 | ||
353 | class QSplitterData | 353 | class QSplitterData |
354 | { | 354 | { |
355 | public: | 355 | public: |
356 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} | 356 | QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} |
357 | 357 | ||
358 | QPtrList<QSplitterLayoutStruct> list; | 358 | QPtrList<QSplitterLayoutStruct> list; |
359 | bool opaque; | 359 | bool opaque; |
360 | bool firstShow; | 360 | bool firstShow; |
361 | }; | 361 | }; |
362 | 362 | ||
363 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, | 363 | void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, |
364 | int space, int spacer ); | 364 | int space, int spacer ); |
365 | #endif // DOXYGEN_SKIP_INTERNAL | 365 | #endif // DOXYGEN_SKIP_INTERNAL |
366 | 366 | ||
367 | 367 | ||
368 | /*! | 368 | /*! |
369 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h | 369 | \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h |
370 | \brief The KDGanttMinimizeSplitter class implements a splitter | 370 | \brief The KDGanttMinimizeSplitter class implements a splitter |
371 | widget with minimize buttons. | 371 | widget with minimize buttons. |
372 | 372 | ||
373 | This class (and its documentation) is largely a copy of Qt's | 373 | This class (and its documentation) is largely a copy of Qt's |
374 | QSplitter; the copying was necessary because QSplitter is not | 374 | QSplitter; the copying was necessary because QSplitter is not |
375 | extensible at all. QSplitter and its documentation are licensed | 375 | extensible at all. QSplitter and its documentation are licensed |
376 | according to the GPL and the Qt Professional License (if you hold | 376 | according to the GPL and the Qt Professional License (if you hold |
377 | such a license) and are (C) Trolltech AS. | 377 | such a license) and are (C) Trolltech AS. |
378 | 378 | ||
379 | A splitter lets the user control the size of child widgets by | 379 | A splitter lets the user control the size of child widgets by |
380 | dragging the boundary between the children. Any number of widgets | 380 | dragging the boundary between the children. Any number of widgets |
381 | may be controlled. | 381 | may be controlled. |
382 | 382 | ||
383 | To show a QListBox, a QListView and a QTextEdit side by side: | 383 | To show a QListBox, a QListView and a QTextEdit side by side: |
384 | 384 | ||
385 | \code | 385 | \code |
386 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); | 386 | KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); |
387 | QListBox *lb = new QListBox( split ); | 387 | QListBox *lb = new QListBox( split ); |
388 | QListView *lv = new QListView( split ); | 388 | QListView *lv = new QListView( split ); |
389 | QTextEdit *ed = new QTextEdit( split ); | 389 | QTextEdit *ed = new QTextEdit( split ); |
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 | ||
417 | static QSize minSize( const QWidget* /*w*/ ) | 417 | static 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 |
423 | static QSize minSizeHint( const QWidget* w ) | 423 | static 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 | */ |
442 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) | 442 | KDGanttMinimizeSplitter::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 | */ |
456 | KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) | 456 | KDGanttMinimizeSplitter::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 | */ |
469 | KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() | 469 | KDGanttMinimizeSplitter::~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 |
479 | void KDGanttMinimizeSplitter::init() | 479 | void 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 | ||
490 | void KDGanttMinimizeSplitter::toggle() | 495 | void 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 | */ |
506 | void KDGanttMinimizeSplitter::setOrientation( Orientation o ) | 511 | void 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 | */ |
533 | void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) | 538 | void 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 | */ |
548 | QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) | 553 | QSplitterLayoutStruct *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() ) |
582 | newHandle->show(); //will trigger sending of post events | 587 | newHandle->show(); //will trigger sending of post events |
583 | return s; | 588 | return s; |
584 | } | 589 | } |
585 | 590 | ||
586 | 591 | ||
587 | /*! | 592 | /*! |
588 | Tells the splitter that a child widget has been inserted or removed. | 593 | Tells the splitter that a child widget has been inserted or removed. |
589 | The event is passed in \a c. | 594 | The event is passed in \a c. |
590 | */ | 595 | */ |
591 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | 596 | void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) |
592 | { | 597 | { |
593 | if ( c->type() == QEvent::ChildInserted ) { | 598 | if ( c->type() == QEvent::ChildInserted ) { |
594 | if ( !c->child()->isWidgetType() ) | 599 | if ( !c->child()->isWidgetType() ) |
595 | return; | 600 | return; |
596 | 601 | ||
597 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) | 602 | if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) |
598 | return; | 603 | return; |
599 | 604 | ||
600 | QSplitterLayoutStruct *s = data->list.first(); | 605 | QSplitterLayoutStruct *s = data->list.first(); |
601 | while ( s ) { | 606 | while ( s ) { |
602 | if ( s->wid == c->child() ) | 607 | if ( s->wid == c->child() ) |
603 | return; | 608 | return; |
604 | s = data->list.next(); | 609 | s = data->list.next(); |
605 | } | 610 | } |
606 | addWidget( (QWidget*)c->child() ); | 611 | addWidget( (QWidget*)c->child() ); |
607 | recalc( isVisible() ); | 612 | recalc( isVisible() ); |
608 | 613 | ||
609 | } else if ( c->type() == QEvent::ChildRemoved ) { | 614 | } else if ( c->type() == QEvent::ChildRemoved ) { |
610 | QSplitterLayoutStruct *p = 0; | 615 | QSplitterLayoutStruct *p = 0; |
611 | if ( data->list.count() > 1 ) | 616 | if ( data->list.count() > 1 ) |
612 | p = data->list.at(1); //remove handle _after_ first widget. | 617 | p = data->list.at(1); //remove handle _after_ first widget. |
613 | QSplitterLayoutStruct *s = data->list.first(); | 618 | QSplitterLayoutStruct *s = data->list.first(); |
614 | while ( s ) { | 619 | while ( s ) { |
615 | if ( s->wid == c->child() ) { | 620 | if ( s->wid == c->child() ) { |
616 | data->list.removeRef( s ); | 621 | data->list.removeRef( s ); |
617 | delete s; | 622 | delete s; |
618 | if ( p && p->isSplitter ) { | 623 | if ( p && p->isSplitter ) { |
619 | data->list.removeRef( p ); | 624 | data->list.removeRef( p ); |
620 | delete p->wid; //will call childEvent | 625 | delete p->wid; //will call childEvent |
621 | delete p; | 626 | delete p; |
622 | } | 627 | } |
623 | recalcId(); | 628 | recalcId(); |
624 | doResize(); | 629 | doResize(); |
625 | return; | 630 | return; |
626 | } | 631 | } |
627 | p = s; | 632 | p = s; |
628 | s = data->list.next(); | 633 | s = data->list.next(); |
629 | } | 634 | } |
630 | } | 635 | } |
631 | } | 636 | } |
632 | 637 | ||
633 | 638 | ||
634 | /*! | 639 | /*! |
635 | Shows a rubber band at position \a p. If \a p is negative, the | 640 | Shows a rubber band at position \a p. If \a p is negative, the |
636 | rubber band is removed. | 641 | rubber band is removed. |
637 | */ | 642 | */ |
638 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 643 | void KDGanttMinimizeSplitter::setRubberband( int p ) |
639 | { | 644 | { |
640 | QPainter paint( this ); | 645 | QPainter paint( this ); |
641 | paint.setPen( gray ); | 646 | paint.setPen( gray ); |
642 | paint.setBrush( gray ); | 647 | paint.setBrush( gray ); |
643 | paint.setRasterOp( XorROP ); | 648 | paint.setRasterOp( XorROP ); |
644 | QRect r = contentsRect(); | 649 | QRect r = contentsRect(); |
645 | const int rBord = 3; //Themable???? | 650 | const int rBord = 3; //Themable???? |
646 | #if QT_VERSION >= 0x030000 | 651 | #if QT_VERSION >= 0x030000 |
647 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 652 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
648 | #else | 653 | #else |
649 | int sw = style().splitterWidth(); | 654 | int sw = style().splitterWidth(); |
650 | #endif | 655 | #endif |
651 | if ( orient == Horizontal ) { | 656 | if ( orient == Horizontal ) { |
652 | if ( opaqueOldPos >= 0 ) | 657 | if ( opaqueOldPos >= 0 ) |
653 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), | 658 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), |
654 | 2*rBord, r.height() ); | 659 | 2*rBord, r.height() ); |
655 | if ( p >= 0 ) | 660 | if ( p >= 0 ) |
656 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); | 661 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); |
657 | } else { | 662 | } else { |
658 | if ( opaqueOldPos >= 0 ) | 663 | if ( opaqueOldPos >= 0 ) |
659 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, | 664 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, |
660 | r.width(), 2*rBord ); | 665 | r.width(), 2*rBord ); |
661 | if ( p >= 0 ) | 666 | if ( p >= 0 ) |
662 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); | 667 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); |
663 | } | 668 | } |
664 | opaqueOldPos = p; | 669 | opaqueOldPos = p; |
665 | } | 670 | } |
666 | 671 | ||
667 | 672 | ||
668 | /*! \reimp */ | 673 | /*! \reimp */ |
669 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 674 | bool KDGanttMinimizeSplitter::event( QEvent *e ) |
670 | { | 675 | { |
671 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { | 676 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { |
672 | recalc( isVisible() ); | 677 | recalc( isVisible() ); |
673 | if ( e->type() == QEvent::Show ) | 678 | if ( e->type() == QEvent::Show ) |
674 | data->firstShow = FALSE; | 679 | data->firstShow = FALSE; |
675 | } | 680 | } |
676 | return QWidget::event( e ); | 681 | return QWidget::event( e ); |
677 | } | 682 | } |
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 | ||
14 | int KApplication::random() | 14 | int KApplication::random() |
15 | { | 15 | { |
16 | return rand(); | 16 | return rand(); |
17 | } | 17 | } |
18 | 18 | ||
19 | //US | 19 | //US |
20 | QString KApplication::randomString(int length) | 20 | QString 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 | } |
36 | int KApplication::execDialog( QDialog* d ) | 36 | int 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 | } |
44 | void KApplication::showLicence() | 44 | void 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 | ||
49 | void 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 | } | ||
49 | void KApplication::showFile(QString caption, QString fn) | 64 | void 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 | ||
70 | bool KApplication::convert2latin1(QString fileName) | 85 | bool 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 | } |
93 | void KApplication::showText(QString caption, QString text) | 108 | void 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 | ||
10 | class KApplication | 10 | class 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,256 +1,256 @@ | |||
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 | ||
37 | using namespace KRES; | 37 | using namespace KRES; |
38 | 38 | ||
39 | QDict<Factory> *Factory::mSelves = 0; | 39 | QDict<Factory> *Factory::mSelves = 0; |
40 | static KStaticDeleter< QDict<Factory> > staticDeleter; | 40 | static KStaticDeleter< QDict<Factory> > staticDeleter; |
41 | 41 | ||
42 | Factory *Factory::self( const QString& resourceFamily) | 42 | Factory *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 | ||
62 | Factory::Factory( const QString& resourceFamily) : | 62 | Factory::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 | ||
138 | Factory::~Factory() | 138 | Factory::~Factory() |
139 | { | 139 | { |
140 | } | 140 | } |
141 | 141 | ||
142 | QStringList Factory::typeNames() const | 142 | QStringList 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 | ||
158 | ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) | 158 | ConfigWidget *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 | ||
191 | QString Factory::typeName( const QString &type ) const | 191 | QString Factory::typeName( const QString &type ) const |
192 | { | 192 | { |
193 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 193 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
194 | return QString(); | 194 | return QString(); |
195 | 195 | ||
196 | 196 | ||
197 | //US KService::Ptr ptr = mTypeMap[ type ]; | 197 | //US KService::Ptr ptr = mTypeMap[ type ]; |
198 | //US return ptr->name(); | 198 | //US return ptr->name(); |
199 | PluginInfo* pi = mTypeMap[ type ]; | 199 | PluginInfo* pi = mTypeMap[ type ]; |
200 | return pi->nameLabel; | 200 | return pi->nameLabel; |
201 | 201 | ||
202 | } | 202 | } |
203 | 203 | ||
204 | QString Factory::typeDescription( const QString &type ) const | 204 | QString Factory::typeDescription( const QString &type ) const |
205 | { | 205 | { |
206 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 206 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
207 | return QString(); | 207 | return QString(); |
208 | 208 | ||
209 | //US KService::Ptr ptr = mTypeMap[ type ]; | 209 | //US KService::Ptr ptr = mTypeMap[ type ]; |
210 | //US return ptr->comment(); | 210 | //US return ptr->comment(); |
211 | PluginInfo* pi = mTypeMap[ type ]; | 211 | PluginInfo* pi = mTypeMap[ type ]; |
212 | return pi->descriptionLabel; | 212 | return pi->descriptionLabel; |
213 | } | 213 | } |
214 | 214 | ||
215 | Resource *Factory::resource( const QString& type, const KConfig *config ) | 215 | Resource *Factory::resource( const QString& type, const KConfig *config ) |
216 | { | 216 | { |
217 | 217 | ||
218 | 218 | ||
219 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) | 219 | if ( type.isEmpty() || !mTypeMap.contains( type ) ) |
220 | return 0; | 220 | return 0; |
221 | 221 | ||
222 | /*US load the lib not dynamicly. !! | 222 | /*US load the lib not dynamicly. !! |
223 | KService::Ptr ptr = mTypeMap[ type ]; | 223 | KService::Ptr ptr = mTypeMap[ type ]; |
224 | KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); | 224 | KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); |
225 | if ( !factory ) { | 225 | if ( !factory ) { |
226 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; | 226 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; |
227 | return 0; | 227 | return 0; |
228 | } | 228 | } |
229 | */ | 229 | */ |
230 | PluginInfo* pi = mTypeMap[ type ]; | 230 | PluginInfo* pi = mTypeMap[ type ]; |
231 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); | 231 | KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); |
232 | if ( !factory ) { | 232 | if ( !factory ) { |
233 | qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); | 233 | qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); |
234 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; | 234 | kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; |
235 | return 0; | 235 | return 0; |
236 | } | 236 | } |
237 | 237 | ||
238 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); | 238 | PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); |
239 | 239 | ||
240 | if ( !pluginFactory ) { | 240 | if ( !pluginFactory ) { |
241 | qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); | 241 | qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); |
242 | kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; | 242 | kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; |
243 | return 0; | 243 | return 0; |
244 | } | 244 | } |
245 | 245 | ||
246 | Resource *resource = pluginFactory->resource( config ); | 246 | Resource *resource = pluginFactory->resource( config ); |
247 | if ( !resource ) { | 247 | if ( !resource ) { |
248 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; | 248 | //US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; |
249 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); | 249 | qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); |
250 | return 0; | 250 | return 0; |
251 | } | 251 | } |
252 | 252 | ||
253 | resource->setType( type ); | 253 | resource->setType( type ); |
254 | 254 | ||
255 | return resource; | 255 | return resource; |
256 | } | 256 | } |