summaryrefslogtreecommitdiff
authorerik <erik>2007-01-29 22:00:04 (UTC)
committer erik <erik>2007-01-29 22:00:04 (UTC)
commit9a3875c32922a322d991e67b13e89242f71a862c (patch) (unidiff)
tree4f5c7c79f7e1ee70f19b5cc3d75131b8151ad9cd
parent02ef45be75a3024df11365956e1cce6392d9103c (diff)
downloadopie-9a3875c32922a322d991e67b13e89242f71a862c.zip
opie-9a3875c32922a322d991e67b13e89242f71a862c.tar.gz
opie-9a3875c32922a322d991e67b13e89242f71a862c.tar.bz2
Each file in this commit exhibits a problem where a variable is made in
some way but never used. This is a tricky problem with Qt since almost all UI forms are made but not used (like QLabel). But I am pretty confident that these changes are correct and do not have any aspect of a change to the UI. In most cases, there are just variables that are made and then copied over (like in iteration over lists or assignment of pointers based on conditionals).
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libqtaux/qsplitter.cpp2
-rw-r--r--noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp2
-rw-r--r--noncore/apps/tinykate/mainwindow/tinykate.cpp6
-rw-r--r--noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp11
4 files changed, 7 insertions, 14 deletions
diff --git a/libqtaux/qsplitter.cpp b/libqtaux/qsplitter.cpp
index 39321f8..959d5e1 100644
--- a/libqtaux/qsplitter.cpp
+++ b/libqtaux/qsplitter.cpp
@@ -1,1124 +1,1124 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2** $Id$
3** 3**
4** Splitter widget 4** Splitter widget
5** 5**
6** Created: 980105 6** Created: 980105
7** 7**
8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. 8** Copyright (C) 1992-2000 Trolltech AS. All rights reserved.
9** 9**
10** This file is part of the widgets module of the Qt GUI Toolkit. 10** This file is part of the widgets module of the Qt GUI Toolkit.
11** 11**
12** This file may be distributed under the terms of the Q Public License 12** This file may be distributed under the terms of the Q Public License
13** as defined by Trolltech AS of Norway and appearing in the file 13** as defined by Trolltech AS of Norway and appearing in the file
14** LICENSE.QPL included in the packaging of this file. 14** LICENSE.QPL included in the packaging of this file.
15** 15**
16** This file may be distributed and/or modified under the terms of the 16** This file may be distributed and/or modified under the terms of the
17** GNU General Public License version 2 as published by the Free Software 17** GNU General Public License version 2 as published by the Free Software
18** Foundation and appearing in the file LICENSE.GPL included in the 18** Foundation and appearing in the file LICENSE.GPL included in the
19** packaging of this file. 19** packaging of this file.
20** 20**
21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 21** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
22** licenses may use this file in accordance with the Qt Commercial License 22** licenses may use this file in accordance with the Qt Commercial License
23** Agreement provided with the Software. 23** Agreement provided with the Software.
24** 24**
25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 25** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 26** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27** 27**
28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 28** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
29** information about Qt Commercial License Agreements. 29** information about Qt Commercial License Agreements.
30** See http://www.trolltech.com/qpl/ for QPL licensing information. 30** See http://www.trolltech.com/qpl/ for QPL licensing information.
31** See http://www.trolltech.com/gpl/ for GPL licensing information. 31** See http://www.trolltech.com/gpl/ for GPL licensing information.
32** 32**
33** Contact info@trolltech.com if any conditions of this licensing are 33** Contact info@trolltech.com if any conditions of this licensing are
34** not clear to you. 34** not clear to you.
35** 35**
36**********************************************************************/ 36**********************************************************************/
37#include "qsplitter.h" 37#include "qsplitter.h"
38 38
39#include "qdrawutil.h" 39#include "qdrawutil.h"
40#include "qlayoutengine_p.h" 40#include "qlayoutengine_p.h"
41#include "qobjectlist.h" 41#include "qobjectlist.h"
42#include "qapplication.h" //sendPostedEvents 42#include "qapplication.h" //sendPostedEvents
43 43
44class QSplitterHandle : public QWidget 44class QSplitterHandle : public QWidget
45{ 45{
46public: 46public:
47 QSplitterHandle( Qt::Orientation o, 47 QSplitterHandle( Qt::Orientation o,
48 QSplitter *parent, const char* name=0 ); 48 QSplitter *parent, const char* name=0 );
49 void setOrientation( Qt::Orientation o ); 49 void setOrientation( Qt::Orientation o );
50 Qt::Orientation orientation() const { return orient; } 50 Qt::Orientation orientation() const { return orient; }
51 51
52 bool opaque() const { return s->opaqueResize(); } 52 bool opaque() const { return s->opaqueResize(); }
53 53
54 QSize sizeHint() const; 54 QSize sizeHint() const;
55 QSizePolicy sizePolicy() const; 55 QSizePolicy sizePolicy() const;
56 56
57 int id() const { return myId; } // data->list.at(id())->wid == this 57 int id() const { return myId; } // data->list.at(id())->wid == this
58 void setId( int i ) { myId = i; } 58 void setId( int i ) { myId = i; }
59 59
60protected: 60protected:
61 void paintEvent( QPaintEvent * ); 61 void paintEvent( QPaintEvent * );
62 void mouseMoveEvent( QMouseEvent * ); 62 void mouseMoveEvent( QMouseEvent * );
63 void mousePressEvent( QMouseEvent * ); 63 void mousePressEvent( QMouseEvent * );
64 void mouseReleaseEvent( QMouseEvent * ); 64 void mouseReleaseEvent( QMouseEvent * );
65 65
66private: 66private:
67 Qt::Orientation orient; 67 Qt::Orientation orient;
68 bool opaq; 68 bool opaq;
69 int myId; 69 int myId;
70 70
71 QSplitter *s; 71 QSplitter *s;
72}; 72};
73 73
74static int mouseOffset; 74static int mouseOffset;
75static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky 75static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky
76 76
77 77
78QSplitterHandle::QSplitterHandle( Qt::Orientation o, 78QSplitterHandle::QSplitterHandle( Qt::Orientation o,
79 QSplitter *parent, const char * name ) 79 QSplitter *parent, const char * name )
80 : QWidget( parent, name ) 80 : QWidget( parent, name )
81{ 81{
82 s = parent; 82 s = parent;
83 setOrientation(o); 83 setOrientation(o);
84} 84}
85 85
86QSizePolicy QSplitterHandle::sizePolicy() const 86QSizePolicy QSplitterHandle::sizePolicy() const
87{ 87{
88 //### removeme 3.0 88 //### removeme 3.0
89 return QWidget::sizePolicy(); 89 return QWidget::sizePolicy();
90} 90}
91 91
92QSize QSplitterHandle::sizeHint() const 92QSize QSplitterHandle::sizeHint() const
93{ 93{
94 int sw = style().splitterWidth(); 94 int sw = style().splitterWidth();
95 return QSize(sw,sw).expandedTo( QApplication::globalStrut() ); 95 return QSize(sw,sw).expandedTo( QApplication::globalStrut() );
96} 96}
97 97
98void QSplitterHandle::setOrientation( Qt::Orientation o ) 98void QSplitterHandle::setOrientation( Qt::Orientation o )
99{ 99{
100 orient = o; 100 orient = o;
101#ifndef QT_NO_CURSOR 101#ifndef QT_NO_CURSOR
102 if ( o == QSplitter::Horizontal ) 102 if ( o == QSplitter::Horizontal )
103 setCursor( splitHCursor ); 103 setCursor( splitHCursor );
104 else 104 else
105 setCursor( splitVCursor ); 105 setCursor( splitVCursor );
106#endif 106#endif
107} 107}
108 108
109 109
110void QSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 110void QSplitterHandle::mouseMoveEvent( QMouseEvent *e )
111{ 111{
112 if ( !(e->state()&LeftButton) ) 112 if ( !(e->state()&LeftButton) )
113 return; 113 return;
114 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 114 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
115 - mouseOffset; 115 - mouseOffset;
116 if ( opaque() ) { 116 if ( opaque() ) {
117 s->moveSplitter( pos, id() ); 117 s->moveSplitter( pos, id() );
118 } else { 118 } else {
119 int min = pos; int max = pos; 119 int min = pos; int max = pos;
120 s->getRange( id(), &min, &max ); 120 s->getRange( id(), &min, &max );
121 s->setRubberband( QMAX( min, QMIN(max, pos ))); 121 s->setRubberband( QMAX( min, QMIN(max, pos )));
122 } 122 }
123} 123}
124 124
125void QSplitterHandle::mousePressEvent( QMouseEvent *e ) 125void QSplitterHandle::mousePressEvent( QMouseEvent *e )
126{ 126{
127 if ( e->button() == LeftButton ) 127 if ( e->button() == LeftButton )
128 mouseOffset = s->pick(e->pos()); 128 mouseOffset = s->pick(e->pos());
129} 129}
130 130
131void QSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 131void QSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
132{ 132{
133 if ( !opaque() && e->button() == LeftButton ) { 133 if ( !opaque() && e->button() == LeftButton ) {
134 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())); 134 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()));
135 s->setRubberband( -1 ); 135 s->setRubberband( -1 );
136 s->moveSplitter( pos, id() ); 136 s->moveSplitter( pos, id() );
137 } 137 }
138} 138}
139 139
140void QSplitterHandle::paintEvent( QPaintEvent * ) 140void QSplitterHandle::paintEvent( QPaintEvent * )
141{ 141{
142 QPainter p( this ); 142 QPainter p( this );
143 s->drawSplitter( &p, 0, 0, width(), height() ); 143 s->drawSplitter( &p, 0, 0, width(), height() );
144} 144}
145 145
146 146
147class QSplitterLayoutStruct 147class QSplitterLayoutStruct
148{ 148{
149public: 149public:
150 QSplitter::ResizeMode mode; 150 QSplitter::ResizeMode mode;
151 QCOORD sizer; 151 QCOORD sizer;
152 bool isSplitter; 152 bool isSplitter;
153 QWidget *wid; 153 QWidget *wid;
154}; 154};
155 155
156class QSplitterData 156class QSplitterData
157{ 157{
158public: 158public:
159 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 159 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
160 160
161 QList<QSplitterLayoutStruct> list; 161 QList<QSplitterLayoutStruct> list;
162 bool opaque; 162 bool opaque;
163 bool firstShow; 163 bool firstShow;
164}; 164};
165 165
166 166
167// NOT REVISED 167// NOT REVISED
168/*! 168/*!
169 \class QSplitter qsplitter.h 169 \class QSplitter qsplitter.h
170 \brief The QSplitter class implements a splitter widget. 170 \brief The QSplitter class implements a splitter widget.
171 171
172 \ingroup organizers 172 \ingroup organizers
173 173
174 A splitter lets the user control the size of child widgets by 174 A splitter lets the user control the size of child widgets by
175 dragging the boundary between the children. Any number of widgets 175 dragging the boundary between the children. Any number of widgets
176 may be controlled. 176 may be controlled.
177 177
178 To show a QListBox, a QListView and a QMultiLineEdit side by side: 178 To show a QListBox, a QListView and a QMultiLineEdit side by side:
179 179
180 \code 180 \code
181 QSplitter *split = new QSplitter( parent ); 181 QSplitter *split = new QSplitter( parent );
182 QListBox *lb = new QListBox( split ); 182 QListBox *lb = new QListBox( split );
183 QListView *lv = new QListView( split ); 183 QListView *lv = new QListView( split );
184 QMultiLineEdit *ed = new QMultiLineEdit( split ); 184 QMultiLineEdit *ed = new QMultiLineEdit( split );
185 \endcode 185 \endcode
186 186
187 In QSplitter the boundary can be either horizontal or vertical. The 187 In QSplitter the boundary can be either horizontal or vertical. The
188 default is horizontal (the children are side by side) and you 188 default is horizontal (the children are side by side) and you
189 can use setOrientation( QSplitter::Vertical ) to set it to vertical. 189 can use setOrientation( QSplitter::Vertical ) to set it to vertical.
190 190
191 By default, all widgets can be as large or as small as the user 191 By default, all widgets can be as large or as small as the user
192 wishes, down to \link QWidget::minimumSizeHint() minimumSizeHint()\endlink. 192 wishes, down to \link QWidget::minimumSizeHint() minimumSizeHint()\endlink.
193 You can naturally use setMinimumSize() and/or 193 You can naturally use setMinimumSize() and/or
194 setMaximumSize() on the children. Use setResizeMode() to specify that 194 setMaximumSize() on the children. Use setResizeMode() to specify that
195 a widget should keep its size when the splitter is resized. 195 a widget should keep its size when the splitter is resized.
196 196
197 QSplitter normally resizes the children only at the end of a 197 QSplitter normally resizes the children only at the end of a
198 resize operation, but if you call setOpaqueResize( TRUE ), the 198 resize operation, but if you call setOpaqueResize( TRUE ), the
199 widgets are resized as often as possible. 199 widgets are resized as often as possible.
200 200
201 The initial distribution of size between the widgets is determined 201 The initial distribution of size between the widgets is determined
202 by the initial size of each widget. You can also use setSizes() to 202 by the initial size of each widget. You can also use setSizes() to
203 set the sizes of all the widgets. The function sizes() returns the 203 set the sizes of all the widgets. The function sizes() returns the
204 sizes set by the user. 204 sizes set by the user.
205 205
206 If you hide() a child, its space will be distributed among the other 206 If you hide() a child, its space will be distributed among the other
207 children. When you show() it again, it will be reinstated. 207 children. When you show() it again, it will be reinstated.
208 208
209 <img src=qsplitter-m.png> <img src=qsplitter-w.png> 209 <img src=qsplitter-m.png> <img src=qsplitter-w.png>
210 210
211 \sa QTabBar 211 \sa QTabBar
212*/ 212*/
213 213
214 214
215 215
216static QSize minSize( const QWidget *w ) 216static QSize minSize( const QWidget *w )
217{ 217{
218 QSize min = w->minimumSize(); 218 QSize min = w->minimumSize();
219 QSize s; 219 QSize s;
220 if ( min.height() <= 0 || min.width() <= 0 ) 220 if ( min.height() <= 0 || min.width() <= 0 )
221 s = w->minimumSizeHint(); 221 s = w->minimumSizeHint();
222 if ( min.height() > 0 ) 222 if ( min.height() > 0 )
223 s.setHeight( min.height() ); 223 s.setHeight( min.height() );
224 if ( min.width() > 0 ) 224 if ( min.width() > 0 )
225 s.setWidth( min.width() ); 225 s.setWidth( min.width() );
226 return s.expandedTo(QSize(0,0)); 226 return s.expandedTo(QSize(0,0));
227} 227}
228 228
229/*! 229/*!
230 Constructs a horizontal splitter. 230 Constructs a horizontal splitter.
231*/ 231*/
232 232
233QSplitter::QSplitter( QWidget *parent, const char *name ) 233QSplitter::QSplitter( QWidget *parent, const char *name )
234 :QFrame(parent,name,WPaintUnclipped) 234 :QFrame(parent,name,WPaintUnclipped)
235{ 235{
236 orient = Horizontal; 236 orient = Horizontal;
237 init(); 237 init();
238} 238}
239 239
240 240
241/*! 241/*!
242 Constructs splitter with orientation \a o. 242 Constructs splitter with orientation \a o.
243*/ 243*/
244 244
245QSplitter::QSplitter( Orientation o, QWidget *parent, const char *name ) 245QSplitter::QSplitter( Orientation o, QWidget *parent, const char *name )
246 :QFrame(parent,name,WPaintUnclipped) 246 :QFrame(parent,name,WPaintUnclipped)
247{ 247{
248 orient = o; 248 orient = o;
249 init(); 249 init();
250} 250}
251 251
252 252
253/*! 253/*!
254 Destructs the splitter. 254 Destructs the splitter.
255*/ 255*/
256 256
257QSplitter::~QSplitter() 257QSplitter::~QSplitter()
258{ 258{
259 data->list.setAutoDelete( TRUE ); 259 data->list.setAutoDelete( TRUE );
260 delete data; 260 delete data;
261} 261}
262 262
263 263
264void QSplitter::init() 264void QSplitter::init()
265{ 265{
266 data = new QSplitterData; 266 data = new QSplitterData;
267 if ( orient == Horizontal ) 267 if ( orient == Horizontal )
268 setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum) ); 268 setSizePolicy( QSizePolicy(QSizePolicy::Fixed,QSizePolicy::Minimum) );
269 else 269 else
270 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed) ); 270 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Fixed) );
271} 271}
272 272
273 273
274/*! 274/*!
275 \fn void QSplitter::refresh() 275 \fn void QSplitter::refresh()
276 276
277 Updates the splitter state. You should not need to call this 277 Updates the splitter state. You should not need to call this
278 function during normal use of the splitter. 278 function during normal use of the splitter.
279*/ 279*/
280 280
281 281
282/*! Sets the orientation to \a o. By default the orientation is 282/*! Sets the orientation to \a o. By default the orientation is
283 horizontal (the widgets are side by side). 283 horizontal (the widgets are side by side).
284 284
285 \sa orientation() 285 \sa orientation()
286*/ 286*/
287 287
288void QSplitter::setOrientation( Orientation o ) 288void QSplitter::setOrientation( Orientation o )
289{ 289{
290 if ( orient == o ) 290 if ( orient == o )
291 return; 291 return;
292 orient = o; 292 orient = o;
293 293
294 if ( orient == Horizontal ) 294 if ( orient == Horizontal )
295 setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ) ); 295 setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ) );
296 else 296 else
297 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) ); 297 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) );
298 298
299 QSplitterLayoutStruct *s = data->list.first(); 299 QSplitterLayoutStruct *s = data->list.first();
300 while ( s ) { 300 while ( s ) {
301 if ( s->isSplitter ) 301 if ( s->isSplitter )
302 ((QSplitterHandle*)s->wid)->setOrientation( o ); 302 ((QSplitterHandle*)s->wid)->setOrientation( o );
303 s = data->list.next(); // ### next at end of loop, no iterator 303 s = data->list.next(); // ### next at end of loop, no iterator
304 } 304 }
305 recalc( isVisible() ); 305 recalc( isVisible() );
306} 306}
307 307
308 308
309/*! 309/*!
310 \fn Orientation QSplitter::orientation() const 310 \fn Orientation QSplitter::orientation() const
311 311
312 Returns the orientation (\c Horizontal or \c Vertical) of the splitter. 312 Returns the orientation (\c Horizontal or \c Vertical) of the splitter.
313 \sa setOrientation() 313 \sa setOrientation()
314*/ 314*/
315 315
316/*! 316/*!
317 \reimp 317 \reimp
318*/ 318*/
319void QSplitter::resizeEvent( QResizeEvent * ) 319void QSplitter::resizeEvent( QResizeEvent * )
320{ 320{
321 doResize(); 321 doResize();
322} 322}
323 323
324 324
325/*! 325/*!
326 Inserts the widget \a w at the end, or at the beginning if \a first is TRUE 326 Inserts the widget \a w at the end, or at the beginning if \a first is TRUE
327 327
328 It is the responsibility of the caller of this function to make sure 328 It is the responsibility of the caller of this function to make sure
329 that \a w is not already in the splitter, and to call recalcId if 329 that \a w is not already in the splitter, and to call recalcId if
330 needed. (If \a first is TRUE, then recalcId is very probably 330 needed. (If \a first is TRUE, then recalcId is very probably
331 needed.) 331 needed.)
332*/ 332*/
333 333
334QSplitterLayoutStruct *QSplitter::addWidget( QWidget *w, bool first ) 334QSplitterLayoutStruct *QSplitter::addWidget( QWidget *w, bool first )
335{ 335{
336 QSplitterLayoutStruct *s; 336 QSplitterLayoutStruct *s;
337 QSplitterHandle *newHandle = 0; 337 QSplitterHandle *newHandle = 0;
338 if ( data->list.count() > 0 ) { 338 if ( data->list.count() > 0 ) {
339 s = new QSplitterLayoutStruct; 339 s = new QSplitterLayoutStruct;
340 s->mode = KeepSize; 340 s->mode = KeepSize;
341 newHandle = new QSplitterHandle( orientation(), this ); 341 newHandle = new QSplitterHandle( orientation(), this );
342 s->wid = newHandle; 342 s->wid = newHandle;
343 newHandle->setId(data->list.count()); 343 newHandle->setId(data->list.count());
344 s->isSplitter = TRUE; 344 s->isSplitter = TRUE;
345 s->sizer = pick( newHandle->sizeHint() ); 345 s->sizer = pick( newHandle->sizeHint() );
346 if ( first ) 346 if ( first )
347 data->list.insert( 0, s ); 347 data->list.insert( 0, s );
348 else 348 else
349 data->list.append( s ); 349 data->list.append( s );
350 } 350 }
351 s = new QSplitterLayoutStruct; 351 s = new QSplitterLayoutStruct;
352 s->mode = Stretch; 352 s->mode = Stretch;
353 s->wid = w; 353 s->wid = w;
354 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 354 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() )
355 s->sizer = pick( w->sizeHint() ); 355 s->sizer = pick( w->sizeHint() );
356 else 356 else
357 s->sizer = pick( w->size() ); 357 s->sizer = pick( w->size() );
358 s->isSplitter = FALSE; 358 s->isSplitter = FALSE;
359 if ( first ) 359 if ( first )
360 data->list.insert( 0, s ); 360 data->list.insert( 0, s );
361 else 361 else
362 data->list.append( s ); 362 data->list.append( s );
363 if ( newHandle && isVisible() ) 363 if ( newHandle && isVisible() )
364 newHandle->show(); //will trigger sending of post events 364 newHandle->show(); //will trigger sending of post events
365 return s; 365 return s;
366} 366}
367 367
368 368
369/*! 369/*!
370 Tells the splitter that a child widget has been inserted/removed. 370 Tells the splitter that a child widget has been inserted/removed.
371*/ 371*/
372 372
373void QSplitter::childEvent( QChildEvent *c ) 373void QSplitter::childEvent( QChildEvent *c )
374{ 374{
375 if ( c->type() == QEvent::ChildInserted ) { 375 if ( c->type() == QEvent::ChildInserted ) {
376 if ( !c->child()->isWidgetType() ) 376 if ( !c->child()->isWidgetType() )
377 return; 377 return;
378 378
379 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 379 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) )
380 return; 380 return;
381 381
382 QSplitterLayoutStruct *s = data->list.first(); 382 QSplitterLayoutStruct *s = data->list.first();
383 while ( s ) { 383 while ( s ) {
384 if ( s->wid == c->child() ) 384 if ( s->wid == c->child() )
385 return; 385 return;
386 s = data->list.next(); 386 s = data->list.next();
387 } 387 }
388 addWidget( (QWidget*)c->child() ); 388 addWidget( (QWidget*)c->child() );
389 recalc( isVisible() ); 389 recalc( isVisible() );
390 390
391 } else if ( c->type() == QEvent::ChildRemoved ) { 391 } else if ( c->type() == QEvent::ChildRemoved ) {
392 QSplitterLayoutStruct *p = 0; 392 QSplitterLayoutStruct *p = 0;
393 if ( data->list.count() > 1 ) 393 if ( data->list.count() > 1 )
394 p = data->list.at(1); //remove handle _after_ first widget. 394 p = data->list.at(1); //remove handle _after_ first widget.
395 QSplitterLayoutStruct *s = data->list.first(); 395 QSplitterLayoutStruct *s = data->list.first();
396 while ( s ) { 396 while ( s ) {
397 if ( s->wid == c->child() ) { 397 if ( s->wid == c->child() ) {
398 data->list.removeRef( s ); 398 data->list.removeRef( s );
399 delete s; 399 delete s;
400 if ( p && p->isSplitter ) { 400 if ( p && p->isSplitter ) {
401 data->list.removeRef( p ); 401 data->list.removeRef( p );
402 delete p->wid; //will call childEvent 402 delete p->wid; //will call childEvent
403 delete p; 403 delete p;
404 } 404 }
405 recalcId(); 405 recalcId();
406 doResize(); 406 doResize();
407 return; 407 return;
408 } 408 }
409 p = s; 409 p = s;
410 s = data->list.next(); 410 s = data->list.next();
411 } 411 }
412 } 412 }
413} 413}
414 414
415 415
416/*! 416/*!
417 Shows a rubber band at position \a p. If \a p is negative, the 417 Shows a rubber band at position \a p. If \a p is negative, the
418 rubber band is removed. 418 rubber band is removed.
419*/ 419*/
420 420
421void QSplitter::setRubberband( int p ) 421void QSplitter::setRubberband( int p )
422{ 422{
423 QPainter paint( this ); 423 QPainter paint( this );
424 paint.setPen( gray ); 424 paint.setPen( gray );
425 paint.setBrush( gray ); 425 paint.setBrush( gray );
426 paint.setRasterOp( XorROP ); 426 paint.setRasterOp( XorROP );
427 QRect r = contentsRect(); 427 QRect r = contentsRect();
428 const int rBord = 3; //Themable???? 428 const int rBord = 3; //Themable????
429 const int sw = style().splitterWidth(); 429 const int sw = style().splitterWidth();
430 if ( orient == Horizontal ) { 430 if ( orient == Horizontal ) {
431 if ( opaqueOldPos >= 0 ) 431 if ( opaqueOldPos >= 0 )
432 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 432 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
433 2*rBord, r.height() ); 433 2*rBord, r.height() );
434 if ( p >= 0 ) 434 if ( p >= 0 )
435 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 435 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
436 } else { 436 } else {
437 if ( opaqueOldPos >= 0 ) 437 if ( opaqueOldPos >= 0 )
438 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 438 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
439 r.width(), 2*rBord ); 439 r.width(), 2*rBord );
440 if ( p >= 0 ) 440 if ( p >= 0 )
441 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 441 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
442 } 442 }
443 opaqueOldPos = p; 443 opaqueOldPos = p;
444} 444}
445 445
446 446
447/*! \reimp */ 447/*! \reimp */
448 448
449bool QSplitter::event( QEvent *e ) 449bool QSplitter::event( QEvent *e )
450{ 450{
451 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 451 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) {
452 recalc( isVisible() ); 452 recalc( isVisible() );
453 if ( e->type() == QEvent::Show ) 453 if ( e->type() == QEvent::Show )
454 data->firstShow = FALSE; 454 data->firstShow = FALSE;
455 } 455 }
456 return QWidget::event( e ); 456 return QWidget::event( e );
457} 457}
458 458
459 459
460/*! 460/*!
461 Draws the splitter handle in the rectangle described by \a x, \a y, 461 Draws the splitter handle in the rectangle described by \a x, \a y,
462 \a w, \a h using painter \a p. 462 \a w, \a h using painter \a p.
463 \sa QStyle::drawSplitter 463 \sa QStyle::drawSplitter
464*/ 464*/
465 465
466void QSplitter::drawSplitter( QPainter *p, 466void QSplitter::drawSplitter( QPainter *p,
467 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 467 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
468{ 468{
469 style().drawSplitter( p, x, y, w, h, colorGroup(), orient ); 469 style().drawSplitter( p, x, y, w, h, colorGroup(), orient );
470} 470}
471 471
472 472
473/*! 473/*!
474 Returns the id of the splitter to the right of or below the widget \a w, 474 Returns the id of the splitter to the right of or below the widget \a w,
475 or 0 if there is no such splitter. 475 or 0 if there is no such splitter.
476 (ie. it is either not in this QSplitter, or it is at the end). 476 (ie. it is either not in this QSplitter, or it is at the end).
477*/ 477*/
478 478
479int QSplitter::idAfter( QWidget* w ) const 479int QSplitter::idAfter( QWidget* w ) const
480{ 480{
481 QSplitterLayoutStruct *s = data->list.first(); 481 QSplitterLayoutStruct *s = data->list.first();
482 bool seen_w = FALSE; 482 bool seen_w = FALSE;
483 while ( s ) { 483 while ( s ) {
484 if ( s->isSplitter && seen_w ) 484 if ( s->isSplitter && seen_w )
485 return data->list.at(); 485 return data->list.at();
486 if ( !s->isSplitter && s->wid == w ) 486 if ( !s->isSplitter && s->wid == w )
487 seen_w = TRUE; 487 seen_w = TRUE;
488 s = data->list.next(); 488 s = data->list.next();
489 } 489 }
490 return 0; 490 return 0;
491} 491}
492 492
493 493
494/*! 494/*!
495 Moves the left/top edge of the splitter handle with id \a id as 495 Moves the left/top edge of the splitter handle with id \a id as
496 close as possible to \a p which is the distance from the left (or 496 close as possible to \a p which is the distance from the left (or
497 top) edge of the widget. 497 top) edge of the widget.
498 498
499 \sa idAfter() 499 \sa idAfter()
500*/ 500*/
501void QSplitter::moveSplitter( QCOORD p, int id ) 501void QSplitter::moveSplitter( QCOORD p, int id )
502{ 502{
503 p = adjustPos( p, id ); 503 p = adjustPos( p, id );
504 504
505 QSplitterLayoutStruct *s = data->list.at(id); 505 QSplitterLayoutStruct *s = data->list.at(id);
506 int oldP = orient == Horizontal? s->wid->x() : s->wid->y(); 506 int oldP = orient == Horizontal? s->wid->x() : s->wid->y();
507 bool upLeft = p < oldP; 507 bool upLeft = p < oldP;
508 508
509 moveAfter( p, id, upLeft ); 509 moveAfter( p, id, upLeft );
510 moveBefore( p-1, id-1, upLeft ); 510 moveBefore( p-1, id-1, upLeft );
511 511
512 storeSizes(); 512 storeSizes();
513} 513}
514 514
515 515
516void QSplitter::setG( QWidget *w, int p, int s ) 516void QSplitter::setG( QWidget *w, int p, int s )
517{ 517{
518 if ( orient == Horizontal ) 518 if ( orient == Horizontal )
519 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 519 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
520 else 520 else
521 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 521 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
522} 522}
523 523
524 524
525/*! 525/*!
526 Places the right/bottom edge of the widget at \a id at position \a pos. 526 Places the right/bottom edge of the widget at \a id at position \a pos.
527 527
528 \sa idAfter() 528 \sa idAfter()
529*/ 529*/
530 530
531void QSplitter::moveBefore( int pos, int id, bool upLeft ) 531void QSplitter::moveBefore( int pos, int id, bool upLeft )
532{ 532{
533 QSplitterLayoutStruct *s = data->list.at(id); 533 QSplitterLayoutStruct *s = data->list.at(id);
534 if ( !s ) 534 if ( !s )
535 return; 535 return;
536 QWidget *w = s->wid; 536 QWidget *w = s->wid;
537 if ( w->isHidden() ) { 537 if ( w->isHidden() ) {
538 moveBefore( pos, id-1, upLeft ); 538 moveBefore( pos, id-1, upLeft );
539 } else if ( s->isSplitter ) { 539 } else if ( s->isSplitter ) {
540 int dd = s->sizer; 540 int dd = s->sizer;
541 if ( upLeft ) { 541 if ( upLeft ) {
542 setG( w, pos-dd+1, dd ); 542 setG( w, pos-dd+1, dd );
543 moveBefore( pos-dd, id-1, upLeft ); 543 moveBefore( pos-dd, id-1, upLeft );
544 } else { 544 } else {
545 moveBefore( pos-dd, id-1, upLeft ); 545 moveBefore( pos-dd, id-1, upLeft );
546 setG( w, pos-dd+1, dd ); 546 setG( w, pos-dd+1, dd );
547 } 547 }
548 } else { 548 } else {
549 int left = pick( w->pos() ); 549 int left = pick( w->pos() );
550 int dd = pos - left + 1; 550 int dd = pos - left + 1;
551 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 551 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
552 int newLeft = pos-dd+1; 552 int newLeft = pos-dd+1;
553 setG( w, newLeft, dd ); 553 setG( w, newLeft, dd );
554 if ( left != newLeft ) 554 if ( left != newLeft )
555 moveBefore( newLeft-1, id-1, upLeft ); 555 moveBefore( newLeft-1, id-1, upLeft );
556 } 556 }
557} 557}
558 558
559 559
560/*! 560/*!
561 Places the left/top edge of the widget at \a id at position \a pos. 561 Places the left/top edge of the widget at \a id at position \a pos.
562 562
563 \sa idAfter() 563 \sa idAfter()
564*/ 564*/
565 565
566void QSplitter::moveAfter( int pos, int id, bool upLeft ) 566void QSplitter::moveAfter( int pos, int id, bool upLeft )
567{ 567{
568 QSplitterLayoutStruct *s = id < int(data->list.count()) ? 568 QSplitterLayoutStruct *s = id < int(data->list.count()) ?
569 data->list.at(id) : 0; 569 data->list.at(id) : 0;
570 if ( !s ) 570 if ( !s )
571 return; 571 return;
572 QWidget *w = s->wid; 572 QWidget *w = s->wid;
573 if ( w->isHidden() ) { 573 if ( w->isHidden() ) {
574 moveAfter( pos, id+1, upLeft ); 574 moveAfter( pos, id+1, upLeft );
575 } else if ( pick( w->pos() ) == pos ) { 575 } else if ( pick( w->pos() ) == pos ) {
576 //No need to do anything if it's already there. 576 //No need to do anything if it's already there.
577 return; 577 return;
578 } else if ( s->isSplitter ) { 578 } else if ( s->isSplitter ) {
579 int dd = s->sizer; 579 int dd = s->sizer;
580 if ( upLeft ) { 580 if ( upLeft ) {
581 setG( w, pos, dd ); 581 setG( w, pos, dd );
582 moveAfter( pos+dd, id+1, upLeft ); 582 moveAfter( pos+dd, id+1, upLeft );
583 } else { 583 } else {
584 moveAfter( pos+dd, id+1, upLeft ); 584 moveAfter( pos+dd, id+1, upLeft );
585 setG( w, pos, dd ); 585 setG( w, pos, dd );
586 } 586 }
587 } else { 587 } else {
588 int right = pick( w->geometry().bottomRight() ); 588 int right = pick( w->geometry().bottomRight() );
589 589
590 int dd = right - pos + 1; 590 int dd = right - pos + 1;
591 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 591 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
592 int newRight = pos+dd-1; 592 int newRight = pos+dd-1;
593 setG( w, pos, dd ); 593 setG( w, pos, dd );
594 moveAfter( newRight+1, id+1, upLeft ); 594 moveAfter( newRight+1, id+1, upLeft );
595 } 595 }
596} 596}
597 597
598 598
599/*! 599/*!
600 Returns the valid range of the splitter with id \a id in \a min and \a max. 600 Returns the valid range of the splitter with id \a id in \a min and \a max.
601 601
602 \sa idAfter() 602 \sa idAfter()
603*/ 603*/
604 604
605void QSplitter::getRange( int id, int *min, int *max ) 605void QSplitter::getRange( int id, int *min, int *max )
606{ 606{
607 int minB = 0;//before 607 int minB = 0;//before
608 int maxB = 0; 608 int maxB = 0;
609 int minA = 0; 609 int minA = 0;
610 int maxA = 0;//after 610 int maxA = 0;//after
611 int n = data->list.count(); 611 int n = data->list.count();
612 if ( id < 0 || id >= n ) 612 if ( id < 0 || id >= n )
613 return; 613 return;
614 int i; 614 int i;
615 for ( i = 0; i < id; i++ ) { 615 for ( i = 0; i < id; i++ ) {
616 QSplitterLayoutStruct *s = data->list.at(i); 616 QSplitterLayoutStruct *s = data->list.at(i);
617 if ( s->wid->isHidden() ) { 617 if ( s->wid->isHidden() ) {
618 //ignore 618 //ignore
619 } else if ( s->isSplitter ) { 619 } else if ( s->isSplitter ) {
620 minB += s->sizer; 620 minB += s->sizer;
621 maxB += s->sizer; 621 maxB += s->sizer;
622 } else { 622 } else {
623 minB += pick( minSize(s->wid) ); 623 minB += pick( minSize(s->wid) );
624 maxB += pick( s->wid->maximumSize() ); 624 maxB += pick( s->wid->maximumSize() );
625 } 625 }
626 } 626 }
627 for ( i = id; i < n; i++ ) { 627 for ( i = id; i < n; i++ ) {
628 QSplitterLayoutStruct *s = data->list.at(i); 628 QSplitterLayoutStruct *s = data->list.at(i);
629 if ( s->wid->isHidden() ) { 629 if ( s->wid->isHidden() ) {
630 //ignore 630 //ignore
631 } else if ( s->isSplitter ) { 631 } else if ( s->isSplitter ) {
632 minA += s->sizer; 632 minA += s->sizer;
633 maxA += s->sizer; 633 maxA += s->sizer;
634 } else { 634 } else {
635 minA += pick( minSize(s->wid) ); 635 minA += pick( minSize(s->wid) );
636 maxA += pick( s->wid->maximumSize() ); 636 maxA += pick( s->wid->maximumSize() );
637 } 637 }
638 } 638 }
639 QRect r = contentsRect(); 639 QRect r = contentsRect();
640 if ( min ) 640 if ( min )
641 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 641 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
642 if ( max ) 642 if ( max )
643 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 643 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
644 644
645} 645}
646 646
647 647
648/*! 648/*!
649 Returns the legal position closest to \a p of the splitter with id \a id. 649 Returns the legal position closest to \a p of the splitter with id \a id.
650 650
651 \sa idAfter() 651 \sa idAfter()
652*/ 652*/
653 653
654int QSplitter::adjustPos( int p, int id ) 654int QSplitter::adjustPos( int p, int id )
655{ 655{
656 int min = 0; 656 int min = 0;
657 int max = 0; 657 int max = 0;
658 getRange( id, &min, &max ); 658 getRange( id, &min, &max );
659 p = QMAX( min, QMIN( p, max ) ); 659 p = QMAX( min, QMIN( p, max ) );
660 660
661 return p; 661 return p;
662} 662}
663 663
664 664
665void QSplitter::doResize() 665void QSplitter::doResize()
666{ 666{
667 QRect r = contentsRect(); 667 QRect r = contentsRect();
668 int i; 668 int i;
669 int n = data->list.count(); 669 int n = data->list.count();
670 QArray<QLayoutStruct> a( n ); 670 QArray<QLayoutStruct> a( n );
671 for ( i = 0; i< n; i++ ) { 671 for ( i = 0; i< n; i++ ) {
672 a[i].init(); 672 a[i].init();
673 QSplitterLayoutStruct *s = data->list.at(i); 673 QSplitterLayoutStruct *s = data->list.at(i);
674 if ( s->wid->isHidden() ) { 674 if ( s->wid->isHidden() ) {
675 a[i].stretch = 0; 675 a[i].stretch = 0;
676 a[i].sizeHint = a[i].minimumSize = 0; 676 a[i].sizeHint = a[i].minimumSize = 0;
677 a[i].maximumSize = 0; 677 a[i].maximumSize = 0;
678 } else if ( s->isSplitter ) { 678 } else if ( s->isSplitter ) {
679 a[i].stretch = 0; 679 a[i].stretch = 0;
680 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; 680 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer;
681 a[i].empty = FALSE; 681 a[i].empty = FALSE;
682 } else if ( s->mode == KeepSize ) { 682 } else if ( s->mode == KeepSize ) {
683 a[i].stretch = 0; 683 a[i].stretch = 0;
684 a[i].minimumSize = pick( minSize(s->wid) ); 684 a[i].minimumSize = pick( minSize(s->wid) );
685 a[i].sizeHint = s->sizer; 685 a[i].sizeHint = s->sizer;
686 a[i].maximumSize = pick( s->wid->maximumSize() ); 686 a[i].maximumSize = pick( s->wid->maximumSize() );
687 a[i].empty = FALSE; 687 a[i].empty = FALSE;
688 } else if ( s->mode == FollowSizeHint ) { 688 } else if ( s->mode == FollowSizeHint ) {
689 a[i].stretch = 0; 689 a[i].stretch = 0;
690 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); 690 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() );
691 a[i].maximumSize = pick( s->wid->maximumSize() ); 691 a[i].maximumSize = pick( s->wid->maximumSize() );
692 a[i].empty = FALSE; 692 a[i].empty = FALSE;
693 } else { //proportional 693 } else { //proportional
694 a[i].stretch = s->sizer; 694 a[i].stretch = s->sizer;
695 a[i].maximumSize = pick( s->wid->maximumSize() ); 695 a[i].maximumSize = pick( s->wid->maximumSize() );
696 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); 696 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) );
697 a[i].empty = FALSE; 697 a[i].empty = FALSE;
698 } 698 }
699 } 699 }
700 700
701 qGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); 701 qGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 );
702 for ( i = 0; i< n; i++ ) { 702 for ( i = 0; i< n; i++ ) {
703 QSplitterLayoutStruct *s = data->list.at(i); 703 QSplitterLayoutStruct *s = data->list.at(i);
704 if ( orient == Horizontal ) 704 if ( orient == Horizontal )
705 s->wid->setGeometry( a[i].pos, r.top(), a[i].size, r.height() ); 705 s->wid->setGeometry( a[i].pos, r.top(), a[i].size, r.height() );
706 else 706 else
707 s->wid->setGeometry( r.left(), a[i].pos, r.width(), a[i].size ); 707 s->wid->setGeometry( r.left(), a[i].pos, r.width(), a[i].size );
708 } 708 }
709 709
710} 710}
711 711
712 712
713void QSplitter::recalc( bool update ) 713void QSplitter::recalc( bool update )
714{ 714{
715 int fi = 2*frameWidth(); 715 int fi = 2*frameWidth();
716 int maxl = fi; 716 int maxl = fi;
717 int minl = fi; 717 int minl = fi;
718 int maxt = QWIDGETSIZE_MAX; 718 int maxt = QWIDGETSIZE_MAX;
719 int mint = fi; 719 int mint = fi;
720 int n = data->list.count(); 720 int n = data->list.count();
721 bool first = TRUE; 721 bool first = TRUE;
722 /* 722 /*
723 The splitter before a hidden widget is always hidden. 723 The splitter before a hidden widget is always hidden.
724 The splitter before the first visible widget is hidden. 724 The splitter before the first visible widget is hidden.
725 The splitter before any other visible widget is visible. 725 The splitter before any other visible widget is visible.
726 */ 726 */
727 for ( int i = 0; i< n; i++ ) { 727 for ( int i = 0; i< n; i++ ) {
728 QSplitterLayoutStruct *s = data->list.at(i); 728 QSplitterLayoutStruct *s = data->list.at(i);
729 if ( !s->isSplitter ) { 729 if ( !s->isSplitter ) {
730 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; 730 QSplitterLayoutStruct *p = (i > 0) ? data->list.at( i-1 ) : 0;
731 if ( p && p->isSplitter ) 731 if ( p && p->isSplitter )
732 if ( first || s->wid->isHidden() ) 732 if ( first || s->wid->isHidden() )
733 p->wid->hide(); //may trigger new recalc 733 p->wid->hide(); //may trigger new recalc
734 else 734 else
735 p->wid->show(); //may trigger new recalc 735 p->wid->show(); //may trigger new recalc
736 if ( !s->wid->isHidden() ) 736 if ( !s->wid->isHidden() )
737 first = FALSE; 737 first = FALSE;
738 } 738 }
739 } 739 }
740 740
741 bool empty=TRUE; 741 bool empty=TRUE;
742 for ( int j = 0; j< n; j++ ) { 742 for ( int j = 0; j< n; j++ ) {
743 QSplitterLayoutStruct *s = data->list.at(j); 743 QSplitterLayoutStruct *s = data->list.at(j);
744 if ( !s->wid->isHidden() ) { 744 if ( !s->wid->isHidden() ) {
745 empty = FALSE; 745 empty = FALSE;
746 if ( s->isSplitter ) { 746 if ( s->isSplitter ) {
747 minl += s->sizer; 747 minl += s->sizer;
748 maxl += s->sizer; 748 maxl += s->sizer;
749 } else { 749 } else {
750 QSize minS = minSize(s->wid); 750 QSize minS = minSize(s->wid);
751 minl += pick( minS ); 751 minl += pick( minS );
752 maxl += pick( s->wid->maximumSize() ); 752 maxl += pick( s->wid->maximumSize() );
753 mint = QMAX( mint, trans( minS )); 753 mint = QMAX( mint, trans( minS ));
754 int tm = trans( s->wid->maximumSize() ); 754 int tm = trans( s->wid->maximumSize() );
755 if ( tm > 0 ) 755 if ( tm > 0 )
756 maxt = QMIN( maxt, tm ); 756 maxt = QMIN( maxt, tm );
757 } 757 }
758 } 758 }
759 } 759 }
760 if ( empty ) 760 if ( empty )
761 maxl = maxt = 0; 761 maxl = maxt = 0;
762 else 762 else
763 maxl = QMIN( maxl, QWIDGETSIZE_MAX ); 763 maxl = QMIN( maxl, QWIDGETSIZE_MAX );
764 if ( maxt < mint ) 764 if ( maxt < mint )
765 maxt = mint; 765 maxt = mint;
766 766
767 if ( orient == Horizontal ) { 767 if ( orient == Horizontal ) {
768 setMaximumSize( maxl, maxt ); 768 setMaximumSize( maxl, maxt );
769 setMinimumSize( minl, mint ); 769 setMinimumSize( minl, mint );
770 } else { 770 } else {
771 setMaximumSize( maxt, maxl ); 771 setMaximumSize( maxt, maxl );
772 setMinimumSize( mint, minl ); 772 setMinimumSize( mint, minl );
773 } 773 }
774 if ( update ) 774 if ( update )
775 doResize(); 775 doResize();
776} 776}
777 777
778/*! \enum QSplitter::ResizeMode 778/*! \enum QSplitter::ResizeMode
779 779
780 This enum type describes how QSplitter will resize each of its child widgets. The currently defined values are: <ul> 780 This enum type describes how QSplitter will resize each of its child widgets. The currently defined values are: <ul>
781 781
782 <li> \c Stretch - the widget will be resized when the splitter 782 <li> \c Stretch - the widget will be resized when the splitter
783 itself is resized. 783 itself is resized.
784 784
785 <li> \c KeepSize - QSplitter will try to keep this widget's size 785 <li> \c KeepSize - QSplitter will try to keep this widget's size
786 unchanged. 786 unchanged.
787 787
788 <li> \c FollowSizeHint - QSplitter will resize the widget when its 788 <li> \c FollowSizeHint - QSplitter will resize the widget when its
789 size hint changes. 789 size hint changes.
790 790
791 </ul> 791 </ul>
792 792
793*/ 793*/
794 794
795/*! 795/*!
796 Sets resize mode of \a w to \a mode. 796 Sets resize mode of \a w to \a mode.
797 797
798 \sa ResizeMode 798 \sa ResizeMode
799*/ 799*/
800 800
801void QSplitter::setResizeMode( QWidget *w, ResizeMode mode ) 801void QSplitter::setResizeMode( QWidget *w, ResizeMode mode )
802{ 802{
803 processChildEvents(); 803 processChildEvents();
804 QSplitterLayoutStruct *s = data->list.first(); 804 QSplitterLayoutStruct *s = data->list.first();
805 while ( s ) { 805 while ( s ) {
806 if ( s->wid == w ) { 806 if ( s->wid == w ) {
807 s->mode = mode; 807 s->mode = mode;
808 return; 808 return;
809 } 809 }
810 s = data->list.next(); 810 s = data->list.next();
811 } 811 }
812 s = addWidget( w, TRUE ); 812 s = addWidget( w, TRUE );
813 s->mode = mode; 813 s->mode = mode;
814} 814}
815 815
816 816
817/*! 817/*!
818 Returns TRUE if opaque resize is on, FALSE otherwise. 818 Returns TRUE if opaque resize is on, FALSE otherwise.
819 819
820 \sa setOpaqueResize() 820 \sa setOpaqueResize()
821*/ 821*/
822 822
823bool QSplitter::opaqueResize() const 823bool QSplitter::opaqueResize() const
824{ 824{
825 return data->opaque; 825 return data->opaque;
826} 826}
827 827
828 828
829/*! 829/*!
830 Sets opaque resize to \a on. Opaque resize is initially turned off. 830 Sets opaque resize to \a on. Opaque resize is initially turned off.
831 831
832 \sa opaqueResize() 832 \sa opaqueResize()
833*/ 833*/
834 834
835void QSplitter::setOpaqueResize( bool on ) 835void QSplitter::setOpaqueResize( bool on )
836{ 836{
837 data->opaque = on; 837 data->opaque = on;
838} 838}
839 839
840 840
841/*! 841/*!
842 Moves \a w to the leftmost/top position. 842 Moves \a w to the leftmost/top position.
843*/ 843*/
844 844
845void QSplitter::moveToFirst( QWidget *w ) 845void QSplitter::moveToFirst( QWidget *w )
846{ 846{
847 processChildEvents(); 847 processChildEvents();
848 bool found = FALSE; 848 bool found = FALSE;
849 QSplitterLayoutStruct *s = data->list.first(); 849 QSplitterLayoutStruct *s = data->list.first();
850 while ( s ) { 850 while ( s ) {
851 if ( s->wid == w ) { 851 if ( s->wid == w ) {
852 found = TRUE; 852 found = TRUE;
853 QSplitterLayoutStruct *p = data->list.prev(); 853 QSplitterLayoutStruct *p = data->list.prev();
854 if ( p ) { // not already at first place 854 if ( p ) { // not already at first place
855 data->list.take(); //take p 855 data->list.take(); //take p
856 data->list.take(); // take s 856 data->list.take(); // take s
857 data->list.insert( 0, p ); 857 data->list.insert( 0, p );
858 data->list.insert( 0, s ); 858 data->list.insert( 0, s );
859 } 859 }
860 break; 860 break;
861 } 861 }
862 s = data->list.next(); 862 s = data->list.next();
863 } 863 }
864 if ( !found ) 864 if ( !found )
865 addWidget( w, TRUE ); 865 addWidget( w, TRUE );
866 recalcId(); 866 recalcId();
867} 867}
868 868
869 869
870/*! 870/*!
871 Moves \a w to the rightmost/bottom position. 871 Moves \a w to the rightmost/bottom position.
872*/ 872*/
873 873
874void QSplitter::moveToLast( QWidget *w ) 874void QSplitter::moveToLast( QWidget *w )
875{ 875{
876 processChildEvents(); 876 processChildEvents();
877 bool found = FALSE; 877 bool found = FALSE;
878 QSplitterLayoutStruct *s = data->list.first(); 878 QSplitterLayoutStruct *s = data->list.first();
879 while ( s ) { 879 while ( s ) {
880 if ( s->wid == w ) { 880 if ( s->wid == w ) {
881 found = TRUE; 881 found = TRUE;
882 data->list.take(); // take s 882 data->list.take(); // take s
883 QSplitterLayoutStruct *p = data->list.current(); 883 QSplitterLayoutStruct *p = data->list.current();
884 if ( p ) { // the splitter handle after s 884 if ( p ) { // the splitter handle after s
885 data->list.take(); //take p 885 data->list.take(); //take p
886 data->list.append( p ); 886 data->list.append( p );
887 } 887 }
888 data->list.append( s ); 888 data->list.append( s );
889 break; 889 break;
890 } 890 }
891 s = data->list.next(); 891 s = data->list.next();
892 } 892 }
893 if ( !found ) 893 if ( !found )
894 addWidget( w); 894 addWidget( w);
895 recalcId(); 895 recalcId();
896} 896}
897 897
898 898
899void QSplitter::recalcId() 899void QSplitter::recalcId()
900{ 900{
901 int n = data->list.count(); 901 int n = data->list.count();
902 for ( int i = 0; i < n; i++ ) { 902 for ( int i = 0; i < n; i++ ) {
903 QSplitterLayoutStruct *s = data->list.at(i); 903 QSplitterLayoutStruct *s = data->list.at(i);
904 if ( s->isSplitter ) 904 if ( s->isSplitter )
905 ((QSplitterHandle*)s->wid)->setId(i); 905 ((QSplitterHandle*)s->wid)->setId(i);
906 } 906 }
907} 907}
908 908
909 909
910/*!\reimp 910/*!\reimp
911*/ 911*/
912QSize QSplitter::sizeHint() const 912QSize QSplitter::sizeHint() const
913{ 913{
914 constPolish(); 914 constPolish();
915 int l = 0; 915 int l = 0;
916 int t = 0; 916 int t = 0;
917 if ( children() ) { 917 if ( children() ) {
918 const QObjectList * c = children(); 918 const QObjectList * c = children();
919 QObjectListIt it( *c ); 919 QObjectListIt it( *c );
920 QObject * o; 920 QObject * o;
921 921
922 while( (o=it.current()) != 0 ) { 922 while( (o=it.current()) != 0 ) {
923 ++it; 923 ++it;
924 if ( o->isWidgetType() && 924 if ( o->isWidgetType() &&
925 !((QWidget*)o)->isHidden() ) { 925 !((QWidget*)o)->isHidden() ) {
926 QSize s = ((QWidget*)o)->sizeHint(); 926 QSize s = ((QWidget*)o)->sizeHint();
927 if ( s.isValid() ) { 927 if ( s.isValid() ) {
928 l += pick( s ); 928 l += pick( s );
929 t = QMAX( t, trans( s ) ); 929 t = QMAX( t, trans( s ) );
930 } 930 }
931 } 931 }
932 } 932 }
933 } 933 }
934 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 934 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
935} 935}
936 936
937 937
938/*! 938/*!
939\reimp 939\reimp
940*/ 940*/
941 941
942QSize QSplitter::minimumSizeHint() const 942QSize QSplitter::minimumSizeHint() const
943{ 943{
944 constPolish(); 944 constPolish();
945 int l = 0; 945 int l = 0;
946 int t = 0; 946 int t = 0;
947 if ( children() ) { 947 if ( children() ) {
948 const QObjectList * c = children(); 948 const QObjectList * c = children();
949 QObjectListIt it( *c ); 949 QObjectListIt it( *c );
950 QObject * o; 950 QObject * o;
951 951
952 while( (o=it.current()) != 0 ) { 952 while( (o=it.current()) != 0 ) {
953 ++it; 953 ++it;
954 if ( o->isWidgetType() && 954 if ( o->isWidgetType() &&
955 !((QWidget*)o)->isHidden() ) { 955 !((QWidget*)o)->isHidden() ) {
956 QSize s = minSize((QWidget*)o); 956 QSize s = minSize((QWidget*)o);
957 if ( s.isValid() ) { 957 if ( s.isValid() ) {
958 l += pick( s ); 958 l += pick( s );
959 t = QMAX( t, trans( s ) ); 959 t = QMAX( t, trans( s ) );
960 } 960 }
961 } 961 }
962 } 962 }
963 } 963 }
964 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 964 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l );
965} 965}
966 966
967 967
968 968
969/*!\reimp 969/*!\reimp
970*/ 970*/
971QSizePolicy QSplitter::sizePolicy() const 971QSizePolicy QSplitter::sizePolicy() const
972{ 972{
973 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ); 973 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
974} 974}
975 975
976 976
977/*! 977/*!
978 Calculates stretch parameters from current sizes 978 Calculates stretch parameters from current sizes
979*/ 979*/
980 980
981void QSplitter::storeSizes() 981void QSplitter::storeSizes()
982{ 982{
983 QSplitterLayoutStruct *s = data->list.first(); 983 QSplitterLayoutStruct *s = data->list.first();
984 while ( s ) { 984 while ( s ) {
985 if ( !s->isSplitter ) 985 if ( !s->isSplitter )
986 s->sizer = pick( s->wid->size() ); 986 s->sizer = pick( s->wid->size() );
987 s = data->list.next(); 987 s = data->list.next();
988 } 988 }
989} 989}
990 990
991 991
992#if 0 // ### remove this code ASAP 992#if 0 // ### remove this code ASAP
993 993
994/*! 994/*!
995 Hides \a w if \a hide is TRUE, and updates the splitter. 995 Hides \a w if \a hide is TRUE, and updates the splitter.
996 996
997 \warning Due to a limitation in the current implementation, 997 \warning Due to a limitation in the current implementation,
998 calling QWidget::hide() will not work. 998 calling QWidget::hide() will not work.
999*/ 999*/
1000 1000
1001void QSplitter::setHidden( QWidget *w, bool hide ) 1001void QSplitter::setHidden( QWidget *w, bool hide )
1002{ 1002{
1003 if ( w == w1 ) { 1003 if ( w == w1 ) {
1004 w1show = !hide; 1004 w1show = !hide;
1005 } else if ( w == w2 ) { 1005 } else if ( w == w2 ) {
1006 w2show = !hide; 1006 w2show = !hide;
1007 } else { 1007 } else {
1008#ifdef CHECK_RANGE 1008#ifdef CHECK_RANGE
1009 qWarning( "QSplitter::setHidden(), unknown widget" ); 1009 qWarning( "QSplitter::setHidden(), unknown widget" );
1010#endif 1010#endif
1011 return; 1011 return;
1012 } 1012 }
1013 if ( hide ) 1013 if ( hide )
1014 w->hide(); 1014 w->hide();
1015 else 1015 else
1016 w->show(); 1016 w->show();
1017 recalc( TRUE ); 1017 recalc( TRUE );
1018} 1018}
1019 1019
1020 1020
1021/*! 1021/*!
1022 Returns the hidden status of \a w 1022 Returns the hidden status of \a w
1023*/ 1023*/
1024 1024
1025bool QSplitter::isHidden( QWidget *w ) const 1025bool QSplitter::isHidden( QWidget *w ) const
1026{ 1026{
1027 if ( w == w1 ) 1027 if ( w == w1 )
1028 return !w1show; 1028 return !w1show;
1029 else if ( w == w2 ) 1029 else if ( w == w2 )
1030 return !w2show; 1030 return !w2show;
1031#ifdef CHECK_RANGE 1031#ifdef CHECK_RANGE
1032 else 1032 else
1033 qWarning( "QSplitter::isHidden(), unknown widget" ); 1033 qWarning( "QSplitter::isHidden(), unknown widget" );
1034#endif 1034#endif
1035 return FALSE; 1035 return FALSE;
1036} 1036}
1037#endif 1037#endif
1038 1038
1039 1039
1040/*! 1040/*!
1041 Returns a list of the size parameters of all the widgets in this 1041 Returns a list of the size parameters of all the widgets in this
1042 splitter. 1042 splitter.
1043 1043
1044 Giving the values to setSizes() will give a splitter with the same 1044 Giving the values to setSizes() will give a splitter with the same
1045 layout as this one. 1045 layout as this one.
1046 1046
1047 \sa setSizes() 1047 \sa setSizes()
1048*/ 1048*/
1049 1049
1050QValueList<int> QSplitter::sizes() const 1050QValueList<int> QSplitter::sizes() const
1051{ 1051{
1052 if ( !testWState(WState_Polished) ) { 1052 if ( !testWState(WState_Polished) ) {
1053 QWidget* that = (QWidget*) this; 1053 QWidget* that = (QWidget*) this;
1054 that->polish(); 1054 that->polish();
1055 } 1055 }
1056 QValueList<int> list; 1056 QValueList<int> list;
1057 QSplitterLayoutStruct *s = data->list.first(); 1057 QSplitterLayoutStruct *s = data->list.first();
1058 while ( s ) { 1058 while ( s ) {
1059 if ( !s->isSplitter ) 1059 if ( !s->isSplitter )
1060 list.append( s->sizer ); 1060 list.append( s->sizer );
1061 s = data->list.next(); 1061 s = data->list.next();
1062 } 1062 }
1063 return list; 1063 return list;
1064} 1064}
1065 1065
1066 1066
1067 1067
1068/*! 1068/*!
1069 Sets the size parameters to the values given in \a list. 1069 Sets the size parameters to the values given in \a list.
1070 If the splitter is horizontal, the values set the sizes from 1070 If the splitter is horizontal, the values set the sizes from
1071 left to right. If it is vertical, the sizes are applied from 1071 left to right. If it is vertical, the sizes are applied from
1072 top to bottom. 1072 top to bottom.
1073 Extra values in \a list are ignored. 1073 Extra values in \a list are ignored.
1074 1074
1075 If \a list contains too few values, the result is undefined 1075 If \a list contains too few values, the result is undefined
1076 but the program will still be well-behaved. 1076 but the program will still be well-behaved.
1077 1077
1078 \sa sizes() 1078 \sa sizes()
1079*/ 1079*/
1080 1080
1081void QSplitter::setSizes( QValueList<int> list ) 1081void QSplitter::setSizes( QValueList<int> list )
1082{ 1082{
1083 processChildEvents(); 1083 processChildEvents();
1084 QValueList<int>::Iterator it = list.begin(); 1084 QValueList<int>::Iterator it = list.begin();
1085 QSplitterLayoutStruct *s = data->list.first(); 1085 QSplitterLayoutStruct *s = data->list.first();
1086 while ( s && it != list.end() ) { 1086 while ( s && it != list.end() ) {
1087 if ( !s->isSplitter ) { 1087 if ( !s->isSplitter ) {
1088 s->sizer = *it; 1088 s->sizer = *it;
1089 ++it; 1089 ++it;
1090 } 1090 }
1091 s = data->list.next(); 1091 s = data->list.next();
1092 } 1092 }
1093 doResize(); 1093 doResize();
1094} 1094}
1095 1095
1096 1096
1097/*! 1097/*!
1098 Gets all posted child events, ensuring that the internal state of 1098 Gets all posted child events, ensuring that the internal state of
1099 the splitter is consistent with the programmer's idea. 1099 the splitter is consistent with the programmer's idea.
1100*/ 1100*/
1101 1101
1102void QSplitter::processChildEvents() 1102void QSplitter::processChildEvents()
1103{ 1103{
1104 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1104 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1105} 1105}
1106 1106
1107 1107
1108/*! 1108/*!
1109 \reimp 1109 \reimp
1110*/ 1110*/
1111 1111
1112void QSplitter::styleChange( QStyle& old ) 1112void QSplitter::styleChange( QStyle& old )
1113{ 1113{
1114 int sw = style().splitterWidth(); 1114 int sw = style().splitterWidth();
1115 QSplitterLayoutStruct *s = data->list.first(); 1115 QSplitterLayoutStruct *s = data->list.first();
1116 while ( s ) { 1116 while ( s ) {
1117 if ( s->isSplitter ) 1117 if ( s->isSplitter )
1118 s->sizer = sw; 1118 s->sizer = sw;
1119 s = data->list.next(); 1119 s = data->list.next();
1120 } 1120 }
1121 doResize(); 1121 doResize();
1122 QFrame::styleChange( old ); 1122 QFrame::styleChange( old );
1123} 1123}
1124 1124
diff --git a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
index 9fa4452..d8f5aa7 100644
--- a/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
+++ b/noncore/apps/tinykate/libkate/document/katesyntaxdocument.cpp
@@ -1,311 +1,309 @@
1/*************************************************************************** 1/***************************************************************************
2 katesyntaxdocument.cpp - description 2 katesyntaxdocument.cpp - description
3 ------------------- 3 -------------------
4 begin : Sat 31 March 2001 4 begin : Sat 31 March 2001
5 copyright : (C) 2001,2002 by Joseph Wenninger 5 copyright : (C) 2001,2002 by Joseph Wenninger
6 email : jowenn@kde.org 6 email : jowenn@kde.org
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "katesyntaxdocument.h" 18#include "katesyntaxdocument.h"
19#include "kateconfig.h" 19#include "kateconfig.h"
20#include "kdebug.h" 20#include "kdebug.h"
21#include "kstddirs.h" 21#include "kstddirs.h"
22#include "klocale.h" 22#include "klocale.h"
23#include "kmessagebox.h" 23#include "kmessagebox.h"
24#include "kglobal.h" 24#include "kglobal.h"
25 25
26/* OPIE */ 26/* OPIE */
27#include <opie2/odebug.h> 27#include <opie2/odebug.h>
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29 29
30/* QT */ 30/* QT */
31#include <qfile.h> 31#include <qfile.h>
32#include <qstringlist.h> 32#include <qstringlist.h>
33#include <qdir.h> 33#include <qdir.h>
34 34
35SyntaxDocument::SyntaxDocument() 35SyntaxDocument::SyntaxDocument()
36{ 36{
37 m_root=0; 37 m_root=0;
38 currentFile=""; 38 currentFile="";
39 setupModeList(); 39 setupModeList();
40} 40}
41 41
42void SyntaxDocument::setIdentifier(const QString& identifier) 42void SyntaxDocument::setIdentifier(const QString& identifier)
43{ 43{
44#warning FIXME delete m_root; 44#warning FIXME delete m_root;
45 m_root=Opie::Core::XMLElement::load(identifier); 45 m_root=Opie::Core::XMLElement::load(identifier);
46 if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) ); 46 if (!m_root) KMessageBox::error( 0L, i18n("Can't open %1").arg(identifier) );
47 47
48} 48}
49 49
50SyntaxDocument::~SyntaxDocument() 50SyntaxDocument::~SyntaxDocument()
51{ 51{
52} 52}
53 53
54void SyntaxDocument::setupModeList(bool force) 54void SyntaxDocument::setupModeList(bool force)
55{ 55{
56 56
57 if (myModeList.count() > 0) return; 57 if (myModeList.count() > 0) return;
58 58
59 KateConfig *config=KGlobal::config(); 59 KateConfig *config=KGlobal::config();
60 KStandardDirs *dirs = KGlobal::dirs();
61 60
62// QStringList list=dirs->findAllResources("data","kate/syntax/*.xml",false,true);
63 QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/"; 61 QString path=QPEApplication::qpeDir() +"share/tinykate/syntax/";
64 62
65 QDir dir(path); 63 QDir dir(path);
66 QStringList list=dir.entryList("*.xml"); 64 QStringList list=dir.entryList("*.xml");
67 65
68 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it ) 66 for ( QStringList::Iterator it = list.begin(); it != list.end(); ++it )
69 { 67 {
70 QString Group="Highlighting_Cache"+path+*it; 68 QString Group="Highlighting_Cache"+path+*it;
71 if ((config->hasGroup(Group)) && (!force)) 69 if ((config->hasGroup(Group)) && (!force))
72 { 70 {
73 config->setGroup(Group); 71 config->setGroup(Group);
74 syntaxModeListItem *mli=new syntaxModeListItem; 72 syntaxModeListItem *mli=new syntaxModeListItem;
75 mli->name = config->readEntry("name",""); 73 mli->name = config->readEntry("name","");
76 mli->section = config->readEntry("section",""); 74 mli->section = config->readEntry("section","");
77 mli->mimetype = config->readEntry("mimetype",""); 75 mli->mimetype = config->readEntry("mimetype","");
78 mli->extension = config->readEntry("extension",""); 76 mli->extension = config->readEntry("extension","");
79 mli->identifier = path+*it; 77 mli->identifier = path+*it;
80 myModeList.append(mli); 78 myModeList.append(mli);
81 } 79 }
82 else 80 else
83 { 81 {
84 odebug << "Found a description file:"+path+(*it) << oendl; 82 odebug << "Found a description file:"+path+(*it) << oendl;
85 setIdentifier(path+(*it)); 83 setIdentifier(path+(*it));
86 Opie::Core::XMLElement *e=m_root; 84 Opie::Core::XMLElement *e=m_root;
87 if (e) 85 if (e)
88 { 86 {
89 e=e->firstChild(); 87 e=e->firstChild();
90 odebug << e->tagName() << oendl; 88 odebug << e->tagName() << oendl;
91 if (e->tagName()=="language") 89 if (e->tagName()=="language")
92 { 90 {
93 syntaxModeListItem *mli=new syntaxModeListItem; 91 syntaxModeListItem *mli=new syntaxModeListItem;
94 mli->name = e->attribute("name"); 92 mli->name = e->attribute("name");
95 mli->section = e->attribute("section"); 93 mli->section = e->attribute("section");
96 mli->mimetype = e->attribute("mimetype"); 94 mli->mimetype = e->attribute("mimetype");
97 mli->extension = e->attribute("extensions"); 95 mli->extension = e->attribute("extensions");
98 odebug << QString("valid description for: %1/%2").arg(mli->section).arg(mli->name) << oendl; 96 odebug << QString("valid description for: %1/%2").arg(mli->section).arg(mli->name) << oendl;
99 if (mli->section.isEmpty()) 97 if (mli->section.isEmpty())
100 mli->section=i18n("Other"); 98 mli->section=i18n("Other");
101 99
102 mli->identifier = path+(*it); 100 mli->identifier = path+(*it);
103 config->setGroup(Group); 101 config->setGroup(Group);
104 config->writeEntry("name",mli->name); 102 config->writeEntry("name",mli->name);
105 config->writeEntry("section",mli->section); 103 config->writeEntry("section",mli->section);
106 config->writeEntry("mimetype",mli->mimetype); 104 config->writeEntry("mimetype",mli->mimetype);
107 config->writeEntry("extension",mli->extension); 105 config->writeEntry("extension",mli->extension);
108 myModeList.append(mli); 106 myModeList.append(mli);
109 } 107 }
110 } 108 }
111 } 109 }
112 } 110 }
113 config->write(); 111 config->write();
114// config->sync(); 112// config->sync();
115} 113}
116 114
117SyntaxModeList SyntaxDocument::modeList() 115SyntaxModeList SyntaxDocument::modeList()
118{ 116{
119 return myModeList; 117 return myModeList;
120} 118}
121 119
122bool SyntaxDocument::nextGroup( syntaxContextData* data) 120bool SyntaxDocument::nextGroup( syntaxContextData* data)
123{ 121{
124 if(!data) return false; 122 if(!data) return false;
125 123
126 if (!data->currentGroup) 124 if (!data->currentGroup)
127 data->currentGroup=data->parent->firstChild(); 125 data->currentGroup=data->parent->firstChild();
128 else 126 else
129 data->currentGroup=data->currentGroup->nextChild(); 127 data->currentGroup=data->currentGroup->nextChild();
130 128
131 data->item=0; 129 data->item=0;
132 130
133 if (!data->currentGroup) 131 if (!data->currentGroup)
134 return false; 132 return false;
135 else 133 else
136 return true; 134 return true;
137} 135}
138 136
139bool SyntaxDocument::nextItem( syntaxContextData* data) 137bool SyntaxDocument::nextItem( syntaxContextData* data)
140{ 138{
141 if(!data) return false; 139 if(!data) return false;
142 140
143 if (!data->item) 141 if (!data->item)
144 data->item=data->currentGroup->firstChild(); 142 data->item=data->currentGroup->firstChild();
145 else 143 else
146 data->item=data->item->nextChild(); 144 data->item=data->item->nextChild();
147 145
148 if (!data->item) 146 if (!data->item)
149 return false; 147 return false;
150 else 148 else
151 return true; 149 return true;
152} 150}
153 151
154QString SyntaxDocument::groupItemData( syntaxContextData* data,QString name) 152QString SyntaxDocument::groupItemData( syntaxContextData* data,QString name)
155{ 153{
156 if(!data) 154 if(!data)
157 return QString::null; 155 return QString::null;
158 156
159 if ( (data->item) && (name.isEmpty())) 157 if ( (data->item) && (name.isEmpty()))
160 return data->item->tagName(); 158 return data->item->tagName();
161 159
162 if (data->item) 160 if (data->item)
163 return data->item->attribute(name); 161 return data->item->attribute(name);
164 else 162 else
165 return QString(); 163 return QString();
166} 164}
167 165
168QString SyntaxDocument::groupData( syntaxContextData* data,QString name) 166QString SyntaxDocument::groupData( syntaxContextData* data,QString name)
169{ 167{
170 if(!data) 168 if(!data)
171 return QString::null; 169 return QString::null;
172 170
173 if (data->currentGroup) 171 if (data->currentGroup)
174 return data->currentGroup->attribute(name); 172 return data->currentGroup->attribute(name);
175 else 173 else
176 return QString(); 174 return QString();
177} 175}
178 176
179void SyntaxDocument::freeGroupInfo( syntaxContextData* data) 177void SyntaxDocument::freeGroupInfo( syntaxContextData* data)
180{ 178{
181 if (data) 179 if (data)
182 delete data; 180 delete data;
183} 181}
184 182
185syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data) 183syntaxContextData* SyntaxDocument::getSubItems(syntaxContextData* data)
186{ 184{
187 syntaxContextData *retval=new syntaxContextData; 185 syntaxContextData *retval=new syntaxContextData;
188 retval->parent=0; 186 retval->parent=0;
189 retval->currentGroup=0; 187 retval->currentGroup=0;
190 retval->item=0; 188 retval->item=0;
191 if (data != 0) 189 if (data != 0)
192 { 190 {
193 retval->parent=data->currentGroup; 191 retval->parent=data->currentGroup;
194 retval->currentGroup=data->item; 192 retval->currentGroup=data->item;
195 retval->item=0; 193 retval->item=0;
196 } 194 }
197 195
198 return retval; 196 return retval;
199} 197}
200 198
201syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config) 199syntaxContextData* SyntaxDocument::getConfig(const QString& mainGroupName, const QString &Config)
202{ 200{
203 Opie::Core::XMLElement *e = m_root->firstChild()->firstChild(); 201 Opie::Core::XMLElement *e = m_root->firstChild()->firstChild();
204 202
205 while (e) 203 while (e)
206 { 204 {
207 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; 205 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl;
208 206
209 if (e->tagName().compare(mainGroupName)==0 ) 207 if (e->tagName().compare(mainGroupName)==0 )
210 { 208 {
211 Opie::Core::XMLElement *e1=e->firstChild(); 209 Opie::Core::XMLElement *e1=e->firstChild();
212 210
213 while (e1) 211 while (e1)
214 { 212 {
215 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; 213 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl;
216 214
217 if (e1->tagName()==Config) 215 if (e1->tagName()==Config)
218 { 216 {
219 syntaxContextData *data=new ( syntaxContextData); 217 syntaxContextData *data=new ( syntaxContextData);
220 data->currentGroup=0; 218 data->currentGroup=0;
221 data->parent=0; 219 data->parent=0;
222 data->item=e1; 220 data->item=e1;
223 return data; 221 return data;
224 } 222 }
225 223
226 e1=e1->nextChild(); 224 e1=e1->nextChild();
227 } 225 }
228 226
229 kdDebug(13010) << "WARNING :returning null 3"<< endl; 227 kdDebug(13010) << "WARNING :returning null 3"<< endl;
230 return 0; 228 return 0;
231 } 229 }
232 230
233 e=e->nextChild(); 231 e=e->nextChild();
234 } 232 }
235 233
236 kdDebug(13010) << "WARNING :returning null 4" << endl; 234 kdDebug(13010) << "WARNING :returning null 4" << endl;
237 return 0; 235 return 0;
238} 236}
239 237
240 238
241 239
242syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, const QString &group) 240syntaxContextData* SyntaxDocument::getGroupInfo(const QString& mainGroupName, const QString &group)
243{ 241{
244 242
245 Opie::Core::XMLElement *e=m_root->firstChild()->firstChild(); 243 Opie::Core::XMLElement *e=m_root->firstChild()->firstChild();
246 244
247 while (e) 245 while (e)
248 { 246 {
249 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl; 247 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (outer loop) " <<endl;
250 248
251 if (e->tagName().compare(mainGroupName)==0 ) 249 if (e->tagName().compare(mainGroupName)==0 )
252 { 250 {
253 Opie::Core::XMLElement *e1=e->firstChild(); 251 Opie::Core::XMLElement *e1=e->firstChild();
254 252
255 while (e1) 253 while (e1)
256 { 254 {
257 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl; 255 kdDebug(13010)<<"in SyntaxDocument::getGroupInfo (inner loop) " <<endl;
258 if (e1->tagName()==group+"s") 256 if (e1->tagName()==group+"s")
259 { 257 {
260 syntaxContextData *data=new ( syntaxContextData); 258 syntaxContextData *data=new ( syntaxContextData);
261 data->parent=e1; 259 data->parent=e1;
262 data->currentGroup=0; 260 data->currentGroup=0;
263 data->item=0; 261 data->item=0;
264 return data; 262 return data;
265 } 263 }
266 264
267 e1=e1->nextChild(); 265 e1=e1->nextChild();
268 } 266 }
269 267
270 kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl; 268 kdDebug(13010) << "WARNING : getGroupInfo returning null :1 " << endl;
271 return 0; 269 return 0;
272 } 270 }
273 271
274 e=e->nextChild(); 272 e=e->nextChild();
275 } 273 }
276 274
277 kdDebug(13010) << "WARNING : getGroupInfo returning null :2" << endl; 275 kdDebug(13010) << "WARNING : getGroupInfo returning null :2" << endl;
278 return 0; 276 return 0;
279} 277}
280 278
281 279
282QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList) 280QStringList& SyntaxDocument::finddata(const QString& mainGroup,const QString& type,bool clearList)
283{ 281{
284 Opie::Core::XMLElement *e = m_root->firstChild(); 282 Opie::Core::XMLElement *e = m_root->firstChild();
285 if (clearList) 283 if (clearList)
286 m_data.clear(); 284 m_data.clear();
287 285
288 for(e=e->firstChild(); e; e=e->nextChild()) 286 for(e=e->firstChild(); e; e=e->nextChild())
289 { 287 {
290 if (e->tagName()==mainGroup) 288 if (e->tagName()==mainGroup)
291 { 289 {
292 for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild()) 290 for (Opie::Core::XMLElement *e1=e->firstChild();e1;e1=e1->nextChild())
293 { 291 {
294 if (e1->tagName()!="list") continue; 292 if (e1->tagName()!="list") continue;
295 293
296 if (e1->attribute("name")==type) 294 if (e1->attribute("name")==type)
297 { 295 {
298 for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild()) 296 for (Opie::Core::XMLElement *e2=e1->firstChild();e2;e2=e2->nextChild())
299 { 297 {
300 odebug << "FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value() << oendl; 298 odebug << "FOUND A LIST ENTRY("+e2->tagName()+"):"+e2->firstChild()->value() << oendl;
301 m_data+=e2->firstChild()->value().stripWhiteSpace(); 299 m_data+=e2->firstChild()->value().stripWhiteSpace();
302 } 300 }
303 break; 301 break;
304 } 302 }
305 } 303 }
306 break; 304 break;
307 } 305 }
308 } 306 }
309 307
310 return m_data; 308 return m_data;
311} 309}
diff --git a/noncore/apps/tinykate/mainwindow/tinykate.cpp b/noncore/apps/tinykate/mainwindow/tinykate.cpp
index e87464e..e920d5b 100644
--- a/noncore/apps/tinykate/mainwindow/tinykate.cpp
+++ b/noncore/apps/tinykate/mainwindow/tinykate.cpp
@@ -1,427 +1,425 @@
1/*************************************************************************** 1/***************************************************************************
2 tinykate.cpp 2 tinykate.cpp
3 Tiny KATE mainwindow 3 Tiny KATE mainwindow
4 ------------------- 4 -------------------
5 begin : November 2002 5 begin : November 2002
6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org> 6 copyright : (C) 2002 by Joseph Wenninger <jowenn@kde.org>
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free softwaSre; you can redistribute it and/or modify * 11 * This program is free softwaSre; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation. * 13 * the Free Software Foundation. *
14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE * 14 * ONLY VERSION 2 OF THE LICENSE IS APPLICABLE *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "tinykate.h" 18#include "tinykate.h"
19 19
20#include "katedocument.h" 20#include "katedocument.h"
21#include "kglobal.h" 21#include "kglobal.h"
22 22
23/* OPIE */ 23/* OPIE */
24#include <opie2/odebug.h> 24#include <opie2/odebug.h>
25#include <opie2/ofiledialog.h> 25#include <opie2/ofiledialog.h>
26#include <opie2/oresource.h> 26#include <opie2/oresource.h>
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28 28
29/* QT */ 29/* QT */
30#include <qaction.h> 30#include <qaction.h>
31#include <qtoolbutton.h> 31#include <qtoolbutton.h>
32#include <qmenubar.h> 32#include <qmenubar.h>
33#include <qmessagebox.h> 33#include <qmessagebox.h>
34 34
35 35
36using namespace Opie::Ui; 36using namespace Opie::Ui;
37TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) : 37TinyKate::TinyKate( QWidget *parent, const char *name, WFlags f) :
38 QMainWindow( parent, name, f ) 38 QMainWindow( parent, name, f )
39{ 39{
40 shutDown=false; 40 shutDown=false;
41 nextUnnamed=0; 41 nextUnnamed=0;
42 currentView=0; 42 currentView=0;
43 viewCount=0; 43 viewCount=0;
44 setCaption(tr("TinyKATE")); 44 setCaption(tr("TinyKATE"));
45 KGlobal::setAppName("TinyKATE"); 45 KGlobal::setAppName("TinyKATE");
46 46
47 QMenuBar *mb = new QMenuBar( this ); 47 QMenuBar *mb = new QMenuBar( this );
48 mb->setMargin( 0 ); 48 mb->setMargin( 0 );
49 49
50 tabwidget=new OTabWidget(this); 50 tabwidget=new OTabWidget(this);
51 setCentralWidget(tabwidget); 51 setCentralWidget(tabwidget);
52 connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*))); 52 connect(tabwidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(slotCurrentChanged(QWidget*)));
53 53
54 //FILE ACTIONS 54 //FILE ACTIONS
55 QPopupMenu *popup = new QPopupMenu( this ); 55 QPopupMenu *popup = new QPopupMenu( this );
56 56
57 // Action for creating a new document 57 // Action for creating a new document
58 QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ), 58 QAction *a = new QAction( tr( "New" ), Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
59 QString::null, 0, this, 0 ); 59 QString::null, 0, this, 0 );
60 a->addTo( popup ); 60 a->addTo( popup );
61 connect(a, SIGNAL(activated()), this, SLOT(slotNew())); 61 connect(a, SIGNAL(activated()), this, SLOT(slotNew()));
62 62
63 // Action for opening an exisiting document 63 // Action for opening an exisiting document
64 a = new QAction( tr( "Open" ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ), 64 a = new QAction( tr( "Open" ), Opie::Core::OResource::loadPixmap( "fileopen", Opie::Core::OResource::SmallIcon ),
65 QString::null, 0, this, 0 ); 65 QString::null, 0, this, 0 );
66 a->addTo(popup); 66 a->addTo(popup);
67 connect(a, SIGNAL(activated()), this, SLOT(slotOpen())); 67 connect(a, SIGNAL(activated()), this, SLOT(slotOpen()));
68 68
69 69
70 // Action for saving document 70 // Action for saving document
71 a = new QAction( tr( "Save" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ), 71 a = new QAction( tr( "Save" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ),
72 QString::null, 0, this, 0 ); 72 QString::null, 0, this, 0 );
73 a->addTo(popup); 73 a->addTo(popup);
74 connect(a, SIGNAL(activated()), this, SLOT(slotSave())); 74 connect(a, SIGNAL(activated()), this, SLOT(slotSave()));
75 75
76 // Action for saving document to a new name 76 // Action for saving document to a new name
77 a = new QAction( tr( "Save As" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ), 77 a = new QAction( tr( "Save As" ), Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ),
78 QString::null, 0, this, 0 ); 78 QString::null, 0, this, 0 );
79 a->addTo(popup); 79 a->addTo(popup);
80 connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs())); 80 connect(a, SIGNAL(activated()), this, SLOT(slotSaveAs()));
81 81
82 // Action for closing the currently active document 82 // Action for closing the currently active document
83 a = new QAction( tr( "Close" ), Opie::Core::OResource::loadPixmap( "quit_icon", Opie::Core::OResource::SmallIcon ), 83 a = new QAction( tr( "Close" ), Opie::Core::OResource::loadPixmap( "quit_icon", Opie::Core::OResource::SmallIcon ),
84 QString::null, 0, this, 0 ); 84 QString::null, 0, this, 0 );
85 a->addTo(popup); 85 a->addTo(popup);
86 connect(a, SIGNAL(activated()), this, SLOT(slotClose())); 86 connect(a, SIGNAL(activated()), this, SLOT(slotClose()));
87 87
88 88
89 mb->insertItem(tr("File"),popup); 89 mb->insertItem(tr("File"),popup);
90 90
91 //EDIT ACTIONS 91 //EDIT ACTIONS
92 popup = new QPopupMenu( this ); 92 popup = new QPopupMenu( this );
93 bool useBigIcon = qApp->desktop()->size().width() > 330; 93 bool useBigIcon = qApp->desktop()->size().width() > 330;
94 94
95 // Action for cutting text 95 // Action for cutting text
96 editCut = new QToolButton( 0 ); 96 editCut = new QToolButton( 0 );
97 editCut->setUsesBigPixmap( useBigIcon ); 97 editCut->setUsesBigPixmap( useBigIcon );
98 editCut->setAutoRaise( true ); 98 editCut->setAutoRaise( true );
99 editCut->setIconSet( Opie::Core::OResource::loadPixmap( "cut", Opie::Core::OResource::SmallIcon ) ); 99 editCut->setIconSet( Opie::Core::OResource::loadPixmap( "cut", Opie::Core::OResource::SmallIcon ) );
100 100
101 // Action for Copying text 101 // Action for Copying text
102 editCopy = new QToolButton( 0 ); 102 editCopy = new QToolButton( 0 );
103 editCopy->setUsesBigPixmap( useBigIcon ); 103 editCopy->setUsesBigPixmap( useBigIcon );
104 editCopy->setAutoRaise( true ); 104 editCopy->setAutoRaise( true );
105 editCopy->setIconSet( Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ) ); 105 editCopy->setIconSet( Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ) );
106 106
107 // Action for pasting text 107 // Action for pasting text
108 editPaste = new QToolButton( 0 ); 108 editPaste = new QToolButton( 0 );
109 editPaste->setUsesBigPixmap( useBigIcon ); 109 editPaste->setUsesBigPixmap( useBigIcon );
110 editPaste->setAutoRaise( true ); 110 editPaste->setAutoRaise( true );
111 editPaste->setIconSet( Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ) ); 111 editPaste->setIconSet( Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ) );
112 112
113 // Action for finding text 113 // Action for finding text
114 editFind = new QAction( tr( "Find..." ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ), 114 editFind = new QAction( tr( "Find..." ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ),
115 QString::null, 0, this, 0 ); 115 QString::null, 0, this, 0 );
116 editFind->addTo(popup); 116 editFind->addTo(popup);
117 117
118 // Action for replacing text 118 // Action for replacing text
119 editReplace = new QAction( tr( "Replace..." ), QString::null, 0, this, 0 ); 119 editReplace = new QAction( tr( "Replace..." ), QString::null, 0, this, 0 );
120 editReplace->addTo(popup); 120 editReplace->addTo(popup);
121 121
122 // Action for going to a specific line 122 // Action for going to a specific line
123 editGotoLine = new QAction( tr( "Goto Line..." ), QString::null, 0, this, 0 ); 123 editGotoLine = new QAction( tr( "Goto Line..." ), QString::null, 0, this, 0 );
124 editGotoLine->addTo(popup); 124 editGotoLine->addTo(popup);
125 125
126 // Action for undo 126 // Action for undo
127 editUndo = new QToolButton( 0 ); 127 editUndo = new QToolButton( 0 );
128 editUndo->setUsesBigPixmap( useBigIcon ); 128 editUndo->setUsesBigPixmap( useBigIcon );
129 editUndo->setAutoRaise( true ); 129 editUndo->setAutoRaise( true );
130 editUndo->setIconSet( Opie::Core::OResource::loadPixmap( "undo", Opie::Core::OResource::SmallIcon ) ); 130 editUndo->setIconSet( Opie::Core::OResource::loadPixmap( "undo", Opie::Core::OResource::SmallIcon ) );
131 131
132 // Action for redo 132 // Action for redo
133 editRedo = new QToolButton( 0 ); 133 editRedo = new QToolButton( 0 );
134 editRedo->setUsesBigPixmap( useBigIcon ); 134 editRedo->setUsesBigPixmap( useBigIcon );
135 editRedo->setAutoRaise( true ); 135 editRedo->setAutoRaise( true );
136 editRedo->setIconSet( Opie::Core::OResource::loadPixmap( "redo", Opie::Core::OResource::SmallIcon ) ); 136 editRedo->setIconSet( Opie::Core::OResource::loadPixmap( "redo", Opie::Core::OResource::SmallIcon ) );
137 137
138 mb->insertItem(tr("Edit"),popup); 138 mb->insertItem(tr("Edit"),popup);
139 139
140 //VIEW ACITONS 140 //VIEW ACITONS
141 popup = new QPopupMenu( this ); 141 popup = new QPopupMenu( this );
142 142
143 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 ); 143 viewIncFontSizes = new QAction( tr( "Font +" ), QString::null, 0, this, 0 );
144 viewIncFontSizes->addTo( popup ); 144 viewIncFontSizes->addTo( popup );
145 145
146 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 ); 146 viewDecFontSizes = new QAction( tr( "Font -" ), QString::null, 0, this, 0 );
147 viewDecFontSizes->addTo( popup ); 147 viewDecFontSizes->addTo( popup );
148 148
149 mb->insertItem(tr("View"),popup); 149 mb->insertItem(tr("View"),popup);
150 150
151 popup = new QPopupMenu( this ); 151 popup = new QPopupMenu( this );
152 mb->insertItem(tr("Utils"),popup); 152 mb->insertItem(tr("Utils"),popup);
153 153
154 154
155 mb->insertItem( editCut ); 155 mb->insertItem( editCut );
156 mb->insertItem( editCopy ); 156 mb->insertItem( editCopy );
157 mb->insertItem( editPaste ); 157 mb->insertItem( editPaste );
158 mb->insertItem( editUndo ); 158 mb->insertItem( editUndo );
159 mb->insertItem( editRedo ); 159 mb->insertItem( editRedo );
160 160
161 161
162 //Highlight management 162 //Highlight management
163 hlmenu=new QPopupMenu(this); 163 hlmenu=new QPopupMenu(this);
164 HlManager *hlm=HlManager::self(); 164 HlManager *hlm=HlManager::self();
165 for (int i=0;i<hlm->highlights();i++) 165 for (int i=0;i<hlm->highlights();i++)
166 { 166 {
167 hlmenu->insertItem(hlm->hlName(i),i); 167 hlmenu->insertItem(hlm->hlName(i),i);
168 } 168 }
169 popup->insertItem(tr("Highlighting"),hlmenu); 169 popup->insertItem(tr("Highlighting"),hlmenu);
170 170
171 171
172 utilSettings = new QAction( tr( "Settings" ), 172 utilSettings = new QAction( tr( "Settings" ),
173 Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ), 173 Opie::Core::OResource::loadPixmap( "SettingsIcon", Opie::Core::OResource::SmallIcon ),
174 QString::null, 0, this, 0 ); 174 QString::null, 0, this, 0 );
175 utilSettings->addTo( popup); 175 utilSettings->addTo( popup);
176 176
177 if( qApp->argc() > 1) open(qApp->argv()[1]); 177 if( qApp->argc() > 1) open(qApp->argv()[1]);
178 else slotNew(); 178 else slotNew();
179 179
180} 180}
181 181
182TinyKate::~TinyKate( ) 182TinyKate::~TinyKate( )
183{ 183{
184 owarn << "TinyKate destructor\n" << oendl; 184 owarn << "TinyKate destructor\n" << oendl;
185 185
186 if( KGlobal::config() != 0 ) 186 if( KGlobal::config() != 0 )
187 { 187 {
188 owarn << "deleting KateConfig object..\n" << oendl; 188 owarn << "deleting KateConfig object..\n" << oendl;
189 delete KGlobal::config(); 189 delete KGlobal::config();
190 } 190 }
191} 191}
192 192
193void TinyKate::slotOpen( ) 193void TinyKate::slotOpen( )
194{ 194{
195 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL, 195 QString filename = OFileDialog::getOpenFileName( OFileSelector::EXTENDED_ALL,
196 QString::null); 196 QString::null);
197 if (!filename.isEmpty()) 197 if (!filename.isEmpty())
198 { 198 {
199 open(filename); 199 open(filename);
200 } 200 }
201} 201}
202 202
203void TinyKate::open(const QString & filename) 203void TinyKate::open(const QString & filename)
204{ 204{
205 KateDocument *kd= new KateDocument(false, false, this,0,this); 205 KateDocument *kd= new KateDocument(false, false, this,0,this);
206 KTextEditor::View *kv;
207 QString realFileName; 206 QString realFileName;
208 //check if filename is a .desktop file 207 //check if filename is a .desktop file
209 if ( filename.find( ".desktop", 0, true ) != -1 ) { 208 if ( filename.find( ".desktop", 0, true ) != -1 ) {
210 switch ( QMessageBox::warning( this, tr( "TinyKATE" ), 209 switch ( QMessageBox::warning( this, tr( "TinyKATE" ),
211 tr("TinyKATE has detected<BR>you selected a <B>.desktop</B> file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?" ), 210 tr("TinyKATE has detected<BR>you selected a <B>.desktop</B> file.<BR>Open <B>.desktop</B> file or <B>linked</B> file?" ),
212 tr(".desktop File"), 211 tr(".desktop File"),
213 tr("Linked Document"), 0, 1, 1 ) ) 212 tr("Linked Document"), 0, 1, 1 ) )
214 { 213 {
215 case 0: //desktop 214 case 0: //desktop
216 realFileName = filename; 215 realFileName = filename;
217 break; 216 break;
218 case 1: //linked 217 case 1: //linked
219 DocLnk docLnk( filename ); 218 DocLnk docLnk( filename );
220 realFileName = docLnk.file(); 219 realFileName = docLnk.file();
221 break; 220 break;
222 }; 221 };
223 } else { 222 } else {
224 realFileName = filename; 223 realFileName = filename;
225 } 224 }
226 225
227 QFileInfo fileInfo( realFileName ); 226 QFileInfo fileInfo( realFileName );
228 QString filenamed = fileInfo.fileName(); 227 QString filenamed = fileInfo.fileName();
229 tabwidget->addTab(kv=kd->createView(tabwidget,"bLAH"),"tinykate/tinykate", filenamed ); 228 tabwidget->addTab(kd->createView(tabwidget,"Unnamed kateview"),"tinykate/tinykate", filenamed );
230 odebug << realFileName << oendl; 229 odebug << realFileName << oendl;
231 230
232 kd->setDocName( filenamed); 231 kd->setDocName( filenamed);
233 kd->open( realFileName ); 232 kd->open( realFileName );
234 viewCount++; 233 viewCount++;
235} 234}
236 235
237void TinyKate::setDocument(const QString& fileref) 236void TinyKate::setDocument(const QString& fileref)
238{ 237{
239 open( fileref ); 238 open( fileref );
240} 239}
241 240
242void TinyKate::slotCurrentChanged( QWidget * view) 241void TinyKate::slotCurrentChanged( QWidget * view)
243{ 242{
244 if (currentView) 243 if (currentView)
245 { 244 {
246 245
247 disconnect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); 246 disconnect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy()));
248 disconnect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); 247 disconnect(editCut,SIGNAL(clicked()),currentView,SLOT(cut()));
249 disconnect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); 248 disconnect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste()));
250 disconnect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); 249 disconnect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo()));
251 disconnect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); 250 disconnect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo()));
252 disconnect(editFind,SIGNAL(activated()),currentView,SLOT(find())); 251 disconnect(editFind,SIGNAL(activated()),currentView,SLOT(find()));
253 disconnect(editReplace,SIGNAL(activated()),currentView,SLOT(replace())); 252 disconnect(editReplace,SIGNAL(activated()),currentView,SLOT(replace()));
254 disconnect(editGotoLine,SIGNAL(activated()),currentView,SLOT(gotoLine())); 253 disconnect(editGotoLine,SIGNAL(activated()),currentView,SLOT(gotoLine()));
255 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 254 disconnect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
256 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 255 disconnect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
257 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 256 disconnect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
258 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 257 disconnect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
259 } 258 }
260 259
261 currentView=(KTextEditor::View*)view; 260 currentView=(KTextEditor::View*)view;
262 261
263 connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy())); 262 connect(editCopy,SIGNAL(clicked()),currentView,SLOT(copy()));
264 connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut())); 263 connect(editCut,SIGNAL(clicked()),currentView,SLOT(cut()));
265 connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste())); 264 connect(editPaste,SIGNAL(clicked()),currentView,SLOT(paste()));
266 connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo())); 265 connect(editUndo,SIGNAL(clicked()),currentView,SLOT(undo()));
267 connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo())); 266 connect(editRedo,SIGNAL(clicked()),currentView,SLOT(redo()));
268 connect(editFind,SIGNAL(activated()),currentView,SLOT(find())); 267 connect(editFind,SIGNAL(activated()),currentView,SLOT(find()));
269 connect(editReplace,SIGNAL(activated()),currentView,SLOT(replace())); 268 connect(editReplace,SIGNAL(activated()),currentView,SLOT(replace()));
270 connect(editGotoLine,SIGNAL(activated()),currentView,SLOT(gotoLine())); 269 connect(editGotoLine,SIGNAL(activated()),currentView,SLOT(gotoLine()));
271 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes())); 270 connect(viewIncFontSizes,SIGNAL(activated()), currentView,SLOT(slotIncFontSizes()));
272 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes())); 271 connect(viewDecFontSizes,SIGNAL(activated()), currentView,SLOT(slotDecFontSizes()));
273 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int))); 272 connect(hlmenu,SIGNAL(activated(int)), currentView,SLOT(setHl(int)));
274 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog())); 273 connect(utilSettings,SIGNAL(activated()), currentView,SLOT(configDialog()));
275 274
276} 275}
277 276
278void TinyKate::slotNew( ) 277void TinyKate::slotNew( )
279{ 278{
280 KateDocument *kd= new KateDocument(false, false, this,0,this); 279 KateDocument *kd= new KateDocument(false, false, this,0,this);
281 KTextEditor::View *kv;
282 280
283 kd->setDocName(tr("Unnamed %1").arg(nextUnnamed++)); 281 kd->setDocName(tr("Unnamed %1").arg(nextUnnamed++));
284 kd->setNewDoc(true); 282 kd->setNewDoc(true);
285 tabwidget->addTab(kv=kd->createView(tabwidget,"BLAH"), 283 tabwidget->addTab(kd->createView(tabwidget,"Unnamed"),
286 "tinykate/tinykate", 284 "tinykate/tinykate",
287 kd->docName()); 285 kd->docName());
288 viewCount++; 286 viewCount++;
289} 287}
290 288
291bool TinyKate::checkSave() { 289bool TinyKate::checkSave() {
292 if (currentView==0) return true; 290 if (currentView==0) return true;
293 291
294 KateView *kv = (KateView*) currentView; 292 KateView *kv = (KateView*) currentView;
295 if(kv->isModified()) { 293 if(kv->isModified()) {
296 KateDocument *kd = (KateDocument*) kv->document(); 294 KateDocument *kd = (KateDocument*) kv->document();
297 switch( QMessageBox::information( 0, (tr("TinyKATE")), 295 switch( QMessageBox::information( 0, (tr("TinyKATE")),
298 (tr("Do you want to save\n" 296 (tr("Do you want to save\n"
299 "changes to the document\n" 297 "changes to the document\n"
300 "%1?\n").arg(kd->docName())), 298 "%1?\n").arg(kd->docName())),
301 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) ) 299 (tr("Save")), (tr("Don't Save")), (tr("&Cancel")), 2, 2 ) )
302 { 300 {
303 case 0: 301 case 0:
304 { 302 {
305 return saveDocument(); 303 return saveDocument();
306 } 304 }
307 break; 305 break;
308 306
309 case 1: 307 case 1:
310 { 308 {
311 return true; 309 return true;
312 } 310 }
313 break; 311 break;
314 312
315 default: 313 default:
316 { 314 {
317 return false; 315 return false;
318 } 316 }
319 break; 317 break;
320 }; 318 };
321 } 319 }
322 else { 320 else {
323 return true; 321 return true;
324 } 322 }
325} 323}
326 324
327bool TinyKate::closeDocument() 325bool TinyKate::closeDocument()
328{ 326{
329 if (currentView==0) return true; 327 if (currentView==0) return true;
330 KTextEditor::View *dv=currentView; 328 KTextEditor::View *dv=currentView;
331 if(checkSave()) { 329 if(checkSave()) {
332 currentView=0; 330 currentView=0;
333 tabwidget->removePage(dv); 331 tabwidget->removePage(dv);
334 delete dv->document(); 332 delete dv->document();
335 viewCount--; 333 viewCount--;
336 if ((!viewCount) && (!shutDown)) slotNew(); 334 if ((!viewCount) && (!shutDown)) slotNew();
337 return true; 335 return true;
338 } 336 }
339 else 337 else
340 return false; 338 return false;
341} 339}
342 340
343void TinyKate::slotClose( ) 341void TinyKate::slotClose( )
344{ 342{
345 closeDocument(); 343 closeDocument();
346} 344}
347 345
348bool TinyKate::saveDocument() 346bool TinyKate::saveDocument()
349{ 347{
350 // feel free to make this how you want 348 // feel free to make this how you want
351 if (currentView==0) return false; 349 if (currentView==0) return false;
352 350
353 // KateView *kv = (KateView*) currentView; 351 // KateView *kv = (KateView*) currentView;
354 KateDocument *kd = (KateDocument*) currentView->document(); 352 KateDocument *kd = (KateDocument*) currentView->document();
355 // odebug << "saving file "+kd->docName() << oendl; 353 // odebug << "saving file "+kd->docName() << oendl;
356 if( kd->isNewDoc()) { 354 if( kd->isNewDoc()) {
357 return saveDocumentAs(); 355 return saveDocumentAs();
358 } 356 }
359 else 357 else
360 return kd->saveFile(); 358 return kd->saveFile();
361 // FIXME check result of saveFile and show message if failed? 359 // FIXME check result of saveFile and show message if failed?
362 // kv->save(); 360 // kv->save();
363 // kd->saveFile(); 361 // kd->saveFile();
364} 362}
365 363
366bool TinyKate::saveDocumentAs() 364bool TinyKate::saveDocumentAs()
367{ 365{
368 if (currentView==0) return false; 366 if (currentView==0) return false;
369 367
370 bool result = false; 368 bool result = false;
371 KateDocument *kd = (KateDocument*) currentView->document(); 369 KateDocument *kd = (KateDocument*) currentView->document();
372 370
373 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL, 371 QString filename= OFileDialog::getSaveFileName(OFileSelector::EXTENDED_ALL,
374 QString::null); 372 QString::null);
375 if (!filename.isEmpty()) 373 if (!filename.isEmpty())
376 { 374 {
377 odebug << "saving file "+filename << oendl; 375 odebug << "saving file "+filename << oendl;
378 QFileInfo fi(filename); 376 QFileInfo fi(filename);
379 if(fi.exists()) { 377 if(fi.exists()) {
380 if ( QMessageBox::warning(this,tr("TinyKATE"), 378 if ( QMessageBox::warning(this,tr("TinyKATE"),
381 tr("The file %1\n" 379 tr("The file %1\n"
382 "already exists.\n\n" 380 "already exists.\n\n"
383 "Are you sure you want to\n" 381 "Are you sure you want to\n"
384 "overwrite it?") 382 "overwrite it?")
385 .arg(fi.fileName()), 383 .arg(fi.fileName()),
386 tr("Yes"),tr("No"),0,0,1) != 0) { 384 tr("Yes"),tr("No"),0,0,1) != 0) {
387 return false; 385 return false;
388 } 386 }
389 } 387 }
390 QString filenamed = fi.fileName(); 388 QString filenamed = fi.fileName();
391 kd->setDocFile( filename); 389 kd->setDocFile( filename);
392 kd->setDocName( filenamed); 390 kd->setDocName( filenamed);
393 kd->setNewDoc(false); 391 kd->setNewDoc(false);
394 result = kd->saveFile(); 392 result = kd->saveFile();
395 // FIXME check result of saveFile and show message if failed? 393 // FIXME check result of saveFile and show message if failed?
396 tabwidget->changeTab( tabwidget->currentWidget(), "tinykate/tinykate", filenamed ); 394 tabwidget->changeTab( tabwidget->currentWidget(), "tinykate/tinykate", filenamed );
397 } 395 }
398 return result; 396 return result;
399} 397}
400 398
401void TinyKate::slotSave() 399void TinyKate::slotSave()
402{ 400{
403 saveDocument(); 401 saveDocument();
404} 402}
405 403
406void TinyKate::slotSaveAs() 404void TinyKate::slotSaveAs()
407{ 405{
408 saveDocumentAs(); 406 saveDocumentAs();
409} 407}
410 408
411void TinyKate::closeEvent(QCloseEvent *e) { 409void TinyKate::closeEvent(QCloseEvent *e) {
412 // Close all documents 410 // Close all documents
413 shutDown = true; 411 shutDown = true;
414 while (currentView!=0) 412 while (currentView!=0)
415 { 413 {
416 if(!closeDocument()) { 414 if(!closeDocument()) {
417 // User cancelled 415 // User cancelled
418 shutDown=false; 416 shutDown=false;
419 break; 417 break;
420 } 418 }
421 } 419 }
422 420
423 if(shutDown) 421 if(shutDown)
424 e->accept(); 422 e->accept();
425 else 423 else
426 e->ignore(); 424 e->ignore();
427} 425}
diff --git a/noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp b/noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp
index 147eb9c..d4f9943 100644
--- a/noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp
+++ b/noncore/graphics/opie-eye/impl/dcim/dcim_lister.cpp
@@ -1,181 +1,178 @@
1/* 1/*
2 * GPLv2 zecke@handhelds.org 2 * GPLv2 zecke@handhelds.org
3 */ 3 */
4 4
5#include "dcim_lister.h" 5#include "dcim_lister.h"
6#include <lib/slavemaster.h> 6#include <lib/slavemaster.h>
7 7
8#include <opie2/odebug.h> 8#include <opie2/odebug.h>
9#include <qpe/storage.h> 9#include <qpe/storage.h>
10 10
11#include <qdir.h> 11#include <qdir.h>
12#include <qfileinfo.h> 12#include <qfileinfo.h>
13#include <qimage.h> 13#include <qimage.h>
14 14
15DCIM_DirLister::DCIM_DirLister() 15DCIM_DirLister::DCIM_DirLister()
16 : PDirLister( "dcim_dirlister" ) 16 : PDirLister( "dcim_dirlister" )
17{ 17{
18 18
19 /* 19 /*
20 * create a SlaveMaster and lets connect the signal of 20 * create a SlaveMaster and lets connect the signal of
21 * it to our interface 21 * it to our interface
22 */ 22 */
23 SlaveHelper::slaveConnectSignals( this ); 23 SlaveHelper::slaveConnectSignals( this );
24 m_mode = ListingUnknown; 24 m_mode = ListingUnknown;
25} 25}
26 26
27DCIM_DirLister::~DCIM_DirLister() {} 27DCIM_DirLister::~DCIM_DirLister() {}
28 28
29QString DCIM_DirLister::defaultPath()const { 29QString DCIM_DirLister::defaultPath()const {
30 m_mode = ListingStart; 30 m_mode = ListingStart;
31 return QString::null; 31 return QString::null;
32} 32}
33 33
34QString DCIM_DirLister::setStartPath( const QString& str) { 34QString DCIM_DirLister::setStartPath( const QString& str) {
35 /** 35 /**
36 * IconView adds a '/' to path. Lets strip 36 * IconView adds a '/' to path. Lets strip
37 * that. 37 * that.
38 */ 38 */
39 QString st = str.mid( 1 ); 39 QString st = str.mid( 1 );
40 if ( ListingStart == m_mode && m_map.contains( st ) ) { 40 if ( ListingStart == m_mode && m_map.contains( st ) ) {
41 m_path = m_map[st]+ "/dcim"; 41 m_path = m_map[st]+ "/dcim";
42 m_mode = ListingFolder; 42 m_mode = ListingFolder;
43 }else if ( m_mode == ListingFolder ) { 43 }else if ( m_mode == ListingFolder ) {
44 m_mode = ListingFiles; 44 m_mode = ListingFiles;
45 m_path = str; 45 m_path = str;
46 }else if ( m_mode == ListingReFolder ) { 46 }else if ( m_mode == ListingReFolder ) {
47 m_mode = ListingFolder; 47 m_mode = ListingFolder;
48 } 48 }
49 49
50 owarn << " StartPath2 " << str << " " << m_path << oendl; 50 owarn << " StartPath2 " << str << " " << m_path << oendl;
51 51
52 return m_path; 52 return m_path;
53} 53}
54 54
55 55
56QString DCIM_DirLister::currentPath()const { 56QString DCIM_DirLister::currentPath()const {
57 return m_path; 57 return m_path;
58} 58}
59 59
60/* 60/*
61 * depending on the mode we will either 61 * depending on the mode we will either
62 * Find Digital Cameras 62 * Find Digital Cameras
63 */ 63 */
64QStringList DCIM_DirLister::folders()const { 64QStringList DCIM_DirLister::folders()const {
65 QStringList lst; 65 QStringList lst;
66 66
67 switch( m_mode ) { 67 switch( m_mode ) {
68 case ListingUnknown: 68 case ListingUnknown:
69 case ListingStart: 69 case ListingStart:
70 lst = findCameras(); 70 lst = findCameras();
71 break; 71 break;
72 case ListingFolder: 72 case ListingFolder:
73 lst = findAlbums(); 73 lst = findAlbums();
74 break; 74 break;
75 case ListingFiles: 75 case ListingFiles:
76 default: 76 default:
77 break; 77 break;
78 } 78 }
79 79
80 return lst; 80 return lst;
81} 81}
82 82
83QStringList DCIM_DirLister::files()const { 83QStringList DCIM_DirLister::files()const {
84 if ( m_mode != ListingFiles ) 84 if ( m_mode != ListingFiles )
85 return QStringList(); 85 return QStringList();
86 else 86 else
87 return findImages(); 87 return findImages();
88} 88}
89 89
90QString DCIM_DirLister::dirUp( const QString& p )const { 90QString DCIM_DirLister::dirUp( const QString& p )const {
91 QString str; 91 QString str;
92 92
93 switch( m_mode ) { 93 switch( m_mode ) {
94 case ListingFiles: 94 case ListingFiles:
95 m_mode = ListingReFolder; 95 m_mode = ListingReFolder;
96 str = PDirLister::dirUp( p ); 96 str = PDirLister::dirUp( p );
97 break; 97 break;
98 case ListingFolder: 98 case ListingFolder:
99 m_mode = ListingStart; 99 m_mode = ListingStart;
100 break; 100 break;
101 case ListingUnknown: 101 case ListingUnknown:
102 case ListingStart: 102 case ListingStart:
103 default: 103 default:
104 break; 104 break;
105 } 105 }
106 106
107 /* down cases */ 107 /* down cases */
108 owarn << " New String " << str << " old path " << m_mode << oendl; 108 owarn << " New String " << str << " old path " << m_mode << oendl;
109 m_path = str; 109 m_path = str;
110 return str; 110 return str;
111} 111}
112 112
113 113
114QStringList DCIM_DirLister::findCameras()const { 114QStringList DCIM_DirLister::findCameras()const {
115 QStringList lst; 115 QStringList lst;
116 StorageInfo inf; 116 StorageInfo inf;
117 117
118 m_map.clear(); 118 m_map.clear();
119 119
120 const QList<FileSystem> &list = inf.fileSystems(); 120 const QList<FileSystem> &list = inf.fileSystems();
121 QListIterator<FileSystem> it( list );
122 121
123 122 for ( QListIterator<FileSystem> it( list ); it.current()!=0 ; ++it )
124 FileSystem *sys; 123 if ( QFileInfo( it.current()->path() + "/dcim/" ).exists() ) {
125 for ( sys = it.current(); (sys=it.current())!=0 ; ++it ) 124 lst << it.current()->name();
126 if ( QFileInfo( sys->path() + "/dcim/" ).exists() ) { 125 m_map.insert( it.current()->name(), it.current()->path() );
127 lst << sys->name();
128 m_map.insert( sys->name(), sys->path() );
129 } 126 }
130 127
131 if ( lst.isEmpty() ) { 128 if ( lst.isEmpty() ) {
132 m_mode = ListingUnknown; 129 m_mode = ListingUnknown;
133 lst << QObject::tr("Error no Camera Dir found"); 130 lst << QObject::tr("Error no Camera Dir found");
134 }else 131 }else
135 m_mode = ListingStart; 132 m_mode = ListingStart;
136 133
137 return lst; 134 return lst;
138} 135}
139 136
140QStringList DCIM_DirLister::findAlbums()const { 137QStringList DCIM_DirLister::findAlbums()const {
141 QStringList lst = QDir( m_path ).entryList( QDir::Dirs ); 138 QStringList lst = QDir( m_path ).entryList( QDir::Dirs );
142 lst.remove( "." ); 139 lst.remove( "." );
143 lst.remove( ".." ); 140 lst.remove( ".." );
144 141
145 return lst; 142 return lst;
146} 143}
147 144
148QStringList DCIM_DirLister::findImages()const { 145QStringList DCIM_DirLister::findImages()const {
149 return QDir( m_path ).entryList("*.jpg *.jpeg *.png", QDir::Files ); 146 return QDir( m_path ).entryList("*.jpg *.jpeg *.png", QDir::Files );
150} 147}
151 148
152void DCIM_DirLister::deleteImage( const QString& fl ) { 149void DCIM_DirLister::deleteImage( const QString& fl ) {
153 QFileInfo inf( fl ); 150 QFileInfo inf( fl );
154 QFile::remove( fl ); 151 QFile::remove( fl );
155 QFile::remove( inf.dirPath ()+"/preview/"+ 152 QFile::remove( inf.dirPath ()+"/preview/"+
156 inf.fileName() ); 153 inf.fileName() );
157} 154}
158 155
159void DCIM_DirLister::thumbNail( const QString& _str, int w, int h ) { 156void DCIM_DirLister::thumbNail( const QString& _str, int w, int h ) {
160 QFileInfo inf( _str ); 157 QFileInfo inf( _str );
161 QString str = QFileInfo( inf.dirPath()+"/preview"+ inf.fileName() ).exists() ? 158 QString str = QFileInfo( inf.dirPath()+"/preview"+ inf.fileName() ).exists() ?
162 inf.dirPath()+"/preview"+ inf.fileName() : _str; 159 inf.dirPath()+"/preview"+ inf.fileName() : _str;
163 160
164 SlaveMaster::self()->thumbNail( str, w, h ); 161 SlaveMaster::self()->thumbNail( str, w, h );
165} 162}
166 163
167QImage DCIM_DirLister::image( const QString& str, Factor f, int m ) { 164QImage DCIM_DirLister::image( const QString& str, Factor f, int m ) {
168 return SlaveMaster::self()->image( str, f, m ); 165 return SlaveMaster::self()->image( str, f, m );
169} 166}
170 167
171void DCIM_DirLister::imageInfo( const QString& str ) { 168void DCIM_DirLister::imageInfo( const QString& str ) {
172 SlaveMaster::self()->thumbInfo( str ); 169 SlaveMaster::self()->thumbInfo( str );
173} 170}
174 171
175void DCIM_DirLister::fullImageInfo( const QString& str ) { 172void DCIM_DirLister::fullImageInfo( const QString& str ) {
176 SlaveMaster::self()->imageInfo( str ); 173 SlaveMaster::self()->imageInfo( str );
177} 174}
178 175
179QString DCIM_DirLister::nameToFname( const QString& name )const { 176QString DCIM_DirLister::nameToFname( const QString& name )const {
180 return name; 177 return name;
181} 178}