summaryrefslogtreecommitdiffabout
path: root/microkde
authorMichael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
committer Michael Krelin <hacker@klever.net>2007-07-04 11:23:42 (UTC)
commita08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff)
tree8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde
parent11edc920afe4f274c0964436633aa632c8288a40 (diff)
downloadkdepimpi-p1.zip
kdepimpi-p1.tar.gz
kdepimpi-p1.tar.bz2
initial public commit of qt4 portp1
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.cpp194
-rw-r--r--microkde/KDGanttMinimizeSplitter.h35
-rwxr-xr-xmicrokde/fncolordialog.h16
-rw-r--r--microkde/kapplication.cpp33
-rw-r--r--microkde/kcolorbutton.cpp3
-rw-r--r--microkde/kconfig.cpp30
-rw-r--r--microkde/kconfig.h6
-rw-r--r--microkde/kdatepickernew.cpp2
-rw-r--r--microkde/kdatetbl.cpp99
-rw-r--r--microkde/kdatetbl.h20
-rw-r--r--microkde/kdebug.h4
-rw-r--r--microkde/kdecore/kcatalogue.cpp4
-rw-r--r--microkde/kdecore/kconfigbase.h4
-rw-r--r--microkde/kdecore/klibloader.cpp29
-rw-r--r--microkde/kdecore/klibloader.h10
-rw-r--r--microkde/kdecore/klocale.cpp23
-rw-r--r--microkde/kdecore/klocale.h4
-rw-r--r--microkde/kdecore/kmdcodec.cpp139
-rw-r--r--microkde/kdecore/kmdcodec.h38
-rw-r--r--microkde/kdecore/kprefs.cpp16
-rw-r--r--microkde/kdecore/kprefs.h10
-rw-r--r--microkde/kdecore/kshortcut.h8
-rw-r--r--microkde/kdecore/kstandarddirs.cpp24
-rw-r--r--microkde/kdecore/kstandarddirs.h10
-rw-r--r--microkde/kdeui/kaction.cpp75
-rw-r--r--microkde/kdeui/kaction.h26
-rw-r--r--microkde/kdeui/kactionclasses.cpp111
-rw-r--r--microkde/kdeui/kactionclasses.h51
-rw-r--r--microkde/kdeui/kactioncollection.cpp50
-rw-r--r--microkde/kdeui/kactioncollection.h4
-rw-r--r--microkde/kdeui/kbuttonbox.cpp18
-rw-r--r--microkde/kdeui/kbuttonbox.h4
-rw-r--r--microkde/kdeui/kguiitem.cpp14
-rw-r--r--microkde/kdeui/kguiitem.h12
-rw-r--r--microkde/kdeui/kjanuswidget.cpp140
-rw-r--r--microkde/kdeui/kjanuswidget.h56
-rw-r--r--microkde/kdeui/klistbox.cpp56
-rw-r--r--microkde/kdeui/klistbox.h25
-rw-r--r--microkde/kdeui/klistview.cpp337
-rw-r--r--microkde/kdeui/klistview.h121
-rw-r--r--microkde/kdeui/kmainwindow.cpp97
-rw-r--r--microkde/kdeui/kmainwindow.h19
-rw-r--r--microkde/kdeui/knuminput.cpp61
-rw-r--r--microkde/kdeui/knuminput.h15
-rw-r--r--microkde/kdeui/kpopupmenu.cpp5
-rw-r--r--microkde/kdeui/kpopupmenu.h6
-rw-r--r--microkde/kdeui/kseparator.cpp18
-rw-r--r--microkde/kdeui/kseparator.h8
-rw-r--r--microkde/kdeui/ksqueezedtextlabel.cpp3
-rw-r--r--microkde/kdeui/ksqueezedtextlabel.h2
-rw-r--r--microkde/kdeui/kstdaction.cpp2
-rw-r--r--microkde/kdeui/ktoolbar.cpp185
-rw-r--r--microkde/kdeui/ktoolbar.h68
-rw-r--r--microkde/kdeui/ktoolbarbutton.cpp106
-rw-r--r--microkde/kdeui/ktoolbarbutton.h17
-rw-r--r--microkde/kdeui/ktoolbarhandler.cpp26
-rw-r--r--microkde/kdeui/ktoolbarhandler.h10
-rw-r--r--microkde/kdeui/kxmlguiclient.cpp12
-rw-r--r--microkde/kdeui/kxmlguiclient.h6
-rw-r--r--microkde/kdialog.cpp10
-rw-r--r--microkde/kdialog.h6
-rw-r--r--microkde/kdialogbase.cpp20
-rw-r--r--microkde/kdialogbase.h16
-rw-r--r--microkde/keditlistbox.cpp33
-rw-r--r--microkde/keditlistbox.h16
-rw-r--r--microkde/kfiledialog.cpp14
-rw-r--r--microkde/kfontdialog.cpp4
-rw-r--r--microkde/kglobal.cpp5
-rw-r--r--microkde/kglobalsettings.cpp1
-rw-r--r--microkde/kiconloader.cpp12
-rw-r--r--microkde/kiconloader.h4
-rw-r--r--microkde/kio/kfile/kurlrequester.cpp10
-rw-r--r--microkde/kio/kfile/kurlrequester.h4
-rw-r--r--microkde/kio/kio/kdirwatch.cpp12
-rw-r--r--microkde/kio/kio/kdirwatch_p.h10
-rw-r--r--microkde/klineedit.h2
-rw-r--r--microkde/klineeditdlg.h4
-rw-r--r--microkde/kresources/configdialog.cpp17
-rw-r--r--microkde/kresources/configpage.cpp38
-rw-r--r--microkde/kresources/configpage.h10
-rw-r--r--microkde/kresources/factory.cpp6
-rw-r--r--microkde/kresources/factory.h4
-rw-r--r--microkde/kresources/kcmkresources.cpp7
-rw-r--r--microkde/kresources/manager.h8
-rw-r--r--microkde/kresources/managerimpl.cpp10
-rw-r--r--microkde/kresources/managerimpl.h8
-rw-r--r--microkde/kresources/resource.h4
-rw-r--r--microkde/kresources/selectdialog.cpp22
-rw-r--r--microkde/kresources/selectdialog.h10
-rw-r--r--microkde/ksystemtray.cpp3
-rw-r--r--microkde/ksystemtray.h2
-rw-r--r--microkde/ktempfile.cpp4
-rw-r--r--microkde/ktempfile.h4
-rw-r--r--microkde/ktextedit.cpp16
-rw-r--r--microkde/ktextedit.h6
-rw-r--r--microkde/kurl.cpp30
-rw-r--r--microkde/kurl.h14
-rw-r--r--microkde/kutils/kcmultidialog.cpp16
-rw-r--r--microkde/kutils/kcmultidialog.h8
-rw-r--r--microkde/microkde.pro4
-rw-r--r--microkde/microkdeE.pro2
-rw-r--r--microkde/ofileselector_p.cpp2
-rw-r--r--microkde/ofileselector_p.h2
-rw-r--r--microkde/qlayoutengine_p.h8
104 files changed, 1617 insertions, 1358 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp
index 72c4e60..4172cd0 100644
--- a/microkde/KDGanttMinimizeSplitter.cpp
+++ b/microkde/KDGanttMinimizeSplitter.cpp
@@ -1,1716 +1,1728 @@
1/* -*- Mode: C++ -*- 1/* -*- Mode: C++ -*-
2 $Id$ 2 $Id$
3*/ 3*/
4 4
5/**************************************************************************** 5/****************************************************************************
6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved. 6 ** Copyright (C) 2002-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 7 **
8 ** This file is part of the KDGantt library. 8 ** This file is part of the KDGantt library.
9 ** 9 **
10 ** This file may be distributed and/or modified under the terms of the 10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 13 ** packaging of this file.
14 ** 14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 17 ** the Software.
18 ** 18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 23 ** information about KDGantt Commercial License Agreements.
24 ** 24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 26 ** licensing are not clear to you.
27 ** 27 **
28 ** As a special exception, permission is given to link this program 28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 30 ** without including the source code for Qt in the source distribution.
31 ** 31 **
32 **********************************************************************/ 32 **********************************************************************/
33 33
34#include "KDGanttMinimizeSplitter.h" 34#include "KDGanttMinimizeSplitter.h"
35#ifndef QT_NO_SPLITTER___ 35#ifndef QT_NO_SPLITTER___
36 36
37#include "qpainter.h" 37#include "qpainter.h"
38#include "qdrawutil.h" 38#include "qdrawutil.h"
39#include "qbitmap.h" 39#include "qbitmap.h"
40#if QT_VERSION >= 0x030000 40#if QT_VERSION >= 0x030000
41#include "qptrlist.h" 41#include "q3ptrlist.h"
42#include "qmemarray.h" 42#include "q3memarray.h"
43#else 43#else
44#include <qlist.h> 44#include <qlist.h>
45#include <qarray.h> 45#include <qarray.h>
46#define QPtrList QList 46#define Q3PtrList QList
47#define QMemArray QArray 47#define Q3MemArray QArray
48#endif 48#endif
49#include "qlayoutengine_p.h" 49#include "qlayoutengine_p.h"
50#include "qobjectlist.h" 50#include "qobject.h"
51#include "qstyle.h" 51#include "qstyle.h"
52#include "qapplication.h" //sendPostedEvents 52#include "qapplication.h" //sendPostedEvents
53#include <qvaluelist.h> 53#include <q3valuelist.h>
54#include <qcursor.h> 54#include <qcursor.h>
55#include <qframe.h> 55#include <q3frame.h>
56#include <QDesktopWidget>
57//Added by qt3to4:
58#include <Q3PointArray>
59#include <QPixmap>
60#include <QResizeEvent>
61#include <QMouseEvent>
62#include <QChildEvent>
63#include <QEvent>
64#include <QPaintEvent>
56#ifndef KDGANTT_MASTER_CVS 65#ifndef KDGANTT_MASTER_CVS
57//#include "KDGanttMinimizeSplitter.moc" 66//#include "KDGanttMinimizeSplitter.moc"
58#endif 67#endif
59 68
60 69
61 70
62#ifndef DOXYGEN_SKIP_INTERNAL 71#ifndef DOXYGEN_SKIP_INTERNAL
63 72
64#if QT_VERSION >= 232 73#if QT_VERSION >= 232
65static int mouseOffset; 74static int mouseOffset;
66static 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
67 76
68class KDRubberBand: public QFrame 77class KDRubberBand: public Q3Frame
69{ 78{
70public: 79public:
71 KDRubberBand( QWidget *parent, const char * name, WFlags f ) :QFrame ( parent, name, f ) {;} 80 KDRubberBand( QWidget *parent, const char * name, Qt::WFlags f ) :Q3Frame ( parent, name, f ) {;}
72 81
73protected: 82protected:
74 virtual void mousePressEvent ( QMouseEvent * ) 83 virtual void mousePressEvent ( QMouseEvent * )
75 { 84 {
76 close(); 85 close();
77 }; 86 };
78 87
79}; 88};
80 89
81KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, 90KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o,
82 KDGanttMinimizeSplitter *parent, const char * name ) 91 KDGanttMinimizeSplitter *parent, const char * name )
83 : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) 92 : _activeButton( 0 ), _collapsed( false )
84{ 93{
85 94 setObjectName(name);
95 setParent(parent);
86 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { 96 if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) {
87 mSizeHint = QSize(7,7); 97 mSizeHint = QSize(7,7);
88 mUseOffset = true; 98 mUseOffset = true;
89 } else { 99 } else {
90 mSizeHint = QSize(6,6); 100 mSizeHint = QSize(6,6);
91 mUseOffset = false; 101 mUseOffset = false;
92 } 102 }
93 s = parent; 103 s = parent;
94 setOrientation(o); 104 setOrientation(o);
95 setMouseTracking( true ); 105 setMouseTracking( true );
96 mMouseDown = false; 106 mMouseDown = false;
97 //setMaximumHeight( 5 ); // test only 107 //setMaximumHeight( 5 ); // test only
98} 108}
99 109
100QSize KDGanttSplitterHandle::sizeHint() const 110QSize KDGanttSplitterHandle::sizeHint() const
101{ 111{
102 return mSizeHint; 112 return mSizeHint;
103} 113}
104 114
105void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) 115void KDGanttSplitterHandle::setOrientation( Qt::Orientation o )
106{ 116{
107 orient = o; 117 orient = o;
108#ifndef QT_NO_CURSOR 118#ifndef QT_NO_CURSOR
109 if ( o == KDGanttMinimizeSplitter::Horizontal ) 119 if ( o == Qt::Horizontal )
110 setCursor( splitHCursor ); 120 setCursor( Qt::splitHCursor );
111 else 121 else
112 setCursor( splitVCursor ); 122 setCursor( Qt::splitVCursor );
113#endif 123#endif
114} 124}
115 125
116 126
117void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) 127void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e )
118{ 128{
119 updateCursor( e->pos() ); 129 updateCursor( e->pos() );
120 if ( !(e->state()&LeftButton) ) 130 if ( !(e->state()&Qt::LeftButton) )
121 return; 131 return;
122 132
123 if ( _activeButton != 0) 133 if ( _activeButton != 0)
124 return; 134 return;
125 135
126 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 136 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
127 - mouseOffset; 137 - mouseOffset;
128 if ( opaque() ) { 138 if ( opaque() ) {
129 s->moveSplitter( pos, id() ); 139 s->moveSplitter( pos, id() );
130 } else { 140 } else {
131 int min = pos; int max = pos; 141 int min = pos; int max = pos;
132 s->getRange( id(), &min, &max ); 142 s->getRange( id(), &min, &max );
133 s->setRubberband( QMAX( min, QMIN(max, pos ))); 143 s->setRubberband( QMAX( min, QMIN(max, pos )));
134 } 144 }
135 _collapsed = false; 145 _collapsed = false;
136} 146}
137 147
138void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) 148void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e )
139{ 149{
140 if ( e->button() == LeftButton ) { 150 if ( e->button() == Qt::LeftButton ) {
141 _activeButton = onButton( e->pos() ); 151 _activeButton = onButton( e->pos() );
142 mouseOffset = s->pick(e->pos()); 152 mouseOffset = s->pick(e->pos());
143 mMouseDown = true; 153 mMouseDown = true;
144 repaint(); 154 repaint();
145 updateCursor( e->pos() ); 155 updateCursor( e->pos() );
146 } 156 }
147} 157}
148 158
149void KDGanttSplitterHandle::updateCursor( const QPoint& p) 159void KDGanttSplitterHandle::updateCursor( const QPoint& p)
150{ 160{
151 if ( onButton( p ) != 0 ) { 161 if ( onButton( p ) != 0 ) {
152 setCursor( arrowCursor ); 162 setCursor( Qt::arrowCursor );
153 } 163 }
154 else { 164 else {
155 if ( orient == KDGanttMinimizeSplitter::Horizontal ) 165 if ( orient == Qt::Horizontal )
156 setCursor( splitHCursor ); 166 setCursor( Qt::splitHCursor );
157 else 167 else
158 setCursor( splitVCursor ); 168 setCursor( Qt::splitVCursor );
159 } 169 }
160} 170}
161void KDGanttSplitterHandle::toggle() 171void KDGanttSplitterHandle::toggle()
162{ 172{
163 int pos; 173 int pos;
164 int min, max; 174 int min, max;
165 if ( !_collapsed ) { 175 if ( !_collapsed ) {
166 s->expandPos( id(), &min, &max ); 176 s->expandPos( id(), &min, &max );
167 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left 177 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left
168 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 178 || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
169 pos = min; 179 pos = min;
170 } 180 }
171 else { 181 else {
172 pos = max; 182 pos = max;
173 } 183 }
174 184
175 _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); 185 _origPos = s->pick(mapToParent( QPoint( 0,0 ) ));
176 s->moveSplitter( pos, id() ); 186 s->moveSplitter( pos, id() );
177 _collapsed = true; 187 _collapsed = true;
178 } 188 }
179 else { 189 else {
180 s->moveSplitter( _origPos, id() ); 190 s->moveSplitter( _origPos, id() );
181 _collapsed = false; 191 _collapsed = false;
182 } 192 }
183 repaint(); 193 repaint();
184} 194}
185 195
186void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) 196void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e )
187{ 197{
188 mMouseDown = false; 198 mMouseDown = false;
189 if ( _activeButton != 0 ) { 199 if ( _activeButton != 0 ) {
190 if ( onButton( e->pos() ) == _activeButton ) 200 if ( onButton( e->pos() ) == _activeButton )
191 { 201 {
192 toggle(); 202 toggle();
193 } 203 }
194 _activeButton = 0; 204 _activeButton = 0;
195 updateCursor( e->pos() ); 205 updateCursor( e->pos() );
196 } 206 }
197 else { 207 else {
198 if ( !opaque() && e->button() == LeftButton ) { 208 if ( !opaque() && e->button() == Qt::LeftButton ) {
199 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) 209 QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos()))
200 - mouseOffset; 210 - mouseOffset;
201 s->setRubberband( -1 ); 211 s->setRubberband( -1 );
202 s->moveSplitter( pos, id() ); 212 s->moveSplitter( pos, id() );
203 } 213 }
204 } 214 }
205 if ( s->rubberBand() ) { 215 if ( s->rubberBand() ) {
206 //qDebug("hide rubberband "); 216 //qDebug("hide rubberband ");
207 s->rubberBand()->close(); 217 s->rubberBand()->close();
208 } 218 }
209 repaint(); 219 repaint();
210} 220}
211 221
212int KDGanttSplitterHandle::onButton( const QPoint& p ) 222int KDGanttSplitterHandle::onButton( const QPoint& p )
213{ 223{
214 QValueList<QPointArray> list = buttonRegions(); 224 Q3ValueList<Q3PointArray> list = buttonRegions();
215 int index = 1; 225 int index = 1;
216 int add = 12; 226 int add = 12;
217 for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 227 for( Q3ValueList<Q3PointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
218 QRect rect = (*it).boundingRect(); 228 QRect rect = (*it).boundingRect();
219 rect.setLeft( rect.left()- add ); 229 rect.setLeft( rect.left()- add );
220 rect.setRight( rect.right() + add); 230 rect.setRight( rect.right() + add);
221 rect.setTop( rect.top()- add ); 231 rect.setTop( rect.top()- add );
222 rect.setBottom( rect.bottom() + add); 232 rect.setBottom( rect.bottom() + add);
223 if ( rect.contains( p ) ) { 233 if ( rect.contains( p ) ) {
224 return index; 234 return index;
225 } 235 }
226 index++; 236 index++;
227 } 237 }
228 return 0; 238 return 0;
229} 239}
230 240
231 241
232QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() 242Q3ValueList<Q3PointArray> KDGanttSplitterHandle::buttonRegions()
233{ 243{
234 QValueList<QPointArray> list; 244 Q3ValueList<Q3PointArray> list;
235 245
236 int sw = 8; 246 int sw = 8;
237 int yyy = 1; 247 int yyy = 1;
238 int xxx = 1; 248 int xxx = 1;
239 int voffset[] = { (int) -sw*3, (int) sw*3 }; 249 int voffset[] = { (int) -sw*3, (int) sw*3 };
240 for ( int i = 0; i < 2; i++ ) { 250 for ( int i = 0; i < 2; i++ ) {
241 QPointArray arr; 251 Q3PointArray arr;
242 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || 252 if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ||
243 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { 253 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) {
244 int mid = height()/2 + voffset[i]; 254 int mid = height()/2 + voffset[i];
245 arr.setPoints( 3, 255 arr.setPoints( 3,
246 1-xxx, mid - sw + 4, 256 1-xxx, mid - sw + 4,
247 sw-3-xxx, mid, 257 sw-3-xxx, mid,
248 1-xxx, mid + sw -4); 258 1-xxx, mid + sw -4);
249 } 259 }
250 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 260 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
251 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 261 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
252 int mid = height()/2 + voffset[i]; 262 int mid = height()/2 + voffset[i];
253 arr.setPoints( 3, 263 arr.setPoints( 3,
254 sw-4, mid - sw + 4, 264 sw-4, mid - sw + 4,
255 0, mid, 265 0, mid,
256 sw-4, mid + sw - 4); 266 sw-4, mid + sw - 4);
257 } 267 }
258 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 268 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
259 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) { 269 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down) {
260 int mid = width()/2 + voffset[i]; 270 int mid = width()/2 + voffset[i];
261 arr.setPoints( 3, 271 arr.setPoints( 3,
262 mid - sw + 4, sw-4, 272 mid - sw + 4, sw-4,
263 mid, 0, 273 mid, 0,
264 mid + sw - 4, sw-4 ); 274 mid + sw - 4, sw-4 );
265 } 275 }
266 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down || 276 else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Down ||
267 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { 277 _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) {
268 int mid = width()/2 + voffset[i]; 278 int mid = width()/2 + voffset[i];
269 arr.setPoints( 3, 279 arr.setPoints( 3,
270 mid - sw + 4, 1-yyy, 280 mid - sw + 4, 1-yyy,
271 mid, sw-3-yyy, 281 mid, sw-3-yyy,
272 mid + sw -4, 1-yyy); 282 mid + sw -4, 1-yyy);
273 } 283 }
274 list.append( arr ); 284 list.append( arr );
275 } 285 }
276 return list; 286 return list;
277} 287}
278 288
279void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) 289void KDGanttSplitterHandle::paintEvent( QPaintEvent * )
280{ 290{
281 QPixmap buffer( size() ); 291 QPixmap buffer( size() );
282 QPainter p( &buffer ); 292 QPainter p( &buffer );
283 293
284 //LR 294 //LR
285 // Draw the splitter rectangle 295 // Draw the splitter rectangle
286 p.setBrush( colorGroup().background() ); 296 p.setBrush( colorGroup().background() );
287 p.setPen( colorGroup().foreground() ); 297 p.setPen( colorGroup().foreground() );
288 //p.drawRect( rect() ); 298 //p.drawRect( rect() );
289#ifndef DESKTOP_VERSION 299#ifndef DESKTOP_VERSION
290 if ( mMouseDown && ! _activeButton) 300 if ( mMouseDown && ! _activeButton)
291 buffer.fill( colorGroup().background().dark() ); 301 buffer.fill( colorGroup().background().dark() );
292 else 302 else
293#endif 303#endif
294 buffer.fill( colorGroup().background() ); 304 buffer.fill( colorGroup().background() );
295 //buffer.fill( backgroundColor() ); 305 //buffer.fill( backgroundColor() );
296 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); 306 // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup());
297 307
298 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size 308 int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size
299 309
300 // arrow color 310 // arrow color
301 QColor col; 311 QColor col;
302 if ( _activeButton ) 312 if ( _activeButton )
303 col = colorGroup().background().dark( 250 ); 313 col = colorGroup().background().dark( 250 );
304 else { 314 else {
305 if ( mMouseDown ) 315 if ( mMouseDown )
306 col = Qt::white; 316 col = Qt::white;
307 else 317 else
308 col = colorGroup().background().dark( 150 ); 318 col = colorGroup().background().dark( 150 );
309 } 319 }
310 //QColor col = backgroundColor().dark( 130 ); 320 //QColor col = backgroundColor().dark( 130 );
311 p.setBrush( col ); 321 p.setBrush( col );
312 p.setPen( col ); 322 p.setPen( col );
313 323
314 QValueList<QPointArray> list = buttonRegions(); 324 Q3ValueList<Q3PointArray> list = buttonRegions();
315 int index = 1; 325 int index = 1;
316 if ( mUseOffset ) 326 if ( mUseOffset )
317 p.translate( 0, 1 ); 327 p.translate( 0, 1 );
318 for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { 328 for ( Q3ValueList<Q3PointArray>::Iterator it = list.begin(); it != list.end(); ++it ) {
319 if ( index == _activeButton ) { 329 if ( index == _activeButton ) {
320 330
321 /* 331 /*
322 if ( ! _collapsed ) { 332 if ( ! _collapsed ) {
323 p.save(); 333 p.save();
324 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ), 334 // p.translate( parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftHorizontal ),
325 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) ); 335 // parentWidget()->style().pixelMetric( QStyle::PM_ButtonShiftVertical ) );
326 p.translate( -1, 0 ); 336 p.translate( -1, 0 );
327 p.drawPolygon( *it, true ); 337 p.drawPolygon( *it, true );
328 p.restore(); } else 338 p.restore(); } else
329 */ 339 */
330 p.drawPolygon( *it, true ); 340 p.drawPolygon( *it, true );
331 341
332 } 342 }
333 else { 343 else {
334 /* 344 /*
335 if ( ! _collapsed ) { 345 if ( ! _collapsed ) {
336 p.save(); 346 p.save();
337 p.translate( -1, 0 ); 347 p.translate( -1, 0 );
338 p.drawPolygon( *it, true ); 348 p.drawPolygon( *it, true );
339 p.restore(); 349 p.restore();
340 } else 350 } else
341 */ 351 */
342 p.drawPolygon( *it, true ); 352 p.drawPolygon( *it, true );
343 353
344 } 354 }
345 index++; 355 index++;
346 } 356 }
347 357
348 // Draw the lines between the arrows 358 // Draw the lines between the arrows
349 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left || 359 if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left ||
350 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { 360 s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) {
351 int mid = height()/2; 361 int mid = height()/2;
352 p.drawLine ( 1, mid - sw, 1, mid + sw ); 362 p.drawLine ( 1, mid - sw, 1, mid + sw );
353 p.drawLine ( 3, mid - sw, 3, mid + sw ); 363 p.drawLine ( 3, mid - sw, 3, mid + sw );
354 } 364 }
355 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up || 365 else if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Up ||
356 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) { 366 s->minimizeDirection() == KDGanttMinimizeSplitter::Down ) {
357 int mid = width()/2; 367 int mid = width()/2;
358 p.drawLine( mid -sw, 1, mid +sw, 1 ); 368 p.drawLine( mid -sw, 1, mid +sw, 1 );
359 p.drawLine( mid -sw, 3, mid +sw, 3 ); 369 p.drawLine( mid -sw, 3, mid +sw, 3 );
360 } 370 }
361 bitBlt( this, 0, 0, &buffer ); 371 bitBlt( this, 0, 0, &buffer );
362 372
363} 373}
364#endif 374#endif
365 375
366class QSplitterLayoutStruct 376class QSplitterLayoutStruct
367{ 377{
368public: 378public:
369 KDGanttMinimizeSplitter::ResizeMode mode; 379 KDGanttMinimizeSplitter::ResizeMode mode;
370 QCOORD sizer; 380 QCOORD sizer;
371 bool isSplitter; 381 bool isSplitter;
372 QWidget *wid; 382 QWidget *wid;
373}; 383};
374 384
375class QSplitterData 385class QSplitterData
376{ 386{
377public: 387public:
378 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {} 388 QSplitterData() : opaque( FALSE ), firstShow( TRUE ) {}
379 389
380 QPtrList<QSplitterLayoutStruct> list; 390 Q3PtrList<QSplitterLayoutStruct> list;
381 bool opaque; 391 bool opaque;
382 bool firstShow; 392 bool firstShow;
383}; 393};
384 394
385void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 395void kdganttGeomCalc( Q3MemArray<QLayoutStruct> &chain, int start, int count, int pos,
386 int space, int spacer ); 396 int space, int spacer );
387#endif // DOXYGEN_SKIP_INTERNAL 397#endif // DOXYGEN_SKIP_INTERNAL
388 398
389 399
390/*! 400/*!
391 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h 401 \class KDGanttMinimizeSplitter KDGanttMinimizeSplitter.h
392 \brief The KDGanttMinimizeSplitter class implements a splitter 402 \brief The KDGanttMinimizeSplitter class implements a splitter
393 widget with minimize buttons. 403 widget with minimize buttons.
394 404
395 This class (and its documentation) is largely a copy of Qt's 405 This class (and its documentation) is largely a copy of Qt's
396 QSplitter; the copying was necessary because QSplitter is not 406 QSplitter; the copying was necessary because QSplitter is not
397 extensible at all. QSplitter and its documentation are licensed 407 extensible at all. QSplitter and its documentation are licensed
398 according to the GPL and the Qt Professional License (if you hold 408 according to the GPL and the Qt Professional License (if you hold
399 such a license) and are (C) Trolltech AS. 409 such a license) and are (C) Trolltech AS.
400 410
401 A splitter lets the user control the size of child widgets by 411 A splitter lets the user control the size of child widgets by
402 dragging the boundary between the children. Any number of widgets 412 dragging the boundary between the children. Any number of widgets
403 may be controlled. 413 may be controlled.
404 414
405 To show a QListBox, a QListView and a QTextEdit side by side: 415 To show a QListBox, a QListView and a QTextEdit side by side:
406 416
407 \code 417 \code
408 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent ); 418 KDGanttMinimizeSplitter *split = new KDGanttMinimizeSplitter( parent );
409 QListBox *lb = new QListBox( split ); 419 QListBox *lb = new QListBox( split );
410 QListView *lv = new QListView( split ); 420 QListView *lv = new QListView( split );
411 QTextEdit *ed = new QTextEdit( split ); 421 QTextEdit *ed = new QTextEdit( split );
412 \endcode 422 \endcode
413 423
414 In KDGanttMinimizeSplitter, the boundary can be either horizontal or 424 In KDGanttMinimizeSplitter, the boundary can be either horizontal or
415 vertical. The default is horizontal (the children are side by side) 425 vertical. The default is horizontal (the children are side by side)
416 but you can use setOrientation( QSplitter::Vertical ) to set it to 426 but you can use setOrientation( QSplitter::Vertical ) to set it to
417 vertical. 427 vertical.
418 428
419 Use setResizeMode() to specify 429 Use setResizeMode() to specify
420 that a widget should keep its size when the splitter is resized. 430 that a widget should keep its size when the splitter is resized.
421 431
422 Although KDGanttMinimizeSplitter normally resizes the children only 432 Although KDGanttMinimizeSplitter normally resizes the children only
423 at the end of a resize operation, if you call setOpaqueResize( TRUE 433 at the end of a resize operation, if you call setOpaqueResize( TRUE
424 ) the widgets are resized as often as possible. 434 ) the widgets are resized as often as possible.
425 435
426 The initial distribution of size between the widgets is determined 436 The initial distribution of size between the widgets is determined
427 by the initial size of each widget. You can also use setSizes() to 437 by the initial size of each widget. You can also use setSizes() to
428 set the sizes of all the widgets. The function sizes() returns the 438 set the sizes of all the widgets. The function sizes() returns the
429 sizes set by the user. 439 sizes set by the user.
430 440
431 If you hide() a child, its space will be distributed among the other 441 If you hide() a child, its space will be distributed among the other
432 children. It will be reinstated when you show() it again. It is also 442 children. It will be reinstated when you show() it again. It is also
433 possible to reorder the widgets within the splitter using 443 possible to reorder the widgets within the splitter using
434 moveToFirst() and moveToLast(). 444 moveToFirst() and moveToLast().
435*/ 445*/
436 446
437 447
438 448
439static QSize minSize( const QWidget* /*w*/ ) 449static QSize minSize( const QWidget* /*w*/ )
440{ 450{
441 return QSize(0,0); 451 return QSize(0,0);
442} 452}
443 453
444// This is the original version of minSize 454// This is the original version of minSize
445static QSize minSizeHint( const QWidget* w ) 455static QSize minSizeHint( const QWidget* w )
446{ 456{
447 QSize min = w->minimumSize(); 457 QSize min = w->minimumSize();
448 QSize s; 458 QSize s;
449 if ( min.height() <= 0 || min.width() <= 0 ) 459 if ( min.height() <= 0 || min.width() <= 0 )
450 s = w->minimumSizeHint(); 460 s = w->minimumSizeHint();
451 if ( min.height() > 0 ) 461 if ( min.height() > 0 )
452 s.setHeight( min.height() ); 462 s.setHeight( min.height() );
453 if ( min.width() > 0 ) 463 if ( min.width() > 0 )
454 s.setWidth( min.width() ); 464 s.setWidth( min.width() );
455 return s.expandedTo(QSize(0,0)); 465 return s.expandedTo(QSize(0,0));
456} 466}
457 467
458 468
459/*! 469/*!
460 Constructs a horizontal splitter with the \a parent and \a 470 Constructs a horizontal splitter with the \a parent and \a
461 name arguments being passed on to the QFrame constructor. 471 name arguments being passed on to the QFrame constructor.
462*/ 472*/
463KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name ) 473KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( QWidget *parent, const char *name )
464 :QFrame(parent,name,WPaintUnclipped) 474 :Q3Frame(parent,name)
465{ 475{
476 setAttribute(Qt::WA_PaintUnclipped);
466 mRubberBand = 0; 477 mRubberBand = 0;
467 mFirstHandle = 0; 478 mFirstHandle = 0;
468#if QT_VERSION >= 232 479#if QT_VERSION >= 232
469 orient = Horizontal; 480 orient = Qt::Horizontal;
470 init(); 481 init();
471#endif 482#endif
472} 483}
473 484
474/*! 485/*!
475 Constructs a splitter with orientation \a o with the \a parent 486 Constructs a splitter with orientation \a o with the \a parent
476 and \a name arguments being passed on to the QFrame constructor. 487 and \a name arguments being passed on to the QFrame constructor.
477*/ 488*/
478KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Orientation o, QWidget *parent, const char *name ) 489KDGanttMinimizeSplitter::KDGanttMinimizeSplitter( Qt::Orientation o, QWidget *parent, const char *name )
479 :QFrame(parent,name,WPaintUnclipped) 490 :Q3Frame(parent,name)
480{ 491{
481 492 setAttribute(Qt::WA_PaintUnclipped);
482 mRubberBand = 0; 493 mRubberBand = 0;
483 mFirstHandle = 0; 494 mFirstHandle = 0;
484#if QT_VERSION >= 232 495#if QT_VERSION >= 232
485 orient = o; 496 orient = o;
486 init(); 497 init();
487#endif 498#endif
488} 499}
489 500
490/*! 501/*!
491 Destroys the splitter and any children. 502 Destroys the splitter and any children.
492*/ 503*/
493KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter() 504KDGanttMinimizeSplitter::~KDGanttMinimizeSplitter()
494{ 505{
495#if QT_VERSION >= 232 506#if QT_VERSION >= 232
496 data->list.setAutoDelete( TRUE ); 507 data->list.setAutoDelete( TRUE );
497 delete data; 508 delete data;
498#endif 509#endif
499 if ( mRubberBand ) 510 if ( mRubberBand )
500 delete mRubberBand; 511 delete mRubberBand;
501} 512}
502 513
503 514
504#if QT_VERSION >= 232 515#if QT_VERSION >= 232
505void KDGanttMinimizeSplitter::init() 516void KDGanttMinimizeSplitter::init()
506{ 517{
507 data = new QSplitterData; 518 data = new QSplitterData;
508 if ( orient == Horizontal ) 519 if ( orient == Qt::Horizontal )
509 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) ); 520 setSizePolicy( QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Minimum) );
510 else 521 else
511 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) ); 522 setSizePolicy( QSizePolicy(QSizePolicy::Minimum,QSizePolicy::Expanding) );
512#ifndef DESKTOP_VERSION 523#ifndef DESKTOP_VERSION
513 setOpaqueResize( false ); 524 setOpaqueResize( false );
514#else 525#else
515 setOpaqueResize( true ); 526 setOpaqueResize( true );
516#endif 527#endif
517} 528}
518#endif 529#endif
519 530
520 531
521void KDGanttMinimizeSplitter::toggle() 532void KDGanttMinimizeSplitter::toggle()
522{ 533{
523 if ( mFirstHandle ) 534 if ( mFirstHandle )
524 mFirstHandle->toggle(); 535 mFirstHandle->toggle();
525 else 536 else
526 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available "); 537 qDebug("KDGanttMinimizeSplitter::toggle::sorry, handle not available ");
527 538
528} 539}
529 540
530 541
531/*! 542/*!
532 \brief the orientation of the splitter 543 \brief the orientation of the splitter
533 544
534 By default the orientation is horizontal (the widgets are side by side). 545 By default the orientation is horizontal (the widgets are side by side).
535 The possible orientations are Qt:Vertical and Qt::Horizontal (the default). 546 The possible orientations are Qt:Vertical and Qt::Horizontal (the default).
536*/ 547*/
537void KDGanttMinimizeSplitter::setOrientation( Orientation o ) 548void KDGanttMinimizeSplitter::setOrientation( Qt::Orientation o )
538{ 549{
539#if QT_VERSION >= 232 550#if QT_VERSION >= 232
540 if ( orient == o ) 551 if ( orient == o )
541 return; 552 return;
542 orient = o; 553 orient = o;
543 554
544 if ( orient == Horizontal ) 555 if ( orient == Qt::Horizontal )
545 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); 556 setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) );
546 else 557 else
547 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 558 setSizePolicy( QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Expanding ) );
548 559
549 QSplitterLayoutStruct *s = data->list.first(); 560 QSplitterLayoutStruct *s = data->list.first();
550 while ( s ) { 561 while ( s ) {
551 if ( s->isSplitter ) 562 if ( s->isSplitter )
552 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o ); 563 ((KDGanttSplitterHandle*)s->wid)->setOrientation( o );
553 s = data->list.next(); // ### next at end of loop, no iterator 564 s = data->list.next(); // ### next at end of loop, no iterator
554 } 565 }
555 recalc( isVisible() ); 566 recalc( isVisible() );
556#endif 567#endif
557} 568}
558 569
559 570
560#if QT_VERSION >= 232 571#if QT_VERSION >= 232
561/*! 572/*!
562 \reimp 573 \reimp
563*/ 574*/
564void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * ) 575void KDGanttMinimizeSplitter::resizeEvent( QResizeEvent * )
565{ 576{
566 doResize(); 577 doResize();
567} 578}
568 579
569 580
570/* 581/*
571 Inserts the widget \a w at the end (or at the beginning if \a first 582 Inserts the widget \a w at the end (or at the beginning if \a first
572 is TRUE) of the splitter's list of widgets. 583 is TRUE) of the splitter's list of widgets.
573 584
574 It is the responsibility of the caller of this function to make sure 585 It is the responsibility of the caller of this function to make sure
575 that \a w is not already in the splitter and to call recalcId if 586 that \a w is not already in the splitter and to call recalcId if
576 needed. (If \a first is TRUE, then recalcId is very probably 587 needed. (If \a first is TRUE, then recalcId is very probably
577 needed.) 588 needed.)
578*/ 589*/
579QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first ) 590QSplitterLayoutStruct *KDGanttMinimizeSplitter::addWidget( QWidget *w, bool first )
580{ 591{
581 QSplitterLayoutStruct *s; 592 QSplitterLayoutStruct *s;
582 KDGanttSplitterHandle *newHandle = 0; 593 KDGanttSplitterHandle *newHandle = 0;
583 if ( data->list.count() > 0 ) { 594 if ( data->list.count() > 0 ) {
584 s = new QSplitterLayoutStruct; 595 s = new QSplitterLayoutStruct;
585 s->mode = KeepSize; 596 s->mode = KeepSize;
586 QString tmp = "qt_splithandle_"; 597 QString tmp = "qt_splithandle_";
587 tmp += w->name(); 598 tmp += w->name();
588 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() ); 599 newHandle = new KDGanttSplitterHandle( orientation(), this, tmp.latin1() );
589 if ( ! mFirstHandle ) 600 if ( ! mFirstHandle )
590 mFirstHandle = newHandle; 601 mFirstHandle = newHandle;
591 s->wid = newHandle; 602 s->wid = newHandle;
592 newHandle->setId(data->list.count()); 603 newHandle->setId(data->list.count());
593 s->isSplitter = TRUE; 604 s->isSplitter = TRUE;
594 s->sizer = pick( newHandle->sizeHint() ); 605 s->sizer = pick( newHandle->sizeHint() );
595 if ( first ) 606 if ( first )
596 data->list.insert( 0, s ); 607 data->list.insert( 0, s );
597 else 608 else
598 data->list.append( s ); 609 data->list.append( s );
599 } 610 }
600 s = new QSplitterLayoutStruct; 611 s = new QSplitterLayoutStruct;
601 s->mode = Stretch; 612 s->mode = Stretch;
602 s->wid = w; 613 s->wid = w;
603 if ( !testWState( WState_Resized ) && w->sizeHint().isValid() ) 614 if ( !testAttribute( Qt::WA_Resized ) && w->sizeHint().isValid() )
604 s->sizer = pick( w->sizeHint() ); 615 s->sizer = pick( w->sizeHint() );
605 else 616 else
606 s->sizer = pick( w->size() ); 617 s->sizer = pick( w->size() );
607 s->isSplitter = FALSE; 618 s->isSplitter = FALSE;
608 if ( first ) 619 if ( first )
609 data->list.insert( 0, s ); 620 data->list.insert( 0, s );
610 else 621 else
611 data->list.append( s ); 622 data->list.append( s );
612 if ( newHandle && isVisible() ) 623 if ( newHandle && isVisible() )
613 newHandle->show(); //will trigger sending of post events 624 newHandle->show(); //will trigger sending of post events
614 return s; 625 return s;
615} 626}
616 627
617 628
618/*! 629/*!
619 Tells the splitter that a child widget has been inserted or removed. 630 Tells the splitter that a child widget has been inserted or removed.
620 The event is passed in \a c. 631 The event is passed in \a c.
621*/ 632*/
622void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) 633void KDGanttMinimizeSplitter::childEvent( QChildEvent *c )
623{ 634{
624 if ( c->type() == QEvent::ChildInserted ) { 635 if ( c->type() == QEvent::ChildAdded ) {
625 if ( !c->child()->isWidgetType() ) 636 if ( !c->child()->isWidgetType() )
626 return; 637 return;
627 638
628 if ( ((QWidget*)c->child())->testWFlags( WType_TopLevel ) ) 639 QWidget *cw = (QWidget*)c->child();
640
641 if ( (cw->windowFlags())&Qt::Window )
642 return;
643
644 // avoid infinite recursion
645 if(cw->objectName().startsWith("qt_splithandle_"))
629 return; 646 return;
630 647
631 QSplitterLayoutStruct *s = data->list.first(); 648 QSplitterLayoutStruct *s = data->list.first();
632 while ( s ) { 649 while ( s ) {
633 if ( s->wid == c->child() ) 650 if ( s->wid == cw )
634 return; 651 return;
635 s = data->list.next(); 652 s = data->list.next();
636 } 653 }
637 addWidget( (QWidget*)c->child() ); 654 addWidget( cw );
638 recalc( isVisible() ); 655 recalc( isVisible() );
639 656
640 } else if ( c->type() == QEvent::ChildRemoved ) { 657 } else if ( c->type() == QEvent::ChildRemoved ) {
641 QSplitterLayoutStruct *p = 0; 658 QSplitterLayoutStruct *p = 0;
642 if ( data->list.count() > 1 ) 659 if ( data->list.count() > 1 )
643 p = data->list.at(1); //remove handle _after_ first widget. 660 p = data->list.at(1); //remove handle _after_ first widget.
644 QSplitterLayoutStruct *s = data->list.first(); 661 QSplitterLayoutStruct *s = data->list.first();
645 while ( s ) { 662 while ( s ) {
646 if ( s->wid == c->child() ) { 663 if ( s->wid == c->child() ) {
647 data->list.removeRef( s ); 664 data->list.removeRef( s );
648 delete s; 665 delete s;
649 if ( p && p->isSplitter ) { 666 if ( p && p->isSplitter ) {
650 data->list.removeRef( p ); 667 data->list.removeRef( p );
651 delete p->wid; //will call childEvent 668 delete p->wid; //will call childEvent
652 delete p; 669 delete p;
653 } 670 }
654 recalcId(); 671 recalcId();
655 doResize(); 672 doResize();
656 return; 673 return;
657 } 674 }
658 p = s; 675 p = s;
659 s = data->list.next(); 676 s = data->list.next();
660 } 677 }
661 } 678 }
662} 679}
663 680
664 681
665/*! 682/*!
666 Shows a rubber band at position \a p. If \a p is negative, the 683 Shows a rubber band at position \a p. If \a p is negative, the
667 rubber band is removed. 684 rubber band is removed.
668*/ 685*/
669void KDGanttMinimizeSplitter::setRubberband( int p ) 686void KDGanttMinimizeSplitter::setRubberband( int p )
670{ 687{
671#ifdef DESKTOP_VERSION 688#ifdef DESKTOP_VERSION
672 QPainter paint( this ); 689 QPainter paint( this );
673 paint.setPen( gray ); 690 paint.setPen( Qt::gray );
674 paint.setBrush( gray ); 691 paint.setBrush( Qt::gray );
675 paint.setRasterOp( XorROP ); 692 paint.setCompositionMode( QPainter::CompositionMode_Xor );
676 QRect r = contentsRect(); 693 QRect r = contentsRect();
677 const int rBord = 3; //Themable???? 694 const int rBord = 3; //Themable????
678#if QT_VERSION >= 0x030000 695#if QT_VERSION >= 0x030000
679 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 696 int sw = style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this);
680#else 697#else
681 int sw = style().splitterWidth(); 698 int sw = style().splitterWidth();
682#endif 699#endif
683 if ( orient == Horizontal ) { 700 if ( orient == Qt::Horizontal ) {
684 if ( opaqueOldPos >= 0 ) 701 if ( opaqueOldPos >= 0 )
685 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), 702 paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(),
686 2*rBord, r.height() ); 703 2*rBord, r.height() );
687 if ( p >= 0 ) 704 if ( p >= 0 )
688 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); 705 paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() );
689 } else { 706 } else {
690 if ( opaqueOldPos >= 0 ) 707 if ( opaqueOldPos >= 0 )
691 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, 708 paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord,
692 r.width(), 2*rBord ); 709 r.width(), 2*rBord );
693 if ( p >= 0 ) 710 if ( p >= 0 )
694 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); 711 paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord );
695 } 712 }
696 opaqueOldPos = p; 713 opaqueOldPos = p;
697#else 714#else
698 if ( !mRubberBand ) { 715 if ( !mRubberBand ) {
699 mRubberBand = new KDRubberBand( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); 716 mRubberBand = new KDRubberBand( 0, "rubber", Qt::WStyle_NoBorder | Qt::WStyle_Customize | Qt::WStyle_StaysOnTop);
700 mRubberBand->setFrameStyle( Box | Raised ); 717 mRubberBand->setFrameStyle( Box | Raised );
701 //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); 718 //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) );
702 mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() )); 719 mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() ));
703 } 720 }
704 QRect r = contentsRect(); 721 QRect r = contentsRect();
705 static int rBord = 0; //Themable???? 722 static int rBord = 0; //Themable????
706 if ( !rBord ) { 723 if ( !rBord ) {
707 if (QApplication::desktop()->width() <= 320 ) 724 if (QApplication::desktop()->width() <= 320 )
708 rBord = 3; 725 rBord = 3;
709 else 726 else
710 rBord = 4; 727 rBord = 4;
711 } 728 }
712 int sw = style().splitterWidth(); 729 int sw = style().splitterWidth();
713 if ( orient == Horizontal ) { 730 if ( orient == Qt::Horizontal ) {
714 if ( p >= 0 ) { 731 if ( p >= 0 ) {
715 QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); 732 QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y()));
716 mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); 733 mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() );
717 } 734 }
718 } else { 735 } else {
719 if ( p >= 0 ) { 736 if ( p >= 0 ) {
720 QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); 737 QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord));
721 mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); 738 mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord);
722 } 739 }
723 } 740 }
724 opaqueOldPos = p; 741 opaqueOldPos = p;
725 if ( ! mRubberBand->isVisible() ) { 742 if ( ! mRubberBand->isVisible() ) {
726 mRubberBand->show(); 743 mRubberBand->show();
727 } 744 }
728#endif 745#endif
729} 746}
730 747
731 748
732/*! \reimp */ 749/*! \reimp */
733bool KDGanttMinimizeSplitter::event( QEvent *e ) 750bool KDGanttMinimizeSplitter::event( QEvent *e )
734{ 751{
735 if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { 752 if ( e->type() == QEvent::LayoutRequest || ( e->type() == QEvent::Show && data->firstShow ) ) {
736 recalc( isVisible() ); 753 recalc( isVisible() );
737 if ( e->type() == QEvent::Show ) 754 if ( e->type() == QEvent::Show )
738 data->firstShow = FALSE; 755 data->firstShow = FALSE;
739 } 756 }
740 return QWidget::event( e ); 757 return QWidget::event( e );
741} 758}
742 759
743 760
744/*! 761/*!
745 \obsolete 762 \obsolete
746 763
747 Draws the splitter handle in the rectangle described by \a x, \a y, 764 Draws the splitter handle in the rectangle described by \a x, \a y,
748 \a w, \a h using painter \a p. 765 \a w, \a h using painter \a p.
749 \sa QStyle::drawPrimitive() 766 \sa QStyle::drawPrimitive()
750*/ 767*/
751void KDGanttMinimizeSplitter::drawSplitter( QPainter *p, 768void KDGanttMinimizeSplitter::drawSplitter( QPainter *p,
752 QCOORD x, QCOORD y, QCOORD w, QCOORD h ) 769 QCOORD x, QCOORD y, QCOORD w, QCOORD h )
753{ 770{
754#if 0 771#if 0
755 // LR 772 // LR
756 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(), 773 style().drawPrimitive(QStyle::PE_Splitter, p, QRect(x, y, w, h), colorGroup(),
757 (orientation() == Qt::Horizontal ? 774 (orientation() == Qt::Horizontal ?
758 QStyle::Style_Horizontal : 0)); 775 QStyle::State_Horizontal : 0));
759#endif 776#endif
760} 777}
761 778
762 779
763/*! 780/*!
764 Returns the id of the splitter to the right of or below the widget \a w, 781 Returns the id of the splitter to the right of or below the widget \a w,
765 or 0 if there is no such splitter 782 or 0 if there is no such splitter
766 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end). 783 (i.e. it is either not in this KDGanttMinimizeSplitter or it is at the end).
767*/ 784*/
768int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const 785int KDGanttMinimizeSplitter::idAfter( QWidget* w ) const
769{ 786{
770 QSplitterLayoutStruct *s = data->list.first(); 787 QSplitterLayoutStruct *s = data->list.first();
771 bool seen_w = FALSE; 788 bool seen_w = FALSE;
772 while ( s ) { 789 while ( s ) {
773 if ( s->isSplitter && seen_w ) 790 if ( s->isSplitter && seen_w )
774 return data->list.at(); 791 return data->list.at();
775 if ( !s->isSplitter && s->wid == w ) 792 if ( !s->isSplitter && s->wid == w )
776 seen_w = TRUE; 793 seen_w = TRUE;
777 s = data->list.next(); 794 s = data->list.next();
778 } 795 }
779 return 0; 796 return 0;
780} 797}
781 798
782 799
783/*! 800/*!
784 Moves the left/top edge of the splitter handle with id \a id as 801 Moves the left/top edge of the splitter handle with id \a id as
785 close as possible to position \a p, which is the distance from the 802 close as possible to position \a p, which is the distance from the
786 left (or top) edge of the widget. 803 left (or top) edge of the widget.
787 804
788 For Arabic and Hebrew the layout is reversed, and using this 805 For Arabic and Hebrew the layout is reversed, and using this
789 function to set the position of the splitter might lead to 806 function to set the position of the splitter might lead to
790 unexpected results, since in Arabic and Hebrew the position of 807 unexpected results, since in Arabic and Hebrew the position of
791 splitter one is to the left of the position of splitter zero. 808 splitter one is to the left of the position of splitter zero.
792 809
793 \sa idAfter() 810 \sa idAfter()
794*/ 811*/
795void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id ) 812void KDGanttMinimizeSplitter::moveSplitter( QCOORD p, int id )
796{ 813{
797 p = adjustPos( p, id ); 814 p = adjustPos( p, id );
798 QSplitterLayoutStruct *s = data->list.at(id); 815 QSplitterLayoutStruct *s = data->list.at(id);
799 int oldP = orient == Horizontal ? s->wid->x() : s->wid->y(); 816 int oldP = orient == Qt::Horizontal ? s->wid->x() : s->wid->y();
800 bool upLeft; 817 bool upLeft;
801 if ( false && orient == Horizontal ) { 818 if ( false && orient == Qt::Horizontal ) {
802 p += s->wid->width(); 819 p += s->wid->width();
803 upLeft = p > oldP; 820 upLeft = p > oldP;
804 } else 821 } else
805 upLeft = p < oldP; 822 upLeft = p < oldP;
806 823
807 moveAfter( p, id, upLeft ); 824 moveAfter( p, id, upLeft );
808 moveBefore( p-1, id-1, upLeft ); 825 moveBefore( p-1, id-1, upLeft );
809 826
810 storeSizes(); 827 storeSizes();
811} 828}
812 829
813 830
814void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter ) 831void KDGanttMinimizeSplitter::setG( QWidget *w, int p, int s, bool isSplitter )
815{ 832{
816 if ( orient == Horizontal ) { 833 if ( orient == Qt::Horizontal ) {
817 if ( false && orient == Horizontal && !isSplitter ) 834 if ( false && orient == Qt::Horizontal && !isSplitter )
818 p = contentsRect().width() - p - s; 835 p = contentsRect().width() - p - s;
819 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() ); 836 w->setGeometry( p, contentsRect().y(), s, contentsRect().height() );
820 } else 837 } else
821 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s ); 838 w->setGeometry( contentsRect().x(), p, contentsRect().width(), s );
822} 839}
823 840
824 841
825/* 842/*
826 Places the right/bottom edge of the widget at \a id at position \a pos. 843 Places the right/bottom edge of the widget at \a id at position \a pos.
827 844
828 \sa idAfter() 845 \sa idAfter()
829*/ 846*/
830void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft ) 847void KDGanttMinimizeSplitter::moveBefore( int pos, int id, bool upLeft )
831{ 848{
832 if( id < 0 ) 849 if( id < 0 )
833 return; 850 return;
834 QSplitterLayoutStruct *s = data->list.at(id); 851 QSplitterLayoutStruct *s = data->list.at(id);
835 if ( !s ) 852 if ( !s )
836 return; 853 return;
837 QWidget *w = s->wid; 854 QWidget *w = s->wid;
838 if ( w->isHidden() ) { 855 if ( w->isHidden() ) {
839 moveBefore( pos, id-1, upLeft ); 856 moveBefore( pos, id-1, upLeft );
840 } else if ( s->isSplitter ) { 857 } else if ( s->isSplitter ) {
841 int pos1, pos2; 858 int pos1, pos2;
842 int dd = s->sizer; 859 int dd = s->sizer;
843 if( false && orient == Horizontal ) { 860 if( false && orient == Qt::Horizontal ) {
844 pos1 = pos; 861 pos1 = pos;
845 pos2 = pos + dd; 862 pos2 = pos + dd;
846 } else { 863 } else {
847 pos2 = pos - dd; 864 pos2 = pos - dd;
848 pos1 = pos2 + 1; 865 pos1 = pos2 + 1;
849 } 866 }
850 if ( upLeft ) { 867 if ( upLeft ) {
851 setG( w, pos1, dd, TRUE ); 868 setG( w, pos1, dd, TRUE );
852 moveBefore( pos2, id-1, upLeft ); 869 moveBefore( pos2, id-1, upLeft );
853 } else { 870 } else {
854 moveBefore( pos2, id-1, upLeft ); 871 moveBefore( pos2, id-1, upLeft );
855 setG( w, pos1, dd, TRUE ); 872 setG( w, pos1, dd, TRUE );
856 } 873 }
857 } else { 874 } else {
858 int dd, newLeft, nextPos; 875 int dd, newLeft, nextPos;
859 if( false && orient == Horizontal ) { 876 if( false && orient == Qt::Horizontal ) {
860 dd = w->geometry().right() - pos; 877 dd = w->geometry().right() - pos;
861 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 878 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
862 newLeft = pos+1; 879 newLeft = pos+1;
863 nextPos = newLeft + dd; 880 nextPos = newLeft + dd;
864 } else { 881 } else {
865 dd = pos - pick( w->pos() ) + 1; 882 dd = pos - pick( w->pos() ) + 1;
866 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 883 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
867 newLeft = pos-dd+1; 884 newLeft = pos-dd+1;
868 nextPos = newLeft - 1; 885 nextPos = newLeft - 1;
869 } 886 }
870 setG( w, newLeft, dd, TRUE ); 887 setG( w, newLeft, dd, TRUE );
871 moveBefore( nextPos, id-1, upLeft ); 888 moveBefore( nextPos, id-1, upLeft );
872 } 889 }
873} 890}
874 891
875 892
876/* 893/*
877 Places the left/top edge of the widget at \a id at position \a pos. 894 Places the left/top edge of the widget at \a id at position \a pos.
878 895
879 \sa idAfter() 896 \sa idAfter()
880*/ 897*/
881void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft ) 898void KDGanttMinimizeSplitter::moveAfter( int pos, int id, bool upLeft )
882{ 899{
883 QSplitterLayoutStruct *s = id < int(data->list.count()) ? 900 QSplitterLayoutStruct *s = id < int(data->list.count()) ?
884 data->list.at(id) : 0; 901 data->list.at(id) : 0;
885 if ( !s ) 902 if ( !s )
886 return; 903 return;
887 QWidget *w = s->wid; 904 QWidget *w = s->wid;
888 if ( w->isHidden() ) { 905 if ( w->isHidden() ) {
889 moveAfter( pos, id+1, upLeft ); 906 moveAfter( pos, id+1, upLeft );
890 } else if ( pick( w->pos() ) == pos ) { 907 } else if ( pick( w->pos() ) == pos ) {
891 //No need to do anything if it's already there. 908 //No need to do anything if it's already there.
892 return; 909 return;
893 } else if ( s->isSplitter ) { 910 } else if ( s->isSplitter ) {
894 int dd = s->sizer; 911 int dd = s->sizer;
895 int pos1, pos2; 912 int pos1, pos2;
896 if( false && orient == Horizontal ) { 913 if( false && orient == Qt::Horizontal ) {
897 pos2 = pos - dd; 914 pos2 = pos - dd;
898 pos1 = pos2 + 1; 915 pos1 = pos2 + 1;
899 } else { 916 } else {
900 pos1 = pos; 917 pos1 = pos;
901 pos2 = pos + dd; 918 pos2 = pos + dd;
902 } 919 }
903 if ( upLeft ) { 920 if ( upLeft ) {
904 setG( w, pos1, dd, TRUE ); 921 setG( w, pos1, dd, TRUE );
905 moveAfter( pos2, id+1, upLeft ); 922 moveAfter( pos2, id+1, upLeft );
906 } else { 923 } else {
907 moveAfter( pos2, id+1, upLeft ); 924 moveAfter( pos2, id+1, upLeft );
908 setG( w, pos1, dd, TRUE ); 925 setG( w, pos1, dd, TRUE );
909 } 926 }
910 } else { 927 } else {
911 int left = pick( w->pos() ); 928 int left = pick( w->pos() );
912 int right, dd,/* newRight,*/ newLeft, nextPos; 929 int right, dd,/* newRight,*/ newLeft, nextPos;
913 if ( false && orient == Horizontal ) { 930 if ( false && orient == Qt::Horizontal ) {
914 dd = pos - left + 1; 931 dd = pos - left + 1;
915 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 932 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
916 newLeft = pos-dd+1; 933 newLeft = pos-dd+1;
917 nextPos = newLeft - 1; 934 nextPos = newLeft - 1;
918 } else { 935 } else {
919 right = pick( w->geometry().bottomRight() ); 936 right = pick( w->geometry().bottomRight() );
920 dd = right - pos + 1; 937 dd = right - pos + 1;
921 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize()))); 938 dd = QMAX( pick(minSize(w)), QMIN(dd, pick(w->maximumSize())));
922 /*newRight = pos+dd-1;*/ 939 /*newRight = pos+dd-1;*/
923 newLeft = pos; 940 newLeft = pos;
924 nextPos = newLeft + dd; 941 nextPos = newLeft + dd;
925 } 942 }
926 setG( w, newLeft, dd, TRUE ); 943 setG( w, newLeft, dd, TRUE );
927 /*if( right != newRight )*/ 944 /*if( right != newRight )*/
928 moveAfter( nextPos, id+1, upLeft ); 945 moveAfter( nextPos, id+1, upLeft );
929 } 946 }
930} 947}
931 948
932 949
933void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max ) 950void KDGanttMinimizeSplitter::expandPos( int id, int* min, int* max )
934{ 951{
935 QSplitterLayoutStruct *s = data->list.at(id-1); 952 QSplitterLayoutStruct *s = data->list.at(id-1);
936 QWidget* w = s->wid; 953 QWidget* w = s->wid;
937 *min = pick( w->mapToParent( QPoint(0,0) ) ); 954 *min = pick( w->mapToParent( QPoint(0,0) ) );
938 955
939 if ( (uint) id == data->list.count() ) { 956 if ( (uint) id == data->list.count() ) {
940 pick( size() ); 957 pick( size() );
941 } 958 }
942 else { 959 else {
943 QSplitterLayoutStruct *s = data->list.at(id+1); 960 QSplitterLayoutStruct *s = data->list.at(id+1);
944 QWidget* w = s->wid; 961 QWidget* w = s->wid;
945 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8; 962 *max = pick( w->mapToParent( QPoint( w->width(), w->height() ) ) ) -8;
946 } 963 }
947} 964}
948 965
949 966
950/*! 967/*!
951 Returns the valid range of the splitter with id \a id in \a *min and \a *max. 968 Returns the valid range of the splitter with id \a id in \a *min and \a *max.
952 969
953 \sa idAfter() 970 \sa idAfter()
954*/ 971*/
955 972
956void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max ) 973void KDGanttMinimizeSplitter::getRange( int id, int *min, int *max )
957{ 974{
958 int minB = 0;//before 975 int minB = 0;//before
959 int maxB = 0; 976 int maxB = 0;
960 int minA = 0; 977 int minA = 0;
961 int maxA = 0;//after 978 int maxA = 0;//after
962 int n = data->list.count(); 979 int n = data->list.count();
963 if ( id < 0 || id >= n ) 980 if ( id < 0 || id >= n )
964 return; 981 return;
965 int i; 982 int i;
966 for ( i = 0; i < id; i++ ) { 983 for ( i = 0; i < id; i++ ) {
967 QSplitterLayoutStruct *s = data->list.at(i); 984 QSplitterLayoutStruct *s = data->list.at(i);
968 if ( s->wid->isHidden() ) { 985 if ( s->wid->isHidden() ) {
969 //ignore 986 //ignore
970 } else if ( s->isSplitter ) { 987 } else if ( s->isSplitter ) {
971 minB += s->sizer; 988 minB += s->sizer;
972 maxB += s->sizer; 989 maxB += s->sizer;
973 } else { 990 } else {
974 minB += pick( minSize(s->wid) ); 991 minB += pick( minSize(s->wid) );
975 maxB += pick( s->wid->maximumSize() ); 992 maxB += pick( s->wid->maximumSize() );
976 } 993 }
977 } 994 }
978 for ( i = id; i < n; i++ ) { 995 for ( i = id; i < n; i++ ) {
979 QSplitterLayoutStruct *s = data->list.at(i); 996 QSplitterLayoutStruct *s = data->list.at(i);
980 if ( s->wid->isHidden() ) { 997 if ( s->wid->isHidden() ) {
981 //ignore 998 //ignore
982 } else if ( s->isSplitter ) { 999 } else if ( s->isSplitter ) {
983 minA += s->sizer; 1000 minA += s->sizer;
984 maxA += s->sizer; 1001 maxA += s->sizer;
985 } else { 1002 } else {
986 minA += pick( minSize(s->wid) ); 1003 minA += pick( minSize(s->wid) );
987 maxA += pick( s->wid->maximumSize() ); 1004 maxA += pick( s->wid->maximumSize() );
988 } 1005 }
989 } 1006 }
990 QRect r = contentsRect(); 1007 QRect r = contentsRect();
991 if ( orient == Horizontal && false ) { 1008 if ( orient == Qt::Horizontal && false ) {
992#if QT_VERSION >= 0x030000 1009#if QT_VERSION >= 0x030000
993 int splitterWidth = style().pixelMetric(QStyle::PM_SplitterWidth, this); 1010 int splitterWidth = style()->pixelMetric(QStyle::PM_SplitterWidth, 0,this);
994#else 1011#else
995 int splitterWidth = style().splitterWidth(); 1012 int splitterWidth = style().splitterWidth();
996#endif 1013#endif
997 1014
998 if ( min ) 1015 if ( min )
999 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth; 1016 *min = pick(r.topRight()) - QMIN( maxB, pick(r.size())-minA ) - splitterWidth;
1000 if ( max ) 1017 if ( max )
1001 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth; 1018 *max = pick(r.topRight()) - QMAX( minB, pick(r.size())-maxA ) - splitterWidth;
1002 } else { 1019 } else {
1003 if ( min ) 1020 if ( min )
1004 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA ); 1021 *min = pick(r.topLeft()) + QMAX( minB, pick(r.size())-maxA );
1005 if ( max ) 1022 if ( max )
1006 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA ); 1023 *max = pick(r.topLeft()) + QMIN( maxB, pick(r.size())-minA );
1007 } 1024 }
1008} 1025}
1009 1026
1010 1027
1011/*! 1028/*!
1012 Returns the closest legal position to \a p of the splitter with id \a id. 1029 Returns the closest legal position to \a p of the splitter with id \a id.
1013 1030
1014 \sa idAfter() 1031 \sa idAfter()
1015*/ 1032*/
1016 1033
1017int KDGanttMinimizeSplitter::adjustPos( int p, int id ) 1034int KDGanttMinimizeSplitter::adjustPos( int p, int id )
1018{ 1035{
1019 int min = 0; 1036 int min = 0;
1020 int max = 0; 1037 int max = 0;
1021 getRange( id, &min, &max ); 1038 getRange( id, &min, &max );
1022 p = QMAX( min, QMIN( p, max ) ); 1039 p = QMAX( min, QMIN( p, max ) );
1023 1040
1024 return p; 1041 return p;
1025} 1042}
1026 1043
1027 1044
1028void KDGanttMinimizeSplitter::doResize() 1045void KDGanttMinimizeSplitter::doResize()
1029{ 1046{
1030 QRect r = contentsRect(); 1047 QRect r = contentsRect();
1031 int i; 1048 int i;
1032 int n = data->list.count(); 1049 int n = data->list.count();
1033 QMemArray<QLayoutStruct> a( n ); 1050 Q3MemArray<QLayoutStruct> a( n );
1034 for ( i = 0; i< n; i++ ) { 1051 for ( i = 0; i< n; i++ ) {
1035 a[i].init(); 1052 a[i].init();
1036 QSplitterLayoutStruct *s = data->list.at(i); 1053 QSplitterLayoutStruct *s = data->list.at(i);
1037 if ( s->wid->isHidden() ) { 1054 if ( s->wid->isHidden() ) {
1038 a[i].stretch = 0; 1055 a[i].stretch = 0;
1039 a[i].sizeHint = a[i].minimumSize = 0; 1056 a[i].sizeHint = a[i].minimumSize = 0;
1040 a[i].maximumSize = 0; 1057 a[i].maximumSize = 0;
1041 } else if ( s->isSplitter ) { 1058 } else if ( s->isSplitter ) {
1042 a[i].stretch = 0; 1059 a[i].stretch = 0;
1043 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer; 1060 a[i].sizeHint = a[i].minimumSize = a[i].maximumSize = s->sizer;
1044 a[i].empty = FALSE; 1061 a[i].empty = FALSE;
1045 } else if ( s->mode == KeepSize ) { 1062 } else if ( s->mode == KeepSize ) {
1046 a[i].stretch = 0; 1063 a[i].stretch = 0;
1047 a[i].minimumSize = pick( minSize(s->wid) ); 1064 a[i].minimumSize = pick( minSize(s->wid) );
1048 a[i].sizeHint = s->sizer; 1065 a[i].sizeHint = s->sizer;
1049 a[i].maximumSize = pick( s->wid->maximumSize() ); 1066 a[i].maximumSize = pick( s->wid->maximumSize() );
1050 a[i].empty = FALSE; 1067 a[i].empty = FALSE;
1051 } else if ( s->mode == FollowSizeHint ) { 1068 } else if ( s->mode == FollowSizeHint ) {
1052 a[i].stretch = 0; 1069 a[i].stretch = 0;
1053 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() ); 1070 a[i].minimumSize = a[i].sizeHint = pick( s->wid->sizeHint() );
1054 a[i].maximumSize = pick( s->wid->maximumSize() ); 1071 a[i].maximumSize = pick( s->wid->maximumSize() );
1055 a[i].empty = FALSE; 1072 a[i].empty = FALSE;
1056 } else { //proportional 1073 } else { //proportional
1057 a[i].stretch = s->sizer; 1074 a[i].stretch = s->sizer;
1058 a[i].maximumSize = pick( s->wid->maximumSize() ); 1075 a[i].maximumSize = pick( s->wid->maximumSize() );
1059 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) ); 1076 a[i].sizeHint = a[i].minimumSize = pick( minSize(s->wid) );
1060 a[i].empty = FALSE; 1077 a[i].empty = FALSE;
1061 } 1078 }
1062 } 1079 }
1063 1080
1064 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 ); 1081 kdganttGeomCalc( a, 0, n, pick( r.topLeft() ), pick( r.size() ), 0 );
1065 1082
1066 for ( i = 0; i< n; i++ ) { 1083 for ( i = 0; i< n; i++ ) {
1067 QSplitterLayoutStruct *s = data->list.at(i); 1084 QSplitterLayoutStruct *s = data->list.at(i);
1068 setG( s->wid, a[i].pos, a[i].size ); 1085 setG( s->wid, a[i].pos, a[i].size );
1069 } 1086 }
1070 1087
1071} 1088}
1072 1089
1073 1090
1074void KDGanttMinimizeSplitter::recalc( bool update ) 1091void KDGanttMinimizeSplitter::recalc( bool update )
1075{ 1092{
1076 int fi = 2*frameWidth(); 1093 int fi = 2*frameWidth();
1077 int maxl = fi; 1094 int maxl = fi;
1078 int minl = fi; 1095 int minl = fi;
1079 int maxt = QWIDGETSIZE_MAX; 1096 int maxt = QWIDGETSIZE_MAX;
1080 int mint = fi; 1097 int mint = fi;
1081 int n = data->list.count(); 1098 int n = data->list.count();
1082 bool first = TRUE; 1099 bool first = TRUE;
1083 /* 1100 /*
1084 The splitter before a hidden widget is always hidden. 1101 The splitter before a hidden widget is always hidden.
1085 The splitter before the first visible widget is hidden. 1102 The splitter before the first visible widget is hidden.
1086 The splitter before any other visible widget is visible. 1103 The splitter before any other visible widget is visible.
1087 */ 1104 */
1088 for ( int i = 0; i< n; i++ ) { 1105 for ( int i = 0; i< n; i++ ) {
1089 QSplitterLayoutStruct *s = data->list.at(i); 1106 QSplitterLayoutStruct *s = data->list.at(i);
1090 if ( !s->isSplitter ) { 1107 if ( !s->isSplitter ) {
1091 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0; 1108 QSplitterLayoutStruct *p = (i > 0) ? p = data->list.at( i-1 ) : 0;
1092 if ( p && p->isSplitter ) 1109 if ( p && p->isSplitter )
1093 if ( first || s->wid->isHidden() ) 1110 if ( first || s->wid->isHidden() )
1094 p->wid->hide(); //may trigger new recalc 1111 p->wid->hide(); //may trigger new recalc
1095 else 1112 else
1096 p->wid->show(); //may trigger new recalc 1113 p->wid->show(); //may trigger new recalc
1097 if ( !s->wid->isHidden() ) 1114 if ( !s->wid->isHidden() )
1098 first = FALSE; 1115 first = FALSE;
1099 } 1116 }
1100 } 1117 }
1101 1118
1102 bool empty=TRUE; 1119 bool empty=TRUE;
1103 for ( int j = 0; j< n; j++ ) { 1120 for ( int j = 0; j< n; j++ ) {
1104 QSplitterLayoutStruct *s = data->list.at(j); 1121 QSplitterLayoutStruct *s = data->list.at(j);
1105 if ( !s->wid->isHidden() ) { 1122 if ( !s->wid->isHidden() ) {
1106 empty = FALSE; 1123 empty = FALSE;
1107 if ( s->isSplitter ) { 1124 if ( s->isSplitter ) {
1108 minl += s->sizer; 1125 minl += s->sizer;
1109 maxl += s->sizer; 1126 maxl += s->sizer;
1110 } else { 1127 } else {
1111 QSize minS = minSize(s->wid); 1128 QSize minS = minSize(s->wid);
1112 minl += pick( minS ); 1129 minl += pick( minS );
1113 maxl += pick( s->wid->maximumSize() ); 1130 maxl += pick( s->wid->maximumSize() );
1114 mint = QMAX( mint, trans( minS )); 1131 mint = QMAX( mint, trans( minS ));
1115 int tm = trans( s->wid->maximumSize() ); 1132 int tm = trans( s->wid->maximumSize() );
1116 if ( tm > 0 ) 1133 if ( tm > 0 )
1117 maxt = QMIN( maxt, tm ); 1134 maxt = QMIN( maxt, tm );
1118 } 1135 }
1119 } 1136 }
1120 } 1137 }
1121 if ( empty ) { 1138 if ( empty ) {
1122 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) { 1139 if ( parentWidget() != 0 && parentWidget()->inherits("KDGanttMinimizeSplitter") ) {
1123 // nested splitters; be nice 1140 // nested splitters; be nice
1124 maxl = maxt = 0; 1141 maxl = maxt = 0;
1125 } else { 1142 } else {
1126 // KDGanttMinimizeSplitter with no children yet 1143 // KDGanttMinimizeSplitter with no children yet
1127 maxl = QWIDGETSIZE_MAX; 1144 maxl = QWIDGETSIZE_MAX;
1128 } 1145 }
1129 } else { 1146 } else {
1130 maxl = QMIN( maxl, QWIDGETSIZE_MAX ); 1147 maxl = QMIN( maxl, QWIDGETSIZE_MAX );
1131 } 1148 }
1132 if ( maxt < mint ) 1149 if ( maxt < mint )
1133 maxt = mint; 1150 maxt = mint;
1134 1151
1135 if ( orient == Horizontal ) { 1152 if ( orient == Qt::Horizontal ) {
1136 setMaximumSize( maxl, maxt ); 1153 setMaximumSize( maxl, maxt );
1137 setMinimumSize( minl, mint ); 1154 setMinimumSize( minl, mint );
1138 } else { 1155 } else {
1139 setMaximumSize( maxt, maxl ); 1156 setMaximumSize( maxt, maxl );
1140 setMinimumSize( mint, minl ); 1157 setMinimumSize( mint, minl );
1141 } 1158 }
1142 if ( update ) 1159 if ( update )
1143 doResize(); 1160 doResize();
1144} 1161}
1145 1162
1146/*! 1163/*!
1147 Sets resize mode of \a w to \a mode. 1164 Sets resize mode of \a w to \a mode.
1148 1165
1149 \sa ResizeMode 1166 \sa ResizeMode
1150*/ 1167*/
1151 1168
1152void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode ) 1169void KDGanttMinimizeSplitter::setResizeMode( QWidget *w, ResizeMode mode )
1153{ 1170{
1154 processChildEvents(); 1171 processChildEvents();
1155 QSplitterLayoutStruct *s = data->list.first(); 1172 QSplitterLayoutStruct *s = data->list.first();
1156 while ( s ) { 1173 while ( s ) {
1157 if ( s->wid == w ) { 1174 if ( s->wid == w ) {
1158 s->mode = mode; 1175 s->mode = mode;
1159 return; 1176 return;
1160 } 1177 }
1161 s = data->list.next(); 1178 s = data->list.next();
1162 } 1179 }
1163 s = addWidget( w, TRUE ); 1180 s = addWidget( w, TRUE );
1164 s->mode = mode; 1181 s->mode = mode;
1165} 1182}
1166 1183
1167 1184
1168/*! 1185/*!
1169 Returns TRUE if opaque resize is on; otherwise returns FALSE. 1186 Returns TRUE if opaque resize is on; otherwise returns FALSE.
1170 1187
1171 \sa setOpaqueResize() 1188 \sa setOpaqueResize()
1172*/ 1189*/
1173 1190
1174bool KDGanttMinimizeSplitter::opaqueResize() const 1191bool KDGanttMinimizeSplitter::opaqueResize() const
1175{ 1192{
1176 return data->opaque; 1193 return data->opaque;
1177} 1194}
1178 1195
1179 1196
1180/*! 1197/*!
1181 If \a on is TRUE then opaque resizing is turned on; otherwise 1198 If \a on is TRUE then opaque resizing is turned on; otherwise
1182 opaque resizing is turned off. 1199 opaque resizing is turned off.
1183 Opaque resizing is initially turned off. 1200 Opaque resizing is initially turned off.
1184 1201
1185 \sa opaqueResize() 1202 \sa opaqueResize()
1186*/ 1203*/
1187 1204
1188void KDGanttMinimizeSplitter::setOpaqueResize( bool on ) 1205void KDGanttMinimizeSplitter::setOpaqueResize( bool on )
1189{ 1206{
1190 data->opaque = on; 1207 data->opaque = on;
1191} 1208}
1192 1209
1193 1210
1194/*! 1211/*!
1195 Moves widget \a w to the leftmost/top position. 1212 Moves widget \a w to the leftmost/top position.
1196*/ 1213*/
1197 1214
1198void KDGanttMinimizeSplitter::moveToFirst( QWidget *w ) 1215void KDGanttMinimizeSplitter::moveToFirst( QWidget *w )
1199{ 1216{
1200 processChildEvents(); 1217 processChildEvents();
1201 bool found = FALSE; 1218 bool found = FALSE;
1202 QSplitterLayoutStruct *s = data->list.first(); 1219 QSplitterLayoutStruct *s = data->list.first();
1203 while ( s ) { 1220 while ( s ) {
1204 if ( s->wid == w ) { 1221 if ( s->wid == w ) {
1205 found = TRUE; 1222 found = TRUE;
1206 QSplitterLayoutStruct *p = data->list.prev(); 1223 QSplitterLayoutStruct *p = data->list.prev();
1207 if ( p ) { // not already at first place 1224 if ( p ) { // not already at first place
1208 data->list.take(); //take p 1225 data->list.take(); //take p
1209 data->list.take(); // take s 1226 data->list.take(); // take s
1210 data->list.insert( 0, p ); 1227 data->list.insert( 0, p );
1211 data->list.insert( 0, s ); 1228 data->list.insert( 0, s );
1212 } 1229 }
1213 break; 1230 break;
1214 } 1231 }
1215 s = data->list.next(); 1232 s = data->list.next();
1216 } 1233 }
1217 if ( !found ) 1234 if ( !found )
1218 addWidget( w, TRUE ); 1235 addWidget( w, TRUE );
1219 recalcId(); 1236 recalcId();
1220} 1237}
1221 1238
1222 1239
1223/*! 1240/*!
1224 Moves widget \a w to the rightmost/bottom position. 1241 Moves widget \a w to the rightmost/bottom position.
1225*/ 1242*/
1226 1243
1227void KDGanttMinimizeSplitter::moveToLast( QWidget *w ) 1244void KDGanttMinimizeSplitter::moveToLast( QWidget *w )
1228{ 1245{
1229 processChildEvents(); 1246 processChildEvents();
1230 bool found = FALSE; 1247 bool found = FALSE;
1231 QSplitterLayoutStruct *s = data->list.first(); 1248 QSplitterLayoutStruct *s = data->list.first();
1232 while ( s ) { 1249 while ( s ) {
1233 if ( s->wid == w ) { 1250 if ( s->wid == w ) {
1234 found = TRUE; 1251 found = TRUE;
1235 data->list.take(); // take s 1252 data->list.take(); // take s
1236 QSplitterLayoutStruct *p = data->list.current(); 1253 QSplitterLayoutStruct *p = data->list.current();
1237 if ( p ) { // the splitter handle after s 1254 if ( p ) { // the splitter handle after s
1238 data->list.take(); //take p 1255 data->list.take(); //take p
1239 data->list.append( p ); 1256 data->list.append( p );
1240 } 1257 }
1241 data->list.append( s ); 1258 data->list.append( s );
1242 break; 1259 break;
1243 } 1260 }
1244 s = data->list.next(); 1261 s = data->list.next();
1245 } 1262 }
1246 if ( !found ) 1263 if ( !found )
1247 addWidget( w); 1264 addWidget( w);
1248 recalcId(); 1265 recalcId();
1249} 1266}
1250 1267
1251 1268
1252void KDGanttMinimizeSplitter::recalcId() 1269void KDGanttMinimizeSplitter::recalcId()
1253{ 1270{
1254 int n = data->list.count(); 1271 int n = data->list.count();
1255 for ( int i = 0; i < n; i++ ) { 1272 for ( int i = 0; i < n; i++ ) {
1256 QSplitterLayoutStruct *s = data->list.at(i); 1273 QSplitterLayoutStruct *s = data->list.at(i);
1257 if ( s->isSplitter ) 1274 if ( s->isSplitter )
1258 ((KDGanttSplitterHandle*)s->wid)->setId(i); 1275 ((KDGanttSplitterHandle*)s->wid)->setId(i);
1259 } 1276 }
1260} 1277}
1261 1278
1262 1279
1263/*!\reimp 1280/*!\reimp
1264*/ 1281*/
1265QSize KDGanttMinimizeSplitter::sizeHint() const 1282QSize KDGanttMinimizeSplitter::sizeHint() const
1266{ 1283{
1267 constPolish(); 1284 constPolish();
1268 int l = 0; 1285 int l = 0;
1269 int t = 0; 1286 int t = 0;
1270 if ( children() ) { 1287 if ( !children().empty() ) {
1271 const QObjectList * c = children(); 1288 const QObjectList c = children();
1272 QObjectListIt it( *c ); 1289 for(QObjectList::const_iterator i=c.begin();i!=c.end();++i) {
1273 QObject * o; 1290 QObject * o = *i;
1274
1275 while( (o=it.current()) != 0 ) {
1276 ++it;
1277 if ( o->isWidgetType() && 1291 if ( o->isWidgetType() &&
1278 !((QWidget*)o)->isHidden() ) { 1292 !((QWidget*)o)->isHidden() ) {
1279 QSize s = ((QWidget*)o)->sizeHint(); 1293 QSize s = ((QWidget*)o)->sizeHint();
1280 if ( s.isValid() ) { 1294 if ( s.isValid() ) {
1281 l += pick( s ); 1295 l += pick( s );
1282 t = QMAX( t, trans( s ) ); 1296 t = QMAX( t, trans( s ) );
1283 } 1297 }
1284 } 1298 }
1285 } 1299 }
1286 } 1300 }
1287 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1301 return orientation() == Qt::Horizontal ? QSize( l, t ) : QSize( t, l );
1288} 1302}
1289 1303
1290 1304
1291/*! 1305/*!
1292\reimp 1306\reimp
1293*/ 1307*/
1294 1308
1295QSize KDGanttMinimizeSplitter::minimumSizeHint() const 1309QSize KDGanttMinimizeSplitter::minimumSizeHint() const
1296{ 1310{
1297 constPolish(); 1311 constPolish();
1298 int l = 0; 1312 int l = 0;
1299 int t = 0; 1313 int t = 0;
1300 if ( children() ) { 1314 if ( !children().empty() ) {
1301 const QObjectList * c = children(); 1315 const QObjectList c = children();
1302 QObjectListIt it( *c ); 1316 for(QObjectList::const_iterator i=c.begin();i!=c.end();++i) {
1303 QObject * o; 1317 QObject * o = *i;
1304
1305 while( (o=it.current()) != 0 ) {
1306 ++it;
1307 if ( o->isWidgetType() && 1318 if ( o->isWidgetType() &&
1308 !((QWidget*)o)->isHidden() ) { 1319 !((QWidget*)o)->isHidden() ) {
1309 QSize s = minSizeHint((QWidget*)o); 1320 QSize s = minSizeHint((QWidget*)o);
1310 if ( s.isValid() ) { 1321 if ( s.isValid() ) {
1311 l += pick( s ); 1322 l += pick( s );
1312 t = QMAX( t, trans( s ) ); 1323 t = QMAX( t, trans( s ) );
1313 } 1324 }
1314 } 1325 }
1315 } 1326 }
1316 } 1327 }
1317 return orientation() == Horizontal ? QSize( l, t ) : QSize( t, l ); 1328 return orientation() == Qt::Horizontal ? QSize( l, t ) : QSize( t, l );
1318} 1329}
1319 1330
1320 1331
1321/* 1332/*
1322 Calculates stretch parameters from current sizes 1333 Calculates stretch parameters from current sizes
1323*/ 1334*/
1324 1335
1325void KDGanttMinimizeSplitter::storeSizes() 1336void KDGanttMinimizeSplitter::storeSizes()
1326{ 1337{
1327 QSplitterLayoutStruct *s = data->list.first(); 1338 QSplitterLayoutStruct *s = data->list.first();
1328 while ( s ) { 1339 while ( s ) {
1329 if ( !s->isSplitter ) 1340 if ( !s->isSplitter )
1330 s->sizer = pick( s->wid->size() ); 1341 s->sizer = pick( s->wid->size() );
1331 s = data->list.next(); 1342 s = data->list.next();
1332 } 1343 }
1333} 1344}
1334 1345
1335 1346
1336#if 0 // ### remove this code ASAP 1347#if 0 // ### remove this code ASAP
1337 1348
1338/*! 1349/*!
1339 Hides \a w if \a hide is TRUE and updates the splitter. 1350 Hides \a w if \a hide is TRUE and updates the splitter.
1340 1351
1341 \warning Due to a limitation in the current implementation, 1352 \warning Due to a limitation in the current implementation,
1342 calling QWidget::hide() will not work. 1353 calling QWidget::hide() will not work.
1343*/ 1354*/
1344 1355
1345void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide ) 1356void KDGanttMinimizeSplitter::setHidden( QWidget *w, bool hide )
1346{ 1357{
1347 if ( w == w1 ) { 1358 if ( w == w1 ) {
1348 w1show = !hide; 1359 w1show = !hide;
1349 } else if ( w == w2 ) { 1360 } else if ( w == w2 ) {
1350 w2show = !hide; 1361 w2show = !hide;
1351 } else { 1362 } else {
1352#ifdef QT_CHECK_RANGE 1363#ifdef QT_CHECK_RANGE
1353 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" ); 1364 qWarning( "KDGanttMinimizeSplitter::setHidden(), unknown widget" );
1354#endif 1365#endif
1355 return; 1366 return;
1356 } 1367 }
1357 if ( hide ) 1368 if ( hide )
1358 w->hide(); 1369 w->hide();
1359 else 1370 else
1360 w->show(); 1371 w->show();
1361 recalc( TRUE ); 1372 recalc( TRUE );
1362} 1373}
1363 1374
1364 1375
1365/*! 1376/*!
1366 Returns the hidden status of \a w 1377 Returns the hidden status of \a w
1367*/ 1378*/
1368 1379
1369bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const 1380bool KDGanttMinimizeSplitter::isHidden( QWidget *w ) const
1370{ 1381{
1371 if ( w == w1 ) 1382 if ( w == w1 )
1372 return !w1show; 1383 return !w1show;
1373 else if ( w == w2 ) 1384 else if ( w == w2 )
1374 return !w2show; 1385 return !w2show;
1375#ifdef QT_CHECK_RANGE 1386#ifdef QT_CHECK_RANGE
1376 else 1387 else
1377 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" ); 1388 qWarning( "KDGanttMinimizeSplitter::isHidden(), unknown widget" );
1378#endif 1389#endif
1379 return FALSE; 1390 return FALSE;
1380} 1391}
1381#endif 1392#endif
1382 1393
1383 1394
1384/*! 1395/*!
1385 Returns a list of the size parameters of all the widgets in this 1396 Returns a list of the size parameters of all the widgets in this
1386 splitter. 1397 splitter.
1387 1398
1388 Giving the values to another splitter's setSizes() function will 1399 Giving the values to another splitter's setSizes() function will
1389 produce a splitter with the same layout as this one. 1400 produce a splitter with the same layout as this one.
1390 1401
1391 Note that if you want to iterate over the list, you should 1402 Note that if you want to iterate over the list, you should
1392 iterate over a copy, e.g. 1403 iterate over a copy, e.g.
1393 \code 1404 \code
1394 QValueList<int> list = mySplitter.sizes(); 1405 QValueList<int> list = mySplitter.sizes();
1395 QValueList<int>::Iterator it = list.begin(); 1406 QValueList<int>::Iterator it = list.begin();
1396 while( it != list.end() ) { 1407 while( it != list.end() ) {
1397 myProcessing( *it ); 1408 myProcessing( *it );
1398 ++it; 1409 ++it;
1399 } 1410 }
1400 \endcode 1411 \endcode
1401 1412
1402 \sa setSizes() 1413 \sa setSizes()
1403*/ 1414*/
1404 1415
1405QValueList<int> KDGanttMinimizeSplitter::sizes() const 1416Q3ValueList<int> KDGanttMinimizeSplitter::sizes() const
1406{ 1417{
1418 /* TODO: hacker
1407 if ( !testWState(WState_Polished) ) { 1419 if ( !testWState(WState_Polished) ) {
1408 QWidget* that = (QWidget*) this; 1420 QWidget* that = (QWidget*) this;
1409 that->polish(); 1421 that->polish();
1410 } 1422 } */
1411 QValueList<int> list; 1423 Q3ValueList<int> list;
1412 QSplitterLayoutStruct *s = data->list.first(); 1424 QSplitterLayoutStruct *s = data->list.first();
1413 while ( s ) { 1425 while ( s ) {
1414 if ( !s->isSplitter ) 1426 if ( !s->isSplitter )
1415 list.append( s->sizer ); 1427 list.append( s->sizer );
1416 s = data->list.next(); 1428 s = data->list.next();
1417 } 1429 }
1418 return list; 1430 return list;
1419} 1431}
1420 1432
1421 1433
1422 1434
1423/*! 1435/*!
1424 Sets the size parameters to the values given in \a list. 1436 Sets the size parameters to the values given in \a list.
1425 If the splitter is horizontal, the values set the sizes from 1437 If the splitter is horizontal, the values set the sizes from
1426 left to right. If it is vertical, the sizes are applied from 1438 left to right. If it is vertical, the sizes are applied from
1427 top to bottom. 1439 top to bottom.
1428 Extra values in \a list are ignored. 1440 Extra values in \a list are ignored.
1429 1441
1430 If \a list contains too few values, the result is undefined 1442 If \a list contains too few values, the result is undefined
1431 but the program will still be well-behaved. 1443 but the program will still be well-behaved.
1432 1444
1433 \sa sizes() 1445 \sa sizes()
1434*/ 1446*/
1435 1447
1436void KDGanttMinimizeSplitter::setSizes( QValueList<int> list ) 1448void KDGanttMinimizeSplitter::setSizes( Q3ValueList<int> list )
1437{ 1449{
1438 processChildEvents(); 1450 processChildEvents();
1439 QValueList<int>::Iterator it = list.begin(); 1451 Q3ValueList<int>::Iterator it = list.begin();
1440 QSplitterLayoutStruct *s = data->list.first(); 1452 QSplitterLayoutStruct *s = data->list.first();
1441 while ( s && it != list.end() ) { 1453 while ( s && it != list.end() ) {
1442 if ( !s->isSplitter ) { 1454 if ( !s->isSplitter ) {
1443 s->sizer = *it; 1455 s->sizer = *it;
1444 ++it; 1456 ++it;
1445 } 1457 }
1446 s = data->list.next(); 1458 s = data->list.next();
1447 } 1459 }
1448 doResize(); 1460 doResize();
1449} 1461}
1450 1462
1451 1463
1452/*! 1464/*!
1453 Gets all posted child events, ensuring that the internal state of 1465 Gets all posted child events, ensuring that the internal state of
1454 the splitter is consistent. 1466 the splitter is consistent.
1455*/ 1467*/
1456 1468
1457void KDGanttMinimizeSplitter::processChildEvents() 1469void KDGanttMinimizeSplitter::processChildEvents()
1458{ 1470{
1459 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1471 QApplication::sendPostedEvents( this, QEvent::ChildAdded );
1460} 1472}
1461 1473
1462 1474
1463/*! 1475/*!
1464 \reimp 1476 \reimp
1465*/ 1477*/
1466 1478
1467void KDGanttMinimizeSplitter::styleChange( QStyle& old ) 1479void KDGanttMinimizeSplitter::styleChange( QStyle& old )
1468{ 1480{
1469 1481
1470#if QT_VERSION >= 0x030000 1482#if QT_VERSION >= 0x030000
1471 int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); 1483 int sw = style()->pixelMetric(QStyle::PM_SplitterWidth, 0, this);
1472#else 1484#else
1473 int sw = style().splitterWidth(); 1485 int sw = style().splitterWidth();
1474#endif 1486#endif
1475 QSplitterLayoutStruct *s = data->list.first(); 1487 QSplitterLayoutStruct *s = data->list.first();
1476 while ( s ) { 1488 while ( s ) {
1477 if ( s->isSplitter ) 1489 if ( s->isSplitter )
1478 s->sizer = sw; 1490 s->sizer = sw;
1479 s = data->list.next(); 1491 s = data->list.next();
1480 } 1492 }
1481 doResize(); 1493 doResize();
1482 QFrame::styleChange( old ); 1494 Q3Frame::styleChange( old );
1483} 1495}
1484 1496
1485#endif 1497#endif
1486 1498
1487/*! 1499/*!
1488 Specifies the direction of the minimize buttons. 1500 Specifies the direction of the minimize buttons.
1489 If the orientation of the splitter is horizontal then with 1501 If the orientation of the splitter is horizontal then with
1490 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used, 1502 KDGanttMinimizeSplitter::Left or KDGanttMinimizeSplitter::Right should be used,
1491 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down 1503 otherwise either KDGanttMinimizeSplitter::Up or KDGanttMinimizeSplitter::Down
1492 should be used. 1504 should be used.
1493*/ 1505*/
1494void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction ) 1506void KDGanttMinimizeSplitter::setMinimizeDirection( Direction direction )
1495{ 1507{
1496 _direction = direction; 1508 _direction = direction;
1497} 1509}
1498 1510
1499/*! 1511/*!
1500 Returns the direction of the minimize buttons. 1512 Returns the direction of the minimize buttons.
1501*/ 1513*/
1502KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const 1514KDGanttMinimizeSplitter::Direction KDGanttMinimizeSplitter::minimizeDirection() const
1503{ 1515{
1504 return _direction; 1516 return _direction;
1505} 1517}
1506 1518
1507/* 1519/*
1508 This is a copy of qGeomCalc() in qlayoutengine.cpp which 1520 This is a copy of qGeomCalc() in qlayoutengine.cpp which
1509 unfortunately isn't exported. 1521 unfortunately isn't exported.
1510*/ 1522*/
1511static inline int toFixed( int i ) { return i * 256; } 1523static inline int toFixed( int i ) { return i * 256; }
1512static inline int fRound( int i ) { 1524static inline int fRound( int i ) {
1513 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256; 1525 return ( i % 256 < 128 ) ? i / 256 : 1 + i / 256;
1514} 1526}
1515void kdganttGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 1527void kdganttGeomCalc( Q3MemArray<QLayoutStruct> &chain, int start, int count, int pos,
1516 int space, int spacer ) 1528 int space, int spacer )
1517{ 1529{
1518 typedef int fixed; 1530 typedef int fixed;
1519 int cHint = 0; 1531 int cHint = 0;
1520 int cMin = 0; 1532 int cMin = 0;
1521 int cMax = 0; 1533 int cMax = 0;
1522 int sumStretch = 0; 1534 int sumStretch = 0;
1523 int spacerCount = 0; 1535 int spacerCount = 0;
1524 1536
1525 bool wannaGrow = FALSE; // anyone who really wants to grow? 1537 bool wannaGrow = FALSE; // anyone who really wants to grow?
1526 // bool canShrink = FALSE; // anyone who could be persuaded to shrink? 1538 // bool canShrink = FALSE; // anyone who could be persuaded to shrink?
1527 1539
1528 int i; 1540 int i;
1529 for ( i = start; i < start + count; i++ ) { 1541 for ( i = start; i < start + count; i++ ) {
1530 chain[i].done = FALSE; 1542 chain[i].done = FALSE;
1531 cHint += chain[i].sizeHint; 1543 cHint += chain[i].sizeHint;
1532 cMin += chain[i].minimumSize; 1544 cMin += chain[i].minimumSize;
1533 cMax += chain[i].maximumSize; 1545 cMax += chain[i].maximumSize;
1534 sumStretch += chain[i].stretch; 1546 sumStretch += chain[i].stretch;
1535 if ( !chain[i].empty ) 1547 if ( !chain[i].empty )
1536 spacerCount++; 1548 spacerCount++;
1537 wannaGrow = wannaGrow || chain[i].expansive; 1549 wannaGrow = wannaGrow || chain[i].expansive;
1538 } 1550 }
1539 1551
1540 int extraspace = 0; 1552 int extraspace = 0;
1541 if ( spacerCount ) 1553 if ( spacerCount )
1542 spacerCount--; // only spacers between things 1554 spacerCount--; // only spacers between things
1543 if ( space < cMin + spacerCount * spacer ) { 1555 if ( space < cMin + spacerCount * spacer ) {
1544 //qDebug("not enough space"); 1556 //qDebug("not enough space");
1545 for ( i = start; i < start+count; i++ ) { 1557 for ( i = start; i < start+count; i++ ) {
1546 chain[i].size = chain[i].minimumSize; 1558 chain[i].size = chain[i].minimumSize;
1547 chain[i].done = TRUE; 1559 chain[i].done = TRUE;
1548 } 1560 }
1549 } else if ( space < cHint + spacerCount*spacer ) { 1561 } else if ( space < cHint + spacerCount*spacer ) {
1550 // Less space than sizeHint, but more than minimum. 1562 // Less space than sizeHint, but more than minimum.
1551 // Currently take space equally from each, like in Qt 2.x. 1563 // Currently take space equally from each, like in Qt 2.x.
1552 // Commented-out lines will give more space to stretchier items. 1564 // Commented-out lines will give more space to stretchier items.
1553 int n = count; 1565 int n = count;
1554 int space_left = space - spacerCount*spacer; 1566 int space_left = space - spacerCount*spacer;
1555 int overdraft = cHint - space_left; 1567 int overdraft = cHint - space_left;
1556 //first give to the fixed ones: 1568 //first give to the fixed ones:
1557 for ( i = start; i < start+count; i++ ) { 1569 for ( i = start; i < start+count; i++ ) {
1558 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) { 1570 if ( !chain[i].done && chain[i].minimumSize >= chain[i].sizeHint) {
1559 chain[i].size = chain[i].sizeHint; 1571 chain[i].size = chain[i].sizeHint;
1560 chain[i].done = TRUE; 1572 chain[i].done = TRUE;
1561 space_left -= chain[i].sizeHint; 1573 space_left -= chain[i].sizeHint;
1562 // sumStretch -= chain[i].stretch; 1574 // sumStretch -= chain[i].stretch;
1563 n--; 1575 n--;
1564 } 1576 }
1565 } 1577 }
1566 bool finished = n == 0; 1578 bool finished = n == 0;
1567 while ( !finished ) { 1579 while ( !finished ) {
1568 finished = TRUE; 1580 finished = TRUE;
1569 fixed fp_over = toFixed( overdraft ); 1581 fixed fp_over = toFixed( overdraft );
1570 fixed fp_w = 0; 1582 fixed fp_w = 0;
1571 1583
1572 for ( i = start; i < start+count; i++ ) { 1584 for ( i = start; i < start+count; i++ ) {
1573 if ( chain[i].done ) 1585 if ( chain[i].done )
1574 continue; 1586 continue;
1575 // if ( sumStretch <= 0 ) 1587 // if ( sumStretch <= 0 )
1576 fp_w += fp_over / n; 1588 fp_w += fp_over / n;
1577 // else 1589 // else
1578 // fp_w += (fp_over * chain[i].stretch) / sumStretch; 1590 // fp_w += (fp_over * chain[i].stretch) / sumStretch;
1579 int w = fRound( fp_w ); 1591 int w = fRound( fp_w );
1580 chain[i].size = chain[i].sizeHint - w; 1592 chain[i].size = chain[i].sizeHint - w;
1581 fp_w -= toFixed( w ); //give the difference to the next 1593 fp_w -= toFixed( w ); //give the difference to the next
1582 if ( chain[i].size < chain[i].minimumSize ) { 1594 if ( chain[i].size < chain[i].minimumSize ) {
1583 chain[i].done = TRUE; 1595 chain[i].done = TRUE;
1584 chain[i].size = chain[i].minimumSize; 1596 chain[i].size = chain[i].minimumSize;
1585 finished = FALSE; 1597 finished = FALSE;
1586 overdraft -= chain[i].sizeHint - chain[i].minimumSize; 1598 overdraft -= chain[i].sizeHint - chain[i].minimumSize;
1587 // sumStretch -= chain[i].stretch; 1599 // sumStretch -= chain[i].stretch;
1588 n--; 1600 n--;
1589 break; 1601 break;
1590 } 1602 }
1591 } 1603 }
1592 } 1604 }
1593 } else { //extra space 1605 } else { //extra space
1594 int n = count; 1606 int n = count;
1595 int space_left = space - spacerCount*spacer; 1607 int space_left = space - spacerCount*spacer;
1596 // first give to the fixed ones, and handle non-expansiveness 1608 // first give to the fixed ones, and handle non-expansiveness
1597 for ( i = start; i < start + count; i++ ) { 1609 for ( i = start; i < start + count; i++ ) {
1598 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint 1610 if ( !chain[i].done && (chain[i].maximumSize <= chain[i].sizeHint
1599 || wannaGrow && !chain[i].expansive) ) { 1611 || wannaGrow && !chain[i].expansive) ) {
1600 chain[i].size = chain[i].sizeHint; 1612 chain[i].size = chain[i].sizeHint;
1601 chain[i].done = TRUE; 1613 chain[i].done = TRUE;
1602 space_left -= chain[i].sizeHint; 1614 space_left -= chain[i].sizeHint;
1603 sumStretch -= chain[i].stretch; 1615 sumStretch -= chain[i].stretch;
1604 n--; 1616 n--;
1605 } 1617 }
1606 } 1618 }
1607 extraspace = space_left; 1619 extraspace = space_left;
1608 /* 1620 /*
1609 Do a trial distribution and calculate how much it is off. 1621 Do a trial distribution and calculate how much it is off.
1610 If there are more deficit pixels than surplus pixels, give 1622 If there are more deficit pixels than surplus pixels, give
1611 the minimum size items what they need, and repeat. 1623 the minimum size items what they need, and repeat.
1612 Otherwise give to the maximum size items, and repeat. 1624 Otherwise give to the maximum size items, and repeat.
1613 1625
1614 I have a wonderful mathematical proof for the correctness 1626 I have a wonderful mathematical proof for the correctness
1615 of this principle, but unfortunately this comment is too 1627 of this principle, but unfortunately this comment is too
1616 small to contain it. 1628 small to contain it.
1617 */ 1629 */
1618 int surplus, deficit; 1630 int surplus, deficit;
1619 do { 1631 do {
1620 surplus = deficit = 0; 1632 surplus = deficit = 0;
1621 fixed fp_space = toFixed( space_left ); 1633 fixed fp_space = toFixed( space_left );
1622 fixed fp_w = 0; 1634 fixed fp_w = 0;
1623 for ( i = start; i < start+count; i++ ) { 1635 for ( i = start; i < start+count; i++ ) {
1624 if ( chain[i].done ) 1636 if ( chain[i].done )
1625 continue; 1637 continue;
1626 extraspace = 0; 1638 extraspace = 0;
1627 if ( sumStretch <= 0 ) 1639 if ( sumStretch <= 0 )
1628 fp_w += fp_space / n; 1640 fp_w += fp_space / n;
1629 else 1641 else
1630 fp_w += (fp_space * chain[i].stretch) / sumStretch; 1642 fp_w += (fp_space * chain[i].stretch) / sumStretch;
1631 int w = fRound( fp_w ); 1643 int w = fRound( fp_w );
1632 chain[i].size = w; 1644 chain[i].size = w;
1633 fp_w -= toFixed( w ); // give the difference to the next 1645 fp_w -= toFixed( w ); // give the difference to the next
1634 if ( w < chain[i].sizeHint ) { 1646 if ( w < chain[i].sizeHint ) {
1635 deficit += chain[i].sizeHint - w; 1647 deficit += chain[i].sizeHint - w;
1636 } else if ( w > chain[i].maximumSize ) { 1648 } else if ( w > chain[i].maximumSize ) {
1637 surplus += w - chain[i].maximumSize; 1649 surplus += w - chain[i].maximumSize;
1638 } 1650 }
1639 } 1651 }
1640 if ( deficit > 0 && surplus <= deficit ) { 1652 if ( deficit > 0 && surplus <= deficit ) {
1641 // give to the ones that have too little 1653 // give to the ones that have too little
1642 for ( i = start; i < start+count; i++ ) { 1654 for ( i = start; i < start+count; i++ ) {
1643 if ( !chain[i].done && 1655 if ( !chain[i].done &&
1644 chain[i].size < chain[i].sizeHint ) { 1656 chain[i].size < chain[i].sizeHint ) {
1645 chain[i].size = chain[i].sizeHint; 1657 chain[i].size = chain[i].sizeHint;
1646 chain[i].done = TRUE; 1658 chain[i].done = TRUE;
1647 space_left -= chain[i].sizeHint; 1659 space_left -= chain[i].sizeHint;
1648 sumStretch -= chain[i].stretch; 1660 sumStretch -= chain[i].stretch;
1649 n--; 1661 n--;
1650 } 1662 }
1651 } 1663 }
1652 } 1664 }
1653 if ( surplus > 0 && surplus >= deficit ) { 1665 if ( surplus > 0 && surplus >= deficit ) {
1654 // take from the ones that have too much 1666 // take from the ones that have too much
1655 for ( i = start; i < start+count; i++ ) { 1667 for ( i = start; i < start+count; i++ ) {
1656 if ( !chain[i].done && 1668 if ( !chain[i].done &&
1657 chain[i].size > chain[i].maximumSize ) { 1669 chain[i].size > chain[i].maximumSize ) {
1658 chain[i].size = chain[i].maximumSize; 1670 chain[i].size = chain[i].maximumSize;
1659 chain[i].done = TRUE; 1671 chain[i].done = TRUE;
1660 space_left -= chain[i].maximumSize; 1672 space_left -= chain[i].maximumSize;
1661 sumStretch -= chain[i].stretch; 1673 sumStretch -= chain[i].stretch;
1662 n--; 1674 n--;
1663 } 1675 }
1664 } 1676 }
1665 } 1677 }
1666 } while ( n > 0 && surplus != deficit ); 1678 } while ( n > 0 && surplus != deficit );
1667 if ( n == 0 ) 1679 if ( n == 0 )
1668 extraspace = space_left; 1680 extraspace = space_left;
1669 } 1681 }
1670 1682
1671 // as a last resort, we distribute the unwanted space equally 1683 // as a last resort, we distribute the unwanted space equally
1672 // among the spacers (counting the start and end of the chain). 1684 // among the spacers (counting the start and end of the chain).
1673 1685
1674 //### should do a sub-pixel allocation of extra space 1686 //### should do a sub-pixel allocation of extra space
1675 int extra = extraspace / ( spacerCount + 2 ); 1687 int extra = extraspace / ( spacerCount + 2 );
1676 int p = pos + extra; 1688 int p = pos + extra;
1677 for ( i = start; i < start+count; i++ ) { 1689 for ( i = start; i < start+count; i++ ) {
1678 chain[i].pos = p; 1690 chain[i].pos = p;
1679 p = p + chain[i].size; 1691 p = p + chain[i].size;
1680 if ( !chain[i].empty ) 1692 if ( !chain[i].empty )
1681 p += spacer+extra; 1693 p += spacer+extra;
1682 } 1694 }
1683} 1695}
1684 1696
1685#endif 1697#endif
1686 1698
1687/*! 1699/*!
1688 \enum KDGanttMinimizeSplitter::Direction 1700 \enum KDGanttMinimizeSplitter::Direction
1689 1701
1690 The values of this enumeration describe into which direction the 1702 The values of this enumeration describe into which direction the
1691 splitter will collapse its child widgets. By extension, it also 1703 splitter will collapse its child widgets. By extension, it also
1692 specifies the orientation of the splitter; collapsing to the left or 1704 specifies the orientation of the splitter; collapsing to the left or
1693 to the right results in a horizontal splitter, collapsing to the top 1705 to the right results in a horizontal splitter, collapsing to the top
1694 or bottom in a vertical splitter. 1706 or bottom in a vertical splitter.
1695*/ 1707*/
1696 1708
1697/*! 1709/*!
1698 \fn Orientation KDGanttMinimizeSplitter::orientation() const 1710 \fn Orientation KDGanttMinimizeSplitter::orientation() const
1699 1711
1700 Returns the orientation of the splitter. 1712 Returns the orientation of the splitter.
1701*/ 1713*/
1702 1714
1703/*! \enum KDGanttMinimizeSplitter::ResizeMode 1715/*! \enum KDGanttMinimizeSplitter::ResizeMode
1704 1716
1705 This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are: 1717 This enum type describes how KDGanttMinimizeSplitter will resize each of its child widgets. The currently defined values are:
1706 1718
1707 Stretch: the widget will be resized when the splitter 1719 Stretch: the widget will be resized when the splitter
1708 itself is resized. 1720 itself is resized.
1709 1721
1710 KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size 1722 KeepSize: KDGanttMinimizeSplitter will try to keep this widget's size
1711 unchanged. 1723 unchanged.
1712 1724
1713 FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the 1725 FollowSizeHint: KDGanttMinimizeSplitter will resize the widget when the
1714 widget's size hint changes. 1726 widget's size hint changes.
1715*/ 1727*/
1716 1728
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h
index 3042e0a..338d965 100644
--- a/microkde/KDGanttMinimizeSplitter.h
+++ b/microkde/KDGanttMinimizeSplitter.h
@@ -1,192 +1,199 @@
1//Added by qt3to4:
2#include <Q3PointArray>
3#include <QPaintEvent>
4#include <QResizeEvent>
5#include <QChildEvent>
6#include <QMouseEvent>
7#include <QEvent>
1/* -*- Mode: C++ -*- 8/* -*- Mode: C++ -*-
2 $Id$ 9 $Id$
3*/ 10*/
4 11
5/**************************************************************************** 12/****************************************************************************
6 ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved. 13 ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 ** 14 **
8 ** This file is part of the KDGantt library. 15 ** This file is part of the KDGantt library.
9 ** 16 **
10 ** This file may be distributed and/or modified under the terms of the 17 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software 18 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the 19 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file. 20 ** packaging of this file.
14 ** 21 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in 22 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with 23 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software. 24 ** the Software.
18 ** 25 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 26 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 27 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 ** 28 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for 29 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements. 30 ** information about KDGantt Commercial License Agreements.
24 ** 31 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this 32 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you. 33 ** licensing are not clear to you.
27 ** 34 **
28 ** As a special exception, permission is given to link this program 35 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable, 36 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution. 37 ** without including the source code for Qt in the source distribution.
31 ** 38 **
32 **********************************************************************/ 39 **********************************************************************/
33 40
34#ifndef KDGANTTMINIMIZESPLITTER_H 41#ifndef KDGANTTMINIMIZESPLITTER_H
35#define KDGANTTMINIMIZESPLITTER_H 42#define KDGANTTMINIMIZESPLITTER_H
36 43
37#ifndef QT_H 44#ifndef QT_H
38#include "qframe.h" 45#include "q3frame.h"
39#include "qvaluelist.h" 46#include "q3valuelist.h"
40#endif // QT_H 47#endif // QT_H
41 48
42#ifndef QT_NO_SPLITTER___ 49#ifndef QT_NO_SPLITTER___
43class QSplitterData; 50class QSplitterData;
44class QSplitterLayoutStruct; 51class QSplitterLayoutStruct;
45class KDGanttSplitterHandle; 52class KDGanttSplitterHandle;
46class KDRubberBand; 53class KDRubberBand;
47class KDGanttMinimizeSplitter : public QFrame 54class KDGanttMinimizeSplitter : public Q3Frame
48{ 55{
49 Q_OBJECT 56 Q_OBJECT
50 // Q_ENUMS( Direction ) 57 // Q_ENUMS( Direction )
51 // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) 58 // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
52 // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) 59 // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection )
53 60
54public: 61public:
55 enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; 62 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
56 enum Direction { Left, Right, Up, Down }; 63 enum Direction { Left, Right, Up, Down };
57 64
58 KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 ); 65 KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 );
59 KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 ); 66 KDGanttMinimizeSplitter( Qt::Orientation, QWidget* parent=0, const char* name=0 );
60 ~KDGanttMinimizeSplitter(); 67 ~KDGanttMinimizeSplitter();
61 68
62 virtual void setOrientation( Orientation ); 69 virtual void setOrientation( Qt::Orientation );
63 Orientation orientation() const { return orient; } 70 Qt::Orientation orientation() const { return orient; }
64 71
65 void setMinimizeDirection( Direction ); 72 void setMinimizeDirection( Direction );
66 Direction minimizeDirection() const; 73 Direction minimizeDirection() const;
67 74
68#if QT_VERSION >= 232 75#if QT_VERSION >= 232
69 virtual void setResizeMode( QWidget *w, ResizeMode ); 76 virtual void setResizeMode( QWidget *w, ResizeMode );
70 virtual void setOpaqueResize( bool = TRUE ); 77 virtual void setOpaqueResize( bool = TRUE );
71 bool opaqueResize() const; 78 bool opaqueResize() const;
72 79
73 void moveToFirst( QWidget * ); 80 void moveToFirst( QWidget * );
74 void moveToLast( QWidget * ); 81 void moveToLast( QWidget * );
75 82
76 void refresh() { recalc( TRUE ); } 83 void refresh() { recalc( TRUE ); }
77 QSize sizeHint() const; 84 QSize sizeHint() const;
78 QSize minimumSizeHint() const; 85 QSize minimumSizeHint() const;
79 86
80 QValueList<int> sizes() const; 87 Q3ValueList<int> sizes() const;
81 void setSizes( QValueList<int> ); 88 void setSizes( Q3ValueList<int> );
82 KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;} 89 KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;}
83 void expandPos( int id, int* min, int* max ); 90 void expandPos( int id, int* min, int* max );
84 KDRubberBand* rubberBand() { return mRubberBand ;} 91 KDRubberBand* rubberBand() { return mRubberBand ;}
85public slots: 92public slots:
86 void toggle(); 93 void toggle();
87protected: 94protected:
88 void childEvent( QChildEvent * ); 95 void childEvent( QChildEvent * );
89 96
90 bool event( QEvent * ); 97 bool event( QEvent * );
91 void resizeEvent( QResizeEvent * ); 98 void resizeEvent( QResizeEvent * );
92 99
93 int idAfter( QWidget* ) const; 100 int idAfter( QWidget* ) const;
94 101
95 void moveSplitter( QCOORD pos, int id ); 102 void moveSplitter( QCOORD pos, int id );
96 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, 103 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
97 QCOORD w, QCOORD h ); 104 QCOORD w, QCOORD h );
98 void styleChange( QStyle& ); 105 void styleChange( QStyle& );
99 int adjustPos( int , int ); 106 int adjustPos( int , int );
100 virtual void setRubberband( int ); 107 virtual void setRubberband( int );
101 void getRange( int id, int*, int* ); 108 void getRange( int id, int*, int* );
102 109
103private: 110private:
104 KDRubberBand* mRubberBand; 111 KDRubberBand* mRubberBand;
105 void init(); 112 void init();
106 void recalc( bool update = FALSE ); 113 void recalc( bool update = FALSE );
107 void doResize(); 114 void doResize();
108 void storeSizes(); 115 void storeSizes();
109 void processChildEvents(); 116 void processChildEvents();
110 QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE ); 117 QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE );
111 void recalcId(); 118 void recalcId();
112 void moveBefore( int pos, int id, bool upLeft ); 119 void moveBefore( int pos, int id, bool upLeft );
113 void moveAfter( int pos, int id, bool upLeft ); 120 void moveAfter( int pos, int id, bool upLeft );
114 void setG( QWidget *w, int p, int s, bool isSplitter = FALSE ); 121 void setG( QWidget *w, int p, int s, bool isSplitter = FALSE );
115 122
116 QCOORD pick( const QPoint &p ) const 123 QCOORD pick( const QPoint &p ) const
117 { return orient == Horizontal ? p.x() : p.y(); } 124 { return orient == Qt::Horizontal ? p.x() : p.y(); }
118 QCOORD pick( const QSize &s ) const 125 QCOORD pick( const QSize &s ) const
119 { return orient == Horizontal ? s.width() : s.height(); } 126 { return orient == Qt::Horizontal ? s.width() : s.height(); }
120 127
121 QCOORD trans( const QPoint &p ) const 128 QCOORD trans( const QPoint &p ) const
122 { return orient == Vertical ? p.x() : p.y(); } 129 { return orient == Qt::Vertical ? p.x() : p.y(); }
123 QCOORD trans( const QSize &s ) const 130 QCOORD trans( const QSize &s ) const
124 { return orient == Vertical ? s.width() : s.height(); } 131 { return orient == Qt::Vertical ? s.width() : s.height(); }
125 KDGanttSplitterHandle* mFirstHandle; 132 KDGanttSplitterHandle* mFirstHandle;
126 QSplitterData *data; 133 QSplitterData *data;
127#endif 134#endif
128 135
129private: 136private:
130 Orientation orient; 137 Qt::Orientation orient;
131 Direction _direction; 138 Direction _direction;
132#ifndef DOXYGEN_SKIP_INTERNAL 139#ifndef DOXYGEN_SKIP_INTERNAL
133 friend class KDGanttSplitterHandle; 140 friend class KDGanttSplitterHandle;
134#endif 141#endif
135 private:// Disabled copy constructor and operator= 142 private:// Disabled copy constructor and operator=
136#if defined(Q_DISABLE_COPY) 143#if defined(Q_DISABLE_COPY)
137 KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); 144 KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
138 KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); 145 KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
139#endif 146#endif
140}; 147};
141 148
142#ifndef DOXYGEN_SKIP_INTERNAL 149#ifndef DOXYGEN_SKIP_INTERNAL
143// This class was continued from a verbatim copy of the 150// This class was continued from a verbatim copy of the
144// QSplitterHandle pertaining to the Qt Enterprise License and the 151// QSplitterHandle pertaining to the Qt Enterprise License and the
145// GPL. It has only been renamed to KDGanttSplitterHandler in order to 152// GPL. It has only been renamed to KDGanttSplitterHandler in order to
146// avoid a symbol clash on some platforms. 153// avoid a symbol clash on some platforms.
147class KDGanttSplitterHandle : public QWidget 154class KDGanttSplitterHandle : public QWidget
148{ 155{
149 Q_OBJECT 156 Q_OBJECT
150#if QT_VERSION >= 232 157#if QT_VERSION >= 232
151public: 158public:
152 KDGanttSplitterHandle( Qt::Orientation o, 159 KDGanttSplitterHandle( Qt::Orientation o,
153 KDGanttMinimizeSplitter *parent, const char* name=0 ); 160 KDGanttMinimizeSplitter *parent, const char* name=0 );
154 void setOrientation( Qt::Orientation o ); 161 void setOrientation( Qt::Orientation o );
155 Qt::Orientation orientation() const { return orient; } 162 Qt::Orientation orientation() const { return orient; }
156 163
157 bool opaque() const { return s->opaqueResize(); } 164 bool opaque() const { return s->opaqueResize(); }
158 165
159 QSize sizeHint() const; 166 QSize sizeHint() const;
160 void toggle(); 167 void toggle();
161 168
162 int id() const { return myId; } // data->list.at(id())->wid == this 169 int id() const { return myId; } // data->list.at(id())->wid == this
163 void setId( int i ) { myId = i; } 170 void setId( int i ) { myId = i; }
164 171
165protected: 172protected:
166 QValueList<QPointArray> buttonRegions(); 173 Q3ValueList<Q3PointArray> buttonRegions();
167 void paintEvent( QPaintEvent * ); 174 void paintEvent( QPaintEvent * );
168 void mouseMoveEvent( QMouseEvent * ); 175 void mouseMoveEvent( QMouseEvent * );
169 void mousePressEvent( QMouseEvent * ); 176 void mousePressEvent( QMouseEvent * );
170 void mouseReleaseEvent( QMouseEvent * ); 177 void mouseReleaseEvent( QMouseEvent * );
171 int onButton( const QPoint& p ); 178 int onButton( const QPoint& p );
172 void updateCursor( const QPoint& p ); 179 void updateCursor( const QPoint& p );
173 180
174private: 181private:
175 bool mMouseDown; 182 bool mMouseDown;
176 QSize mSizeHint; 183 QSize mSizeHint;
177 bool mUseOffset; 184 bool mUseOffset;
178 Qt::Orientation orient; 185 Qt::Orientation orient;
179 bool opaq; 186 bool opaq;
180 int myId; 187 int myId;
181 188
182 KDGanttMinimizeSplitter *s; 189 KDGanttMinimizeSplitter *s;
183 int _activeButton; 190 int _activeButton;
184 bool _collapsed; 191 bool _collapsed;
185 int _origPos; 192 int _origPos;
186#endif 193#endif
187}; 194};
188#endif 195#endif
189 196
190#endif // QT_NO_SPLITTER 197#endif // QT_NO_SPLITTER
191 198
192#endif // KDGANTTMINIMIZESPLITTER_H 199#endif // KDGANTTMINIMIZESPLITTER_H
diff --git a/microkde/fncolordialog.h b/microkde/fncolordialog.h
index 615d2ed..52356be 100755
--- a/microkde/fncolordialog.h
+++ b/microkde/fncolordialog.h
@@ -1,137 +1,137 @@
1/* this program for Sharp SLA300, B500, C7x0, C860 Linux PDA 1/* this program for Sharp SLA300, B500, C7x0, C860 Linux PDA
2 Copyright (C) 2003-2005 Joe Kanemori.<kanemori@ymg.urban.ne.jp> 2 Copyright (C) 2003-2005 Joe Kanemori.<kanemori@ymg.urban.ne.jp>
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundatibannwaon; either version 2 of the License, or 6 the Free Software Foundatibannwaon; either version 2 of the License, or
7 (at your option) any later version. 7 (at your option) any later version.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU General Public License 14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software 15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17*/ 17*/
18/* 18/*
192005/02/27 FreeNote 1.11.10pre 192005/02/27 FreeNote 1.11.10pre
20EPDF‚Ìo—ÍŒ`Ž®‚ðˆê•”•ÏX 20EPDF‚Ìo—ÍŒ`Ž®‚ðˆê•”•ÏX
21EƒCƒ“ƒ|[ƒgŽž‚̃oƒOfix 21EƒCƒ“ƒ|[ƒgŽž‚̃oƒOfix
22 22
23*/ 23*/
24#ifndef FNPALETTEDIALOG_H 24#ifndef FNPALETTEDIALOG_H
25#define FNPALETTEDIALOG_H 25#define FNPALETTEDIALOG_H
26#include <qwidget.h> 26#include <qwidget.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qcolor.h> 29#include <qcolor.h>
30#include <qdialog.h> 30#include <qdialog.h>
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qslider.h> 32#include <qslider.h>
33#include <qspinbox.h> 33#include <qspinbox.h>
34 34
35//----------------------------------------------------------------------------- 35//-----------------------------------------------------------------------------
36// FNPaletteBase 36// FNPaletteBase
37//----------------------------------------------------------------------------- 37//-----------------------------------------------------------------------------
38class Q_EXPORT FNPaletteBase : public QWidget 38class /* Q_EXPORT */ FNPaletteBase : public QWidget
39{ 39{
40 Q_OBJECT 40 Q_OBJECT
41public: 41public:
42 42
43 FNPaletteBase(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 43 FNPaletteBase(QWidget* parent = 0, const char* name = 0, Qt::WFlags fl = 0);
44 44
45 45
46 virtual ~FNPaletteBase(); 46 virtual ~FNPaletteBase();
47 47
48 48
49 void setBGColor(QColor c) { 49 void setBGColor(QColor c) {
50 bgcolor_ = c; 50 bgcolor_ = c;
51 selection_ = c; 51 selection_ = c;
52 redraw(); 52 redraw();
53 }; 53 };
54 QColor color() const { 54 QColor color() const {
55 return selection_; 55 return selection_;
56 }; 56 };
57 57
58protected: 58protected:
59 virtual void paintEvent(QPaintEvent*); 59 virtual void paintEvent(QPaintEvent*);
60 virtual void resizeEvent(QResizeEvent* evt); 60 virtual void resizeEvent(QResizeEvent* evt);
61 virtual void redraw(bool force=false); 61 virtual void redraw(bool force=false);
62 virtual void drawImpl(QPainter& pa); 62 virtual void drawImpl(QPainter& pa);
63 virtual void mouseReleaseEvent(QMouseEvent* evt); 63 virtual void mouseReleaseEvent(QMouseEvent* evt);
64 virtual bool pickColor(int x, int y); 64 virtual bool pickColor(int x, int y);
65 QColor selection_; 65 QColor selection_;
66private: 66private:
67 QPixmap wbuf_; 67 QPixmap wbuf_;
68 QColor bgcolor_; 68 QColor bgcolor_;
69 bool _isblock; 69 bool _isblock;
70 70
71signals: 71signals:
72 void clicked(FNPaletteBase* sender); 72 void clicked(FNPaletteBase* sender);
73}; 73};
74 74
75 75
76 76
77 77
78//----------------------------------------------------------------------------- 78//-----------------------------------------------------------------------------
79// FNColorPalette 79// FNColorPalette
80//----------------------------------------------------------------------------- 80//-----------------------------------------------------------------------------
81class Q_EXPORT FNColorPalette : public FNPaletteBase 81class /* Q_EXPORT */ FNColorPalette : public FNPaletteBase
82{ 82{
83 Q_OBJECT 83 Q_OBJECT
84public: 84public:
85 FNColorPalette(QColor c, QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 85 FNColorPalette(QColor c, QWidget* parent = 0, const char* name = 0, Qt::WFlags fl = 0);
86 virtual ~FNColorPalette(); 86 virtual ~FNColorPalette();
87}; 87};
88 88
89 89
90 90
91 91
92//----------------------------------------------------------------------------- 92//-----------------------------------------------------------------------------
93// FNHSVPalette 93// FNHSVPalette
94//----------------------------------------------------------------------------- 94//-----------------------------------------------------------------------------
95class Q_EXPORT FNHSVPalette : public FNPaletteBase 95class /*Q_EXPORT */ FNHSVPalette : public FNPaletteBase
96{ 96{
97 Q_OBJECT 97 Q_OBJECT
98public: 98public:
99 FNHSVPalette(QWidget* parent = 0, const char* name = 0, WFlags fl = 0); 99 FNHSVPalette(QWidget* parent = 0, const char* name = 0, Qt::WFlags fl = 0);
100 virtual ~FNHSVPalette(); 100 virtual ~FNHSVPalette();
101public slots: 101public slots:
102 void hueChanged(int v); 102 void hueChanged(int v);
103protected: 103protected:
104 virtual void drawImpl(QPainter& pa); 104 virtual void drawImpl(QPainter& pa);
105 int _hue; 105 int _hue;
106}; 106};
107 107
108 108
109 109
110 110
111//----------------------------------------------------------------------------- 111//-----------------------------------------------------------------------------
112// FNColorDialog 112// FNColorDialog
113//----------------------------------------------------------------------------- 113//-----------------------------------------------------------------------------
114class Q_EXPORT FNColorDialog : public QDialog 114class /*Q_EXPORT */FNColorDialog : public QDialog
115{ 115{
116 Q_OBJECT 116 Q_OBJECT
117public: 117public:
118 FNColorDialog(QWidget* parent=0, const char* name=0, WFlags f=0); 118 FNColorDialog(QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
119 virtual ~FNColorDialog(); 119 virtual ~FNColorDialog();
120 void setColor(QColor c); 120 void setColor(QColor c);
121 QColor color() const; 121 QColor color() const;
122public slots: 122public slots:
123 virtual void basePaletteClicked(FNPaletteBase*); 123 virtual void basePaletteClicked(FNPaletteBase*);
124 virtual void hsvPaletteClicked(FNPaletteBase*); 124 virtual void hsvPaletteClicked(FNPaletteBase*);
125 void rgbChanged(int); 125 void rgbChanged(int);
126private: 126private:
127 FNHSVPalette* _palette; 127 FNHSVPalette* _palette;
128 FNColorPalette* _base[16]; 128 FNColorPalette* _base[16];
129 QSlider* _hue; 129 QSlider* _hue;
130 FNColorPalette* _select; 130 FNColorPalette* _select;
131 QSpinBox* _r; 131 QSpinBox* _r;
132 QSpinBox* _g; 132 QSpinBox* _g;
133 QSpinBox* _b; 133 QSpinBox* _b;
134 bool _isblock; 134 bool _isblock;
135 135
136}; 136};
137#endif //FNPALETTEDIALOG_H 137#endif //FNPALETTEDIALOG_H
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index d7c12bb..b058d54 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,251 +1,254 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3 3
4#include "kapplication.h" 4#include "kapplication.h"
5#include "ktextedit.h" 5#include "ktextedit.h"
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qstring.h> 7#include <qstring.h>
8#include <qfile.h> 8#include <qfile.h>
9#include <qtextstream.h> 9#include <q3textstream.h>
10#include <qdialog.h> 10#include <qdialog.h>
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qtextbrowser.h> 12#include <q3textbrowser.h>
13#include <qregexp.h> 13#include <qregexp.h>
14#include <QDesktopWidget>
15//Added by qt3to4:
16#include <Q3VBoxLayout>
14 17
15int KApplication::random() 18int KApplication::random()
16{ 19{
17 return rand(); 20 return rand();
18} 21}
19 22
20//US 23//US
21QString KApplication::randomString(int length) 24QString KApplication::randomString(int length)
22{ 25{
23 if (length <=0 ) return QString::null; 26 if (length <=0 ) return QString::null;
24 27
25 QString str; 28 QString str;
26 while (length--) 29 while (length--)
27 { 30 {
28 int r=random() % 62; 31 int r=random() % 62;
29 r+=48; 32 r+=48;
30 if (r>57) r+=7; 33 if (r>57) r+=7;
31 if (r>90) r+=6; 34 if (r>90) r+=6;
32 str += char(r); 35 str += char(r);
33 // so what if I work backwards? 36 // so what if I work backwards?
34 } 37 }
35 return str; 38 return str;
36} 39}
37int KApplication::execDialog( QDialog* d ) 40int KApplication::execDialog( QDialog* d )
38{ 41{
39 if (QApplication::desktop()->width() <= 640 ) 42 if (QApplication::desktop()->width() <= 640 )
40 d->showMaximized(); 43 d->showMaximized();
41 else 44 else
42 ;//d->resize( 800, 600 ); 45 ;//d->resize( 800, 600 );
43 return d->exec(); 46 return d->exec();
44} 47}
45void KApplication::showLicence() 48void KApplication::showLicence()
46{ 49{
47 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); 50 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" );
48} 51}
49 52
50void KApplication::testCoords( int* x, int* y, int* wid, int * hei ) 53void KApplication::testCoords( int* x, int* y, int* wid, int * hei )
51{ 54{
52 int dWid = QApplication::desktop()->width() ; 55 int dWid = QApplication::desktop()->width() ;
53 int dHei = QApplication::desktop()->height(); 56 int dHei = QApplication::desktop()->height();
54 if ( *x < 0 ) *x = 0; 57 if ( *x < 0 ) *x = 0;
55 if ( *y < 20 ) *y = 20 ; 58 if ( *y < 20 ) *y = 20 ;
56 if ( *x + *wid > dWid ) { 59 if ( *x + *wid > dWid ) {
57 *x = 0; 60 *x = 0;
58 if ( *wid > dWid ) 61 if ( *wid > dWid )
59 *wid = dWid; 62 *wid = dWid;
60 } 63 }
61 if ( *y + *hei > dHei ) { 64 if ( *y + *hei > dHei ) {
62 *y = 20; 65 *y = 20;
63 if ( *hei > dHei ) 66 if ( *hei > dHei )
64 *hei = dHei; 67 *hei = dHei;
65 } 68 }
66} 69}
67void KApplication::showFile(QString caption, QString fn) 70void KApplication::showFile(QString caption, QString fn)
68{ 71{
69 QString text; 72 QString text;
70 QString fileName; 73 QString fileName;
71#ifndef DESKTOP_VERSION 74#ifndef DESKTOP_VERSION
72 fileName = getenv("QPEDIR"); 75 fileName = getenv("QPEDIR");
73 fileName += "/pics/" + fn ; 76 fileName += "/pics/" + fn ;
74#else 77#else
75 fileName = qApp->applicationDirPath () + "/" + fn; 78 fileName = qApp->applicationDirPath () + "/" + fn;
76#endif 79#endif
77 QFile file( fileName ); 80 QFile file( fileName );
78 if (!file.open( IO_ReadOnly ) ) { 81 if (!file.open( QIODevice::ReadOnly ) ) {
79 return ; 82 return ;
80 } 83 }
81 QTextStream ts( &file ); 84 Q3TextStream ts( &file );
82 text = ts.read(); 85 text = ts.read();
83 file.close(); 86 file.close();
84 KApplication::showText( caption, text ); 87 KApplication::showText( caption, text );
85 88
86} 89}
87 90
88bool KApplication::convert2latin1(QString fileName) 91bool KApplication::convert2latin1(QString fileName)
89{ 92{
90 QString text; 93 QString text;
91 QFile file( fileName ); 94 QFile file( fileName );
92 if (!file.open( IO_ReadOnly ) ) { 95 if (!file.open( QIODevice::ReadOnly ) ) {
93 return false; 96 return false;
94 97
95 } 98 }
96 QTextStream ts( &file ); 99 Q3TextStream ts( &file );
97 ts.setEncoding( QTextStream::UnicodeUTF8 ); 100 ts.setEncoding( Q3TextStream::UnicodeUTF8 );
98 text = ts.read(); 101 text = ts.read();
99 file.close(); 102 file.close();
100 if (!file.open( IO_WriteOnly ) ) { 103 if (!file.open( QIODevice::WriteOnly ) ) {
101 return false; 104 return false;
102 } 105 }
103 QTextStream tsIn( &file ); 106 Q3TextStream tsIn( &file );
104 tsIn.setEncoding( QTextStream::Latin1 ); 107 tsIn.setEncoding( Q3TextStream::Latin1 );
105 tsIn << text.latin1(); 108 tsIn << text.latin1();
106 file.close(); 109 file.close();
107 return true; 110 return true;
108 111
109 112
110} 113}
111void KApplication::showText(QString caption, QString text) 114void KApplication::showText(QString caption, QString text)
112{ 115{
113 QDialog dia( 0, "name", true ); ; 116 QDialog dia( 0, "name", true ); ;
114 dia.setCaption( caption ); 117 dia.setCaption( caption );
115 QVBoxLayout* lay = new QVBoxLayout( &dia ); 118 Q3VBoxLayout* lay = new Q3VBoxLayout( &dia );
116 lay->setSpacing( 3 ); 119 lay->setSpacing( 3 );
117 lay->setMargin( 3 ); 120 lay->setMargin( 3 );
118 KTextEdit tb ( &dia ); 121 KTextEdit tb ( &dia );
119 tb.setWordWrap( QMultiLineEdit::WidgetWidth ); 122 tb.setWordWrap( Q3MultiLineEdit::WidgetWidth );
120 lay->addWidget( &tb ); 123 lay->addWidget( &tb );
121 tb.setText( text ); 124 tb.setText( text );
122#ifdef DESKTOP_VERSION 125#ifdef DESKTOP_VERSION
123 dia.resize( 640, 480); 126 dia.resize( 640, 480);
124#else 127#else
125 dia.showMaximized(); 128 dia.showMaximized();
126#endif 129#endif
127 dia.exec(); 130 dia.exec();
128 131
129} 132}
130 133
131#include <qlabel.h> 134#include <qlabel.h>
132#include <qpushbutton.h> 135#include <qpushbutton.h>
133#include <qlayout.h> 136#include <qlayout.h>
134#include <qdir.h> 137#include <qdir.h>
135#include <qradiobutton.h> 138#include <qradiobutton.h>
136#include <qbuttongroup.h> 139#include <q3buttongroup.h>
137#include "kglobal.h" 140#include "kglobal.h"
138#include "klocale.h" 141#include "klocale.h"
139 142
140class KBackupPrefs : public QDialog 143class KBackupPrefs : public QDialog
141{ 144{
142 public: 145 public:
143 KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) : 146 KBackupPrefs( QString message , QWidget *parent=0, const char *name=0 ) :
144 QDialog( parent, name, true ) 147 QDialog( parent, name, true )
145 { 148 {
146 setCaption( i18n("Backup Failed!") ); 149 setCaption( i18n("Backup Failed!") );
147 QVBoxLayout* lay = new QVBoxLayout( this ); 150 Q3VBoxLayout* lay = new Q3VBoxLayout( this );
148 lay->setSpacing( 3 ); 151 lay->setSpacing( 3 );
149 lay->setMargin( 3 ); 152 lay->setMargin( 3 );
150 QLabel * lab = new QLabel( message, this ); 153 QLabel * lab = new QLabel( message, this );
151 lay->addWidget( lab ); 154 lay->addWidget( lab );
152 QButtonGroup* format = new QButtonGroup( 1, Horizontal, i18n("Choose action"), this ); 155 Q3ButtonGroup* format = new Q3ButtonGroup( 1, Qt::Horizontal, i18n("Choose action"), this );
153 lay->addWidget( format ); 156 lay->addWidget( format );
154 format->setExclusive ( true ) ; 157 format->setExclusive ( true ) ;
155 vcal = new QRadioButton(i18n("Try again now"), format ); 158 vcal = new QRadioButton(i18n("Try again now"), format );
156 tcal = new QRadioButton(i18n("Try again later"), format ); 159 tcal = new QRadioButton(i18n("Try again later"), format );
157 ical = new QRadioButton(i18n("Try again tomorrow"), format ); 160 ical = new QRadioButton(i18n("Try again tomorrow"), format );
158 ocal = new QRadioButton(i18n("Disable backup"), format ); 161 ocal = new QRadioButton(i18n("Disable backup"), format );
159 vcal->setChecked( true ); 162 vcal->setChecked( true );
160 QPushButton * ok = new QPushButton( i18n("OK"), this ); 163 QPushButton * ok = new QPushButton( i18n("OK"), this );
161 lay->addWidget(ok ); 164 lay->addWidget(ok );
162 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) ); 165 connect ( ok,SIGNAL(clicked() ),this , SLOT ( accept() ) );
163 } 166 }
164 167
165 bool again() { return vcal->isChecked(); } 168 bool again() { return vcal->isChecked(); }
166 bool later() { return tcal->isChecked(); } 169 bool later() { return tcal->isChecked(); }
167 bool againTomorrow() { return ical->isChecked(); } 170 bool againTomorrow() { return ical->isChecked(); }
168private: 171private:
169 QRadioButton* vcal, *ical, *ocal, *tcal; 172 QRadioButton* vcal, *ical, *ocal, *tcal;
170}; 173};
171int KApplication::createBackup( QString fn, QString dp, int numBup ) 174int KApplication::createBackup( QString fn, QString dp, int numBup )
172{ 175{
173 if ( numBup < 1) return 3; 176 if ( numBup < 1) return 3;
174 int ret = 3; 177 int ret = 3;
175 //qDebug("KApplication::createBackup %s --- %s --- %d", fn.latin1(), dp.latin1(), numBup); 178 //qDebug("KApplication::createBackup %s --- %s --- %d", fn.latin1(), dp.latin1(), numBup);
176 QDir bupDir ( dp ); 179 QDir bupDir ( dp );
177 bool tryAgain = true; 180 bool tryAgain = true;
178 while ( tryAgain ) { 181 while ( tryAgain ) {
179 if ( !bupDir.exists() ) { 182 if ( !bupDir.exists() ) {
180 QString bd = dp.right(25); 183 QString bd = dp.right(25);
181 if ( dp.length() > 25 ) 184 if ( dp.length() > 25 )
182 bd = "..." + bd; 185 bd = "..." + bd;
183 KBackupPrefs noDir( i18n("<b>Backup directory does not exist: </b>") + bd); 186 KBackupPrefs noDir( i18n("<b>Backup directory does not exist: </b>") + bd);
184 if ( !noDir.exec() ) return 3; 187 if ( !noDir.exec() ) return 3;
185 if ( noDir.againTomorrow() ) { 188 if ( noDir.againTomorrow() ) {
186 return 0; 189 return 0;
187 } else if ( noDir.later() ) { 190 } else if ( noDir.later() ) {
188 return 3; 191 return 3;
189 } else if ( !noDir.again() ) { 192 } else if ( !noDir.again() ) {
190 return 2; 193 return 2;
191 } 194 }
192 } else { 195 } else {
193 tryAgain = false; 196 tryAgain = false;
194 } 197 }
195 } 198 }
196 // we have a valid dir! 199 // we have a valid dir!
197 QStringList allFileList = bupDir.entryList(QDir::Files); 200 QStringList allFileList = bupDir.entryList(QDir::Files);
198 QFileInfo fileInfo ( fn ); 201 QFileInfo fileInfo ( fn );
199 QString fName = fileInfo.fileName (); 202 QString fName = fileInfo.fileName ();
200 QStringList fileList; 203 QStringList fileList;
201 204
202 int i; 205 int i;
203 for ( i = 0; i < allFileList.count(); ++i ) { 206 for ( i = 0; i < allFileList.count(); ++i ) {
204 QString fi = allFileList[i]; 207 QString fi = allFileList[i];
205 if ( fi. find( fName ) > -1 ) 208 if ( fi. find( fName ) > -1 )
206 fileList.append( fi ); 209 fileList.append( fi );
207 } 210 }
208 qDebug("KApp: %d backup files exist ", fileList.count()); 211 qDebug("KApp: %d backup files exist ", fileList.count());
209 int count = fileList.count(); 212 int count = fileList.count();
210 fileList.sort(); 213 fileList.sort();
211 int remCount = 0; 214 int remCount = 0;
212 while ( count >= numBup ) { 215 while ( count >= numBup ) {
213 QString fnr = dp + "/"+fileList[remCount]; 216 QString fnr = dp + "/"+fileList[remCount];
214 QFile::remove( fnr ); 217 QFile::remove( fnr );
215 --count; 218 --count;
216 ++remCount; 219 ++remCount;
217 } 220 }
218 QDateTime mRunStart = QDateTime::currentDateTime(); 221 QDateTime mRunStart = QDateTime::currentDateTime();
219 QString file = "%1%2%3-%4%5%6-"; 222 QString file = "%1%2%3-%4%5%6-";
220 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 ); 223 file = file.arg( mRunStart.date().year(), 4).arg( mRunStart.date().month(),2 ).arg( mRunStart.date().day(), 2 ).arg( mRunStart.time().hour(),2 ).arg( mRunStart.time().minute(),2 ).arg( mRunStart.time().second(),2 );
221 file.replace ( QRegExp (" "), "0" ); 224 file.replace ( QRegExp (" "), "0" );
222 file += fName ; 225 file += fName ;
223 file = dp + file; 226 file = dp + file;
224 QString command; 227 QString command;
225 int res = 0; 228 int res = 0;
226#ifdef _WIN32_ 229#ifdef _WIN32_
227 command = "copy \""+ QDir::convertSeparators( fn)+ "\" \""+QDir::convertSeparators(file)+ "\" "; 230 command = "copy \""+ QDir::convertSeparators( fn)+ "\" \""+QDir::convertSeparators(file)+ "\" ";
228#else 231#else
229 command = "cp "+ fn+ " "+file; 232 command = "cp "+ fn+ " "+file;
230#endif 233#endif
231 //qDebug("command %s ",command.latin1() ); 234 //qDebug("command %s ",command.latin1() );
232 tryAgain = true; 235 tryAgain = true;
233 while ( tryAgain ) { 236 while ( tryAgain ) {
234 res = system ( command.latin1() ); 237 res = system ( command.latin1() );
235 qDebug("KApp: Copy result %d ", res); 238 qDebug("KApp: Copy result %d ", res);
236 if ( res != 0 ) { 239 if ( res != 0 ) {
237 KBackupPrefs noDir( i18n("<b>The backup copy command failed!</b>")); 240 KBackupPrefs noDir( i18n("<b>The backup copy command failed!</b>"));
238 if ( !noDir.exec() ) return 3; 241 if ( !noDir.exec() ) return 3;
239 if ( noDir.againTomorrow() ) { 242 if ( noDir.againTomorrow() ) {
240 return 0; 243 return 0;
241 } else if ( noDir.later() ) { 244 } else if ( noDir.later() ) {
242 return 3; 245 return 3;
243 } else if ( !noDir.again() ) { 246 } else if ( !noDir.again() ) {
244 return 2; 247 return 2;
245 } 248 }
246 } else { 249 } else {
247 tryAgain = false; 250 tryAgain = false;
248 } 251 }
249 } 252 }
250 return 1; 253 return 1;
251} 254}
diff --git a/microkde/kcolorbutton.cpp b/microkde/kcolorbutton.cpp
index 197bea2..16618fc 100644
--- a/microkde/kcolorbutton.cpp
+++ b/microkde/kcolorbutton.cpp
@@ -1,54 +1,57 @@
1#include "kcolorbutton.h" 1#include "kcolorbutton.h"
2#include "kcolordialog.h" 2#include "kcolordialog.h"
3#include "qapplication.h" 3#include "qapplication.h"
4#include <QDesktopWidget>
4 5
5 6
6#include "qlayout.h" 7#include "qlayout.h"
7#ifdef DESKTOP_VERSION 8#ifdef DESKTOP_VERSION
8#include <qcolordialog.h> 9#include <qcolordialog.h>
10//Added by qt3to4:
11#include <QPixmap>
9#endif 12#endif
10void KColorButton:: edit() 13void KColorButton:: edit()
11{ 14{
12 15
13#ifdef DESKTOP_VERSION 16#ifdef DESKTOP_VERSION
14 QColor col = QColorDialog::getColor ( mColor ); 17 QColor col = QColorDialog::getColor ( mColor );
15 if ( col.isValid () ) { 18 if ( col.isValid () ) {
16 mColor = col; 19 mColor = col;
17 setColor ( mColor ); 20 setColor ( mColor );
18 emit changed ( mColor ); 21 emit changed ( mColor );
19 emit changedID ( mColor, id ); 22 emit changedID ( mColor, id );
20 } 23 }
21#else 24#else
22 KColorDialog* k = new KColorDialog( this ); 25 KColorDialog* k = new KColorDialog( this );
23 k->setColor( mColor ); 26 k->setColor( mColor );
24 int res = k->exec(); 27 int res = k->exec();
25 if ( res ) { 28 if ( res ) {
26 mColor = k->getColor(); 29 mColor = k->getColor();
27 setColor ( mColor ); 30 setColor ( mColor );
28 emit changed ( mColor ); 31 emit changed ( mColor );
29 emit changedID ( mColor, id ); 32 emit changedID ( mColor, id );
30 } 33 }
31 delete k; 34 delete k;
32#endif 35#endif
33} 36}
34KColorButton::KColorButton( QWidget *p ):QPushButton( p ) 37KColorButton::KColorButton( QWidget *p ):QPushButton( p )
35{ 38{
36 int size = 24; 39 int size = 24;
37 if( QApplication::desktop()->width() < 480 || QApplication::desktop()->height() <= 320 ) 40 if( QApplication::desktop()->width() < 480 || QApplication::desktop()->height() <= 320 )
38 size = 18; 41 size = 18;
39 setFixedSize( size,size ); 42 setFixedSize( size,size );
40 int id = 0; 43 int id = 0;
41 connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() )); 44 connect ( this, SIGNAL( clicked() ), this ,SLOT (edit() ));
42 45
43} 46}
44void KColorButton::setID ( int i) 47void KColorButton::setID ( int i)
45{ 48{
46 id = i; 49 id = i;
47} 50}
48void KColorButton::setColor ( const QColor & c) 51void KColorButton::setColor ( const QColor & c)
49{ 52{
50 mColor = c; 53 mColor = c;
51 QPixmap pix ( height() - 4, width() - 4 ); 54 QPixmap pix ( height() - 4, width() - 4 );
52 pix.fill( c ); 55 pix.fill( c );
53 setPixmap ( pix ); 56 setPixmap ( pix );
54} 57}
diff --git a/microkde/kconfig.cpp b/microkde/kconfig.cpp
index 940196e..12063ca 100644
--- a/microkde/kconfig.cpp
+++ b/microkde/kconfig.cpp
@@ -1,550 +1,552 @@
1#include <qfile.h> 1#include <qfile.h>
2#include <qtextstream.h> 2#include <q3textstream.h>
3#include <qwidget.h> 3#include <qwidget.h>
4//Added by qt3to4:
5#include <Q3ValueList>
4 6
5#include "kdebug.h" 7#include "kdebug.h"
6 8
7#include "kurl.h" 9#include "kurl.h"
8#include "kstandarddirs.h" 10#include "kstandarddirs.h"
9#include "kconfig.h" 11#include "kconfig.h"
10 12
11QString KConfig::mGroup = ""; 13QString KConfig::mGroup = "";
12//QString KConfig::mGroup = "General"; 14//QString KConfig::mGroup = "General";
13 15
14KConfig::KConfig( const QString &fileName ) 16KConfig::KConfig( const QString &fileName )
15 : mFileName( fileName ), mDirty( false ) 17 : mFileName( fileName ), mDirty( false )
16{ 18{
17 19
18 mTempGroup = ""; 20 mTempGroup = "";
19 load(); 21 load();
20 22
21} 23}
22 24
23 25
24KConfig::~KConfig() 26KConfig::~KConfig()
25{ 27{
26 sync(); 28 sync();
27} 29}
28// we need the temp group for plugins on windows 30// we need the temp group for plugins on windows
29void KConfig::setTempGroup( const QString &group ) 31void KConfig::setTempGroup( const QString &group )
30{ 32{
31 mTempGroup = group; 33 mTempGroup = group;
32 34
33 if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/"; 35 if ( mTempGroup.right( 1 ) != "/" ) mTempGroup += "/";
34} 36}
35 37
36 38
37QString KConfig::tempGroup() const { 39QString KConfig::tempGroup() const {
38 return mTempGroup; 40 return mTempGroup;
39} 41}
40 42
41void KConfig::setGroup( const QString &group ) 43void KConfig::setGroup( const QString &group )
42{ 44{
43 45
44 46
45 mGroup = group; 47 mGroup = group;
46 48
47 if ( mGroup.right( 1 ) != "/" ) mGroup += "/"; 49 if ( mGroup.right( 1 ) != "/" ) mGroup += "/";
48} 50}
49 51
50//US 52//US
51QString KConfig::group() const { 53QString KConfig::group() const {
52 return mGroup; 54 return mGroup;
53} 55}
54 56
55//US added method 57//US added method
56QValueList<int> KConfig::readIntListEntry( const QString & key) 58Q3ValueList<int> KConfig::readIntListEntry( const QString & key)
57{ 59{
58// qDebug("KConfig::readIntListEntry key=%s:", key.latin1()); 60// qDebug("KConfig::readIntListEntry key=%s:", key.latin1());
59 61
60 QValueList<int> result; 62 Q3ValueList<int> result;
61 63
62 QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key ); 64 QMap<QString,QString>::ConstIterator mit = mStringMap.find( mGroup + key );
63 65
64 if ( mit == mStringMap.end() ) { 66 if ( mit == mStringMap.end() ) {
65 return result; 67 return result;
66 } 68 }
67 69
68 QStringList valuesAsStrings = QStringList::split(":", *mit ); 70 QStringList valuesAsStrings = QStringList::split(":", *mit );
69 bool ok = false; 71 bool ok = false;
70 bool ok2 = true; 72 bool ok2 = true;
71 int val; 73 int val;
72 74
73 for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) { 75 for ( QStringList::Iterator sit = valuesAsStrings.begin(); sit != valuesAsStrings.end(); ++sit ) {
74 val = (*sit).toInt(&ok); 76 val = (*sit).toInt(&ok);
75 result << val; 77 result << val;
76 if (ok == false) { 78 if (ok == false) {
77 //qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val); 79 //qDebug("KConfig::readIntListEntry str=%s , int=%n:", (*sit).latin1(), &val);
78 ok2 = false; 80 ok2 = false;
79 } 81 }
80 } 82 }
81 83
82 if (ok2 == false) 84 if (ok2 == false)
83 { 85 {
84 86
85 qDebug("KConfig::readIntListEntry: error while reading one of the intvalues."); 87 qDebug("KConfig::readIntListEntry: error while reading one of the intvalues.");
86 } 88 }
87 89
88 return result; 90 return result;
89} 91}
90 92
91int KConfig::readNumEntry( const QString & key, int def ) 93int KConfig::readNumEntry( const QString & key, int def )
92{ 94{
93 QString res = readEntry(key, QString::number(def ) ); 95 QString res = readEntry(key, QString::number(def ) );
94 bool ok = false; 96 bool ok = false;
95 int result = res.toInt(&ok); 97 int result = res.toInt(&ok);
96 if ( ok ) 98 if ( ok )
97 return result; 99 return result;
98 return def; 100 return def;
99} 101}
100 102
101QString KConfig::readEntry( const QString &key, const QString &def ) 103QString KConfig::readEntry( const QString &key, const QString &def )
102{ 104{
103 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 105 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
104 106
105 if ( it == mStringMap.end() ) { 107 if ( it == mStringMap.end() ) {
106 return def; 108 return def;
107 } 109 }
108 110
109 return QString::fromUtf8((*it).latin1()); 111 return QString::fromUtf8((*it).latin1());
110} 112}
111 113
112QSize KConfig::readSizeEntry( const QString &key, QSize* def ) 114QSize KConfig::readSizeEntry( const QString &key, QSize* def )
113{ 115{
114 QValueList<int> intlist = readIntListEntry(key); 116 Q3ValueList<int> intlist = readIntListEntry(key);
115 117
116 if (intlist.count() < 2) 118 if (intlist.count() < 2)
117 { 119 {
118 if (def) 120 if (def)
119 return *def; 121 return *def;
120 else 122 else
121 return QSize(); 123 return QSize();
122 } 124 }
123 125
124 QSize ret; 126 QSize ret;
125 ret.setWidth(intlist[0]); 127 ret.setWidth(intlist[0]);
126 ret.setHeight(intlist[1]); 128 ret.setHeight(intlist[1]);
127 129
128 return ret; 130 return ret;
129} 131}
130 132
131QStringList KConfig::readListEntry( const QString &key ) 133QStringList KConfig::readListEntry( const QString &key )
132{ 134{
133 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key ); 135 QMap<QString,QString>::ConstIterator it = mStringMap.find( mGroup + key );
134 136
135 if ( it == mStringMap.end() ) { 137 if ( it == mStringMap.end() ) {
136 return QStringList(); 138 return QStringList();
137 } 139 }
138 QStringList temp = QStringList::split(":@:", QString::fromUtf8((*it).latin1())); 140 QStringList temp = QStringList::split(":@:", QString::fromUtf8((*it).latin1()));
139 if ( temp.count() == 1 ) 141 if ( temp.count() == 1 )
140 return QStringList::split(":", QString::fromUtf8((*it).latin1())); 142 return QStringList::split(":", QString::fromUtf8((*it).latin1()));
141 return temp; 143 return temp;
142 144
143} 145}
144 146
145bool KConfig::readBoolEntry( const QString &key, bool def ) 147bool KConfig::readBoolEntry( const QString &key, bool def )
146{ 148{
147 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key ); 149 QMap<QString,bool>::ConstIterator it = mBoolMap.find( mGroup + key );
148 150
149 if ( it == mBoolMap.end() ) { 151 if ( it == mBoolMap.end() ) {
150 return def; 152 return def;
151 } 153 }
152 154
153 return *it; 155 return *it;
154} 156}
155 157
156QColor KConfig::readColorEntry( const QString & e, QColor *def ) 158QColor KConfig::readColorEntry( const QString & e, QColor *def )
157{ 159{
158 160
159 QStringList l; 161 QStringList l;
160 l = readListEntry( e.utf8() ); 162 l = readListEntry( e.utf8() );
161 if (l.count() != 3 ) { 163 if (l.count() != 3 ) {
162 if ( def ) 164 if ( def )
163 return *def; 165 return *def;
164 else 166 else
165 return QColor(); 167 return QColor();
166 } 168 }
167 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() ); 169 QColor c ( l[0].toInt(), l[1].toInt(), l[2].toInt() );
168 return c; 170 return c;
169} 171}
170 172
171QFont KConfig::readFontEntry( const QString & e, QFont *def ) 173QFont KConfig::readFontEntry( const QString & e, QFont *def )
172{ 174{
173 QStringList font = readListEntry( e ); 175 QStringList font = readListEntry( e );
174 if ( font.isEmpty() ) 176 if ( font.isEmpty() )
175 return *def; 177 return *def;
176 QFont f; 178 QFont f;
177 f.setFamily( font[0]); 179 f.setFamily( font[0]);
178 f.setBold ( font[1] == "bold"); 180 f.setBold ( font[1] == "bold");
179 f.setPointSize ( font[2].toInt()); 181 f.setPointSize ( font[2].toInt());
180 f.setItalic( font[3] == "italic" ); 182 f.setItalic( font[3] == "italic" );
181 return f; 183 return f;
182} 184}
183 185
184QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def ) 186QDateTime KConfig::readDateTimeEntry( const QString &key, const QDateTime *def )
185{ 187{
186 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key ); 188 QMap<QString,QDateTime>::ConstIterator it = mDateTimeMap.find( mGroup + key );
187 189
188 if ( it == mDateTimeMap.end() ) { 190 if ( it == mDateTimeMap.end() ) {
189 if ( def ) return *def; 191 if ( def ) return *def;
190 else return QDateTime(); 192 else return QDateTime();
191 } 193 }
192 194
193 return *it; 195 return *it;
194} 196}
195 197
196//US added method 198//US added method
197void KConfig::writeEntry( const QString &key, const QValueList<int> &value) 199void KConfig::writeEntry( const QString &key, const Q3ValueList<int> &value)
198{ 200{
199 QStringList valuesAsStrings; 201 QStringList valuesAsStrings;
200 202
201 QValueList<int>::ConstIterator it; 203 Q3ValueList<int>::ConstIterator it;
202 204
203 for( it = value.begin(); it != value.end(); ++it ) 205 for( it = value.begin(); it != value.end(); ++it )
204 { 206 {
205 valuesAsStrings << QString::number(*it); 207 valuesAsStrings << QString::number(*it);
206 } 208 }
207 209
208 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") ); 210 mStringMap.insert( mGroup + key, valuesAsStrings.join(":") );
209 mDirty = true; 211 mDirty = true;
210} 212}
211 213
212void KConfig::writeEntry( const QString & key , int num ) 214void KConfig::writeEntry( const QString & key , int num )
213{ 215{
214 writeEntry( key, QString::number ( num ) ); 216 writeEntry( key, QString::number ( num ) );
215} 217}
216 218
217void KConfig::writeEntry( const QString &key, const QString &value ) 219void KConfig::writeEntry( const QString &key, const QString &value )
218{ 220{
219 mStringMap.insert( mGroup + key, value.utf8() ); 221 mStringMap.insert( mGroup + key, value.utf8() );
220 222
221 mDirty = true; 223 mDirty = true;
222} 224}
223 225
224void KConfig::writeEntry( const QString &key, const QStringList &value ) 226void KConfig::writeEntry( const QString &key, const QStringList &value )
225{ 227{
226 mStringMap.insert( mGroup + key, value.join(":@:").utf8() ); 228 mStringMap.insert( mGroup + key, value.join(":@:").utf8() );
227 229
228 mDirty = true; 230 mDirty = true;
229} 231}
230 232
231void KConfig::writeEntry( const QString &key, bool value) 233void KConfig::writeEntry( const QString &key, bool value)
232{ 234{
233 mBoolMap.insert( mGroup + key, value ); 235 mBoolMap.insert( mGroup + key, value );
234 236
235 mDirty = true; 237 mDirty = true;
236} 238}
237 239
238void KConfig::writeEntry( const QString & e, const QColor & c ) 240void KConfig::writeEntry( const QString & e, const QColor & c )
239{ 241{
240 QStringList l; 242 QStringList l;
241 l.append( QString::number ( c.red() ) ); 243 l.append( QString::number ( c.red() ) );
242 l.append( QString::number ( c.green() ) ); 244 l.append( QString::number ( c.green() ) );
243 l.append( QString::number ( c.blue() ) ); 245 l.append( QString::number ( c.blue() ) );
244 writeEntry( e.utf8(), l ); 246 writeEntry( e.utf8(), l );
245} 247}
246 248
247void KConfig::writeEntry( const QString & e, const QSize & s ) 249void KConfig::writeEntry( const QString & e, const QSize & s )
248{ 250{
249 QValueList<int> intlist; 251 Q3ValueList<int> intlist;
250 intlist << s.width() << s.height(); 252 intlist << s.width() << s.height();
251 writeEntry( e, intlist ); 253 writeEntry( e, intlist );
252} 254}
253 255
254void KConfig::writeEntry( const QString & e , const QFont & f ) 256void KConfig::writeEntry( const QString & e , const QFont & f )
255{ 257{
256 QStringList font; 258 QStringList font;
257 font.append( f.family()); 259 font.append( f.family());
258 font.append( (!f.bold ()?"nonbold":"bold") ); 260 font.append( (!f.bold ()?"nonbold":"bold") );
259 font.append( QString::number ( f.pointSize () ) ); 261 font.append( QString::number ( f.pointSize () ) );
260 font.append( !f.italic ()?"nonitalic":"italic" ); 262 font.append( !f.italic ()?"nonitalic":"italic" );
261 writeEntry( e, font ); 263 writeEntry( e, font );
262} 264}
263 265
264void KConfig::writeEntry( const QString &key, const QDateTime &dt ) 266void KConfig::writeEntry( const QString &key, const QDateTime &dt )
265{ 267{
266 mDateTimeMap.insert( mGroup + key, dt ); 268 mDateTimeMap.insert( mGroup + key, dt );
267} 269}
268 270
269void KConfig::load() 271void KConfig::load()
270{ 272{
271 273
272 274
273 QFile f( mFileName ); 275 QFile f( mFileName );
274 if ( !f.open( IO_ReadOnly ) ) { 276 if ( !f.open( QIODevice::ReadOnly ) ) {
275 //qDebug("KConfig: could not open file %s ",mFileName.latin1() ); 277 //qDebug("KConfig: could not open file %s ",mFileName.latin1() );
276 return; 278 return;
277 } 279 }
278 280
279 mBoolMap.clear(); 281 mBoolMap.clear();
280 mStringMap.clear(); 282 mStringMap.clear();
281 283
282 QTextStream t( &f ); 284 Q3TextStream t( &f );
283 t.setEncoding( QTextStream::Latin1 ); 285 t.setEncoding( Q3TextStream::Latin1 );
284 QString line = t.readLine(); 286 QString line = t.readLine();
285 287
286 while ( !line.isNull() ) { 288 while ( !line.isNull() ) {
287 QStringList tokens = QStringList::split( ",", line ); 289 QStringList tokens = line.split(',');
288 if ( tokens[0] == "bool" ) { 290 if ( tokens[0] == "bool" ) {
289 bool value = false; 291 bool value = false;
290 if ( tokens[2] == "1" ) value = true; 292 if ( tokens[2] == "1" ) value = true;
291 mBoolMap.insert( tokens[1], value ); 293 mBoolMap.insert( tokens[1], value );
292 } else if ( tokens[0] == "QString" ) { 294 } else if ( tokens[0] == "QString" ) {
293 QString value = tokens[2]; 295 QString value = tokens[2];
294 mStringMap.insert( tokens[1], value ); 296 mStringMap.insert( tokens[1], value );
295 } else if ( tokens[0] == "QDateTime" ) { 297 } else if ( tokens[0] == "QDateTime" ) {
296#if 0 298#if 0
297 int year = tokens[2].toInt(); 299 int year = tokens[2].toInt();
298 QDateTime dt( QDate( year, 300 QDateTime dt( QDate( year,
299 tokens[3].toInt(), 301 tokens[3].toInt(),
300 tokens[4].toInt() ), 302 tokens[4].toInt() ),
301 QTime( tokens[5].toInt(), tokens[6].toInt(), 303 QTime( tokens[5].toInt(), tokens[6].toInt(),
302 tokens[7].toInt() ) ); 304 tokens[7].toInt() ) );
303 mDateTimeMap.insert( tokens[1], dt ); 305 mDateTimeMap.insert( tokens[1], dt );
304#endif 306#endif
305 } 307 }
306 308
307 line = t.readLine(); 309 line = t.readLine();
308 } 310 }
309} 311}
310 312
311void KConfig::sync() 313void KConfig::sync()
312{ 314{
313 315
314 if ( !mDirty ) return; 316 if ( !mDirty ) return;
315 //qDebug("KConfig::sync() %s ",mFileName.latin1() ); 317 //qDebug("KConfig::sync() %s ",mFileName.latin1() );
316 //kdDebug() << "KConfig::sync(): " << mFileName << endl; 318 //kdDebug() << "KConfig::sync(): " << mFileName << endl;
317 319
318//US I took the following code from a newer version of KDE 320//US I took the following code from a newer version of KDE
319 // Create the containing dir if needed 321 // Create the containing dir if needed
320 KURL path; 322 KURL path;
321 path.setPath(mFileName); 323 path.setPath(mFileName);
322 QString dir=path.directory(); 324 QString dir=path.directory();
323 KStandardDirs::makeDir(dir); 325 KStandardDirs::makeDir(dir);
324 326
325 QFile f( mFileName ); 327 QFile f( mFileName );
326 if ( !f.open( IO_WriteOnly ) ) { 328 if ( !f.open( QIODevice::WriteOnly ) ) {
327 329
328 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() ); 330 qDebug("KConfig::sync() Can't open file %s ",mFileName.latin1() );
329 331
330 return; 332 return;
331 } 333 }
332 334
333 QTextStream t( &f ); 335 Q3TextStream t( &f );
334 t.setEncoding( QTextStream::Latin1 ); 336 t.setEncoding( Q3TextStream::Latin1 );
335 QMap<QString,bool>::ConstIterator itBool; 337 QMap<QString,bool>::ConstIterator itBool;
336 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) { 338 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) {
337 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl; 339 t << "bool," << itBool.key() << "," << ( *itBool ? "1" : "0" ) << endl;
338 } 340 }
339 341
340 QMap<QString,QString>::ConstIterator itString; 342 QMap<QString,QString>::ConstIterator itString;
341 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) { 343 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) {
342 t << "QString," << itString.key() << "," << (*itString ) << endl; 344 t << "QString," << itString.key() << "," << (*itString ) << endl;
343 } 345 }
344 346
345 QMap<QString,QDateTime>::ConstIterator itDateTime; 347 QMap<QString,QDateTime>::ConstIterator itDateTime;
346 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) { 348 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) {
347 QDateTime dt = *itDateTime; 349 QDateTime dt = *itDateTime;
348 t << "QDateTime," << itDateTime.key() << "," 350 t << "QDateTime," << itDateTime.key() << ","
349 << dt.date().year() << "," 351 << dt.date().year() << ","
350 << dt.date().month() << "," 352 << dt.date().month() << ","
351 << dt.date().day() << "," 353 << dt.date().day() << ","
352 << dt.time().hour() << "," 354 << dt.time().hour() << ","
353 << dt.time().minute() << "," 355 << dt.time().minute() << ","
354 << dt.time().second() << endl; 356 << dt.time().second() << endl;
355 } 357 }
356 358
357 f.close(); 359 f.close();
358 360
359 mDirty = false; 361 mDirty = false;
360} 362}
361 363
362 364
363//US I took the following deleteGroup method from a newer version from KDE. 365//US I took the following deleteGroup method from a newer version from KDE.
364/** 366/**
365 * Deletes a configuration entry group 367 * Deletes a configuration entry group
366 * 368 *
367 * If the group is not empty and bDeep is false, nothing gets 369 * If the group is not empty and bDeep is false, nothing gets
368 * deleted and false is returned. 370 * deleted and false is returned.
369 * If this group is the current group and it is deleted, the 371 * If this group is the current group and it is deleted, the
370 * current group is undefined and should be set with setGroup() 372 * current group is undefined and should be set with setGroup()
371 * before the next operation on the configuration object. 373 * before the next operation on the configuration object.
372 * 374 *
373 * @param group The name of the group 375 * @param group The name of the group
374 * returns true if we deleted at least one entry. 376 * returns true if we deleted at least one entry.
375 */ 377 */
376bool KConfig::deleteGroup( const QString& group) 378bool KConfig::deleteGroup( const QString& group)
377{ 379{
378 bool dirty = false; 380 bool dirty = false;
379 int pos; 381 int pos;
380 382
381 QMap<QString,bool>::Iterator itBool = mBoolMap.begin(); 383 QMap<QString,bool>::Iterator itBool = mBoolMap.begin();
382 QMap<QString,bool>::Iterator delBool; 384 QMap<QString,bool>::Iterator delBool;
383 385
384 while ( itBool != mBoolMap.end() ) { 386 while ( itBool != mBoolMap.end() ) {
385 pos = itBool.key().find( group ); 387 pos = itBool.key().find( group );
386 if (pos == 0) { 388 if (pos == 0) {
387 delBool = itBool; 389 delBool = itBool;
388 ++itBool; 390 ++itBool;
389 mBoolMap.remove(delBool); 391 mBoolMap.remove(delBool);
390 dirty = true; 392 dirty = true;
391 } else 393 } else
392 ++itBool; 394 ++itBool;
393 395
394 } 396 }
395 /* 397 /*
396 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 398 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
397 { 399 {
398 pos = itBool.key().find( group ); 400 pos = itBool.key().find( group );
399 if (pos == 0) { 401 if (pos == 0) {
400 mBoolMap.remove(itBool); 402 mBoolMap.remove(itBool);
401 dirty = true; 403 dirty = true;
402 } 404 }
403 } 405 }
404 */ 406 */
405 QMap<QString,QString>::Iterator itString = mStringMap.begin(); 407 QMap<QString,QString>::Iterator itString = mStringMap.begin();
406 QMap<QString,QString>::Iterator delString ; 408 QMap<QString,QString>::Iterator delString ;
407 while( itString != mStringMap.end() ) { 409 while( itString != mStringMap.end() ) {
408 pos = itString.key().find( group ); 410 pos = itString.key().find( group );
409 if (pos == 0) { 411 if (pos == 0) {
410 delString = itString; 412 delString = itString;
411 ++itString; 413 ++itString;
412 mStringMap.remove(delString); 414 mStringMap.remove(delString);
413 //qDebug("delte++++++++++++++++++ "); 415 //qDebug("delte++++++++++++++++++ ");
414 dirty = true; 416 dirty = true;
415 } else 417 } else
416 ++itString; 418 ++itString;
417 419
418 } 420 }
419 /* this leads to a memory access violation 421 /* this leads to a memory access violation
420 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 422 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
421 { 423 {
422 pos = itString.key().find( group ); 424 pos = itString.key().find( group );
423 if (pos == 0) { 425 if (pos == 0) {
424 mStringMap.remove(itString); 426 mStringMap.remove(itString);
425 dirty = true; 427 dirty = true;
426 } 428 }
427 } 429 }
428 */ 430 */
429 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin(); 431 QMap<QString,QDateTime>::Iterator itDateTime= mDateTimeMap.begin();
430 QMap<QString,QDateTime>::Iterator delDateTime; 432 QMap<QString,QDateTime>::Iterator delDateTime;
431 while ( itDateTime != mDateTimeMap.end() ) { 433 while ( itDateTime != mDateTimeMap.end() ) {
432 pos = itDateTime.key().find( group ); 434 pos = itDateTime.key().find( group );
433 if (pos == 0) { 435 if (pos == 0) {
434 delDateTime = itDateTime; 436 delDateTime = itDateTime;
435 ++itDateTime; 437 ++itDateTime;
436 mDateTimeMap.remove(delDateTime); 438 mDateTimeMap.remove(delDateTime);
437 dirty = true; 439 dirty = true;
438 } else 440 } else
439 ++itDateTime; 441 ++itDateTime;
440 442
441 } 443 }
442 /* 444 /*
443 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 445 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
444 { 446 {
445 pos = itDateTime.key().find( group ); 447 pos = itDateTime.key().find( group );
446 if (pos == 0) { 448 if (pos == 0) {
447 mDateTimeMap.remove(itDateTime); 449 mDateTimeMap.remove(itDateTime);
448 dirty = true; 450 dirty = true;
449 } 451 }
450 } 452 }
451 */ 453 */
452 454
453 if (dirty) 455 if (dirty)
454 mDirty = true; 456 mDirty = true;
455 457
456 return dirty; 458 return dirty;
457 459
458} 460}
459 461
460//US I took the following hasGroup method from a newer version from KDE. 462//US I took the following hasGroup method from a newer version from KDE.
461 /** 463 /**
462 * Returns true if the specified group is known about. 464 * Returns true if the specified group is known about.
463 * 465 *
464 * @param group The group to search for. 466 * @param group The group to search for.
465 * @return Whether the group exists. 467 * @return Whether the group exists.
466 */ 468 */
467bool KConfig::hasGroup(const QString &group) const 469bool KConfig::hasGroup(const QString &group) const
468{ 470{
469 QMap<QString,bool>::ConstIterator itBool; 471 QMap<QString,bool>::ConstIterator itBool;
470 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool ) 472 for( itBool = mBoolMap.begin(); itBool != mBoolMap.end(); ++itBool )
471 { 473 {
472 if (itBool.key().find( group ) == 0) { 474 if (itBool.key().find( group ) == 0) {
473 return true; 475 return true;
474 } 476 }
475 } 477 }
476 478
477 QMap<QString,QString>::ConstIterator itString; 479 QMap<QString,QString>::ConstIterator itString;
478 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString ) 480 for( itString = mStringMap.begin(); itString != mStringMap.end(); ++itString )
479 { 481 {
480 if (itString.key().find( group ) == 0) { 482 if (itString.key().find( group ) == 0) {
481 return true; 483 return true;
482 } 484 }
483 } 485 }
484 486
485 QMap<QString,QDateTime>::ConstIterator itDateTime; 487 QMap<QString,QDateTime>::ConstIterator itDateTime;
486 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime ) 488 for( itDateTime = mDateTimeMap.begin(); itDateTime != mDateTimeMap.end(); ++itDateTime )
487 { 489 {
488 if (itDateTime.key().find( group ) == 0) { 490 if (itDateTime.key().find( group ) == 0) {
489 return true; 491 return true;
490 } 492 }
491 } 493 }
492 494
493 return false; 495 return false;
494} 496}
495 497
496void KConfig::deleteEntry( const QString &key) 498void KConfig::deleteEntry( const QString &key)
497{ 499{
498 bool dirty = false; 500 bool dirty = false;
499 501
500 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 502 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
501 if ( itBool != mBoolMap.end() ) { 503 if ( itBool != mBoolMap.end() ) {
502 mBoolMap.remove(itBool); 504 mBoolMap.remove(itBool);
503 dirty = true; 505 dirty = true;
504 } 506 }
505 507
506 508
507 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 509 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
508 if ( itString != mStringMap.end() ) { 510 if ( itString != mStringMap.end() ) {
509 mStringMap.remove(itString); 511 mStringMap.remove(itString);
510 dirty = true; 512 dirty = true;
511 } 513 }
512 514
513 515
514 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 516 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
515 if ( itDateTime != mDateTimeMap.end() ) { 517 if ( itDateTime != mDateTimeMap.end() ) {
516 mDateTimeMap.remove(itDateTime); 518 mDateTimeMap.remove(itDateTime);
517 dirty = true; 519 dirty = true;
518 } 520 }
519 521
520 if (dirty) 522 if (dirty)
521 mDirty = true; 523 mDirty = true;
522 524
523} 525}
524 526
525//US 527//US
526QString KConfig::getFileName() 528QString KConfig::getFileName()
527{ 529{
528 return mFileName; 530 return mFileName;
529} 531}
530 532
531bool KConfig::hasKey( const QString &key) 533bool KConfig::hasKey( const QString &key)
532{ 534{
533 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key ); 535 QMap<QString,bool>::Iterator itBool = mBoolMap.find( mGroup + key );
534 if ( itBool != mBoolMap.end() ) { 536 if ( itBool != mBoolMap.end() ) {
535 return true; 537 return true;
536 } 538 }
537 539
538 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key ); 540 QMap<QString,QString>::Iterator itString = mStringMap.find( mGroup + key );
539 if ( itString != mStringMap.end() ) { 541 if ( itString != mStringMap.end() ) {
540 return true; 542 return true;
541 } 543 }
542 544
543 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key ); 545 QMap<QString,QDateTime>::Iterator itDateTime = mDateTimeMap.find( mGroup + key );
544 if ( itDateTime != mDateTimeMap.end() ) { 546 if ( itDateTime != mDateTimeMap.end() ) {
545 return true; 547 return true;
546 } 548 }
547 549
548 return false; 550 return false;
549} 551}
550 552
diff --git a/microkde/kconfig.h b/microkde/kconfig.h
index 1a1038f..7b91e44 100644
--- a/microkde/kconfig.h
+++ b/microkde/kconfig.h
@@ -1,105 +1,105 @@
1#ifndef MINIKDE_KCONFIG_H 1#ifndef MINIKDE_KCONFIG_H
2#define MINIKDE_KCONFIG_H 2#define MINIKDE_KCONFIG_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qvaluelist.h> 6#include <q3valuelist.h>
7#include <qcolor.h> 7#include <qcolor.h>
8#include <qfont.h> 8#include <qfont.h>
9#include <qmap.h> 9#include <qmap.h>
10#include <qdatetime.h> 10#include <qdatetime.h>
11 11
12class KConfig 12class KConfig
13{ 13{
14 public: 14 public:
15 KConfig( const QString & ); 15 KConfig( const QString & );
16 ~KConfig(); 16 ~KConfig();
17 17
18 void setTempGroup( const QString &group ); 18 void setTempGroup( const QString &group );
19 QString tempGroup() const; 19 QString tempGroup() const;
20 20
21 void setGroup( const QString & ); 21 void setGroup( const QString & );
22 22
23//US 23//US
24 /** 24 /**
25 * Returns the name of the group in which we are 25 * Returns the name of the group in which we are
26 * searching for keys and from which we are retrieving entries. 26 * searching for keys and from which we are retrieving entries.
27 * 27 *
28 * @return The current group. 28 * @return The current group.
29 */ 29 */
30 QString group() const; 30 QString group() const;
31 31
32//US I took the following deleteGroup method from a newer version from KDE. 32//US I took the following deleteGroup method from a newer version from KDE.
33/** 33/**
34 * Deletes a configuration entry group 34 * Deletes a configuration entry group
35 * 35 *
36 * If the group is not empty and bDeep is false, nothing gets 36 * If the group is not empty and bDeep is false, nothing gets
37 * deleted and false is returned. 37 * deleted and false is returned.
38 * If this group is the current group and it is deleted, the 38 * If this group is the current group and it is deleted, the
39 * current group is undefined and should be set with setGroup() 39 * current group is undefined and should be set with setGroup()
40 * before the next operation on the configuration object. 40 * before the next operation on the configuration object.
41 * 41 *
42 * @param group The name of the group 42 * @param group The name of the group
43 * returns true if we deleted at least one entry. 43 * returns true if we deleted at least one entry.
44 */ 44 */
45 bool deleteGroup( const QString& group); 45 bool deleteGroup( const QString& group);
46 46
47//US I took the following hasGroup method from a newer version from KDE. 47//US I took the following hasGroup method from a newer version from KDE.
48 /** 48 /**
49 * Returns true if the specified group is known about. 49 * Returns true if the specified group is known about.
50 * 50 *
51 * @param group The group to search for. 51 * @param group The group to search for.
52 * @return Whether the group exists. 52 * @return Whether the group exists.
53 */ 53 */
54 bool hasGroup(const QString &group) const; 54 bool hasGroup(const QString &group) const;
55 55
56 56
57 QString getFileName(); 57 QString getFileName();
58 58
59//US added method readIntListEntry 59//US added method readIntListEntry
60 QValueList<int> readIntListEntry( const QString &); 60 Q3ValueList<int> readIntListEntry( const QString &);
61 61
62 int readNumEntry( const QString &, int def=0 ); 62 int readNumEntry( const QString &, int def=0 );
63 QString readEntry( const QString &, const QString &def=QString::null ); 63 QString readEntry( const QString &, const QString &def=QString::null );
64 QStringList readListEntry( const QString & ); 64 QStringList readListEntry( const QString & );
65 bool readBoolEntry( const QString &, bool def=false ); 65 bool readBoolEntry( const QString &, bool def=false );
66 QColor readColorEntry( const QString &, QColor * ); 66 QColor readColorEntry( const QString &, QColor * );
67 QFont readFontEntry( const QString &, QFont * ); 67 QFont readFontEntry( const QString &, QFont * );
68 QDateTime readDateTimeEntry( const QString &, const QDateTime *pDefault = 0 ); 68 QDateTime readDateTimeEntry( const QString &, const QDateTime *pDefault = 0 );
69 QSize readSizeEntry(const QString &, QSize* ); 69 QSize readSizeEntry(const QString &, QSize* );
70 bool hasKey( const QString &); 70 bool hasKey( const QString &);
71 71
72 void writeEntry( const QString &, const QValueList<int>& ); 72 void writeEntry( const QString &, const Q3ValueList<int>& );
73 void writeEntry( const QString &, int ); 73 void writeEntry( const QString &, int );
74 void writeEntry( const QString &key , unsigned int value) { writeEntry( key, int( value ) ); } 74 void writeEntry( const QString &key , unsigned int value) { writeEntry( key, int( value ) ); }
75 void writeEntry( const char *key , unsigned int value) { writeEntry( QString( key ), value ); } 75 void writeEntry( const char *key , unsigned int value) { writeEntry( QString( key ), value ); }
76 void writeEntry( const char *key, int value ) { writeEntry( QString( key ), value ); } 76 void writeEntry( const char *key, int value ) { writeEntry( QString( key ), value ); }
77 void writeEntry( const QString &, const QString & ); 77 void writeEntry( const QString &, const QString & );
78 void writeEntry( const char *key, const QString &value ) { writeEntry( QString( key ), value ); } 78 void writeEntry( const char *key, const QString &value ) { writeEntry( QString( key ), value ); }
79 void writeEntry( const QString &, const QStringList & ); 79 void writeEntry( const QString &, const QStringList & );
80 void writeEntry( const QString &, bool ); 80 void writeEntry( const QString &, bool );
81 void writeEntry( const char *key, bool value ) { writeEntry( QString( key ), value ); } 81 void writeEntry( const char *key, bool value ) { writeEntry( QString( key ), value ); }
82 void writeEntry( const QString &, const QColor & ); 82 void writeEntry( const QString &, const QColor & );
83 void writeEntry( const QString &, const QFont & ); 83 void writeEntry( const QString &, const QFont & );
84 void writeEntry( const QString &, const QDateTime & ); 84 void writeEntry( const QString &, const QDateTime & );
85 void writeEntry( const QString &, const QSize & ); 85 void writeEntry( const QString &, const QSize & );
86 86
87 void deleteEntry( const QString &); 87 void deleteEntry( const QString &);
88 88
89 void load(); 89 void load();
90 void sync(); 90 void sync();
91 91
92 private: 92 private:
93 static QString mGroup; 93 static QString mGroup;
94 QString mTempGroup; 94 QString mTempGroup;
95 95
96 QString mFileName; 96 QString mFileName;
97 97
98 QMap<QString,bool> mBoolMap; 98 QMap<QString,bool> mBoolMap;
99 QMap<QString,QString> mStringMap; 99 QMap<QString,QString> mStringMap;
100 QMap<QString,QDateTime> mDateTimeMap; 100 QMap<QString,QDateTime> mDateTimeMap;
101 101
102 bool mDirty; 102 bool mDirty;
103}; 103};
104 104
105#endif 105#endif
diff --git a/microkde/kdatepickernew.cpp b/microkde/kdatepickernew.cpp
index f60a422..8f8001e 100644
--- a/microkde/kdatepickernew.cpp
+++ b/microkde/kdatepickernew.cpp
@@ -1,485 +1,485 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qframe.h> 22#include <qframe.h>
23#include <qpainter.h> 23#include <qpainter.h>
24#include <qdialog.h> 24#include <qdialog.h>
25#include <qstyle.h> 25#include <qstyle.h>
26#include <qtoolbutton.h> 26#include <qtoolbutton.h>
27#include <qcombobox.h> 27#include <qcombobox.h>
28#include <qtooltip.h> 28#include <qtooltip.h>
29#include <qfont.h> 29#include <qfont.h>
30#include <qvalidator.h> 30#include <qvalidator.h>
31#include <qpopupmenu.h> 31#include <qpopupmenu.h>
32 32
33#include "kdatepicker.h" 33#include "kdatepicker.h"
34#include <kglobal.h> 34#include <kglobal.h>
35#include <kapplication.h> 35#include <kapplication.h>
36#include <klocale.h> 36#include <klocale.h>
37#include <kiconloader.h> 37#include <kiconloader.h>
38#include <ktoolbar.h> 38#include <ktoolbar.h>
39#include <klineedit.h> 39#include <klineedit.h>
40#include <kdebug.h> 40#include <kdebug.h>
41#include <knotifyclient.h> 41#include <knotifyclient.h>
42#include <kcalendarsystem.h> 42#include <kcalendarsystem.h>
43 43
44#include "kdatetbl.h" 44#include "kdatetbl.h"
45#include "kdatepicker.moc" 45#include "kdatepicker.moc"
46 46
47class KDatePicker::KDatePickerPrivate 47class KDatePicker::KDatePickerPrivate
48{ 48{
49public: 49public:
50 KDatePickerPrivate() : closeButton(0L), selectWeek(0L), todayButton(0), navigationLayout(0) {} 50 KDatePickerPrivate() : closeButton(0L), selectWeek(0L), todayButton(0), navigationLayout(0) {}
51 51
52 void fillWeeksCombo(const QDate &date); 52 void fillWeeksCombo(const QDate &date);
53 53
54 KToolBar *tb; 54 KToolBar *tb;
55 QToolButton *closeButton; 55 QToolButton *closeButton;
56 QComboBox *selectWeek; 56 QComboBox *selectWeek;
57 QToolButton *todayButton; 57 QToolButton *todayButton;
58 QBoxLayout *navigationLayout; 58 QBoxLayout *navigationLayout;
59}; 59};
60 60
61void KDatePicker::fillWeeksCombo(const QDate &date) 61void KDatePicker::fillWeeksCombo(const QDate &date)
62{ 62{
63 // every year can have a different number of weeks 63 // every year can have a different number of weeks
64 const KCalendarSystem * calendar = KGlobal::locale()->calendar(); 64 const KCalendarSystem * calendar = KGlobal::locale()->calendar();
65 int i, weeks = calendar->weeksInYear(calendar->year(date)); 65 int i, weeks = calendar->weeksInYear(calendar->year(date));
66 66
67 if ( d->selectWeek->count() == weeks ) return; // we already have the correct number 67 if ( d->selectWeek->count() == weeks ) return; // we already have the correct number
68 68
69 d->selectWeek->clear(); 69 d->selectWeek->clear();
70 70
71 for (i = 1; i <= weeks; i++) 71 for (i = 1; i <= weeks; i++)
72 d->selectWeek->insertItem(i18n("Week %1").arg(i)); 72 d->selectWeek->insertItem(i18n("Week %1").arg(i));
73} 73}
74 74
75KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name) 75KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name)
76 : QFrame(parent,name) 76 : QFrame(parent,name)
77{ 77{
78 init( dt ); 78 init( dt );
79} 79}
80 80
81KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name, WFlags f) 81KDatePicker::KDatePicker(QWidget *parent, QDate dt, const char *name, WFlags f)
82 : QFrame(parent,name, f) 82 : QFrame(parent,name, f)
83{ 83{
84 init( dt ); 84 init( dt );
85} 85}
86 86
87KDatePicker::KDatePicker( QWidget *parent, const char *name ) 87KDatePicker::KDatePicker( QWidget *parent, const char *name )
88 : QFrame(parent,name) 88 : QFrame(parent,name)
89{ 89{
90 init( QDate::currentDate() ); 90 init( QDate::currentDate() );
91} 91}
92 92
93void KDatePicker::init( const QDate &dt ) 93void KDatePicker::init( const QDate &dt )
94{ 94{
95 d = new KDatePickerPrivate(); 95 d = new KDatePickerPrivate();
96 96
97 d->tb = new KToolBar(this); 97 d->tb = new KToolBar(this);
98 98
99 yearBackward = new QToolButton(d->tb); 99 yearBackward = new QToolButton(d->tb);
100 monthBackward = new QToolButton(d->tb); 100 monthBackward = new QToolButton(d->tb);
101 selectMonth = new QToolButton(d->tb); 101 selectMonth = new QToolButton(d->tb);
102 selectYear = new QToolButton(d->tb); 102 selectYear = new QToolButton(d->tb);
103 monthForward = new QToolButton(d->tb); 103 monthForward = new QToolButton(d->tb);
104 yearForward = new QToolButton(d->tb); 104 yearForward = new QToolButton(d->tb);
105 line = new KLineEdit(this); 105 line = new KLineEdit(this);
106 val = new KDateValidator(this); 106 val = new KDateValidator(this);
107 table = new KDateTable(this); 107 table = new KDateTable(this);
108 fontsize = 12;//KGlobalSettings::generalFont().pointSize(); 108 fontsize = 12;//KGlobalSettings::generalFont().pointSize();
109 109
110 110
111 fontsize++; // Make a little bigger 111 fontsize++; // Make a little bigger
112 112
113 d->selectWeek = new QComboBox(false, this); // read only week selection 113 d->selectWeek = new QComboBox(false, this); // read only week selection
114 d->todayButton = new QToolButton(this); 114 d->todayButton = new QToolButton(this);
115 d->todayButton->setIconSet(SmallIconSet("today")); 115 d->todayButton->setIconSet(SmallIconSet("today"));
116 116
117 QToolTip::add(yearForward, i18n("Next year")); 117 QToolTip::add(yearForward, i18n("Next year"));
118 QToolTip::add(yearBackward, i18n("Previous year")); 118 QToolTip::add(yearBackward, i18n("Previous year"));
119 QToolTip::add(monthForward, i18n("Next month")); 119 QToolTip::add(monthForward, i18n("Next month"));
120 QToolTip::add(monthBackward, i18n("Previous month")); 120 QToolTip::add(monthBackward, i18n("Previous month"));
121 QToolTip::add(d->selectWeek, i18n("Select a week")); 121 QToolTip::add(d->selectWeek, i18n("Select a week"));
122 QToolTip::add(selectMonth, i18n("Select a month")); 122 QToolTip::add(selectMonth, i18n("Select a month"));
123 QToolTip::add(selectYear, i18n("Select a year")); 123 QToolTip::add(selectYear, i18n("Select a year"));
124 QToolTip::add(d->todayButton, i18n("Select the current day")); 124 QToolTip::add(d->todayButton, i18n("Select the current day"));
125 125
126 // ----- 126 // -----
127 setFontSize(fontsize); 127 setFontSize(fontsize);
128 line->setValidator(val); 128 line->setValidator(val);
129 line->installEventFilter( this ); 129 line->installEventFilter( this );
130// yearForward->setIconSet(BarIconSet(QString::fromLatin1("2rightarrow"))); 130// yearForward->setIconSet(BarIconSet(QString::fromLatin1("2rightarrow")));
131// yearBackward->setIconSet(BarIconSet(QString::fromLatin1("2leftarrow"))); 131// yearBackward->setIconSet(BarIconSet(QString::fromLatin1("2leftarrow")));
132// monthForward->setIconSet(BarIconSet(QString::fromLatin1("1rightarrow"))); 132// monthForward->setIconSet(BarIconSet(QString::fromLatin1("1rightarrow")));
133// monthBackward->setIconSet(BarIconSet(QString::fromLatin1("1leftarrow"))); 133// monthBackward->setIconSet(BarIconSet(QString::fromLatin1("1leftarrow")));
134 setDate(dt); // set button texts 134 setDate(dt); // set button texts
135 connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate))); 135 connect(table, SIGNAL(dateChanged(QDate)), SLOT(dateChangedSlot(QDate)));
136 connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot())); 136 connect(table, SIGNAL(tableClicked()), SLOT(tableClickedSlot()));
137 connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked())); 137 connect(monthForward, SIGNAL(clicked()), SLOT(monthForwardClicked()));
138 connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked())); 138 connect(monthBackward, SIGNAL(clicked()), SLOT(monthBackwardClicked()));
139 connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked())); 139 connect(yearForward, SIGNAL(clicked()), SLOT(yearForwardClicked()));
140 connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked())); 140 connect(yearBackward, SIGNAL(clicked()), SLOT(yearBackwardClicked()));
141 connect(d->selectWeek, SIGNAL(activated(int)), SLOT(weekSelected(int))); 141 connect(d->selectWeek, SIGNAL(activated(int)), SLOT(weekSelected(int)));
142 connect(d->todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked())); 142 connect(d->todayButton, SIGNAL(clicked()), SLOT(todayButtonClicked()));
143 connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked())); 143 connect(selectMonth, SIGNAL(clicked()), SLOT(selectMonthClicked()));
144 connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked())); 144 connect(selectYear, SIGNAL(clicked()), SLOT(selectYearClicked()));
145 connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed())); 145 connect(line, SIGNAL(returnPressed()), SLOT(lineEnterPressed()));
146 table->setFocus(); 146 table->setFocus();
147 147
148 QBoxLayout * topLayout = new QVBoxLayout(this); 148 QBoxLayout * topLayout = new QVBoxLayout(this);
149 149
150 d->navigationLayout = new QHBoxLayout(topLayout); 150 d->navigationLayout = new QHBoxLayout(topLayout);
151 d->navigationLayout->addWidget(d->tb); 151 d->navigationLayout->addWidget(d->tb);
152 152
153 topLayout->addWidget(table); 153 topLayout->addWidget(table);
154 154
155 QBoxLayout * bottomLayout = new QHBoxLayout(topLayout); 155 QBoxLayout * bottomLayout = new QHBoxLayout(topLayout);
156 bottomLayout->addWidget(d->todayButton); 156 bottomLayout->addWidget(d->todayButton);
157 bottomLayout->addWidget(line); 157 bottomLayout->addWidget(line);
158 bottomLayout->addWidget(d->selectWeek); 158 bottomLayout->addWidget(d->selectWeek);
159} 159}
160 160
161KDatePicker::~KDatePicker() 161KDatePicker::~KDatePicker()
162{ 162{
163 delete d; 163 delete d;
164} 164}
165 165
166bool 166bool
167KDatePicker::eventFilter(QObject *o, QEvent *e ) 167KDatePicker::eventFilter(QObject *o, QEvent *e )
168{ 168{
169 if ( e->type() == QEvent::KeyPress ) { 169 if ( e->type() == QEvent::KeyPress ) {
170 QKeyEvent *k = (QKeyEvent *)e; 170 QKeyEvent *k = (QKeyEvent *)e;
171 171
172 if ( (k->key() == Qt::Key_Prior) || 172 if ( (k->key() == Qt::Key_Prior) ||
173 (k->key() == Qt::Key_Next) || 173 (k->key() == Qt::Key_Next) ||
174 (k->key() == Qt::Key_Up) || 174 (k->key() == Qt::Key_Up) ||
175 (k->key() == Qt::Key_Down) ) 175 (k->key() == Qt::Key_Down) )
176 { 176 {
177 QApplication::sendEvent( table, e ); 177 QApplication::sendEvent( table, e );
178 table->setFocus(); 178 table->setFocus();
179 return true; // eat event 179 return true; // eat event
180 } 180 }
181 } 181 }
182 return QFrame::eventFilter( o, e ); 182 return QFrame::eventFilter( o, e );
183} 183}
184 184
185void 185void
186KDatePicker::resizeEvent(QResizeEvent* e) 186KDatePicker::resizeEvent(QResizeEvent* e)
187{ 187{
188 QWidget::resizeEvent(e); 188 QWidget::resizeEvent(e);
189} 189}
190 190
191void 191void
192KDatePicker::dateChangedSlot(QDate date) 192KDatePicker::dateChangedSlot(QDate date)
193{ 193{
194 kdDebug(298) << "KDatePicker::dateChangedSlot: date changed (" << date.year() << "/" << date.month() << "/" << date.day() << ")." << endl; 194 kdDebug(298) << "KDatePicker::dateChangedSlot: date changed (" << date.year() << "/" << date.month() << "/" << date.day() << ")." << endl;
195 195
196 const KCalendarSystem * calendar = KGlobal::locale()->calendar(); 196 const KCalendarSystem * calendar = KGlobal::locale()->calendar();
197 197
198 line->setText(KGlobal::locale()->formatDate(date, true)); 198 line->setText(KGlobal::locale()->formatDate(date, true));
199 selectMonth->setText(calendar->monthName(date, false)); 199 selectMonth->setText(calendar->monthName(date, false));
200 fillWeeksCombo(date); 200 fillWeeksCombo(date);
201 d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1); 201 d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1);
202 selectYear->setText(calendar->yearString(date, false)); 202 selectYear->setText(calendar->yearString(date, false));
203 203
204 emit(dateChanged(date)); 204 emit(dateChanged(date));
205} 205}
206 206
207void 207void
208KDatePicker::tableClickedSlot() 208KDatePicker::tableClickedSlot()
209{ 209{
210 kdDebug(298) << "KDatePicker::tableClickedSlot: table clicked." << endl; 210 kdDebug(298) << "KDatePicker::tableClickedSlot: table clicked." << endl;
211 emit(dateSelected(table->getDate())); 211 emit(dateSelected(table->getDate()));
212 emit(tableClicked()); 212 emit(tableClicked());
213} 213}
214 214
215const QDate& 215const QDate&
216KDatePicker::getDate() const 216KDatePicker::getDate() const
217{ 217{
218 return table->getDate(); 218 return table->getDate();
219} 219}
220 220
221const QDate & 221const QDate &
222KDatePicker::date() const 222KDatePicker::date() const
223{ 223{
224 return table->getDate(); 224 return table->getDate();
225} 225}
226 226
227bool 227bool
228KDatePicker::setDate(const QDate& date) 228KDatePicker::setDate(const QDate& date)
229{ 229{
230 if(date.isValid()) 230 if(date.isValid())
231 { 231 {
232 const KCalendarSystem * calendar = KGlobal::locale()->calendar(); 232 const KCalendarSystem * calendar = KGlobal::locale()->calendar();
233 233
234 table->setDate(date); 234 table->setDate(date);
235 fillWeeksCombo(date); 235 fillWeeksCombo(date);
236 d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1); 236 d->selectWeek->setCurrentItem(calendar->weekNumber(date) - 1);
237 selectMonth->setText(calendar->monthName(date, false)); 237 selectMonth->setText(calendar->monthName(date, false));
238 selectYear->setText(calendar->yearString(date, true)); 238 selectYear->setText(calendar->yearString(date, true));
239 line->setText(KGlobal::locale()->formatDate(date, true)); 239 line->setText(KGlobal::locale()->formatDate(date, true));
240 return true; 240 return true;
241 } 241 }
242 else 242 else
243 { 243 {
244 kdDebug(298) << "KDatePicker::setDate: refusing to set invalid date." << endl; 244 kdDebug(298) << "KDatePicker::setDate: refusing to set invalid date." << endl;
245 return false; 245 return false;
246 } 246 }
247} 247}
248 248
249void 249void
250KDatePicker::monthForwardClicked() 250KDatePicker::monthForwardClicked()
251{ 251{
252 QDate temp; 252 QDate temp;
253 temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), 1 ); 253 temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), 1 );
254 254
255 setDate( temp ); 255 setDate( temp );
256} 256}
257 257
258void 258void
259KDatePicker::monthBackwardClicked() 259KDatePicker::monthBackwardClicked()
260{ 260{
261 QDate temp; 261 QDate temp;
262 temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), -1 ); 262 temp = KGlobal::locale()->calendar()->addMonths( table->getDate(), -1 );
263 263
264 setDate( temp ); 264 setDate( temp );
265} 265}
266 266
267void 267void
268KDatePicker::yearForwardClicked() 268KDatePicker::yearForwardClicked()
269{ 269{
270 QDate temp; 270 QDate temp;
271 temp = KGlobal::locale()->calendar()->addYears( table->getDate(), 1 ); 271 temp = KGlobal::locale()->calendar()->addYears( table->getDate(), 1 );
272 272
273 setDate( temp ); 273 setDate( temp );
274} 274}
275 275
276void 276void
277KDatePicker::yearBackwardClicked() 277KDatePicker::yearBackwardClicked()
278{ 278{
279 QDate temp; 279 QDate temp;
280 temp = KGlobal::locale()->calendar()->addYears( table->getDate(), -1 ); 280 temp = KGlobal::locale()->calendar()->addYears( table->getDate(), -1 );
281 281
282 setDate( temp ); 282 setDate( temp );
283} 283}
284 284
285void KDatePicker::selectWeekClicked() {} // ### in 3.2 obsolete; kept for binary compatibility 285void KDatePicker::selectWeekClicked() {} // ### in 3.2 obsolete; kept for binary compatibility
286 286
287void 287void
288KDatePicker::weekSelected(int week) 288KDatePicker::weekSelected(int week)
289{ 289{
290 week++; // week number starts with 1 290 week++; // week number starts with 1
291 291
292 const KCalendarSystem * calendar = KGlobal::locale()->calendar(); 292 const KCalendarSystem * calendar = KGlobal::locale()->calendar();
293 293
294 QDate date = table->getDate(); 294 QDate date = table->getDate();
295 int year = calendar->year(date); 295 int year = calendar->year(date);
296 296
297 calendar->setYMD(date, year, 1, 1); 297 calendar->setYMD(date, year, 1, 1);
298 date = calendar->addDays(date, -7); 298 date = calendar->addDays(date, -7);
299 while (calendar->weekNumber(date) != 1) 299 while (calendar->weekNumber(date) != 1)
300 date = calendar->addDays(date, 1); 300 date = calendar->addDays(date, 1);
301 301
302 // date is now first day in week 1 some day in week 1 302 // date is now first day in week 1 some day in week 1
303 date = calendar->addDays(date, (week - calendar->weekNumber(date)) * 7); 303 date = calendar->addDays(date, (week - calendar->weekNumber(date)) * 7);
304 304
305 setDate(date); 305 setDate(date);
306} 306}
307 307
308void 308void
309KDatePicker::selectMonthClicked() 309KDatePicker::selectMonthClicked()
310{ 310{
311 // every year can have different month names (in some calendar systems) 311 // every year can have different month names (in some calendar systems)
312 const KCalendarSystem * calendar = KGlobal::locale()->calendar(); 312 const KCalendarSystem * calendar = KGlobal::locale()->calendar();
313 QDate date = table->getDate(); 313 QDate date = table->getDate();
314 int i, month, months = calendar->monthsInYear(date); 314 int i, month, months = calendar->monthsInYear(date);
315 315
316 QPopupMenu popup(selectMonth); 316 Q3PopupMenu popup(selectMonth);
317 317
318 for (i = 1; i <= months; i++) 318 for (i = 1; i <= months; i++)
319 popup.insertItem(calendar->monthName(i, calendar->year(date)), i); 319 popup.insertItem(calendar->monthName(i, calendar->year(date)), i);
320 320
321 popup.setActiveItem(calendar->month(date) - 1); 321 popup.setActiveItem(calendar->month(date) - 1);
322 322
323 if ( (month = popup.exec(selectMonth->mapToGlobal(QPoint(0, 0)), calendar->month(date) - 1)) == -1 ) return; // canceled 323 if ( (month = popup.exec(selectMonth->mapToGlobal(QPoint(0, 0)), calendar->month(date) - 1)) == -1 ) return; // canceled
324 324
325 int day = calendar->day(date); 325 int day = calendar->day(date);
326 // ----- construct a valid date in this month: 326 // ----- construct a valid date in this month:
327 //date.setYMD(date.year(), month, 1); 327 //date.setYMD(date.year(), month, 1);
328 //date.setYMD(date.year(), month, QMIN(day, date.daysInMonth())); 328 //date.setYMD(date.year(), month, QMIN(day, date.daysInMonth()));
329 calendar->setYMD(date, calendar->year(date), month, 329 calendar->setYMD(date, calendar->year(date), month,
330 QMIN(day, calendar->daysInMonth(date))); 330 QMIN(day, calendar->daysInMonth(date)));
331 // ----- set this month 331 // ----- set this month
332 setDate(date); 332 setDate(date);
333} 333}
334 334
335void 335void
336KDatePicker::selectYearClicked() 336KDatePicker::selectYearClicked()
337{ 337{
338 const KCalendarSystem * calendar = KGlobal::locale()->calendar(); 338 const KCalendarSystem * calendar = KGlobal::locale()->calendar();
339 339
340 int year; 340 int year;
341 KPopupFrame* popup = new KPopupFrame(this); 341 KPopupFrame* popup = new KPopupFrame(this);
342 KDateInternalYearSelector* picker = new KDateInternalYearSelector(popup); 342 KDateInternalYearSelector* picker = new KDateInternalYearSelector(popup);
343 // ----- 343 // -----
344 picker->resize(picker->sizeHint()); 344 picker->resize(picker->sizeHint());
345 popup->setMainWidget(picker); 345 popup->setMainWidget(picker);
346 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int))); 346 connect(picker, SIGNAL(closeMe(int)), popup, SLOT(close(int)));
347 picker->setFocus(); 347 picker->setFocus();
348 if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height())))) 348 if(popup->exec(selectYear->mapToGlobal(QPoint(0, selectMonth->height()))))
349 { 349 {
350 QDate date; 350 QDate date;
351 int day; 351 int day;
352 // ----- 352 // -----
353 year=picker->getYear(); 353 year=picker->getYear();
354 date=table->getDate(); 354 date=table->getDate();
355 day=calendar->day(date); 355 day=calendar->day(date);
356 // ----- construct a valid date in this month: 356 // ----- construct a valid date in this month:
357 //date.setYMD(year, date.month(), 1); 357 //date.setYMD(year, date.month(), 1);
358 //date.setYMD(year, date.month(), QMIN(day, date.daysInMonth())); 358 //date.setYMD(year, date.month(), QMIN(day, date.daysInMonth()));
359 calendar->setYMD(date, year, calendar->month(date), 359 calendar->setYMD(date, year, calendar->month(date),
360 QMIN(day, calendar->daysInMonth(date))); 360 QMIN(day, calendar->daysInMonth(date)));
361 // ----- set this month 361 // ----- set this month
362 setDate(date); 362 setDate(date);
363 } else { 363 } else {
364 KNotifyClient::beep(); 364 KNotifyClient::beep();
365 } 365 }
366 delete popup; 366 delete popup;
367} 367}
368 368
369void 369void
370KDatePicker::setEnabled(bool enable) 370KDatePicker::setEnabled(bool enable)
371{ 371{
372 QWidget *widgets[]= { 372 QWidget *widgets[]= {
373 yearForward, yearBackward, monthForward, monthBackward, 373 yearForward, yearBackward, monthForward, monthBackward,
374 selectMonth, selectYear, 374 selectMonth, selectYear,
375 line, table, d->selectWeek, d->todayButton }; 375 line, table, d->selectWeek, d->todayButton };
376 const int Size=sizeof(widgets)/sizeof(widgets[0]); 376 const int Size=sizeof(widgets)/sizeof(widgets[0]);
377 int count; 377 int count;
378 // ----- 378 // -----
379 for(count=0; count<Size; ++count) 379 for(count=0; count<Size; ++count)
380 { 380 {
381 widgets[count]->setEnabled(enable); 381 widgets[count]->setEnabled(enable);
382 } 382 }
383} 383}
384 384
385void 385void
386KDatePicker::lineEnterPressed() 386KDatePicker::lineEnterPressed()
387{ 387{
388 QDate temp; 388 QDate temp;
389 // ----- 389 // -----
390 if(val->date(line->text(), temp)==QValidator::Acceptable) 390 if(val->date(line->text(), temp)==QValidator::Acceptable)
391 { 391 {
392 kdDebug(298) << "KDatePicker::lineEnterPressed: valid date entered." << endl; 392 kdDebug(298) << "KDatePicker::lineEnterPressed: valid date entered." << endl;
393 emit(dateEntered(temp)); 393 emit(dateEntered(temp));
394 setDate(temp); 394 setDate(temp);
395 } else { 395 } else {
396 KNotifyClient::beep(); 396 KNotifyClient::beep();
397 kdDebug(298) << "KDatePicker::lineEnterPressed: invalid date entered." << endl; 397 kdDebug(298) << "KDatePicker::lineEnterPressed: invalid date entered." << endl;
398 } 398 }
399} 399}
400 400
401void 401void
402KDatePicker::todayButtonClicked() 402KDatePicker::todayButtonClicked()
403{ 403{
404 setDate(QDate::currentDate()); 404 setDate(QDate::currentDate());
405} 405}
406 406
407QSize 407QSize
408KDatePicker::sizeHint() const 408KDatePicker::sizeHint() const
409{ 409{
410 return QWidget::sizeHint(); 410 return QWidget::sizeHint();
411} 411}
412 412
413void 413void
414KDatePicker::setFontSize(int s) 414KDatePicker::setFontSize(int s)
415{ 415{
416 QWidget *buttons[]= { 416 QWidget *buttons[]= {
417 // yearBackward, 417 // yearBackward,
418 // monthBackward, 418 // monthBackward,
419 selectMonth, 419 selectMonth,
420 selectYear, 420 selectYear,
421 // monthForward, 421 // monthForward,
422 // yearForward 422 // yearForward
423 }; 423 };
424 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]); 424 const int NoOfButtons=sizeof(buttons)/sizeof(buttons[0]);
425 int count; 425 int count;
426 QFont font; 426 QFont font;
427 QRect r; 427 QRect r;
428 // ----- 428 // -----
429 fontsize=s; 429 fontsize=s;
430 for(count=0; count<NoOfButtons; ++count) 430 for(count=0; count<NoOfButtons; ++count)
431 { 431 {
432 font=buttons[count]->font(); 432 font=buttons[count]->font();
433 font.setPointSize(s); 433 font.setPointSize(s);
434 buttons[count]->setFont(font); 434 buttons[count]->setFont(font);
435 } 435 }
436 QFontMetrics metrics(selectMonth->fontMetrics()); 436 QFontMetrics metrics(selectMonth->fontMetrics());
437 437
438 for (int i = 1; ; ++i) 438 for (int i = 1; ; ++i)
439 { 439 {
440 QString str = KGlobal::locale()->calendar()->monthName(i, 440 QString str = KGlobal::locale()->calendar()->monthName(i,
441 KGlobal::locale()->calendar()->year(table->getDate()), false); 441 KGlobal::locale()->calendar()->year(table->getDate()), false);
442 if (str.isNull()) break; 442 if (str.isNull()) break;
443 r=metrics.boundingRect(str); 443 r=metrics.boundingRect(str);
444 maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width())); 444 maxMonthRect.setWidth(QMAX(r.width(), maxMonthRect.width()));
445 maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height())); 445 maxMonthRect.setHeight(QMAX(r.height(), maxMonthRect.height()));
446 } 446 }
447 447
448 QSize metricBound = style().sizeFromContents(QStyle::CT_ToolButton, 448 QSize metricBound = style().sizeFromContents(QStyle::CT_ToolButton,
449 selectMonth, 449 selectMonth,
450 maxMonthRect); 450 maxMonthRect);
451 selectMonth->setMinimumSize(metricBound); 451 selectMonth->setMinimumSize(metricBound);
452 452
453 table->setFontSize(s); 453 table->setFontSize(s);
454} 454}
455 455
456void 456void
457KDatePicker::setCloseButton( bool enable ) 457KDatePicker::setCloseButton( bool enable )
458{ 458{
459 if ( enable == (d->closeButton != 0L) ) 459 if ( enable == (d->closeButton != 0L) )
460 return; 460 return;
461 461
462 if ( enable ) { 462 if ( enable ) {
463 d->closeButton = new QToolButton( d->tb ); 463 d->closeButton = new QToolButton( d->tb );
464 d->navigationLayout->addWidget(d->closeButton); 464 d->navigationLayout->addWidget(d->closeButton);
465 QToolTip::add(d->closeButton, i18n("Close")); 465 QToolTip::add(d->closeButton, i18n("Close"));
466 d->closeButton->setPixmap( SmallIcon("remove") ); 466 d->closeButton->setPixmap( SmallIcon("remove") );
467 connect( d->closeButton, SIGNAL( clicked() ), 467 connect( d->closeButton, SIGNAL( clicked() ),
468 topLevelWidget(), SLOT( close() ) ); 468 topLevelWidget(), SLOT( close() ) );
469 } 469 }
470 else { 470 else {
471 delete d->closeButton; 471 delete d->closeButton;
472 d->closeButton = 0L; 472 d->closeButton = 0L;
473 } 473 }
474 474
475 updateGeometry(); 475 updateGeometry();
476} 476}
477 477
478bool KDatePicker::hasCloseButton() const 478bool KDatePicker::hasCloseButton() const
479{ 479{
480 return (d->closeButton != 0L); 480 return (d->closeButton != 0L);
481} 481}
482 482
483void KDatePicker::virtual_hook( int /*id*/, void* /*data*/ ) 483void KDatePicker::virtual_hook( int /*id*/, void* /*data*/ )
484{ /*BASE::virtual_hook( id, data );*/ } 484{ /*BASE::virtual_hook( id, data );*/ }
485 485
diff --git a/microkde/kdatetbl.cpp b/microkde/kdatetbl.cpp
index 353f78d..10dc449 100644
--- a/microkde/kdatetbl.cpp
+++ b/microkde/kdatetbl.cpp
@@ -1,932 +1,939 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/////////////////// KDateTable widget class ////////////////////// 21/////////////////// KDateTable widget class //////////////////////
22// 22//
23// Copyright (C) 1997 Tim D. Gilman 23// Copyright (C) 1997 Tim D. Gilman
24// (C) 1998-2001 Mirko Boehm 24// (C) 1998-2001 Mirko Boehm
25// Written using Qt (http://www.troll.no) for the 25// Written using Qt (http://www.troll.no) for the
26// KDE project (http://www.kde.org) 26// KDE project (http://www.kde.org)
27// 27//
28// This is a support class for the KDatePicker class. It just 28// This is a support class for the KDatePicker class. It just
29// draws the calender table without titles, but could theoretically 29// draws the calender table without titles, but could theoretically
30// be used as a standalone. 30// be used as a standalone.
31// 31//
32// When a date is selected by the user, it emits a signal: 32// When a date is selected by the user, it emits a signal:
33// dateSelected(QDate) 33// dateSelected(QDate)
34 34
35#include <kglobal.h> 35#include <kglobal.h>
36#include <kglobalsettings.h> 36#include <kglobalsettings.h>
37#include <kapplication.h> 37#include <kapplication.h>
38#include <klocale.h> 38#include <klocale.h>
39#include <kdebug.h> 39#include <kdebug.h>
40#include <knotifyclient.h> 40#include <knotifyclient.h>
41#include "kdatetbl.h" 41#include "kdatetbl.h"
42#include <qdatetime.h> 42#include <qdatetime.h>
43#include <qstring.h> 43#include <qstring.h>
44#include <qpen.h> 44#include <qpen.h>
45#include <qpainter.h> 45#include <qpainter.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <QDesktopWidget>
48//Added by qt3to4:
49#include <QResizeEvent>
50#include <QFocusEvent>
51#include <Q3Frame>
52#include <QMouseEvent>
53#include <QKeyEvent>
54#include <QEvent>
47#include <assert.h> 55#include <assert.h>
48#include <qapplication.h> 56#include <qapplication.h>
49 57
50KDateValidator::KDateValidator(QWidget* parent, const char* name) 58KDateValidator::KDateValidator(QWidget* parent, const char* name)
51 : QValidator(parent, name) 59 : QValidator(parent, name)
52{ 60{
53} 61}
54 62
55QValidator::State 63QValidator::State
56KDateValidator::validate(QString& text, int&) const 64KDateValidator::validate(QString& text, int&) const
57{ 65{
58 QDate temp; 66 QDate temp;
59 // ----- everything is tested in date(): 67 // ----- everything is tested in date():
60 return date(text, temp); 68 return date(text, temp);
61} 69}
62 70
63QValidator::State 71QValidator::State
64KDateValidator::date(const QString& text, QDate& d) const 72KDateValidator::date(const QString& text, QDate& d) const
65{ 73{
66 QDate tmp = KGlobal::locale()->readDate(text); 74 QDate tmp = KGlobal::locale()->readDate(text);
67 if (!tmp.isNull()) 75 if (!tmp.isNull())
68 { 76 {
69 d = tmp; 77 d = tmp;
70 return Acceptable; 78 return Acceptable;
71 } else 79 } else
72 return Valid; 80 return QValidator::Intermediate;
73} 81}
74 82
75void 83void
76KDateValidator::fixup( QString& ) const 84KDateValidator::fixup( QString& ) const
77{ 85{
78 86
79} 87}
80 88
81KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, WFlags f) 89KDateTable::KDateTable(QWidget *parent, QDate date_, const char* name, Qt::WFlags f)
82 : QGridView(parent, name, f) 90 : Q3GridView(parent, name, f)
83{ 91{
84 setFont( KGlobalSettings::generalFont() ); 92 setFont( KGlobalSettings::generalFont() );
85 if(!date_.isValid()) 93 if(!date_.isValid())
86 { 94 {
87 date_=QDate::currentDate(); 95 date_=QDate::currentDate();
88 } 96 }
89 setFocusPolicy( QWidget::StrongFocus ); 97 setFocusPolicy( Qt::StrongFocus );
90 setNumRows(7); // 6 weeks max + headline 98 setNumRows(7); // 6 weeks max + headline
91 setNumCols(7); // 7 days a week 99 setNumCols(7); // 7 days a week
92 setHScrollBarMode(AlwaysOff); 100 setHScrollBarMode(AlwaysOff);
93 setVScrollBarMode(AlwaysOff); 101 setVScrollBarMode(AlwaysOff);
94 viewport()->setBackgroundColor(QColor(220,245,255)); 102 viewport()->setBackgroundColor(QColor(220,245,255));
95#if 0 103#if 0
96 viewport()->setEraseColor(lightGray); 104 viewport()->setEraseColor(Qt::lightGray);
97#endif 105#endif
98 mMarkCurrent = false; 106 mMarkCurrent = false;
99 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth 107 setDate(date_); // this initializes firstday, numdays, numDaysPrevMonth
100} 108}
101 109
102void 110void
103KDateTable::paintCell(QPainter *painter, int row, int col) 111KDateTable::paintCell(QPainter *painter, int row, int col)
104{ 112{
105 QRect rect; 113 QRect rect;
106 QString text; 114 QString text;
107 QPen pen; 115 QPen pen;
108 int w=cellWidth(); 116 int w=cellWidth();
109 int h=cellHeight(); 117 int h=cellHeight();
110 int pos; 118 int pos;
111 QBrush brushBlue(blue); 119 QBrush brushBlue(Qt::blue);
112 QBrush brushLightblue(QColor(220,245,255)); 120 QBrush brushLightblue(QColor(220,245,255));
113 QFont _font=font(); 121 QFont _font=font();
114 // ----- 122 // -----
115 if(row==0) 123 if(row==0)
116 { // we are drawing the headline 124 { // we are drawing the headline
117 _font.setBold(true); 125 _font.setBold(true);
118 painter->setFont(_font); 126 painter->setFont(_font);
119 bool normalday = true; 127 bool normalday = true;
120 QString daystr; 128 QString daystr;
121 if (KGlobal::locale()->weekStartsMonday()) 129 if (KGlobal::locale()->weekStartsMonday())
122 { 130 {
123 daystr = KGlobal::locale()->weekDayName(col+1, true); 131 daystr = KGlobal::locale()->weekDayName(col+1, true);
124 if (col == 5 || col == 6) 132 if (col == 5 || col == 6)
125 normalday = false; 133 normalday = false;
126 } else { 134 } else {
127 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true); 135 daystr = KGlobal::locale()->weekDayName(col==0? 7 : col, true);
128 if (col == 0 || col == 6) 136 if (col == 0 || col == 6)
129 normalday = false; 137 normalday = false;
130 } 138 }
131 if (!normalday) 139 if (!normalday)
132 { 140 {
133 painter->setPen(QColor(220,245,255)); 141 painter->setPen(QColor(220,245,255));
134 painter->setBrush(brushLightblue); 142 painter->setBrush(brushLightblue);
135 painter->drawRect(0, 0, w, h); 143 painter->drawRect(0, 0, w, h);
136 painter->setPen(blue); 144 painter->setPen(Qt::blue);
137 } else { 145 } else {
138 painter->setPen(blue); 146 painter->setPen(Qt::blue);
139 painter->setBrush(brushBlue); 147 painter->setBrush(brushBlue);
140 painter->drawRect(0, 0, w, h); 148 painter->drawRect(0, 0, w, h);
141 painter->setPen(white); 149 painter->setPen(Qt::white);
142 } 150 }
143 painter->drawText(0, 0, w, h-1, AlignCenter, 151 painter->drawText(0, 0, w, h-1, Qt::AlignCenter,
144 daystr, -1, &rect); 152 daystr, -1, &rect);
145 painter->setPen(black); 153 painter->setPen(Qt::black);
146 painter->moveTo(0, h-1); 154 painter->drawLine(0, h-1, w-1, h-1);
147 painter->lineTo(w-1, h-1);
148 // ----- draw the weekday: 155 // ----- draw the weekday:
149 } else { 156 } else {
150 painter->setFont(_font); 157 painter->setFont(_font);
151 pos=7*(row-1)+col; 158 pos=7*(row-1)+col;
152 if (KGlobal::locale()->weekStartsMonday()) 159 if (KGlobal::locale()->weekStartsMonday())
153 pos++; 160 pos++;
154 if(pos<firstday || (firstday+numdays<=pos)) 161 if(pos<firstday || (firstday+numdays<=pos))
155 { // we are either 162 { // we are either
156 // ° painting a day of the previous month or 163 // ° painting a day of the previous month or
157 // ° painting a day of the following month 164 // ° painting a day of the following month
158 if(pos<firstday) 165 if(pos<firstday)
159 { // previous month 166 { // previous month
160 text.setNum(numDaysPrevMonth+pos-firstday+1); 167 text.setNum(numDaysPrevMonth+pos-firstday+1);
161 } else { // following month 168 } else { // following month
162 text.setNum(pos-firstday-numdays+1); 169 text.setNum(pos-firstday-numdays+1);
163 } 170 }
164 painter->setPen(gray); 171 painter->setPen(Qt::gray);
165 } else { // paint a day of the current month 172 } else { // paint a day of the current month
166 text.setNum(pos-firstday+1); 173 text.setNum(pos-firstday+1);
167 painter->setPen(black); 174 painter->setPen(Qt::black);
168 } 175 }
169 176
170 pen=painter->pen(); 177 pen=painter->pen();
171 if(firstday+date.day()-1==pos) 178 if(firstday+date.day()-1==pos)
172 { 179 {
173 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 180 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
174 painter->setPen(green); 181 painter->setPen(Qt::green);
175 else 182 else
176 painter->setPen(red); 183 painter->setPen(Qt::red);
177 if(hasFocus()) 184 if(hasFocus())
178 { 185 {
179 painter->setBrush(darkRed); 186 painter->setBrush(Qt::darkRed);
180 pen=white; 187 pen=QColor(Qt::white);
181 } else { 188 } else {
182 painter->setBrush(darkGray); 189 painter->setBrush(Qt::darkGray);
183 pen=white; 190 pen=QColor(Qt::white);
184 } 191 }
185 } else { 192 } else {
186 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos) 193 if(mMarkCurrent && firstday+QDate::currentDate().day()-1==pos)
187 { 194 {
188 painter->setPen(green); 195 painter->setPen(Qt::green);
189 painter->setBrush(darkGreen); 196 painter->setBrush(Qt::darkGreen);
190 pen=white; 197 pen=QColor(Qt::white);
191 } else { 198 } else {
192 painter->setBrush(QColor(220,245,255)); 199 painter->setBrush(QColor(220,245,255));
193 painter->setPen(QColor(220,245,255)); 200 painter->setPen(QColor(220,245,255));
194 } 201 }
195 } 202 }
196 painter->drawRect(0, 0, w, h); 203 painter->drawRect(0, 0, w, h);
197 painter->setPen(pen); 204 painter->setPen(pen);
198 painter->drawText(0, 0, w, h, AlignCenter, text, -1, &rect); 205 painter->drawText(0, 0, w, h, Qt::AlignCenter, text, -1, &rect);
199 } 206 }
200 /* 207 /*
201 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width()); 208 if(rect.width()>maxCell.width()) maxCell.setWidth(rect.width());
202 if(rect.height()>maxCell.height()) { 209 if(rect.height()>maxCell.height()) {
203 maxCell.setHeight(rect.height()); 210 maxCell.setHeight(rect.height());
204 } 211 }
205 */ 212 */
206} 213}
207 214
208void 215void
209KDateTable::keyPressEvent( QKeyEvent *e ) 216KDateTable::keyPressEvent( QKeyEvent *e )
210{ 217{
211 /* 218 /*
212 // not working properly 219 // not working properly
213 if ( e->key() == Qt::Key_Prior ) { 220 if ( e->key() == Qt::Key_Prior ) {
214 if ( date.month() == 1 ) { 221 if ( date.month() == 1 ) {
215 KNotifyClient::beep(); 222 KNotifyClient::beep();
216 return; 223 return;
217 } 224 }
218 int day = date.day(); 225 int day = date.day();
219 if ( day > 27 ) 226 if ( day > 27 )
220 while ( !QDate::isValid( date.year(), date.month()-1, day ) ) 227 while ( !QDate::isValid( date.year(), date.month()-1, day ) )
221 day--; 228 day--;
222 setDate(QDate(date.year(), date.month()-1, day)); 229 setDate(QDate(date.year(), date.month()-1, day));
223 return; 230 return;
224 } 231 }
225 if ( e->key() == Qt::Key_Next ) { 232 if ( e->key() == Qt::Key_Next ) {
226 if ( date.month() == 12 ) { 233 if ( date.month() == 12 ) {
227 KNotifyClient::beep(); 234 KNotifyClient::beep();
228 return; 235 return;
229 } 236 }
230 int day = date.day(); 237 int day = date.day();
231 if ( day > 27 ) 238 if ( day > 27 )
232 while ( !QDate::isValid( date.year(), date.month()+1, day ) ) 239 while ( !QDate::isValid( date.year(), date.month()+1, day ) )
233 day--; 240 day--;
234 setDate(QDate(date.year(), date.month()+1, day)); 241 setDate(QDate(date.year(), date.month()+1, day));
235 return; 242 return;
236 } 243 }
237 */ 244 */
238 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 245 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
239 246
240 int temp=firstday+date.day()-dayoff; 247 int temp=firstday+date.day()-dayoff;
241 int pos = temp; 248 int pos = temp;
242 bool irgnore = true; 249 bool irgnore = true;
243 int add = 0; 250 int add = 0;
244 if ( e->state() != Qt::ControlButton ) { 251 if ( e->state() != Qt::ControlButton ) {
245 if ( e->key() == Qt::Key_Up ) { 252 if ( e->key() == Qt::Key_Up ) {
246 add -= 7; 253 add -= 7;
247 irgnore = false; 254 irgnore = false;
248 } 255 }
249 if ( e->key() == Qt::Key_Down ) { 256 if ( e->key() == Qt::Key_Down ) {
250 add += 7; 257 add += 7;
251 irgnore = false; 258 irgnore = false;
252 } 259 }
253 if ( e->key() == Qt::Key_Left ) { 260 if ( e->key() == Qt::Key_Left ) {
254 --add; 261 --add;
255 irgnore = false; 262 irgnore = false;
256 } 263 }
257 if ( e->key() == Qt::Key_Right ) { 264 if ( e->key() == Qt::Key_Right ) {
258 ++add; 265 ++add;
259 irgnore = false; 266 irgnore = false;
260 } 267 }
261 } 268 }
262 if ( irgnore ) { 269 if ( irgnore ) {
263 e->ignore(); 270 e->ignore();
264 return; 271 return;
265 } 272 }
266 273
267 pos += add; 274 pos += add;
268 setDate(date.addDays( add )); 275 setDate(date.addDays( add ));
269 updateCell(temp/7+1, temp%7); // Update the previously selected cell 276 updateCell(temp/7+1, temp%7); // Update the previously selected cell
270 updateCell(pos/7+1, pos%7); // Update the selected cell 277 updateCell(pos/7+1, pos%7); // Update the selected cell
271 278
272} 279}
273 280
274void 281void
275KDateTable::viewportResizeEvent(QResizeEvent * e) 282KDateTable::viewportResizeEvent(QResizeEvent * e)
276{ 283{
277 QGridView::viewportResizeEvent(e); 284 Q3GridView::viewportResizeEvent(e);
278 285
279 setCellWidth(viewport()->width()/7); 286 setCellWidth(viewport()->width()/7);
280 setCellHeight(viewport()->height()/7); 287 setCellHeight(viewport()->height()/7);
281} 288}
282 289
283void 290void
284KDateTable::setFontSize(int size) 291KDateTable::setFontSize(int size)
285{ 292{
286 int count; 293 int count;
287 QRect rect; 294 QRect rect;
288 // ----- store rectangles: 295 // ----- store rectangles:
289 fontsize=size; 296 fontsize=size;
290 QFont _font = font(); 297 QFont _font = font();
291 _font.setPointSize(fontsize); 298 _font.setPointSize(fontsize);
292 setFont( _font ); 299 setFont( _font );
293 _font.setBold( true ); 300 _font.setBold( true );
294 QFontMetrics metrics(_font); 301 QFontMetrics metrics(_font);
295 302
296 // ----- find largest day name: 303 // ----- find largest day name:
297 maxCell.setWidth(0); 304 maxCell.setWidth(0);
298 maxCell.setHeight(0); 305 maxCell.setHeight(0);
299 for(count=0; count<7; ++count) 306 for(count=0; count<7; ++count)
300 { 307 {
301 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true)); 308 rect=metrics.boundingRect(KGlobal::locale()->weekDayName(count+1, true));
302 maxCell.setWidth(QMAX(maxCell.width(), rect.width())); 309 maxCell.setWidth(QMAX(maxCell.width(), rect.width()));
303 maxCell.setHeight(QMAX(maxCell.height(), rect.height())); 310 maxCell.setHeight(QMAX(maxCell.height(), rect.height()));
304 } 311 }
305 // ----- compare with a real wide number and add some space: 312 // ----- compare with a real wide number and add some space:
306 rect=metrics.boundingRect(QString::fromLatin1("88")); 313 rect=metrics.boundingRect(QString::fromLatin1("88"));
307 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width())); 314 maxCell.setWidth(QMAX(maxCell.width()+2, rect.width()));
308#ifdef DESKTOP_VERSION 315#ifdef DESKTOP_VERSION
309 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height())); 316 maxCell.setHeight(QMAX(maxCell.height()+8, rect.height()));
310#else 317#else
311 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height())); 318 maxCell.setHeight(QMAX(maxCell.height()+4, rect.height()));
312#endif 319#endif
313 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) { 320 if ( maxCell.width() * 1000 / maxCell.height() > 1900 ) {
314 maxCell.setHeight(maxCell.width() * 1000 / 1900 ); 321 maxCell.setHeight(maxCell.width() * 1000 / 1900 );
315 //qDebug("setmax "); 322 //qDebug("setmax ");
316 } 323 }
317} 324}
318 325
319void 326void
320KDateTable::contentsMousePressEvent(QMouseEvent *e) 327KDateTable::contentsMousePressEvent(QMouseEvent *e)
321{ 328{
322 if(e->type()!=QEvent::MouseButtonPress) 329 if(e->type()!=QEvent::MouseButtonPress)
323 { // the KDatePicker only reacts on mouse press events: 330 { // the KDatePicker only reacts on mouse press events:
324 return; 331 return;
325 } 332 }
326 if(!isEnabled()) 333 if(!isEnabled())
327 { 334 {
328 KNotifyClient::beep(); 335 KNotifyClient::beep();
329 return; 336 return;
330 } 337 }
331 338
332 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0; 339 int dayoff = KGlobal::locale()->weekStartsMonday() ? 1 : 0;
333 // ----- 340 // -----
334 int row, col, pos, temp; 341 int row, col, pos, temp;
335 QPoint mouseCoord; 342 QPoint mouseCoord;
336 // ----- 343 // -----
337 mouseCoord = e->pos(); 344 mouseCoord = e->pos();
338 row=rowAt(mouseCoord.y()); 345 row=rowAt(mouseCoord.y());
339 col=columnAt(mouseCoord.x()); 346 col=columnAt(mouseCoord.x());
340 if(row<0 || col<0) 347 if(row<0 || col<0)
341 { // the user clicked on the frame of the table 348 { // the user clicked on the frame of the table
342 return; 349 return;
343 } 350 }
344 pos=7*(row-1)+col+1; 351 pos=7*(row-1)+col+1;
345#if 0 352#if 0
346 if(pos+dayoff<=firstday) 353 if(pos+dayoff<=firstday)
347 { // this day is in the previous month 354 { // this day is in the previous month
348 KNotifyClient::beep(); 355 KNotifyClient::beep();
349 return; 356 return;
350 } 357 }
351 if(firstday+numdays<pos+dayoff) 358 if(firstday+numdays<pos+dayoff)
352 { // this date is in the next month 359 { // this date is in the next month
353 KNotifyClient::beep(); 360 KNotifyClient::beep();
354 return; 361 return;
355 } 362 }
356#endif 363#endif
357 temp=firstday+date.day()-dayoff-1; 364 temp=firstday+date.day()-dayoff-1;
358 QDate da = QDate(date.year(), date.month(),1); 365 QDate da = QDate(date.year(), date.month(),1);
359 setDate(da.addDays( pos-firstday+dayoff-1)); 366 setDate(da.addDays( pos-firstday+dayoff-1));
360 updateCell(temp/7+1, temp%7); // Update the previously selected cell 367 updateCell(temp/7+1, temp%7); // Update the previously selected cell
361 updateCell(row, col); // Update the selected cell 368 updateCell(row, col); // Update the selected cell
362 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid()); 369 // assert(QDate(date.year(), date.month(), pos-firstday+dayoff).isValid());
363 emit(tableClicked()); 370 emit(tableClicked());
364} 371}
365 372
366bool 373bool
367KDateTable::setDate(const QDate& date_) 374KDateTable::setDate(const QDate& date_)
368{ 375{
369 bool changed=false; 376 bool changed=false;
370 QDate temp; 377 QDate temp;
371 mMarkCurrent = false; 378 mMarkCurrent = false;
372 // ----- 379 // -----
373 if(!date_.isValid()) 380 if(!date_.isValid())
374 { 381 {
375 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl; 382 kdDebug() << "KDateTable::setDate: refusing to set invalid date." << endl;
376 return false; 383 return false;
377 } 384 }
378 if(date!=date_) 385 if(date!=date_)
379 { 386 {
380 date=date_; 387 date=date_;
381 changed=true; 388 changed=true;
382 } 389 }
383 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() ); 390 mMarkCurrent = ( date.month() == QDate::currentDate().month() && date.year() == QDate::currentDate().year() );
384 temp.setYMD(date.year(), date.month(), 1); 391 temp.setYMD(date.year(), date.month(), 1);
385 firstday=temp.dayOfWeek(); 392 firstday=temp.dayOfWeek();
386 if(firstday==1) firstday=8; 393 if(firstday==1) firstday=8;
387 numdays=date.daysInMonth(); 394 numdays=date.daysInMonth();
388 if(date.month()==1) 395 if(date.month()==1)
389 { // set to december of previous year 396 { // set to december of previous year
390 temp.setYMD(date.year()-1, 12, 1); 397 temp.setYMD(date.year()-1, 12, 1);
391 } else { // set to previous month 398 } else { // set to previous month
392 temp.setYMD(date.year(), date.month()-1, 1); 399 temp.setYMD(date.year(), date.month()-1, 1);
393 } 400 }
394 numDaysPrevMonth=temp.daysInMonth(); 401 numDaysPrevMonth=temp.daysInMonth();
395 if(changed) 402 if(changed)
396 { 403 {
397 repaintContents(false); 404 repaintContents(false);
398 } 405 }
399 emit(dateChanged(date)); 406 emit(dateChanged(date));
400 return true; 407 return true;
401} 408}
402 409
403const QDate& 410const QDate&
404KDateTable::getDate() const 411KDateTable::getDate() const
405{ 412{
406 return date; 413 return date;
407} 414}
408 415
409void KDateTable::focusInEvent( QFocusEvent *e ) 416void KDateTable::focusInEvent( QFocusEvent *e )
410{ 417{
411 repaintContents(false); 418 repaintContents(false);
412 QGridView::focusInEvent( e ); 419 Q3GridView::focusInEvent( e );
413} 420}
414 421
415void KDateTable::focusOutEvent( QFocusEvent *e ) 422void KDateTable::focusOutEvent( QFocusEvent *e )
416{ 423{
417 repaintContents(false); 424 repaintContents(false);
418 QGridView::focusOutEvent( e ); 425 Q3GridView::focusOutEvent( e );
419} 426}
420 427
421QSize 428QSize
422KDateTable::sizeHint() const 429KDateTable::sizeHint() const
423{ 430{
424 if(maxCell.height()>0 && maxCell.width()>0) 431 if(maxCell.height()>0 && maxCell.width()>0)
425 { 432 {
426 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(), 433 return QSize((maxCell.width()+2)*numCols()+2*frameWidth(),
427 (maxCell.height()+4)*numRows()+2*frameWidth()); 434 (maxCell.height()+4)*numRows()+2*frameWidth());
428 } else { 435 } else {
429 return QSize(-1, -1); 436 return QSize(-1, -1);
430 } 437 }
431} 438}
432 439
433KDateInternalMonthPicker::KDateInternalMonthPicker 440KDateInternalMonthPicker::KDateInternalMonthPicker
434(QWidget* parent, const char* name) 441(QWidget* parent, const char* name)
435 : QGridView(parent, name), 442 : Q3GridView(parent, name),
436 result(0) // invalid 443 result(0) // invalid
437{ 444{
438 QRect rect; 445 QRect rect;
439 QFont font; 446 QFont font;
440 // ----- 447 // -----
441 activeCol = -1; 448 activeCol = -1;
442 activeRow = -1; 449 activeRow = -1;
443 font=KGlobalSettings::generalFont(); 450 font=KGlobalSettings::generalFont();
444 int fontsize = 10; 451 int fontsize = 10;
445 int add = 2; 452 int add = 2;
446 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 453 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
447 add += 8; 454 add += 8;
448 if ( QApplication::desktop()->width() > 640 ) 455 if ( QApplication::desktop()->width() > 640 )
449 add += 6; 456 add += 6;
450 font.setPointSize(fontsize+add); 457 font.setPointSize(fontsize+add);
451 setFont(font); 458 setFont(font);
452 setHScrollBarMode(AlwaysOff); 459 setHScrollBarMode(AlwaysOff);
453 setVScrollBarMode(AlwaysOff); 460 setVScrollBarMode(AlwaysOff);
454 setFrameStyle(QFrame::NoFrame); 461 setFrameStyle(Q3Frame::NoFrame);
455 setNumRows(4); 462 setNumRows(4);
456 setNumCols(3); 463 setNumCols(3);
457 // enable to find drawing failures: 464 // enable to find drawing failures:
458 // setTableFlags(Tbl_clipCellPainting); 465 // setTableFlags(Tbl_clipCellPainting);
459#if 0 466#if 0
460 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 467 viewport()->setEraseColor(Qt::lightGray); // for consistency with the datepicker
461#endif 468#endif
462 // ----- find the preferred size 469 // ----- find the preferred size
463 // (this is slow, possibly, but unfortunatly it is needed here): 470 // (this is slow, possibly, but unfortunatly it is needed here):
464 QFontMetrics metrics(font); 471 QFontMetrics metrics(font);
465 for(int i=1; i <= 12; ++i) 472 for(int i=1; i <= 12; ++i)
466 { 473 {
467 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false)); 474 rect=metrics.boundingRect(KGlobal::locale()->monthName(i, false));
468 if(max.width()<rect.width()) max.setWidth(rect.width()); 475 if(max.width()<rect.width()) max.setWidth(rect.width());
469 if(max.height()<rect.height()) max.setHeight(rect.height()); 476 if(max.height()<rect.height()) max.setHeight(rect.height());
470 } 477 }
471 478
472} 479}
473 480
474QSize 481QSize
475KDateInternalMonthPicker::sizeHint() const 482KDateInternalMonthPicker::sizeHint() const
476{ 483{
477 return QSize((max.width()+6)*numCols()+2*frameWidth(), 484 return QSize((max.width()+6)*numCols()+2*frameWidth(),
478 (max.height()+6)*numRows()+2*frameWidth()); 485 (max.height()+6)*numRows()+2*frameWidth());
479} 486}
480 487
481int 488int
482KDateInternalMonthPicker::getResult() const 489KDateInternalMonthPicker::getResult() const
483{ 490{
484 return result; 491 return result;
485} 492}
486 493
487void 494void
488KDateInternalMonthPicker::setupPainter(QPainter *p) 495KDateInternalMonthPicker::setupPainter(QPainter *p)
489{ 496{
490 p->setPen(black); 497 p->setPen(Qt::black);
491} 498}
492 499
493void 500void
494KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*) 501KDateInternalMonthPicker::viewportResizeEvent(QResizeEvent*)
495{ 502{
496 setCellWidth(width()/3); 503 setCellWidth(width()/3);
497 setCellHeight(height()/4); 504 setCellHeight(height()/4);
498} 505}
499 506
500void 507void
501KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col) 508KDateInternalMonthPicker::paintCell(QPainter* painter, int row, int col)
502{ 509{
503 int index; 510 int index;
504 QString text; 511 QString text;
505 // ----- find the number of the cell: 512 // ----- find the number of the cell:
506 index=3*row+col+1; 513 index=3*row+col+1;
507 text=KGlobal::locale()->monthName(index, false); 514 text=KGlobal::locale()->monthName(index, false);
508 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 515 painter->drawText(0, 0, cellWidth(), cellHeight(), Qt::AlignCenter, text);
509 if ( activeCol == col && activeRow == row ) 516 if ( activeCol == col && activeRow == row )
510 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 517 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
511} 518}
512 519
513void 520void
514KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e) 521KDateInternalMonthPicker::contentsMousePressEvent(QMouseEvent *e)
515{ 522{
516 if(!isEnabled() || e->button() != LeftButton) 523 if(!isEnabled() || e->button() != Qt::LeftButton)
517 { 524 {
518 KNotifyClient::beep(); 525 KNotifyClient::beep();
519 return; 526 return;
520 } 527 }
521 // ----- 528 // -----
522 int row, col; 529 int row, col;
523 QPoint mouseCoord; 530 QPoint mouseCoord;
524 // ----- 531 // -----
525 mouseCoord = e->pos(); 532 mouseCoord = e->pos();
526 row=rowAt(mouseCoord.y()); 533 row=rowAt(mouseCoord.y());
527 col=columnAt(mouseCoord.x()); 534 col=columnAt(mouseCoord.x());
528 535
529 if(row<0 || col<0) 536 if(row<0 || col<0)
530 { // the user clicked on the frame of the table 537 { // the user clicked on the frame of the table
531 activeCol = -1; 538 activeCol = -1;
532 activeRow = -1; 539 activeRow = -1;
533 } else { 540 } else {
534 activeCol = col; 541 activeCol = col;
535 activeRow = row; 542 activeRow = row;
536 updateCell( row, col /*, false */ ); 543 updateCell( row, col /*, false */ );
537 } 544 }
538} 545}
539 546
540void 547void
541KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e) 548KDateInternalMonthPicker::contentsMouseMoveEvent(QMouseEvent *e)
542{ 549{
543 if (e->state() & LeftButton) 550 if (e->state() & Qt::LeftButton)
544 { 551 {
545 int row, col; 552 int row, col;
546 QPoint mouseCoord; 553 QPoint mouseCoord;
547 // ----- 554 // -----
548 mouseCoord = e->pos(); 555 mouseCoord = e->pos();
549 row=rowAt(mouseCoord.y()); 556 row=rowAt(mouseCoord.y());
550 col=columnAt(mouseCoord.x()); 557 col=columnAt(mouseCoord.x());
551 int tmpRow = -1, tmpCol = -1; 558 int tmpRow = -1, tmpCol = -1;
552 if(row<0 || col<0) 559 if(row<0 || col<0)
553 { // the user clicked on the frame of the table 560 { // the user clicked on the frame of the table
554 if ( activeCol > -1 ) 561 if ( activeCol > -1 )
555 { 562 {
556 tmpRow = activeRow; 563 tmpRow = activeRow;
557 tmpCol = activeCol; 564 tmpCol = activeCol;
558 } 565 }
559 activeCol = -1; 566 activeCol = -1;
560 activeRow = -1; 567 activeRow = -1;
561 } else { 568 } else {
562 bool differentCell = (activeRow != row || activeCol != col); 569 bool differentCell = (activeRow != row || activeCol != col);
563 if ( activeCol > -1 && differentCell) 570 if ( activeCol > -1 && differentCell)
564 { 571 {
565 tmpRow = activeRow; 572 tmpRow = activeRow;
566 tmpCol = activeCol; 573 tmpCol = activeCol;
567 } 574 }
568 if ( differentCell) 575 if ( differentCell)
569 { 576 {
570 activeRow = row; 577 activeRow = row;
571 activeCol = col; 578 activeCol = col;
572 updateCell( row, col /*, false */ ); // mark the new active cell 579 updateCell( row, col /*, false */ ); // mark the new active cell
573 } 580 }
574 } 581 }
575 if ( tmpRow > -1 ) // repaint the former active cell 582 if ( tmpRow > -1 ) // repaint the former active cell
576 updateCell( tmpRow, tmpCol /*, true */ ); 583 updateCell( tmpRow, tmpCol /*, true */ );
577 } 584 }
578} 585}
579 586
580void 587void
581KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e) 588KDateInternalMonthPicker::contentsMouseReleaseEvent(QMouseEvent *e)
582{ 589{
583 if(!isEnabled()) 590 if(!isEnabled())
584 { 591 {
585 return; 592 return;
586 } 593 }
587 // ----- 594 // -----
588 int row, col, pos; 595 int row, col, pos;
589 QPoint mouseCoord; 596 QPoint mouseCoord;
590 // ----- 597 // -----
591 mouseCoord = e->pos(); 598 mouseCoord = e->pos();
592 row=rowAt(mouseCoord.y()); 599 row=rowAt(mouseCoord.y());
593 col=columnAt(mouseCoord.x()); 600 col=columnAt(mouseCoord.x());
594 if(row<0 || col<0) 601 if(row<0 || col<0)
595 { // the user clicked on the frame of the table 602 { // the user clicked on the frame of the table
596 emit(closeMe(0)); 603 emit(closeMe(0));
597 } 604 }
598 pos=3*row+col+1; 605 pos=3*row+col+1;
599 result=pos; 606 result=pos;
600 emit(closeMe(1)); 607 emit(closeMe(1));
601} 608}
602 609
603 610
604 611
605KDateInternalYearSelector::KDateInternalYearSelector 612KDateInternalYearSelector::KDateInternalYearSelector
606(int fontsize, QWidget* parent, const char* name) 613(int fontsize, QWidget* parent, const char* name)
607 : QLineEdit(parent, name), 614 : QLineEdit(parent, name),
608 val(new QIntValidator(this)), 615 val(new QIntValidator(this)),
609 result(0) 616 result(0)
610{ 617{
611 QFont font; 618 QFont font;
612 // ----- 619 // -----
613 font=KGlobalSettings::generalFont(); 620 font=KGlobalSettings::generalFont();
614 font.setPointSize(fontsize); 621 font.setPointSize(fontsize);
615 setFont(font); 622 setFont(font);
616#if 0 623#if 0
617 setFrameStyle(QFrame::NoFrame); 624 setFrameStyle(Q3Frame::NoFrame);
618#endif 625#endif
619 // we have to respect the limits of QDate here, I fear: 626 // we have to respect the limits of QDate here, I fear:
620 val->setRange(0, 8000); 627 val->setRange(0, 8000);
621 setValidator(val); 628 setValidator(val);
622 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot())); 629 connect(this, SIGNAL(returnPressed()), SLOT(yearEnteredSlot()));
623} 630}
624 631
625void 632void
626KDateInternalYearSelector::yearEnteredSlot() 633KDateInternalYearSelector::yearEnteredSlot()
627{ 634{
628 bool ok; 635 bool ok;
629 int year; 636 int year;
630 QDate date; 637 QDate date;
631 // ----- check if this is a valid year: 638 // ----- check if this is a valid year:
632 year=text().toInt(&ok); 639 year=text().toInt(&ok);
633 if(!ok) 640 if(!ok)
634 { 641 {
635 KNotifyClient::beep(); 642 KNotifyClient::beep();
636 return; 643 return;
637 } 644 }
638 date.setYMD(year, 1, 1); 645 date.setYMD(year, 1, 1);
639 if(!date.isValid()) 646 if(!date.isValid())
640 { 647 {
641 KNotifyClient::beep(); 648 KNotifyClient::beep();
642 return; 649 return;
643 } 650 }
644 result=year; 651 result=year;
645 emit(closeMe(1)); 652 emit(closeMe(1));
646} 653}
647 654
648int 655int
649KDateInternalYearSelector::getYear() 656KDateInternalYearSelector::getYear()
650{ 657{
651 return result; 658 return result;
652} 659}
653 660
654void 661void
655KDateInternalYearSelector::setYear(int year) 662KDateInternalYearSelector::setYear(int year)
656{ 663{
657 QString temp; 664 QString temp;
658 // ----- 665 // -----
659 temp.setNum(year); 666 temp.setNum(year);
660 setText(temp); 667 setText(temp);
661} 668}
662 669
663KPopupFrame::KPopupFrame(QWidget* parent, const char* name) 670KPopupFrame::KPopupFrame(QWidget* parent, const char* name)
664 : QFrame(parent, name, WType_Popup), 671 : Q3Frame(parent, name, Qt::WType_Popup),
665 result(0), // rejected 672 result(0), // rejected
666 main(0) 673 main(0)
667{ 674{
668 setFrameStyle(QFrame::Box|QFrame::Raised); 675 setFrameStyle(Q3Frame::Box|Q3Frame::Raised);
669 setMidLineWidth(2); 676 setMidLineWidth(2);
670} 677}
671 678
672void 679void
673KPopupFrame::keyPressEvent(QKeyEvent* e) 680KPopupFrame::keyPressEvent(QKeyEvent* e)
674{ 681{
675 if(e->key()==Key_Escape) 682 if(e->key()==Qt::Key_Escape)
676 { 683 {
677 result=0; // rejected 684 result=0; // rejected
678 qApp->exit_loop(); 685 qApp->exit_loop();
679 } 686 }
680} 687}
681 688
682void 689void
683KPopupFrame::close(int r) 690KPopupFrame::close(int r)
684{ 691{
685 result=r; 692 result=r;
686 qApp->exit_loop(); 693 qApp->exit_loop();
687} 694}
688 695
689void 696void
690KPopupFrame::setMainWidget(QWidget* m) 697KPopupFrame::setMainWidget(QWidget* m)
691{ 698{
692 main=m; 699 main=m;
693 if(main!=0) 700 if(main!=0)
694 { 701 {
695 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth()); 702 resize(main->width()+2*frameWidth(), main->height()+2*frameWidth());
696 } 703 }
697} 704}
698 705
699void 706void
700KPopupFrame::resizeEvent(QResizeEvent*) 707KPopupFrame::resizeEvent(QResizeEvent*)
701{ 708{
702 if(main!=0) 709 if(main!=0)
703 { 710 {
704 main->setGeometry(frameWidth(), frameWidth(), 711 main->setGeometry(frameWidth(), frameWidth(),
705 width()-2*frameWidth(), height()-2*frameWidth()); 712 width()-2*frameWidth(), height()-2*frameWidth());
706 } 713 }
707} 714}
708 715
709void 716void
710KPopupFrame::popup(const QPoint &pos) 717KPopupFrame::popup(const QPoint &pos)
711{ 718{
712 // Make sure the whole popup is visible. 719 // Make sure the whole popup is visible.
713 QRect d = QApplication::desktop()->frameGeometry(); 720 QRect d = QApplication::desktop()->frameGeometry();
714 int x = pos.x(); 721 int x = pos.x();
715 int y = pos.y(); 722 int y = pos.y();
716 int w = width(); 723 int w = width();
717 int h = height(); 724 int h = height();
718 if (x+w > d.x()+d.width()) 725 if (x+w > d.x()+d.width())
719 x = d.width() - w; 726 x = d.width() - w;
720 if (y+h > d.y()+d.height()) 727 if (y+h > d.y()+d.height())
721 y = d.height() - h; 728 y = d.height() - h;
722 if (x < d.x()) 729 if (x < d.x())
723 x = 0; 730 x = 0;
724 if (y < d.y()) 731 if (y < d.y())
725 y = 0; 732 y = 0;
726 733
727 // Pop the thingy up. 734 // Pop the thingy up.
728 move(x, y); 735 move(x, y);
729 show(); 736 show();
730} 737}
731 738
732int 739int
733KPopupFrame::exec(QPoint pos) 740KPopupFrame::exec(QPoint pos)
734{ 741{
735 popup(pos); 742 popup(pos);
736 repaint(); 743 repaint();
737 qApp->enter_loop(); 744 qApp->enter_loop();
738 hide(); 745 hide();
739 return result; 746 return result;
740} 747}
741 748
742int 749int
743KPopupFrame::exec(int x, int y) 750KPopupFrame::exec(int x, int y)
744{ 751{
745 return exec(QPoint(x, y)); 752 return exec(QPoint(x, y));
746} 753}
747 754
748void KPopupFrame::virtual_hook( int, void* ) 755void KPopupFrame::virtual_hook( int, void* )
749{ /*BASE::virtual_hook( id, data );*/ } 756{ /*BASE::virtual_hook( id, data );*/ }
750 757
751void KDateTable::virtual_hook( int, void* ) 758void KDateTable::virtual_hook( int, void* )
752{ /*BASE::virtual_hook( id, data );*/ } 759{ /*BASE::virtual_hook( id, data );*/ }
753 760
754//#include "kdatetbl.moc" 761//#include "kdatetbl.moc"
755 762
756 763
757KDateInternalWeekPicker::KDateInternalWeekPicker 764KDateInternalWeekPicker::KDateInternalWeekPicker
758(QWidget* parent, const char* name) 765(QWidget* parent, const char* name)
759 : QGridView(parent, name), 766 : Q3GridView(parent, name),
760 result(0) // invalid 767 result(0) // invalid
761{ 768{
762 QRect rect; 769 QRect rect;
763 QFont font; 770 QFont font;
764 // ----- 771 // -----
765 activeCol = -1; 772 activeCol = -1;
766 activeRow = -1; 773 activeRow = -1;
767 font=KGlobalSettings::generalFont(); 774 font=KGlobalSettings::generalFont();
768 int fontsize = 10; 775 int fontsize = 10;
769 int add = 2; 776 int add = 2;
770 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 777 if ( QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
771 add += 6; 778 add += 6;
772 font.setPointSize(fontsize+add); 779 font.setPointSize(fontsize+add);
773 setFont(font); 780 setFont(font);
774 setHScrollBarMode(AlwaysOff); 781 setHScrollBarMode(AlwaysOff);
775 setVScrollBarMode(AlwaysOff); 782 setVScrollBarMode(AlwaysOff);
776 setFrameStyle(QFrame::NoFrame); 783 setFrameStyle(Q3Frame::NoFrame);
777 if ( QApplication::desktop()->height() > 240 ) { 784 if ( QApplication::desktop()->height() > 240 ) {
778 setNumRows(13); 785 setNumRows(13);
779 setNumCols(4); 786 setNumCols(4);
780 } else { 787 } else {
781 setNumRows(4); 788 setNumRows(4);
782 setNumCols(13); 789 setNumCols(13);
783 } 790 }
784 // enable to find drawing failures: 791 // enable to find drawing failures:
785 // setTableFlags(Tbl_clipCellPainting); 792 // setTableFlags(Tbl_clipCellPainting);
786#if 0 793#if 0
787 viewport()->setEraseColor(lightGray); // for consistency with the datepicker 794 viewport()->setEraseColor(Qt::lightGray); // for consistency with the datepicker
788#endif 795#endif
789 // ----- find the preferred size 796 // ----- find the preferred size
790 // (this is slow, possibly, but unfortunatly it is needed here): 797 // (this is slow, possibly, but unfortunatly it is needed here):
791 QFontMetrics metrics(font); 798 QFontMetrics metrics(font);
792 for(int i=1; i <= 52; ++i) 799 for(int i=1; i <= 52; ++i)
793 { 800 {
794 rect=metrics.boundingRect(QString::number( i )); 801 rect=metrics.boundingRect(QString::number( i ));
795 if(max.width()<rect.width()) max.setWidth(rect.width()); 802 if(max.width()<rect.width()) max.setWidth(rect.width());
796 if(max.height()<rect.height()) max.setHeight(rect.height()); 803 if(max.height()<rect.height()) max.setHeight(rect.height());
797 } 804 }
798 if ( QApplication::desktop()->width() > 640 ) { 805 if ( QApplication::desktop()->width() > 640 ) {
799 806
800 max.setWidth(max.width()+6); 807 max.setWidth(max.width()+6);
801 max.setHeight(max.height()+8); 808 max.setHeight(max.height()+8);
802 } 809 }
803} 810}
804 811
805QSize 812QSize
806KDateInternalWeekPicker::sizeHint() const 813KDateInternalWeekPicker::sizeHint() const
807{ 814{
808 return QSize((max.width()+6)*numCols()+2*frameWidth(), 815 return QSize((max.width()+6)*numCols()+2*frameWidth(),
809 (max.height()+6)*numRows()+2*frameWidth()); 816 (max.height()+6)*numRows()+2*frameWidth());
810} 817}
811 818
812int 819int
813KDateInternalWeekPicker::getResult() const 820KDateInternalWeekPicker::getResult() const
814{ 821{
815 return result; 822 return result;
816} 823}
817 824
818void 825void
819KDateInternalWeekPicker::setupPainter(QPainter *p) 826KDateInternalWeekPicker::setupPainter(QPainter *p)
820{ 827{
821 p->setPen(black); 828 p->setPen(Qt::black);
822} 829}
823 830
824void 831void
825KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*) 832KDateInternalWeekPicker::viewportResizeEvent(QResizeEvent*)
826{ 833{
827 setCellWidth(width()/ numCols()); 834 setCellWidth(width()/ numCols());
828 setCellHeight(height()/ numRows()); 835 setCellHeight(height()/ numRows());
829} 836}
830 837
831void 838void
832KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col) 839KDateInternalWeekPicker::paintCell(QPainter* painter, int row, int col)
833{ 840{
834 int index; 841 int index;
835 QString text; 842 QString text;
836 // ----- find the number of the cell: 843 // ----- find the number of the cell:
837 index=numCols()*row+col+1; 844 index=numCols()*row+col+1;
838 text=QString::number( index ); 845 text=QString::number( index );
839 painter->drawText(0, 0, cellWidth(), cellHeight(), AlignCenter, text); 846 painter->drawText(0, 0, cellWidth(), cellHeight(), Qt::AlignCenter, text);
840 if ( activeCol == col && activeRow == row ) 847 if ( activeCol == col && activeRow == row )
841 painter->drawRect( 0, 0, cellWidth(), cellHeight() ); 848 painter->drawRect( 0, 0, cellWidth(), cellHeight() );
842} 849}
843 850
844void 851void
845KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e) 852KDateInternalWeekPicker::contentsMousePressEvent(QMouseEvent *e)
846{ 853{
847 if(!isEnabled() || e->button() != LeftButton) 854 if(!isEnabled() || e->button() != Qt::LeftButton)
848 { 855 {
849 KNotifyClient::beep(); 856 KNotifyClient::beep();
850 return; 857 return;
851 } 858 }
852 // ----- 859 // -----
853 int row, col; 860 int row, col;
854 QPoint mouseCoord; 861 QPoint mouseCoord;
855 // ----- 862 // -----
856 mouseCoord = e->pos(); 863 mouseCoord = e->pos();
857 row=rowAt(mouseCoord.y()); 864 row=rowAt(mouseCoord.y());
858 col=columnAt(mouseCoord.x()); 865 col=columnAt(mouseCoord.x());
859 866
860 if(row<0 || col<0) 867 if(row<0 || col<0)
861 { // the user clicked on the frame of the table 868 { // the user clicked on the frame of the table
862 activeCol = -1; 869 activeCol = -1;
863 activeRow = -1; 870 activeRow = -1;
864 } else { 871 } else {
865 activeCol = col; 872 activeCol = col;
866 activeRow = row; 873 activeRow = row;
867 updateCell( row, col /*, false */ ); 874 updateCell( row, col /*, false */ );
868 } 875 }
869} 876}
870 877
871void 878void
872KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e) 879KDateInternalWeekPicker::contentsMouseMoveEvent(QMouseEvent *e)
873{ 880{
874 if (e->state() & LeftButton) 881 if (e->state() & Qt::LeftButton)
875 { 882 {
876 int row, col; 883 int row, col;
877 QPoint mouseCoord; 884 QPoint mouseCoord;
878 // ----- 885 // -----
879 mouseCoord = e->pos(); 886 mouseCoord = e->pos();
880 row=rowAt(mouseCoord.y()); 887 row=rowAt(mouseCoord.y());
881 col=columnAt(mouseCoord.x()); 888 col=columnAt(mouseCoord.x());
882 int tmpRow = -1, tmpCol = -1; 889 int tmpRow = -1, tmpCol = -1;
883 if(row<0 || col<0) 890 if(row<0 || col<0)
884 { // the user clicked on the frame of the table 891 { // the user clicked on the frame of the table
885 if ( activeCol > -1 ) 892 if ( activeCol > -1 )
886 { 893 {
887 tmpRow = activeRow; 894 tmpRow = activeRow;
888 tmpCol = activeCol; 895 tmpCol = activeCol;
889 } 896 }
890 activeCol = -1; 897 activeCol = -1;
891 activeRow = -1; 898 activeRow = -1;
892 } else { 899 } else {
893 bool differentCell = (activeRow != row || activeCol != col); 900 bool differentCell = (activeRow != row || activeCol != col);
894 if ( activeCol > -1 && differentCell) 901 if ( activeCol > -1 && differentCell)
895 { 902 {
896 tmpRow = activeRow; 903 tmpRow = activeRow;
897 tmpCol = activeCol; 904 tmpCol = activeCol;
898 } 905 }
899 if ( differentCell) 906 if ( differentCell)
900 { 907 {
901 activeRow = row; 908 activeRow = row;
902 activeCol = col; 909 activeCol = col;
903 updateCell( row, col /*, false */ ); // mark the new active cell 910 updateCell( row, col /*, false */ ); // mark the new active cell
904 } 911 }
905 } 912 }
906 if ( tmpRow > -1 ) // repaint the former active cell 913 if ( tmpRow > -1 ) // repaint the former active cell
907 updateCell( tmpRow, tmpCol /*, true */ ); 914 updateCell( tmpRow, tmpCol /*, true */ );
908 } 915 }
909} 916}
910 917
911void 918void
912KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e) 919KDateInternalWeekPicker::contentsMouseReleaseEvent(QMouseEvent *e)
913{ 920{
914 if(!isEnabled()) 921 if(!isEnabled())
915 { 922 {
916 return; 923 return;
917 } 924 }
918 // ----- 925 // -----
919 int row, col, pos; 926 int row, col, pos;
920 QPoint mouseCoord; 927 QPoint mouseCoord;
921 // ----- 928 // -----
922 mouseCoord = e->pos(); 929 mouseCoord = e->pos();
923 row=rowAt(mouseCoord.y()); 930 row=rowAt(mouseCoord.y());
924 col=columnAt(mouseCoord.x()); 931 col=columnAt(mouseCoord.x());
925 if(row<0 || col<0) 932 if(row<0 || col<0)
926 { // the user clicked on the frame of the table 933 { // the user clicked on the frame of the table
927 emit(closeMe(0)); 934 emit(closeMe(0));
928 } 935 }
929 pos=numCols()*row+col+1; 936 pos=numCols()*row+col+1;
930 result=pos; 937 result=pos;
931 emit(closeMe(1)); 938 emit(closeMe(1));
932} 939}
diff --git a/microkde/kdatetbl.h b/microkde/kdatetbl.h
index 87808df..2d3d2cf 100644
--- a/microkde/kdatetbl.h
+++ b/microkde/kdatetbl.h
@@ -1,372 +1,378 @@
1/* -*- C++ -*- 1/* -*- C++ -*-
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org) 3 Copyright (C) 1997 Tim D. Gilman (tdgilman@best.org)
4 (C) 1998-2001 Mirko Boehm (mirko@kde.org) 4 (C) 1998-2001 Mirko Boehm (mirko@kde.org)
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KDATETBL_H 20#ifndef KDATETBL_H
21#define KDATETBL_H 21#define KDATETBL_H
22 22
23#include <qvalidator.h> 23#include <qvalidator.h>
24#include <qgridview.h> 24#include <q3gridview.h>
25#include <qlineedit.h> 25#include <qlineedit.h>
26#include <qdatetime.h> 26#include <qdatetime.h>
27//Added by qt3to4:
28#include <QResizeEvent>
29#include <QMouseEvent>
30#include <Q3Frame>
31#include <QKeyEvent>
32#include <QFocusEvent>
27 33
28/** 34/**
29* A table containing month names. It is used to pick a month directly. 35* A table containing month names. It is used to pick a month directly.
30* @internal 36* @internal
31* @version $Id$ 37* @version $Id$
32* @author Tim Gilman, Mirko Boehm 38* @author Tim Gilman, Mirko Boehm
33*/ 39*/
34class KDateInternalMonthPicker : public QGridView 40class KDateInternalMonthPicker : public Q3GridView
35{ 41{
36 Q_OBJECT 42 Q_OBJECT
37protected: 43protected:
38 /** 44 /**
39 * Store the month that has been clicked [1..12]. 45 * Store the month that has been clicked [1..12].
40 */ 46 */
41 int result; 47 int result;
42 /** 48 /**
43 * the cell under mouse cursor when LBM is pressed 49 * the cell under mouse cursor when LBM is pressed
44 */ 50 */
45 short int activeCol; 51 short int activeCol;
46 short int activeRow; 52 short int activeRow;
47 /** 53 /**
48 * Contains the largest rectangle needed by the month names. 54 * Contains the largest rectangle needed by the month names.
49 */ 55 */
50 QRect max; 56 QRect max;
51signals: 57signals:
52 /** 58 /**
53 * This is send from the mouse click event handler. 59 * This is send from the mouse click event handler.
54 */ 60 */
55 void closeMe(int); 61 void closeMe(int);
56public: 62public:
57 /** 63 /**
58 * The constructor. 64 * The constructor.
59 */ 65 */
60 KDateInternalMonthPicker(QWidget* parent, const char* name=0); 66 KDateInternalMonthPicker(QWidget* parent, const char* name=0);
61 /** 67 /**
62 * The size hint. 68 * The size hint.
63 */ 69 */
64 QSize sizeHint() const; 70 QSize sizeHint() const;
65 /** 71 /**
66 * Return the result. 0 means no selection (reject()), 1..12 are the 72 * Return the result. 0 means no selection (reject()), 1..12 are the
67 * months. 73 * months.
68 */ 74 */
69 int getResult() const; 75 int getResult() const;
70protected: 76protected:
71 /** 77 /**
72 * Set up the painter. 78 * Set up the painter.
73 */ 79 */
74 void setupPainter(QPainter *p); 80 void setupPainter(QPainter *p);
75 /** 81 /**
76 * The resize event. 82 * The resize event.
77 */ 83 */
78 void viewportResizeEvent(QResizeEvent*); 84 void viewportResizeEvent(QResizeEvent*);
79 /** 85 /**
80 * Paint a cell. This simply draws the month names in it. 86 * Paint a cell. This simply draws the month names in it.
81 */ 87 */
82 virtual void paintCell(QPainter* painter, int row, int col); 88 virtual void paintCell(QPainter* painter, int row, int col);
83 /** 89 /**
84 * Catch mouse click and move events to paint a rectangle around the item. 90 * Catch mouse click and move events to paint a rectangle around the item.
85 */ 91 */
86 void contentsMousePressEvent(QMouseEvent *e); 92 void contentsMousePressEvent(QMouseEvent *e);
87 void contentsMouseMoveEvent(QMouseEvent *e); 93 void contentsMouseMoveEvent(QMouseEvent *e);
88 /** 94 /**
89 * Emit monthSelected(int) when a cell has been released. 95 * Emit monthSelected(int) when a cell has been released.
90 */ 96 */
91 void contentsMouseReleaseEvent(QMouseEvent *e); 97 void contentsMouseReleaseEvent(QMouseEvent *e);
92 98
93private: 99private:
94 class KDateInternalMonthPrivate; 100 class KDateInternalMonthPrivate;
95 KDateInternalMonthPrivate *d; 101 KDateInternalMonthPrivate *d;
96}; 102};
97 103
98/** Year selection widget. 104/** Year selection widget.
99* @internal 105* @internal
100* @version $Id$ 106* @version $Id$
101* @author Tim Gilman, Mirko Boehm 107* @author Tim Gilman, Mirko Boehm
102*/ 108*/
103class KDateInternalYearSelector : public QLineEdit 109class KDateInternalYearSelector : public QLineEdit
104{ 110{
105 Q_OBJECT 111 Q_OBJECT
106protected: 112protected:
107 QIntValidator *val; 113 QIntValidator *val;
108 int result; 114 int result;
109public slots: 115public slots:
110 void yearEnteredSlot(); 116 void yearEnteredSlot();
111signals: 117signals:
112 void closeMe(int); 118 void closeMe(int);
113public: 119public:
114 KDateInternalYearSelector(int fontsize, 120 KDateInternalYearSelector(int fontsize,
115 QWidget* parent=0, 121 QWidget* parent=0,
116 const char* name=0); 122 const char* name=0);
117 int getYear(); 123 int getYear();
118 void setYear(int year); 124 void setYear(int year);
119 125
120private: 126private:
121 class KDateInternalYearPrivate; 127 class KDateInternalYearPrivate;
122 KDateInternalYearPrivate *d; 128 KDateInternalYearPrivate *d;
123}; 129};
124 130
125/** 131/**
126 * Frame with popup menu behaviour. 132 * Frame with popup menu behaviour.
127 * @author Tim Gilman, Mirko Boehm 133 * @author Tim Gilman, Mirko Boehm
128 * @version $Id$ 134 * @version $Id$
129 */ 135 */
130class KPopupFrame : public QFrame 136class KPopupFrame : public Q3Frame
131{ 137{
132 Q_OBJECT 138 Q_OBJECT
133protected: 139protected:
134 /** 140 /**
135 * The result. It is returned from exec() when the popup window closes. 141 * The result. It is returned from exec() when the popup window closes.
136 */ 142 */
137 int result; 143 int result;
138 /** 144 /**
139 * Catch key press events. 145 * Catch key press events.
140 */ 146 */
141 void keyPressEvent(QKeyEvent* e); 147 void keyPressEvent(QKeyEvent* e);
142 /** 148 /**
143 * The only subwidget that uses the whole dialog window. 149 * The only subwidget that uses the whole dialog window.
144 */ 150 */
145 QWidget *main; 151 QWidget *main;
146public slots: 152public slots:
147 /** 153 /**
148 * Close the popup window. This is called from the main widget, usually. 154 * Close the popup window. This is called from the main widget, usually.
149 * @p r is the result returned from exec(). 155 * @p r is the result returned from exec().
150 */ 156 */
151 void close(int r); 157 void close(int r);
152public: 158public:
153 /** 159 /**
154 * The contructor. Creates a dialog without buttons. 160 * The contructor. Creates a dialog without buttons.
155 */ 161 */
156 KPopupFrame(QWidget* parent=0, const char* name=0); 162 KPopupFrame(QWidget* parent=0, const char* name=0);
157 /** 163 /**
158 * Set the main widget. You cannot set the main widget from the constructor, 164 * Set the main widget. You cannot set the main widget from the constructor,
159 * since it must be a child of the frame itselfes. 165 * since it must be a child of the frame itselfes.
160 * Be careful: the size is set to the main widgets size. It is up to you to 166 * Be careful: the size is set to the main widgets size. It is up to you to
161 * set the main widgets correct size before setting it as the main 167 * set the main widgets correct size before setting it as the main
162 * widget. 168 * widget.
163 */ 169 */
164 void setMainWidget(QWidget* m); 170 void setMainWidget(QWidget* m);
165 /** 171 /**
166 * The resize event. Simply resizes the main widget to the whole 172 * The resize event. Simply resizes the main widget to the whole
167 * widgets client size. 173 * widgets client size.
168 */ 174 */
169 void resizeEvent(QResizeEvent*); 175 void resizeEvent(QResizeEvent*);
170 /** 176 /**
171 * Open the popup window at position pos. 177 * Open the popup window at position pos.
172 */ 178 */
173 void popup(const QPoint &pos); 179 void popup(const QPoint &pos);
174 /** 180 /**
175 * Execute the popup window. 181 * Execute the popup window.
176 */ 182 */
177 int exec(QPoint p); 183 int exec(QPoint p);
178 /** 184 /**
179 * Dito. 185 * Dito.
180 */ 186 */
181 int exec(int x, int y); 187 int exec(int x, int y);
182 188
183private: 189private:
184 190
185 virtual bool close(bool alsoDelete) { return QFrame::close(alsoDelete); } 191 virtual bool close(bool alsoDelete) { return Q3Frame::close(alsoDelete); }
186protected: 192protected:
187 virtual void virtual_hook( int id, void* data ); 193 virtual void virtual_hook( int id, void* data );
188private: 194private:
189 class KPopupFramePrivate; 195 class KPopupFramePrivate;
190 KPopupFramePrivate *d; 196 KPopupFramePrivate *d;
191}; 197};
192 198
193/** 199/**
194* Validates user-entered dates. 200* Validates user-entered dates.
195*/ 201*/
196class KDateValidator : public QValidator 202class KDateValidator : public QValidator
197{ 203{
198public: 204public:
199 KDateValidator(QWidget* parent=0, const char* name=0); 205 KDateValidator(QWidget* parent=0, const char* name=0);
200 virtual State validate(QString&, int&) const; 206 virtual State validate(QString&, int&) const;
201 virtual void fixup ( QString & input ) const; 207 virtual void fixup ( QString & input ) const;
202 State date(const QString&, QDate&) const; 208 State date(const QString&, QDate&) const;
203}; 209};
204 210
205/** 211/**
206 * Date selection table. 212 * Date selection table.
207 * This is a support class for the KDatePicker class. It just 213 * This is a support class for the KDatePicker class. It just
208 * draws the calender table without titles, but could theoretically 214 * draws the calender table without titles, but could theoretically
209 * be used as a standalone. 215 * be used as a standalone.
210 * 216 *
211 * When a date is selected by the user, it emits a signal: 217 * When a date is selected by the user, it emits a signal:
212 * dateSelected(QDate) 218 * dateSelected(QDate)
213 * 219 *
214 * @internal 220 * @internal
215 * @version $Id$ 221 * @version $Id$
216 * @author Tim Gilman, Mirko Boehm 222 * @author Tim Gilman, Mirko Boehm
217 */ 223 */
218class KDateTable : public QGridView 224class KDateTable : public Q3GridView
219{ 225{
220 Q_OBJECT 226 Q_OBJECT
221public: 227public:
222 /** 228 /**
223 * The constructor. 229 * The constructor.
224 */ 230 */
225 KDateTable(QWidget *parent=0, 231 KDateTable(QWidget *parent=0,
226 QDate date=QDate::currentDate(), 232 QDate date=QDate::currentDate(),
227 const char* name=0, WFlags f=0); 233 const char* name=0, Qt::WFlags f=0);
228 /** 234 /**
229 * Returns a recommended size for the widget. 235 * Returns a recommended size for the widget.
230 * To save some time, the size of the largest used cell content is 236 * To save some time, the size of the largest used cell content is
231 * calculated in each paintCell() call, since all calculations have 237 * calculated in each paintCell() call, since all calculations have
232 * to be done there anyway. The size is stored in maxCell. The 238 * to be done there anyway. The size is stored in maxCell. The
233 * sizeHint() simply returns a multiple of maxCell. 239 * sizeHint() simply returns a multiple of maxCell.
234 */ 240 */
235 virtual QSize sizeHint() const; 241 virtual QSize sizeHint() const;
236 /** 242 /**
237 * Set the font size of the date table. 243 * Set the font size of the date table.
238 */ 244 */
239 void setFontSize(int size); 245 void setFontSize(int size);
240 /** 246 /**
241 * Select and display this date. 247 * Select and display this date.
242 */ 248 */
243 bool setDate(const QDate&); 249 bool setDate(const QDate&);
244 const QDate& getDate() const; 250 const QDate& getDate() const;
245 251
246 252
247protected: 253protected:
248 bool mMarkCurrent; 254 bool mMarkCurrent;
249 /** 255 /**
250 * Paint a cell. 256 * Paint a cell.
251 */ 257 */
252 virtual void paintCell(QPainter*, int, int); 258 virtual void paintCell(QPainter*, int, int);
253 /** 259 /**
254 * Handle the resize events. 260 * Handle the resize events.
255 */ 261 */
256 virtual void viewportResizeEvent(QResizeEvent *); 262 virtual void viewportResizeEvent(QResizeEvent *);
257 /** 263 /**
258 * React on mouse clicks that select a date. 264 * React on mouse clicks that select a date.
259 */ 265 */
260 virtual void contentsMousePressEvent(QMouseEvent *); 266 virtual void contentsMousePressEvent(QMouseEvent *);
261 virtual void keyPressEvent( QKeyEvent *e ); 267 virtual void keyPressEvent( QKeyEvent *e );
262 virtual void focusInEvent( QFocusEvent *e ); 268 virtual void focusInEvent( QFocusEvent *e );
263 virtual void focusOutEvent( QFocusEvent *e ); 269 virtual void focusOutEvent( QFocusEvent *e );
264 /** 270 /**
265 * The font size of the displayed text. 271 * The font size of the displayed text.
266 */ 272 */
267 int fontsize; 273 int fontsize;
268 /** 274 /**
269 * The currently selected date. 275 * The currently selected date.
270 */ 276 */
271 QDate date; 277 QDate date;
272 /** 278 /**
273 * The day of the first day in the month [1..7]. 279 * The day of the first day in the month [1..7].
274 */ 280 */
275 int firstday; 281 int firstday;
276 /** 282 /**
277 * The number of days in the current month. 283 * The number of days in the current month.
278 */ 284 */
279 int numdays; 285 int numdays;
280 /** 286 /**
281 * The number of days in the previous month. 287 * The number of days in the previous month.
282 */ 288 */
283 int numDaysPrevMonth; 289 int numDaysPrevMonth;
284 /** 290 /**
285 * unused 291 * unused
286 */ 292 */
287 bool unused_hasSelection; 293 bool unused_hasSelection;
288 /** 294 /**
289 * Save the size of the largest used cell content. 295 * Save the size of the largest used cell content.
290 */ 296 */
291 QRect maxCell; 297 QRect maxCell;
292signals: 298signals:
293 /** 299 /**
294 * The selected date changed. 300 * The selected date changed.
295 */ 301 */
296 void dateChanged(QDate); 302 void dateChanged(QDate);
297 /** 303 /**
298 * A date has been selected by clicking on the table. 304 * A date has been selected by clicking on the table.
299 */ 305 */
300 void tableClicked(); 306 void tableClicked();
301 307
302protected: 308protected:
303 virtual void virtual_hook( int id, void* data ); 309 virtual void virtual_hook( int id, void* data );
304private: 310private:
305 class KDateTablePrivate; 311 class KDateTablePrivate;
306 KDateTablePrivate *d; 312 KDateTablePrivate *d;
307}; 313};
308 314
309#endif // KDATETBL_H 315#endif // KDATETBL_H
310class KDateInternalWeekPicker : public QGridView 316class KDateInternalWeekPicker : public Q3GridView
311{ 317{
312 Q_OBJECT 318 Q_OBJECT
313protected: 319protected:
314 /** 320 /**
315 * Store the month that has been clicked [1..12]. 321 * Store the month that has been clicked [1..12].
316 */ 322 */
317 int result; 323 int result;
318 /** 324 /**
319 * the cell under mouse cursor when LBM is pressed 325 * the cell under mouse cursor when LBM is pressed
320 */ 326 */
321 short int activeCol; 327 short int activeCol;
322 short int activeRow; 328 short int activeRow;
323 /** 329 /**
324 * Contains the largest rectangle needed by the month names. 330 * Contains the largest rectangle needed by the month names.
325 */ 331 */
326 QRect max; 332 QRect max;
327signals: 333signals:
328 /** 334 /**
329 * This is send from the mouse click event handler. 335 * This is send from the mouse click event handler.
330 */ 336 */
331 void closeMe(int); 337 void closeMe(int);
332public: 338public:
333 /** 339 /**
334 * The constructor. 340 * The constructor.
335 */ 341 */
336 KDateInternalWeekPicker(QWidget* parent, const char* name=0); 342 KDateInternalWeekPicker(QWidget* parent, const char* name=0);
337 /** 343 /**
338 * The size hint. 344 * The size hint.
339 */ 345 */
340 QSize sizeHint() const; 346 QSize sizeHint() const;
341 /** 347 /**
342 * Return the result. 0 means no selection (reject()), 1..12 are the 348 * Return the result. 0 means no selection (reject()), 1..12 are the
343 * months. 349 * months.
344 */ 350 */
345 int getResult() const; 351 int getResult() const;
346protected: 352protected:
347 /** 353 /**
348 * Set up the painter. 354 * Set up the painter.
349 */ 355 */
350 void setupPainter(QPainter *p); 356 void setupPainter(QPainter *p);
351 /** 357 /**
352 * The resize event. 358 * The resize event.
353 */ 359 */
354 void viewportResizeEvent(QResizeEvent*); 360 void viewportResizeEvent(QResizeEvent*);
355 /** 361 /**
356 * Paint a cell. This simply draws the month names in it. 362 * Paint a cell. This simply draws the month names in it.
357 */ 363 */
358 virtual void paintCell(QPainter* painter, int row, int col); 364 virtual void paintCell(QPainter* painter, int row, int col);
359 /** 365 /**
360 * Catch mouse click and move events to paint a rectangle around the item. 366 * Catch mouse click and move events to paint a rectangle around the item.
361 */ 367 */
362 void contentsMousePressEvent(QMouseEvent *e); 368 void contentsMousePressEvent(QMouseEvent *e);
363 void contentsMouseMoveEvent(QMouseEvent *e); 369 void contentsMouseMoveEvent(QMouseEvent *e);
364 /** 370 /**
365 * Emit monthSelected(int) when a cell has been released. 371 * Emit monthSelected(int) when a cell has been released.
366 */ 372 */
367 void contentsMouseReleaseEvent(QMouseEvent *e); 373 void contentsMouseReleaseEvent(QMouseEvent *e);
368 374
369private: 375private:
370 class KDateInternalMonthPrivate; 376 class KDateInternalMonthPrivate;
371 KDateInternalMonthPrivate *d; 377 KDateInternalMonthPrivate *d;
372}; 378};
diff --git a/microkde/kdebug.h b/microkde/kdebug.h
index bb9cfe3..534943c 100644
--- a/microkde/kdebug.h
+++ b/microkde/kdebug.h
@@ -1,92 +1,94 @@
1#ifndef MINIKDE_KDEBUG_H 1#ifndef MINIKDE_KDEBUG_H
2#define MINIKDE_KDEBUG_H 2#define MINIKDE_KDEBUG_H
3 3
4#include <stdio.h> 4#include <stdio.h>
5 5
6#include <qstring.h> 6#include <qstring.h>
7//Added by qt3to4:
8#include <Q3CString>
7 9
8 10
9 11
10class kdbgstream; 12class kdbgstream;
11typedef kdbgstream & (*KDBGFUNC)(kdbgstream &); // manipulator function 13typedef kdbgstream & (*KDBGFUNC)(kdbgstream &); // manipulator function
12 14
13class kdbgstream { 15class kdbgstream {
14 public: 16 public:
15 kdbgstream(unsigned int _area, unsigned int _level, bool _print = true) : 17 kdbgstream(unsigned int _area, unsigned int _level, bool _print = true) :
16 area(_area), level(_level), print( _print ) { print = false; } 18 area(_area), level(_level), print( _print ) { print = false; }
17 /* kdbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = false) : 19 /* kdbgstream(const char * initialString, unsigned int _area, unsigned int _level, bool _print = false) :
18 output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print) { print = false; }*/ 20 output(QString::fromLatin1(initialString)), area(_area), level(_level), print(_print) { print = false; }*/
19 ~kdbgstream() 21 ~kdbgstream()
20 { 22 {
21 // if (!output.isEmpty()) { 23 // if (!output.isEmpty()) {
22 // fprintf(stderr,"ASSERT: debug output not ended with \\n\n"); 24 // fprintf(stderr,"ASSERT: debug output not ended with \\n\n");
23 //*this << "\n"; 25 //*this << "\n";
24 //} 26 //}
25 } 27 }
26 kdbgstream &operator<<(bool) { 28 kdbgstream &operator<<(bool) {
27 29
28 return *this; 30 return *this;
29 } 31 }
30 kdbgstream &operator<<(short) { 32 kdbgstream &operator<<(short) {
31 33
32 return *this; 34 return *this;
33 } 35 }
34 kdbgstream &operator<<(unsigned short) { 36 kdbgstream &operator<<(unsigned short) {
35 37
36 return *this; 38 return *this;
37 } 39 }
38 kdbgstream &operator<<(char) { 40 kdbgstream &operator<<(char) {
39 41
40 return *this; 42 return *this;
41 } 43 }
42 kdbgstream &operator<<(unsigned char) { 44 kdbgstream &operator<<(unsigned char) {
43 45
44 return *this; 46 return *this;
45 } 47 }
46 48
47 kdbgstream &operator<<(int) { 49 kdbgstream &operator<<(int) {
48 50
49 return *this; 51 return *this;
50 } 52 }
51 kdbgstream &operator<<(unsigned int) { 53 kdbgstream &operator<<(unsigned int) {
52 54
53 return *this; 55 return *this;
54 } 56 }
55 kdbgstream &operator<<(long) { 57 kdbgstream &operator<<(long) {
56 return *this; 58 return *this;
57 } 59 }
58 kdbgstream &operator<<(unsigned long) { 60 kdbgstream &operator<<(unsigned long) {
59 return *this; 61 return *this;
60 } 62 }
61 kdbgstream &operator<<(const QString&) { 63 kdbgstream &operator<<(const QString&) {
62 return *this; 64 return *this;
63 } 65 }
64 kdbgstream &operator<<(const char*) { 66 kdbgstream &operator<<(const char*) {
65 return *this; 67 return *this;
66 } 68 }
67 kdbgstream &operator<<(const QCString&) { 69 kdbgstream &operator<<(const Q3CString&) {
68 return *this; 70 return *this;
69 } 71 }
70 kdbgstream& operator<<(KDBGFUNC f) { 72 kdbgstream& operator<<(KDBGFUNC f) {
71 return (*f)(*this); 73 return (*f)(*this);
72 } 74 }
73 kdbgstream& operator<<(double) { 75 kdbgstream& operator<<(double) {
74 if (!print) return *this; 76 if (!print) return *this;
75 return *this; 77 return *this;
76 } 78 }
77 void flush() { 79 void flush() {
78 return; 80 return;
79 } 81 }
80 private: 82 private:
81 QString output; 83 QString output;
82 unsigned int area, level; 84 unsigned int area, level;
83 bool print; 85 bool print;
84}; 86};
85 87
86inline kdbgstream &endl( kdbgstream &s) { s << "\n"; return s; } 88inline kdbgstream &endl( kdbgstream &s) { s << "\n"; return s; }
87 89
88inline kdbgstream kdDebug(int area = 0) { return kdbgstream(area, 0); } 90inline kdbgstream kdDebug(int area = 0) { return kdbgstream(area, 0); }
89inline kdbgstream kdWarning(int area = 0) { return kdbgstream(area, 0); } 91inline kdbgstream kdWarning(int area = 0) { return kdbgstream(area, 0); }
90inline kdbgstream kdError(int area = 0) { return kdbgstream(area, 0); } 92inline kdbgstream kdError(int area = 0) { return kdbgstream(area, 0); }
91 93
92#endif 94#endif
diff --git a/microkde/kdecore/kcatalogue.cpp b/microkde/kdecore/kcatalogue.cpp
index 97ac326..1600b08 100644
--- a/microkde/kdecore/kcatalogue.cpp
+++ b/microkde/kdecore/kcatalogue.cpp
@@ -1,131 +1,133 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (c) 2001 Hans Petter Bieker <bieker@kde.org> 2 Copyright (c) 2001 Hans Petter Bieker <bieker@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20//US #include <config.h> 20//US #include <config.h>
21 21
22#include <qfile.h> 22#include <qfile.h>
23//Added by qt3to4:
24#include <Q3CString>
23 25
24#include <kdebug.h> 26#include <kdebug.h>
25 27
26#include "kcatalogue.h" 28#include "kcatalogue.h"
27 29
28char *k_nl_find_msg(struct kde_loaded_l10nfile *domain_file, 30char *k_nl_find_msg(struct kde_loaded_l10nfile *domain_file,
29 const char *msgid); 31 const char *msgid);
30void k_nl_unload_domain (struct loaded_domain *domain); 32void k_nl_unload_domain (struct loaded_domain *domain);
31 33
32#ifndef KDE_USE_FINAL // with --enable-final, we're getting this from libintl.cpp 34#ifndef KDE_USE_FINAL // with --enable-final, we're getting this from libintl.cpp
33struct kde_loaded_l10nfile 35struct kde_loaded_l10nfile
34{ 36{
35 const char *filename; 37 const char *filename;
36 int decided; 38 int decided;
37 39
38 const void *data; 40 const void *data;
39 41
40 kde_loaded_l10nfile() : filename(0), decided(0), data(0) {} 42 kde_loaded_l10nfile() : filename(0), decided(0), data(0) {}
41}; 43};
42#endif 44#endif
43 45
44class KCataloguePrivate 46class KCataloguePrivate
45{ 47{
46public: 48public:
47 QString name; 49 QString name;
48 50
49 kde_loaded_l10nfile domain; 51 kde_loaded_l10nfile domain;
50}; 52};
51 53
52KCatalogue::KCatalogue(const QString & name) 54KCatalogue::KCatalogue(const QString & name)
53 : d( new KCataloguePrivate ) 55 : d( new KCataloguePrivate )
54{ 56{
55 d->name = name; 57 d->name = name;
56} 58}
57 59
58KCatalogue::KCatalogue(const KCatalogue & rhs) 60KCatalogue::KCatalogue(const KCatalogue & rhs)
59 : d( new KCataloguePrivate ) 61 : d( new KCataloguePrivate )
60{ 62{
61 *this = rhs; 63 *this = rhs;
62} 64}
63 65
64KCatalogue & KCatalogue::operator=(const KCatalogue & rhs) 66KCatalogue & KCatalogue::operator=(const KCatalogue & rhs)
65{ 67{
66 d->name = rhs.d->name; 68 d->name = rhs.d->name;
67 setFileName( rhs.fileName() ); 69 setFileName( rhs.fileName() );
68 70
69 return *this; 71 return *this;
70} 72}
71 73
72KCatalogue::~KCatalogue() 74KCatalogue::~KCatalogue()
73{ 75{
74 doUnload(); 76 doUnload();
75 77
76 delete d; 78 delete d;
77} 79}
78 80
79QString KCatalogue::name() const 81QString KCatalogue::name() const
80{ 82{
81 return d->name; 83 return d->name;
82} 84}
83 85
84void KCatalogue::setFileName( const QString & fileName ) 86void KCatalogue::setFileName( const QString & fileName )
85{ 87{
86 // nothing to do if the file name is already the same 88 // nothing to do if the file name is already the same
87 if ( this->fileName() == fileName ) return; 89 if ( this->fileName() == fileName ) return;
88 90
89 doUnload(); 91 doUnload();
90 92
91 QCString newFileName = QFile::encodeName( fileName ); 93 Q3CString newFileName = QFile::encodeName( fileName );
92 94
93 if ( !fileName.isEmpty() ) 95 if ( !fileName.isEmpty() )
94 { 96 {
95 // set file name 97 // set file name
96 char *filename = new char[ newFileName.length() + 1 ]; 98 char *filename = new char[ newFileName.length() + 1 ];
97 ::qstrcpy( filename, newFileName ); 99 ::qstrcpy( filename, newFileName );
98 d->domain.filename = filename; 100 d->domain.filename = filename;
99 } 101 }
100} 102}
101 103
102QString KCatalogue::fileName() const 104QString KCatalogue::fileName() const
103{ 105{
104 return QFile::decodeName( d->domain.filename ); 106 return QFile::decodeName( d->domain.filename );
105} 107}
106 108
107const char * KCatalogue::translate(const char * msgid) const 109const char * KCatalogue::translate(const char * msgid) const
108{ 110{
109 qDebug("KCatalogue::translate has to be fixed %s",msgid ); 111 qDebug("KCatalogue::translate has to be fixed %s",msgid );
110//US return ::k_nl_find_msg( &d->domain, msgid ); 112//US return ::k_nl_find_msg( &d->domain, msgid );
111 return msgid; 113 return msgid;
112 114
113} 115}
114 116
115void KCatalogue::doUnload() 117void KCatalogue::doUnload()
116{ 118{
117 // use gettext's unloader 119 // use gettext's unloader
118 if ( d->domain.data ) 120 if ( d->domain.data )
119 { 121 {
120//US ::k_nl_unload_domain( (struct loaded_domain *)d->domain.data ); 122//US ::k_nl_unload_domain( (struct loaded_domain *)d->domain.data );
121 qDebug("KCatalogue::doUnload has to be fixed" ); 123 qDebug("KCatalogue::doUnload has to be fixed" );
122 124
123 } 125 }
124 d->domain.data = 0; 126 d->domain.data = 0;
125 127
126 // free name 128 // free name
127 delete [] const_cast<char *>(d->domain.filename); 129 delete [] const_cast<char *>(d->domain.filename);
128 d->domain.filename = 0; 130 d->domain.filename = 0;
129 131
130 d->domain.decided = 0; 132 d->domain.decided = 0;
131} 133}
diff --git a/microkde/kdecore/kconfigbase.h b/microkde/kdecore/kconfigbase.h
index 7e56d11..1ef6a04 100644
--- a/microkde/kdecore/kconfigbase.h
+++ b/microkde/kdecore/kconfigbase.h
@@ -1,102 +1,104 @@
1/* 1/*
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (c) 1999 Preston Brown <pbrown@kde.org> 3 Copyright (c) 1999 Preston Brown <pbrown@kde.org>
4 Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org> 4 Copyright (c) 1997 Matthias Kalle Dalheimer <kalle@kde.org>
5 Copyright (c) 2001 Waldo Bastian <bastian@kde.org> 5 Copyright (c) 2001 Waldo Bastian <bastian@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23// $Id$ 23// $Id$
24 24
25#ifndef _KCONFIGBASE_H 25#ifndef _KCONFIGBASE_H
26#define _KCONFIGBASE_H 26#define _KCONFIGBASE_H
27 27
28#include "kconfig.h" 28#include "kconfig.h"
29//Added by qt3to4:
30#include <Q3CString>
29 31
30/** 32/**
31 * Helper class to facilitate working with @ref KConfig / @ref KSimpleConfig 33 * Helper class to facilitate working with @ref KConfig / @ref KSimpleConfig
32 * groups. 34 * groups.
33 * 35 *
34 * Careful programmers always set the group of a 36 * Careful programmers always set the group of a
35 * @ref KConfig @ref KSimpleConfig object to the group they want to read from 37 * @ref KConfig @ref KSimpleConfig object to the group they want to read from
36 * and set it back to the old one of afterwards. This is usually 38 * and set it back to the old one of afterwards. This is usually
37 * written as: 39 * written as:
38 * <pre> 40 * <pre>
39 * 41 *
40 * QString oldgroup config->group(); 42 * QString oldgroup config->group();
41 * config->setGroup( "TheGroupThatIWant" ); 43 * config->setGroup( "TheGroupThatIWant" );
42 * ... 44 * ...
43 * config->writeEntry( "Blah", "Blubb" ); 45 * config->writeEntry( "Blah", "Blubb" );
44 * 46 *
45 * config->setGroup( oldgroup ); 47 * config->setGroup( oldgroup );
46 * </pre> 48 * </pre>
47 * 49 *
48 * In order to facilitate this task, you can use 50 * In order to facilitate this task, you can use
49 * KConfigGroupSaver. Simply construct such an object ON THE STACK 51 * KConfigGroupSaver. Simply construct such an object ON THE STACK
50 * when you want to switch to a new group. Then, when the object goes 52 * when you want to switch to a new group. Then, when the object goes
51 * out of scope, the group will automatically be restored. If you 53 * out of scope, the group will automatically be restored. If you
52 * want to use several different groups within a function or method, 54 * want to use several different groups within a function or method,
53 * you can still use KConfigGroupSaver: Simply enclose all work with 55 * you can still use KConfigGroupSaver: Simply enclose all work with
54 * one group (including the creation of the KConfigGroupSaver object) 56 * one group (including the creation of the KConfigGroupSaver object)
55 * in one block. 57 * in one block.
56 * 58 *
57 * @author Matthias Kalle Dalheimer <kalle@kde.org> 59 * @author Matthias Kalle Dalheimer <kalle@kde.org>
58 * @version $Id$ 60 * @version $Id$
59 * @see KConfigBase, KConfig, KSimpleConfig 61 * @see KConfigBase, KConfig, KSimpleConfig
60 * @short Helper class for easier use of KConfig/KSimpleConfig groups 62 * @short Helper class for easier use of KConfig/KSimpleConfig groups
61 */ 63 */
62//US I converted the class in a way that it can be used with KConfig objects of microkde 64//US I converted the class in a way that it can be used with KConfig objects of microkde
63 65
64class KConfigGroupSaver 66class KConfigGroupSaver
65{ 67{
66public: 68public:
67 /** 69 /**
68 * Constructor. You pass a pointer to the KConfigBase-derived 70 * Constructor. You pass a pointer to the KConfigBase-derived
69 * object you want to work with and a string indicating the _new_ 71 * object you want to work with and a string indicating the _new_
70 * group. 72 * group.
71 * 73 *
72 * @param config The KConfigBase-derived object this 74 * @param config The KConfigBase-derived object this
73 * KConfigGroupSaver works on. 75 * KConfigGroupSaver works on.
74 * @param group The new group that the config object should switch to. 76 * @param group The new group that the config object should switch to.
75 */ 77 */
76 KConfigGroupSaver( KConfig* config, QString group ) 78 KConfigGroupSaver( KConfig* config, QString group )
77 /* KDE 4 : make the second parameter const QString & */ 79 /* KDE 4 : make the second parameter const QString & */
78 : _config(config), _oldgroup(config->group()) 80 : _config(config), _oldgroup(config->group())
79 { _config->setGroup( group ); } 81 { _config->setGroup( group ); }
80 82
81 KConfigGroupSaver( KConfig* config, const char *group ) 83 KConfigGroupSaver( KConfig* config, const char *group )
82 : _config(config), _oldgroup(config->group()) 84 : _config(config), _oldgroup(config->group())
83 { _config->setGroup( group ); } 85 { _config->setGroup( group ); }
84 86
85 KConfigGroupSaver( KConfig* config, const QCString &group ) 87 KConfigGroupSaver( KConfig* config, const Q3CString &group )
86 : _config(config), _oldgroup(config->group()) 88 : _config(config), _oldgroup(config->group())
87 { _config->setGroup( group ); } 89 { _config->setGroup( group ); }
88 90
89 ~KConfigGroupSaver() { _config->setGroup( _oldgroup ); } 91 ~KConfigGroupSaver() { _config->setGroup( _oldgroup ); }
90 92
91 KConfig* config() { return _config; }; 93 KConfig* config() { return _config; };
92 94
93private: 95private:
94 KConfig* _config; 96 KConfig* _config;
95 QString _oldgroup; 97 QString _oldgroup;
96 98
97 KConfigGroupSaver(const KConfigGroupSaver&); 99 KConfigGroupSaver(const KConfigGroupSaver&);
98 KConfigGroupSaver& operator=(const KConfigGroupSaver&); 100 KConfigGroupSaver& operator=(const KConfigGroupSaver&);
99 101
100}; 102};
101 103
102#endif 104#endif
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp
index 6d0475a..0b54eb6 100644
--- a/microkde/kdecore/klibloader.cpp
+++ b/microkde/kdecore/klibloader.cpp
@@ -1,653 +1,656 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Torben Weis <weis@kde.org> 2 Copyright (C) 1999 Torben Weis <weis@kde.org>
3 Copyright (C) 2000 Michael Matz <matz@kde.org> 3 Copyright (C) 2000 Michael Matz <matz@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19//US #include <config.h> 19//US #include <config.h>
20#include <qclipboard.h> 20#include <qclipboard.h>
21#include <qfile.h> 21#include <qfile.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qobjectdict.h> 23#include <q3objectdict.h>
24#include <qwidgetlist.h>
25#include <qwidget.h> 24#include <qwidget.h>
25#include <qwidget.h>
26//Added by qt3to4:
27#include <Q3CString>
28#include <Q3PtrList>
26 29
27#include "kapplication.h" 30#include "kapplication.h"
28#include "klibloader.h" 31#include "klibloader.h"
29#include "kstandarddirs.h" 32#include "kstandarddirs.h"
30#include "kdebug.h" 33#include "kdebug.h"
31#include "klocale.h" 34#include "klocale.h"
32 35
33/*US 36/*US
34#ifndef NDEBUG 37#ifndef NDEBUG
35#include "ltdl.h" 38#include "ltdl.h"
36#endif 39#endif
37*/ 40*/
38 41
39//US do everything through qlibrary 42//US do everything through qlibrary
40#ifndef DESKTOP_VERSION 43#ifndef DESKTOP_VERSION
41#include <qpe/qpeapplication.h> 44#include <qpe/qpeapplication.h>
42#include <qtopia/qlibrary.h> 45#include <qtopia/qlibrary.h>
43#else 46#else
44#include <qlibrary.h> 47#include <qlibrary.h>
45#endif 48#endif
46 49
47 50
48template class QAsciiDict<KLibrary>; 51template class Q3AsciiDict<KLibrary>;
49 52
50#include <stdlib.h> //getenv 53#include <stdlib.h> //getenv
51 54
52/*US 55/*US
53#if HAVE_DLFCN_H 56#if HAVE_DLFCN_H
54# include <dlfcn.h> 57# include <dlfcn.h>
55#endif 58#endif
56 59
57#ifdef RTLD_GLOBAL 60#ifdef RTLD_GLOBAL
58# define LT_GLOBAL RTLD_GLOBAL 61# define LT_GLOBAL RTLD_GLOBAL
59#else 62#else
60# ifdef DL_GLOBAL 63# ifdef DL_GLOBAL
61# define LT_GLOBAL DL_GLOBAL 64# define LT_GLOBAL DL_GLOBAL
62# endif 65# endif
63#endif 66#endif
64#ifndef LT_GLOBAL 67#ifndef LT_GLOBAL
65# define LT_GLOBAL 0 68# define LT_GLOBAL 0
66#endif 69#endif
67*/ 70*/
68 71
69/*US 72/*US
70extern "C" { 73extern "C" {
71extern int lt_dlopen_flag; 74extern int lt_dlopen_flag;
72} 75}
73*/ 76*/
74 77
75KLibFactory::KLibFactory( QObject* parent, const char* name ) 78KLibFactory::KLibFactory( QObject* parent, const char* name )
76 : QObject( parent, name ) 79 : QObject( parent, name )
77{ 80{
78} 81}
79 82
80KLibFactory::~KLibFactory() 83KLibFactory::~KLibFactory()
81{ 84{
82// kdDebug(150) << "Deleting KLibFactory " << this << endl; 85// kdDebug(150) << "Deleting KLibFactory " << this << endl;
83} 86}
84 87
85QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args ) 88QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args )
86{ 89{
87 QObject* obj = createObject( parent, name, classname, args ); 90 QObject* obj = createObject( parent, name, classname, args );
88 if ( obj ) 91 if ( obj )
89 emit objectCreated( obj ); 92 emit objectCreated( obj );
90 return obj; 93 return obj;
91} 94}
92 95
93 96
94QObject* KLibFactory::createObject( QObject*, const char*, const char*, const QStringList &) 97QObject* KLibFactory::createObject( QObject*, const char*, const char*, const QStringList &)
95{ 98{
96 return 0; 99 return 0;
97} 100}
98 101
99 102
100// ----------------------------------------------- 103// -----------------------------------------------
101 104
102//US KLibrary::KLibrary( const QString& libname, const QString& filename, void * handle ) 105//US KLibrary::KLibrary( const QString& libname, const QString& filename, void * handle )
103KLibrary::KLibrary( const QString& libname, const QString& filename, QLibrary* handle ) 106KLibrary::KLibrary( const QString& libname, const QString& filename, QLibrary* handle )
104{ 107{
105 /* Make sure, we have a KLibLoader */ 108 /* Make sure, we have a KLibLoader */
106 (void) KLibLoader::self(); 109 (void) KLibLoader::self();
107 m_libname = libname; 110 m_libname = libname;
108 m_filename = filename; 111 m_filename = filename;
109 m_handle = handle; 112 m_handle = handle;
110 m_factory = 0; 113 m_factory = 0;
111 m_timer = 0; 114 m_timer = 0;
112} 115}
113 116
114KLibrary::~KLibrary() 117KLibrary::~KLibrary()
115{ 118{
116// kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl; 119// kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl;
117 if ( m_timer && m_timer->isActive() ) 120 if ( m_timer && m_timer->isActive() )
118 m_timer->stop(); 121 m_timer->stop();
119 122
120 // If any object is remaining, delete 123 // If any object is remaining, delete
121 if ( m_objs.count() > 0 ) 124 if ( m_objs.count() > 0 )
122 { 125 {
123 QPtrListIterator<QObject> it( m_objs ); 126 Q3PtrListIterator<QObject> it( m_objs );
124 for ( ; it.current() ; ++it ) 127 for ( ; it.current() ; ++it )
125 { 128 {
126 kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl; 129 kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl;
127 disconnect( it.current(), SIGNAL( destroyed() ), 130 disconnect( it.current(), SIGNAL( destroyed() ),
128 this, SLOT( slotObjectDestroyed() ) ); 131 this, SLOT( slotObjectDestroyed() ) );
129 } 132 }
130 m_objs.setAutoDelete(true); 133 m_objs.setAutoDelete(true);
131 m_objs.clear(); 134 m_objs.clear();
132 } 135 }
133 136
134 if ( m_factory ) { 137 if ( m_factory ) {
135 //kdDebug(150) << " ... deleting the factory " << m_factory << endl; 138 //kdDebug(150) << " ... deleting the factory " << m_factory << endl;
136 delete m_factory; 139 delete m_factory;
137 } 140 }
138} 141}
139 142
140QString KLibrary::name() const 143QString KLibrary::name() const
141{ 144{
142 return m_libname; 145 return m_libname;
143} 146}
144 147
145QString KLibrary::fileName() const 148QString KLibrary::fileName() const
146{ 149{
147 return m_filename; 150 return m_filename;
148} 151}
149 152
150KLibFactory* KLibrary::factory() 153KLibFactory* KLibrary::factory()
151{ 154{
152 if ( m_factory ) 155 if ( m_factory )
153 return m_factory; 156 return m_factory;
154 157
155 QCString symname; 158 Q3CString symname;
156 symname.sprintf("init_%s", name().latin1() ); 159 symname.sprintf("init_%s", name().latin1() );
157 160
158 void* sym = symbol( symname ); 161 void* sym = symbol( symname );
159 if ( !sym ) 162 if ( !sym )
160 { 163 {
161 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); 164 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data());
162#ifndef NDEBUG 165#ifndef NDEBUG
163//US qDebug("KLibrary: errorcode: %s", lt_dlerror()); 166//US qDebug("KLibrary: errorcode: %s", lt_dlerror());
164#endif 167#endif
165 kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; 168 kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl;
166 return 0; 169 return 0;
167 } 170 }
168 171
169 typedef KLibFactory* (*t_func)(); 172 typedef KLibFactory* (*t_func)();
170 t_func func = (t_func)sym; 173 t_func func = (t_func)sym;
171 m_factory = func(); 174 m_factory = func();
172 175
173 if( !m_factory ) 176 if( !m_factory )
174 { 177 {
175 kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; 178 kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl;
176 return 0; 179 return 0;
177 } 180 }
178 181
179 connect( m_factory, SIGNAL( objectCreated( QObject * ) ), 182 connect( m_factory, SIGNAL( objectCreated( QObject * ) ),
180 this, SLOT( slotObjectCreated( QObject * ) ) ); 183 this, SLOT( slotObjectCreated( QObject * ) ) );
181 184
182 return m_factory; 185 return m_factory;
183} 186}
184 187
185void* KLibrary::symbol( const char* symname ) const 188void* KLibrary::symbol( const char* symname ) const
186{ 189{
187//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); 190//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname );
188 void* sym = m_handle->resolve( symname ); 191 void* sym = m_handle->resolve( symname );
189 if ( !sym ) 192 if ( !sym )
190 { 193 {
191//US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; 194//US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl;
192 return 0; 195 return 0;
193 } 196 }
194 197
195 return sym; 198 return sym;
196} 199}
197 200
198bool KLibrary::hasSymbol( const char* symname ) const 201bool KLibrary::hasSymbol( const char* symname ) const
199{ 202{
200//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); 203//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname );
201 void* sym = m_handle->resolve( symname ); 204 void* sym = m_handle->resolve( symname );
202 return (sym != 0L ); 205 return (sym != 0L );
203} 206}
204 207
205void KLibrary::unload() const 208void KLibrary::unload() const
206{ 209{
207 if (KLibLoader::s_self) 210 if (KLibLoader::s_self)
208 KLibLoader::s_self->unloadLibrary(QFile::encodeName(name())); 211 KLibLoader::s_self->unloadLibrary(QFile::encodeName(name()));
209} 212}
210 213
211void KLibrary::slotObjectCreated( QObject *obj ) 214void KLibrary::slotObjectCreated( QObject *obj )
212{ 215{
213 if ( !obj ) 216 if ( !obj )
214 return; 217 return;
215 218
216 if ( m_timer && m_timer->isActive() ) 219 if ( m_timer && m_timer->isActive() )
217 m_timer->stop(); 220 m_timer->stop();
218 221
219 if ( m_objs.containsRef( obj ) ) 222 if ( m_objs.containsRef( obj ) )
220 return; // we know this object already 223 return; // we know this object already
221 224
222 connect( obj, SIGNAL( destroyed() ), 225 connect( obj, SIGNAL( destroyed() ),
223 this, SLOT( slotObjectDestroyed() ) ); 226 this, SLOT( slotObjectDestroyed() ) );
224 227
225 m_objs.append( obj ); 228 m_objs.append( obj );
226} 229}
227 230
228void KLibrary::slotObjectDestroyed() 231void KLibrary::slotObjectDestroyed()
229{ 232{
230 m_objs.removeRef( sender() ); 233 m_objs.removeRef( sender() );
231 234
232 if ( m_objs.count() == 0 ) 235 if ( m_objs.count() == 0 )
233 { 236 {
234// kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!" 237// kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!"
235// << endl; 238// << endl;
236 239
237 if ( !m_timer ) 240 if ( !m_timer )
238 { 241 {
239 m_timer = new QTimer( this, "klibrary_shutdown_timer" ); 242 m_timer = new QTimer( this, "klibrary_shutdown_timer" );
240 connect( m_timer, SIGNAL( timeout() ), 243 connect( m_timer, SIGNAL( timeout() ),
241 this, SLOT( slotTimeout() ) ); 244 this, SLOT( slotTimeout() ) );
242 } 245 }
243 246
244 // as long as it's not stable make the timeout short, for debugging 247 // as long as it's not stable make the timeout short, for debugging
245 // pleasure (matz) 248 // pleasure (matz)
246 //m_timer->start( 1000*60, true ); 249 //m_timer->start( 1000*60, true );
247 m_timer->start( 1000*10, true ); 250 m_timer->start( 1000*10, true );
248 } 251 }
249} 252}
250 253
251void KLibrary::slotTimeout() 254void KLibrary::slotTimeout()
252{ 255{
253 if ( m_objs.count() != 0 ) 256 if ( m_objs.count() != 0 )
254 return; 257 return;
255 258
256 /* Don't go through KLibLoader::unloadLibrary(), because that uses the 259 /* Don't go through KLibLoader::unloadLibrary(), because that uses the
257 ref counter, but this timeout means to unconditionally close this library 260 ref counter, but this timeout means to unconditionally close this library
258 The destroyed() signal will take care to remove us from all lists. 261 The destroyed() signal will take care to remove us from all lists.
259 */ 262 */
260 delete this; 263 delete this;
261} 264}
262 265
263// ------------------------------------------------- 266// -------------------------------------------------
264 267
265/* This helper class is needed, because KLibraries can go away without 268/* This helper class is needed, because KLibraries can go away without
266 being unloaded. So we need some info about KLibraries even after its 269 being unloaded. So we need some info about KLibraries even after its
267 death. */ 270 death. */
268class KLibWrapPrivate 271class KLibWrapPrivate
269{ 272{
270public: 273public:
271//US KLibWrapPrivate(KLibrary *l, lt_dlhandle h); 274//US KLibWrapPrivate(KLibrary *l, lt_dlhandle h);
272 KLibWrapPrivate(KLibrary *l, QLibrary* h); 275 KLibWrapPrivate(KLibrary *l, QLibrary* h);
273 276
274 KLibrary *lib; 277 KLibrary *lib;
275 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; 278 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode;
276 int ref_count; 279 int ref_count;
277//US lt_dlhandle handle; 280//US lt_dlhandle handle;
278 QLibrary *handle; 281 QLibrary *handle;
279 QString name; 282 QString name;
280 QString filename; 283 QString filename;
281}; 284};
282 285
283//US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h) 286//US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h)
284KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h) 287KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h)
285 : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName()) 288 : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName())
286{ 289{
287 unload_mode = UNKNOWN; 290 unload_mode = UNKNOWN;
288/*US 291/*US
289 if (lt_dlsym(handle, "__kde_do_not_unload") != 0) { 292 if (lt_dlsym(handle, "__kde_do_not_unload") != 0) {
290// kdDebug(150) << "Will not unload " << name << endl; 293// kdDebug(150) << "Will not unload " << name << endl;
291 unload_mode = DONT_UNLOAD; 294 unload_mode = DONT_UNLOAD;
292 } else if (lt_dlsym(handle, "__kde_do_unload") != 0) { 295 } else if (lt_dlsym(handle, "__kde_do_unload") != 0) {
293 unload_mode = UNLOAD; 296 unload_mode = UNLOAD;
294 } 297 }
295*/ 298*/
296//US use instead: 299//US use instead:
297 if (h->resolve("__kde_do_not_unload") != 0) { 300 if (h->resolve("__kde_do_not_unload") != 0) {
298// kdDebug(150) << "Will not unload " << name << endl; 301// kdDebug(150) << "Will not unload " << name << endl;
299 unload_mode = DONT_UNLOAD; 302 unload_mode = DONT_UNLOAD;
300 } else if (h->resolve("__kde_do_unload") != 0) { 303 } else if (h->resolve("__kde_do_unload") != 0) {
301 unload_mode = UNLOAD; 304 unload_mode = UNLOAD;
302 } 305 }
303} 306}
304 307
305class KLibLoaderPrivate 308class KLibLoaderPrivate
306{ 309{
307public: 310public:
308 QPtrList<KLibWrapPrivate> loaded_stack; 311 Q3PtrList<KLibWrapPrivate> loaded_stack;
309 QPtrList<KLibWrapPrivate> pending_close; 312 Q3PtrList<KLibWrapPrivate> pending_close;
310 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; 313 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode;
311 314
312 QString errorMessage; 315 QString errorMessage;
313}; 316};
314 317
315KLibLoader* KLibLoader::s_self = 0; 318KLibLoader* KLibLoader::s_self = 0;
316 319
317KLibLoader* KLibLoader::self() 320KLibLoader* KLibLoader::self()
318{ 321{
319 if ( !s_self ) 322 if ( !s_self )
320 s_self = new KLibLoader; 323 s_self = new KLibLoader;
321 return s_self; 324 return s_self;
322} 325}
323 326
324void KLibLoader::cleanUp() 327void KLibLoader::cleanUp()
325{ 328{
326 if ( !s_self ) 329 if ( !s_self )
327 return; 330 return;
328 331
329 delete s_self; 332 delete s_self;
330 s_self = 0; 333 s_self = 0;
331} 334}
332 335
333KLibLoader::KLibLoader( QObject* parent, const char* name ) 336KLibLoader::KLibLoader( QObject* parent, const char* name )
334 : QObject( parent, name ) 337 : QObject( parent, name )
335{ 338{
336 s_self = this; 339 s_self = this;
337 d = new KLibLoaderPrivate; 340 d = new KLibLoaderPrivate;
338//US lt_dlinit(); 341//US lt_dlinit();
339 d->unload_mode = KLibLoaderPrivate::UNKNOWN; 342 d->unload_mode = KLibLoaderPrivate::UNKNOWN;
340 if (getenv("KDE_NOUNLOAD") != 0) 343 if (getenv("KDE_NOUNLOAD") != 0)
341 d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD; 344 d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD;
342 else if (getenv("KDE_DOUNLOAD") != 0) 345 else if (getenv("KDE_DOUNLOAD") != 0)
343 d->unload_mode = KLibLoaderPrivate::UNLOAD; 346 d->unload_mode = KLibLoaderPrivate::UNLOAD;
344 d->loaded_stack.setAutoDelete( true ); 347 d->loaded_stack.setAutoDelete( true );
345} 348}
346 349
347KLibLoader::~KLibLoader() 350KLibLoader::~KLibLoader()
348{ 351{
349// kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; 352// kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl;
350 353
351 QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); 354 Q3AsciiDictIterator<KLibWrapPrivate> it( m_libs );
352 for (; it.current(); ++it ) 355 for (; it.current(); ++it )
353 { 356 {
354 kdDebug(150) << "The KLibLoader contains the library " << it.current()->name 357 kdDebug(150) << "The KLibLoader contains the library " << it.current()->name
355 << " (" << it.current()->lib << ")" << endl; 358 << " (" << it.current()->lib << ")" << endl;
356 d->pending_close.append(it.current()); 359 d->pending_close.append(it.current());
357 } 360 }
358 361
359 close_pending(0); 362 close_pending(0);
360 363
361 delete d; 364 delete d;
362} 365}
363 366
364//static 367//static
365QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) 368QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ )
366{ 369{
367 QCString libname( name ); 370 Q3CString libname( name );
368 371
369 // only append ".la" if there is no extension 372 // only append ".la" if there is no extension
370 // this allows to load non-libtool libraries as well 373 // this allows to load non-libtool libraries as well
371 // (mhk, 20000228) 374 // (mhk, 20000228)
372 int pos = libname.findRev('/'); 375 int pos = libname.findRev('/');
373 if (pos < 0) 376 if (pos < 0)
374 pos = 0; 377 pos = 0;
375/*US 378/*US
376 if (libname.find('.', pos) < 0) { 379 if (libname.find('.', pos) < 0) {
377 libname += ".la"; 380 libname += ".la";
378 } 381 }
379*/ 382*/
380//US in the microedition we work only with shared libraries. 383//US in the microedition we work only with shared libraries.
381 384
382 if (libname.find('.', pos) < 0) { 385 if (libname.find('.', pos) < 0) {
383#ifdef _WIN32_ 386#ifdef _WIN32_
384 libname += ".dll"; 387 libname += ".dll";
385#else 388#else
386 libname += ".so"; 389 libname += ".so";
387#endif 390#endif
388 } 391 }
389 392
390 // only look up the file if it is not an absolute filename 393 // only look up the file if it is not an absolute filename
391 // (mhk, 20000228) 394 // (mhk, 20000228)
392 QString libfile; 395 QString libfile;
393 if (libname[0] == '/') 396 if (libname[0] == '/')
394 libfile = libname; 397 libfile = libname;
395 else 398 else
396 { 399 {
397//US at this point the libname must exist as real filesname. No expansions will be made later 400//US at this point the libname must exist as real filesname. No expansions will be made later
398// in findResources. Because of that we prepend the lib prefix here to the name 401// in findResources. Because of that we prepend the lib prefix here to the name
399//US I add also the "lib" prefix. I do not how could this could have worked before without it? 402//US I add also the "lib" prefix. I do not how could this could have worked before without it?
400#ifndef _WIN32_ 403#ifndef _WIN32_
401 libname.insert(pos, "lib"); 404 libname.insert(pos, "lib");
402#endif 405#endif
403 406
404 407
405//US libfile = instance->dirs()->findResource( "module", libname ); 408//US libfile = instance->dirs()->findResource( "module", libname );
406 //qDebug("libname = %s ",libname.data() ); 409 //qDebug("libname = %s ",libname.data() );
407 libfile = KGlobal::dirs()->findResource( "module", libname ); 410 libfile = KGlobal::dirs()->findResource( "module", libname );
408 //qDebug("libfile = %s ",libfile.latin1() ); 411 //qDebug("libfile = %s ",libfile.latin1() );
409 412
410 if ( libfile.isEmpty() ) 413 if ( libfile.isEmpty() )
411 { 414 {
412//US libfile = instance->dirs()->findResource( "lib", libname ); 415//US libfile = instance->dirs()->findResource( "lib", libname );
413 libfile = KGlobal::dirs()->findResource( "lib", libname ); 416 libfile = KGlobal::dirs()->findResource( "lib", libname );
414 //qDebug("libfile2 = %s ",libfile.latin1() ); 417 //qDebug("libfile2 = %s ",libfile.latin1() );
415#ifndef NDEBUG 418#ifndef NDEBUG
416 if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules 419 if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules
417 kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl; 420 kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl;
418#endif 421#endif
419 } 422 }
420 if ( libfile.isEmpty() ) 423 if ( libfile.isEmpty() )
421 { 424 {
422#ifndef NDEBUG 425#ifndef NDEBUG
423 kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; 426 kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl;
424 self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname); 427 self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(QString(libname));
425 428
426 qDebug("KLibLoader::library could not find library: %s", libname.data()); 429 qDebug("KLibLoader::library could not find library: %s", libname.data());
427#endif 430#endif
428 431
429 } 432 }
430 else 433 else
431 self()->d->errorMessage = QString::null; 434 self()->d->errorMessage = QString::null;
432 } 435 }
433 436
434 //qDebug("return libfile = %s ",libfile.latin1() ); 437 //qDebug("return libfile = %s ",libfile.latin1() );
435 return libfile; 438 return libfile;
436} 439}
437 440
438 441
439KLibrary* KLibLoader::globalLibrary( const char *name ) 442KLibrary* KLibLoader::globalLibrary( const char *name )
440{ 443{
441KLibrary *tmp; 444KLibrary *tmp;
442/*US 445/*US
443int olt_dlopen_flag = lt_dlopen_flag; 446int olt_dlopen_flag = lt_dlopen_flag;
444 447
445 lt_dlopen_flag |= LT_GLOBAL; 448 lt_dlopen_flag |= LT_GLOBAL;
446 kdDebug(150) << "Loading the next library global with flag " 449 kdDebug(150) << "Loading the next library global with flag "
447 << lt_dlopen_flag 450 << lt_dlopen_flag
448 << "." << endl; 451 << "." << endl;
449*/ 452*/
450 tmp = library(name); 453 tmp = library(name);
451/*US 454/*US
452 lt_dlopen_flag = olt_dlopen_flag; 455 lt_dlopen_flag = olt_dlopen_flag;
453*/ 456*/
454return tmp; 457return tmp;
455} 458}
456 459
457 460
458KLibrary* KLibLoader::library( const char *name ) 461KLibrary* KLibLoader::library( const char *name )
459{ 462{
460 if (!name) 463 if (!name)
461 return 0; 464 return 0;
462 465
463 KLibWrapPrivate* wrap = m_libs[name]; 466 KLibWrapPrivate* wrap = m_libs[name];
464 if (wrap) { 467 if (wrap) {
465 /* Nothing to do to load the library. */ 468 /* Nothing to do to load the library. */
466 wrap->ref_count++; 469 wrap->ref_count++;
467 return wrap->lib; 470 return wrap->lib;
468 } 471 }
469 472
470 /* Test if this library was loaded at some time, but got 473 /* Test if this library was loaded at some time, but got
471 unloaded meanwhile, whithout being dlclose()'ed. */ 474 unloaded meanwhile, whithout being dlclose()'ed. */
472 QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); 475 Q3PtrListIterator<KLibWrapPrivate> it(d->loaded_stack);
473 for (; it.current(); ++it) { 476 for (; it.current(); ++it) {
474 if (it.current()->name == name) 477 if (it.current()->name == name)
475 wrap = it.current(); 478 wrap = it.current();
476 } 479 }
477 480
478 if (wrap) { 481 if (wrap) {
479 d->pending_close.removeRef(wrap); 482 d->pending_close.removeRef(wrap);
480 if (!wrap->lib) { 483 if (!wrap->lib) {
481 /* This lib only was in loaded_stack, but not in m_libs. */ 484 /* This lib only was in loaded_stack, but not in m_libs. */
482 wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); 485 wrap->lib = new KLibrary( name, wrap->filename, wrap->handle );
483 } 486 }
484 wrap->ref_count++; 487 wrap->ref_count++;
485 } else { 488 } else {
486 QString libfile = findLibrary( name ); 489 QString libfile = findLibrary( name );
487 if ( libfile.isEmpty() ) 490 if ( libfile.isEmpty() )
488 return 0; 491 return 0;
489#ifdef DESKTOP_VERSION 492#ifdef DESKTOP_VERSION
490 QLibrary *qlib = new QLibrary( libfile.latin1() ); 493 QLibrary *qlib = new QLibrary( libfile.latin1() );
491#else 494#else
492 QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); 495 QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately );
493#endif 496#endif
494 497
495//US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); 498//US lt_dlhandle handle = lt_dlopen( libfile.latin1() );
496//US if ( !handle ) 499//US if ( !handle )
497 if ( !qlib ) 500 if ( !qlib )
498 { 501 {
499 qDebug( "KLibLoader::library could not load library: %s", libfile.latin1()); 502 qDebug( "KLibLoader::library could not load library: %s", libfile.latin1());
500 d->errorMessage = QString::null; 503 d->errorMessage = QString::null;
501 return 0; 504 return 0;
502 } 505 }
503 else 506 else
504 d->errorMessage = QString::null; 507 d->errorMessage = QString::null;
505 508
506 KLibrary *lib = new KLibrary( name, libfile, qlib ); 509 KLibrary *lib = new KLibrary( name, libfile, qlib );
507 wrap = new KLibWrapPrivate(lib, qlib); 510 wrap = new KLibWrapPrivate(lib, qlib);
508 d->loaded_stack.prepend(wrap); 511 d->loaded_stack.prepend(wrap);
509 } 512 }
510 m_libs.insert( name, wrap ); 513 m_libs.insert( name, wrap );
511 514
512 connect( wrap->lib, SIGNAL( destroyed() ), 515 connect( wrap->lib, SIGNAL( destroyed() ),
513 this, SLOT( slotLibraryDestroyed() ) ); 516 this, SLOT( slotLibraryDestroyed() ) );
514 517
515 return wrap->lib; 518 return wrap->lib;
516} 519}
517 520
518QString KLibLoader::lastErrorMessage() const 521QString KLibLoader::lastErrorMessage() const
519{ 522{
520 return d->errorMessage; 523 return d->errorMessage;
521} 524}
522 525
523void KLibLoader::unloadLibrary( const char *libname ) 526void KLibLoader::unloadLibrary( const char *libname )
524{ 527{
525 KLibWrapPrivate *wrap = m_libs[ libname ]; 528 KLibWrapPrivate *wrap = m_libs[ libname ];
526 if (!wrap) 529 if (!wrap)
527 return; 530 return;
528 if (--wrap->ref_count) 531 if (--wrap->ref_count)
529 return; 532 return;
530 533
531// kdDebug(150) << "closing library " << libname << endl; 534// kdDebug(150) << "closing library " << libname << endl;
532 535
533 m_libs.remove( libname ); 536 m_libs.remove( libname );
534 537
535 disconnect( wrap->lib, SIGNAL( destroyed() ), 538 disconnect( wrap->lib, SIGNAL( destroyed() ),
536 this, SLOT( slotLibraryDestroyed() ) ); 539 this, SLOT( slotLibraryDestroyed() ) );
537 close_pending( wrap ); 540 close_pending( wrap );
538} 541}
539 542
540KLibFactory* KLibLoader::factory( const char* name ) 543KLibFactory* KLibLoader::factory( const char* name )
541{ 544{
542 KLibrary* lib = library( name ); 545 KLibrary* lib = library( name );
543 if ( !lib ) 546 if ( !lib )
544 return 0; 547 return 0;
545 548
546 return lib->factory(); 549 return lib->factory();
547} 550}
548 551
549void KLibLoader::slotLibraryDestroyed() 552void KLibLoader::slotLibraryDestroyed()
550{ 553{
551 const KLibrary *lib = static_cast<const KLibrary *>( sender() ); 554 const KLibrary *lib = static_cast<const KLibrary *>( sender() );
552 555
553 QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); 556 Q3AsciiDictIterator<KLibWrapPrivate> it( m_libs );
554 for (; it.current(); ++it ) 557 for (; it.current(); ++it )
555 if ( it.current()->lib == lib ) 558 if ( it.current()->lib == lib )
556 { 559 {
557 KLibWrapPrivate *wrap = it.current(); 560 KLibWrapPrivate *wrap = it.current();
558 wrap->lib = 0; /* the KLibrary object is already away */ 561 wrap->lib = 0; /* the KLibrary object is already away */
559 m_libs.remove( it.currentKey() ); 562 m_libs.remove( it.currentKey() );
560 close_pending( wrap ); 563 close_pending( wrap );
561 return; 564 return;
562 } 565 }
563} 566}
564 567
565void KLibLoader::close_pending(KLibWrapPrivate *wrap) 568void KLibLoader::close_pending(KLibWrapPrivate *wrap)
566{ 569{
567 if (wrap && !d->pending_close.containsRef( wrap )) 570 if (wrap && !d->pending_close.containsRef( wrap ))
568 d->pending_close.append( wrap ); 571 d->pending_close.append( wrap );
569 572
570 /* First delete all KLibrary objects in pending_close, but _don't_ unload 573 /* First delete all KLibrary objects in pending_close, but _don't_ unload
571 the DSO behind it. */ 574 the DSO behind it. */
572 QPtrListIterator<KLibWrapPrivate> it(d->pending_close); 575 Q3PtrListIterator<KLibWrapPrivate> it(d->pending_close);
573 for (; it.current(); ++it) { 576 for (; it.current(); ++it) {
574 wrap = it.current(); 577 wrap = it.current();
575 if (wrap->lib) { 578 if (wrap->lib) {
576 disconnect( wrap->lib, SIGNAL( destroyed() ), 579 disconnect( wrap->lib, SIGNAL( destroyed() ),
577 this, SLOT( slotLibraryDestroyed() ) ); 580 this, SLOT( slotLibraryDestroyed() ) );
578 delete wrap->lib; 581 delete wrap->lib;
579 wrap->lib = 0; 582 wrap->lib = 0;
580 } 583 }
581 } 584 }
582 585
583 if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return; 586 if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return;
584 587
585 bool deleted_one = false; 588 bool deleted_one = false;
586 while ((wrap = d->loaded_stack.first())) { 589 while ((wrap = d->loaded_stack.first())) {
587 /* Let's first see, if we want to try to unload this lib. 590 /* Let's first see, if we want to try to unload this lib.
588 If the env. var KDE_DOUNLOAD is set, we try to unload every lib. 591 If the env. var KDE_DOUNLOAD is set, we try to unload every lib.
589 If not, we look at the lib itself, and unload it only, if it exports 592 If not, we look at the lib itself, and unload it only, if it exports
590 the symbol __kde_do_unload. */ 593 the symbol __kde_do_unload. */
591 if (d->unload_mode != KLibLoaderPrivate::UNLOAD 594 if (d->unload_mode != KLibLoaderPrivate::UNLOAD
592 && wrap->unload_mode != KLibWrapPrivate::UNLOAD) 595 && wrap->unload_mode != KLibWrapPrivate::UNLOAD)
593 break; 596 break;
594 597
595 /* Now ensure, that the libs are only unloaded in the reverse direction 598 /* Now ensure, that the libs are only unloaded in the reverse direction
596 they were loaded. */ 599 they were loaded. */
597 if (!d->pending_close.containsRef( wrap )) { 600 if (!d->pending_close.containsRef( wrap )) {
598 if (!deleted_one) 601 if (!deleted_one)
599 /* Only diagnose, if we really haven't deleted anything. */ 602 /* Only diagnose, if we really haven't deleted anything. */
600// kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; 603// kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl;
601 break; 604 break;
602 } 605 }
603 606
604// kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; 607// kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl;
605 608
606#if 0 609#if 0
607#ifndef Q_WS_QWS 610#ifndef Q_WS_QWS
608 if ( !deleted_one ) { 611 if ( !deleted_one ) {
609 /* Only do the hack once in this loop. 612 /* Only do the hack once in this loop.
610 WABA: *HACK* 613 WABA: *HACK*
611 We need to make sure to clear the clipboard before unloading a DSO 614 We need to make sure to clear the clipboard before unloading a DSO
612 because the DSO could have defined an object derived from QMimeSource 615 because the DSO could have defined an object derived from QMimeSource
613 and placed that on the clipboard. */ 616 and placed that on the clipboard. */
614 /*kapp->clipboard()->clear();*/ 617 /*kapp->clipboard()->clear();*/
615 618
616 /* Well.. let's do something more subtle... convert the clipboard context 619 /* Well.. let's do something more subtle... convert the clipboard context
617 to text. That should be safe as it only uses objects defined by Qt. */ 620 to text. That should be safe as it only uses objects defined by Qt. */
618 621
619 QWidgetList *widgetlist = QApplication::topLevelWidgets(); 622 QWidgetList *widgetlist = QApplication::topLevelWidgets();
620 QWidget *co = widgetlist->first(); 623 QWidget *co = widgetlist->first();
621 while (co) { 624 while (co) {
622 if (qstrcmp(co->name(), "internal clipboard owner") == 0) { 625 if (qstrcmp(co->name(), "internal clipboard owner") == 0) {
623 if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId()) 626 if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId())
624 kapp->clipboard()->setText(kapp->clipboard()->text()); 627 kapp->clipboard()->setText(kapp->clipboard()->text());
625 628
626 break; 629 break;
627 } 630 }
628 co = widgetlist->next(); 631 co = widgetlist->next();
629 } 632 }
630 delete widgetlist; 633 delete widgetlist;
631 } 634 }
632#else 635#else
633 // FIXME(E): Implement in Qt Embedded 636 // FIXME(E): Implement in Qt Embedded
634#endif 637#endif
635 638
636#endif // 0 639#endif // 0
637 deleted_one = true; 640 deleted_one = true;
638//US lt_dlclose(wrap->handle); 641//US lt_dlclose(wrap->handle);
639 wrap->handle->unload(); 642 wrap->handle->unload();
640 643
641 d->pending_close.removeRef(wrap); 644 d->pending_close.removeRef(wrap);
642 /* loaded_stack is AutoDelete, so wrap is freed */ 645 /* loaded_stack is AutoDelete, so wrap is freed */
643 d->loaded_stack.remove(); 646 d->loaded_stack.remove();
644 } 647 }
645} 648}
646 649
647void KLibLoader::virtual_hook( int, void* ) 650void KLibLoader::virtual_hook( int, void* )
648{ /*BASE::virtual_hook( id, data );*/ } 651{ /*BASE::virtual_hook( id, data );*/ }
649 652
650void KLibFactory::virtual_hook( int, void* ) 653void KLibFactory::virtual_hook( int, void* )
651{ /*BASE::virtual_hook( id, data );*/ } 654{ /*BASE::virtual_hook( id, data );*/ }
652 655
653//US #include "klibloader.moc" 656//US #include "klibloader.moc"
diff --git a/microkde/kdecore/klibloader.h b/microkde/kdecore/klibloader.h
index ed57109..53d146e 100644
--- a/microkde/kdecore/klibloader.h
+++ b/microkde/kdecore/klibloader.h
@@ -1,405 +1,405 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Torben Weis <weis@kde.org> 2 Copyright (C) 1999 Torben Weis <weis@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18#ifndef KLIBLOADER_H 18#ifndef KLIBLOADER_H
19#define KLIBLOADER_H 19#define KLIBLOADER_H
20 20
21#include <qobject.h> 21#include <qobject.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qstringlist.h> 23#include <qstringlist.h>
24#include <qasciidict.h> 24#include <q3asciidict.h>
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26#include <kglobal.h> 26#include <kglobal.h>
27 27
28#include <stdlib.h> // For backwards compatibility 28#include <stdlib.h> // For backwards compatibility
29 29
30class KInstance; 30class KInstance;
31class QTimer; 31class QTimer;
32class KLibrary; 32class KLibrary;
33class KLibFactory; 33class KLibFactory;
34class KLibFactoryPrivate; 34class KLibFactoryPrivate;
35class KLibLoaderPrivate; 35class KLibLoaderPrivate;
36class KLibraryPrivate; 36class KLibraryPrivate;
37 37
38class QLibrary; 38class QLibrary;
39 39
40#define K_EXPORT_COMPONENT_FACTORY( libname, factory ) \ 40#define K_EXPORT_COMPONENT_FACTORY( libname, factory ) \
41 extern "C" { void *init_##libname() { return new factory; } } 41 extern "C" { void *init_##libname() { return new factory; } }
42 42
43/** 43/**
44 * @short Represents a dynamically loaded library. 44 * @short Represents a dynamically loaded library.
45 * 45 *
46 * KLibrary allows you to look up symbols of the shared library. 46 * KLibrary allows you to look up symbols of the shared library.
47 * Use @ref KLibLoader to create a new instance of KLibrary. 47 * Use @ref KLibLoader to create a new instance of KLibrary.
48 * 48 *
49 * @see KLibLoader 49 * @see KLibLoader
50 * @author Torben Weis <weis@kde.org> 50 * @author Torben Weis <weis@kde.org>
51 */ 51 */
52class KLibrary : public QObject 52class KLibrary : public QObject
53{ 53{
54 friend class KLibLoader; 54 friend class KLibLoader;
55 friend class QAsciiDict<KLibrary>; 55 friend class Q3AsciiDict<KLibrary>;
56 56
57 Q_OBJECT 57 Q_OBJECT
58public: 58public:
59 /** 59 /**
60 * @internal 60 * @internal
61 * Don't create KLibrary objects on your own. Instead use @ref KLibLoader. 61 * Don't create KLibrary objects on your own. Instead use @ref KLibLoader.
62 */ 62 */
63//US KLibrary( const QString& libname, const QString& filename, void * handle ); 63//US KLibrary( const QString& libname, const QString& filename, void * handle );
64 KLibrary( const QString& libname, const QString& filename, QLibrary* handle ); 64 KLibrary( const QString& libname, const QString& filename, QLibrary* handle );
65 65
66 /** 66 /**
67 * Returns the name of the library. 67 * Returns the name of the library.
68 * @return The name of the library like "libkspread". 68 * @return The name of the library like "libkspread".
69 */ 69 */
70 QString name() const; 70 QString name() const;
71 71
72 /** 72 /**
73 * Returns the file name of the library. 73 * Returns the file name of the library.
74 * @return The filename of the library, for example "/opt/kde2&/lib/libkspread.la" 74 * @return The filename of the library, for example "/opt/kde2&/lib/libkspread.la"
75 */ 75 */
76 QString fileName() const; 76 QString fileName() const;
77 77
78 /** 78 /**
79 * Returns the factory of the library. 79 * Returns the factory of the library.
80 * @return The factory of the library if there is any, otherwise 0 80 * @return The factory of the library if there is any, otherwise 0
81 */ 81 */
82 KLibFactory* factory(); 82 KLibFactory* factory();
83 83
84 /** 84 /**
85 * Looks up a symbol from the library. This is a very low level 85 * Looks up a symbol from the library. This is a very low level
86 * function that you usually don't want to use. Usually you should 86 * function that you usually don't want to use. Usually you should
87 * check using @ref hasSymbol() whether the symbol actually exists, 87 * check using @ref hasSymbol() whether the symbol actually exists,
88 * otherwise a warning will be printed. 88 * otherwise a warning will be printed.
89 * @param name the name of the symbol to look up 89 * @param name the name of the symbol to look up
90 * @return the address of the symbol, or 0 if it does not exist 90 * @return the address of the symbol, or 0 if it does not exist
91 * @see #hasSymbol 91 * @see #hasSymbol
92 */ 92 */
93 void* symbol( const char* name ) const; 93 void* symbol( const char* name ) const;
94 94
95 /** 95 /**
96 * Looks up a symbol from the library. This is a very low level 96 * Looks up a symbol from the library. This is a very low level
97 * function that you usually don't want to use. 97 * function that you usually don't want to use.
98 * Unlike @ref symbol(), this method doesn't warn if the symbol doesn't exist, 98 * Unlike @ref symbol(), this method doesn't warn if the symbol doesn't exist,
99 * so if the symbol might or might not exist, better use hasSymbol() before symbol(). 99 * so if the symbol might or might not exist, better use hasSymbol() before symbol().
100 * @param name the name of the symbol to check 100 * @param name the name of the symbol to check
101 * @return true if the symbol exists 101 * @return true if the symbol exists
102 * @since 3.1 102 * @since 3.1
103 */ 103 */
104 bool hasSymbol( const char* name ) const; 104 bool hasSymbol( const char* name ) const;
105 105
106 /** 106 /**
107 * Unloads the library. 107 * Unloads the library.
108 * This typically results in the deletion of this object. You should 108 * This typically results in the deletion of this object. You should
109 * not reference its pointer after calling this function. 109 * not reference its pointer after calling this function.
110 */ 110 */
111 void unload() const; 111 void unload() const;
112 112
113private slots: 113private slots:
114 void slotObjectCreated( QObject *obj ); 114 void slotObjectCreated( QObject *obj );
115 void slotObjectDestroyed(); 115 void slotObjectDestroyed();
116 void slotTimeout(); 116 void slotTimeout();
117 117
118private: 118private:
119 /** 119 /**
120 * @internal 120 * @internal
121 * Don't destruct KLibrary objects yourself. Instead use @ref unload() instead. 121 * Don't destruct KLibrary objects yourself. Instead use @ref unload() instead.
122 */ 122 */
123 ~KLibrary(); 123 ~KLibrary();
124 124
125 QString m_libname; 125 QString m_libname;
126 QString m_filename; 126 QString m_filename;
127 KLibFactory* m_factory; 127 KLibFactory* m_factory;
128//US void * m_handle; 128//US void * m_handle;
129 QLibrary* m_handle; 129 QLibrary* m_handle;
130 QPtrList<QObject> m_objs; 130 Q3PtrList<QObject> m_objs;
131 QTimer *m_timer; 131 QTimer *m_timer;
132 KLibraryPrivate *d; 132 KLibraryPrivate *d;
133}; 133};
134 134
135class KLibWrapPrivate; 135class KLibWrapPrivate;
136 136
137/** 137/**
138 * The KLibLoader allows you to load libraries dynamically at runtime. 138 * The KLibLoader allows you to load libraries dynamically at runtime.
139 * Dependent libraries are loaded automatically. 139 * Dependent libraries are loaded automatically.
140 * 140 *
141 * KLibLoader follows the singleton pattern. You can not create multiple 141 * KLibLoader follows the singleton pattern. You can not create multiple
142 * instances. Use @ref self() to get a pointer to the loader. 142 * instances. Use @ref self() to get a pointer to the loader.
143 * 143 *
144 * @see KLibrary 144 * @see KLibrary
145 * @author Torben Weis <weis@kde.org> 145 * @author Torben Weis <weis@kde.org>
146 */ 146 */
147class KLibLoader : public QObject 147class KLibLoader : public QObject
148{ 148{
149 friend class KLibrary; 149 friend class KLibrary;
150 150
151 Q_OBJECT 151 Q_OBJECT
152public: 152public:
153 /** 153 /**
154 * You should NEVER destruct an instance of KLibLoader 154 * You should NEVER destruct an instance of KLibLoader
155 * until you know what you are doing. This will release 155 * until you know what you are doing. This will release
156 * the loaded libraries. 156 * the loaded libraries.
157 */ 157 */
158 ~KLibLoader(); 158 ~KLibLoader();
159 159
160 /** 160 /**
161 * Loads and initializes a library. Loading a library multiple times is 161 * Loads and initializes a library. Loading a library multiple times is
162 * handled gracefully. 162 * handled gracefully.
163 * 163 *
164 * This is a convenience function that returns the factory immediately 164 * This is a convenience function that returns the factory immediately
165 * @param libname This is the library name without extension. Usually that is something like 165 * @param libname This is the library name without extension. Usually that is something like
166 * "libkspread". The function will then search for a file named 166 * "libkspread". The function will then search for a file named
167 * "libkspread.la" in the KDE library paths. 167 * "libkspread.la" in the KDE library paths.
168 * The *.la files are created by libtool and contain 168 * The *.la files are created by libtool and contain
169 * important information especially about the libraries dependencies 169 * important information especially about the libraries dependencies
170 * on other shared libs. Loading a "libfoo.so" could not solve the 170 * on other shared libs. Loading a "libfoo.so" could not solve the
171 * dependencies problem. 171 * dependencies problem.
172 * 172 *
173 * You can, however, give a library name ending in ".so" 173 * You can, however, give a library name ending in ".so"
174 * (or whatever is used on your platform), and the library 174 * (or whatever is used on your platform), and the library
175 * will be loaded without resolving dependencies. USE WITH CARE :) 175 * will be loaded without resolving dependencies. USE WITH CARE :)
176 * @return the @ref KLibFactory, or 0 if the library does not exist or it does 176 * @return the @ref KLibFactory, or 0 if the library does not exist or it does
177 * not have a factory 177 * not have a factory
178 * @see #library 178 * @see #library
179 */ 179 */
180 KLibFactory* factory( const char* libname ); 180 KLibFactory* factory( const char* libname );
181 181
182 /** 182 /**
183 * Loads and initializes a library. Loading a library multiple times is 183 * Loads and initializes a library. Loading a library multiple times is
184 * handled gracefully. 184 * handled gracefully.
185 * 185 *
186 * @param libname This is the library name without extension. Usually that is something like 186 * @param libname This is the library name without extension. Usually that is something like
187 * "libkspread". The function will then search for a file named 187 * "libkspread". The function will then search for a file named
188 * "libkspread.la" in the KDE library paths. 188 * "libkspread.la" in the KDE library paths.
189 * The *.la files are created by libtool and contain 189 * The *.la files are created by libtool and contain
190 * important information especially about the libraries dependencies 190 * important information especially about the libraries dependencies
191 * on other shared libs. Loading a "libfoo.so" could not solve the 191 * on other shared libs. Loading a "libfoo.so" could not solve the
192 * dependencies problem. 192 * dependencies problem.
193 * 193 *
194 * You can, however, give a library name ending in ".so" 194 * You can, however, give a library name ending in ".so"
195 * (or whatever is used on your platform), and the library 195 * (or whatever is used on your platform), and the library
196 * will be loaded without resolving dependencies. USE WITH CARE :) 196 * will be loaded without resolving dependencies. USE WITH CARE :)
197 * @return @ref KLibrary is invalid (0) when the library couldn't be dlopened. in such 197 * @return @ref KLibrary is invalid (0) when the library couldn't be dlopened. in such
198 * a case you can retrieve the error message by calling KLibLoader::lastErrorMessage() 198 * a case you can retrieve the error message by calling KLibLoader::lastErrorMessage()
199 * 199 *
200 * @see #factory 200 * @see #factory
201 */ 201 */
202 virtual KLibrary* library( const char* libname ); 202 virtual KLibrary* library( const char* libname );
203 203
204 /** 204 /**
205 * Loads and initializes a library. Loading a library multiple times is 205 * Loads and initializes a library. Loading a library multiple times is
206 * handled gracefully. The library is loaded such that the symbols are 206 * handled gracefully. The library is loaded such that the symbols are
207 * globally accessible so libraries with dependencies can be loaded 207 * globally accessible so libraries with dependencies can be loaded
208 * sequentially. 208 * sequentially.
209 * 209 *
210 * @param name This is the library name without extension. Usually that is something like 210 * @param name This is the library name without extension. Usually that is something like
211 * "libkspread". The function will then search for a file named 211 * "libkspread". The function will then search for a file named
212 * "libkspread.la" in the KDE library paths. 212 * "libkspread.la" in the KDE library paths.
213 * The *.la files are created by libtool and contain 213 * The *.la files are created by libtool and contain
214 * important information especially about the libraries dependencies 214 * important information especially about the libraries dependencies
215 * on other shared libs. Loading a "libfoo.so" could not solve the 215 * on other shared libs. Loading a "libfoo.so" could not solve the
216 * dependencies problem. 216 * dependencies problem.
217 * 217 *
218 * You can, however, give a library name ending in ".so" 218 * You can, however, give a library name ending in ".so"
219 * (or whatever is used on your platform), and the library 219 * (or whatever is used on your platform), and the library
220 * will be loaded without resolving dependencies. USE WITH CARE :) 220 * will be loaded without resolving dependencies. USE WITH CARE :)
221 * @return KLibrariy is invalid (0) when the library couldn't be dlopened. in such 221 * @return KLibrariy is invalid (0) when the library couldn't be dlopened. in such
222 * a case you can retrieve the error message by calling KLibLoader::lastErrorMessage() 222 * a case you can retrieve the error message by calling KLibLoader::lastErrorMessage()
223 * 223 *
224 * @see #factory 224 * @see #factory
225 */ 225 */
226 KLibrary* globalLibrary( const char *name ); 226 KLibrary* globalLibrary( const char *name );
227 227
228 /* 228 /*
229 * Returns an error message that can be useful to debug the problem. 229 * Returns an error message that can be useful to debug the problem.
230 * Returns QString::null if the last call to @ref #library() was successful. 230 * Returns QString::null if the last call to @ref #library() was successful.
231 * You can call this function more than once. The error message is only 231 * You can call this function more than once. The error message is only
232 * reset by a new call to library(). 232 * reset by a new call to library().
233 * @return the last error message, or QString::null if there was no error 233 * @return the last error message, or QString::null if there was no error
234 */ 234 */
235 QString lastErrorMessage() const; 235 QString lastErrorMessage() const;
236 236
237 /** 237 /**
238 * Unloads the library with the given name. 238 * Unloads the library with the given name.
239 * @param libname This is the library name without extension. Usually that is something like 239 * @param libname This is the library name without extension. Usually that is something like
240 * "libkspread". The function will then search for a file named 240 * "libkspread". The function will then search for a file named
241 * "libkspread.la" in the KDE library paths. 241 * "libkspread.la" in the KDE library paths.
242 * The *.la files are created by libtool and contain 242 * The *.la files are created by libtool and contain
243 * important information especially about the libraries dependencies 243 * important information especially about the libraries dependencies
244 * on other shared libs. Loading a "libfoo.so" could not solve the 244 * on other shared libs. Loading a "libfoo.so" could not solve the
245 * dependencies problem. 245 * dependencies problem.
246 * 246 *
247 * You can, however, give a library name ending in ".so" 247 * You can, however, give a library name ending in ".so"
248 * (or whatever is used on your platform), and the library 248 * (or whatever is used on your platform), and the library
249 * will be loaded without resolving dependencies. USE WITH CARE :) 249 * will be loaded without resolving dependencies. USE WITH CARE :)
250 */ 250 */
251 virtual void unloadLibrary( const char *libname ); 251 virtual void unloadLibrary( const char *libname );
252 252
253 /** 253 /**
254 * Returns a pointer to the factory. Use this function to get an instance 254 * Returns a pointer to the factory. Use this function to get an instance
255 * of KLibLoader. 255 * of KLibLoader.
256 * @return a pointer to the loader. If no loader exists until now 256 * @return a pointer to the loader. If no loader exists until now
257 * then one is created. 257 * then one is created.
258 */ 258 */
259 static KLibLoader* self(); 259 static KLibLoader* self();
260 260
261 /** 261 /**
262 * @internal 262 * @internal
263 * Internal Method, called by the KApplication destructor. 263 * Internal Method, called by the KApplication destructor.
264 * Do not call it. 264 * Do not call it.
265 * This is what makes it possible to rely on ~KLibFactory 265 * This is what makes it possible to rely on ~KLibFactory
266 * being called in all cases, whether the library is unloaded 266 * being called in all cases, whether the library is unloaded
267 * while the application is running or when exiting. 267 * while the application is running or when exiting.
268 */ 268 */
269 static void cleanUp(); 269 static void cleanUp();
270 270
271 /** 271 /**
272 * Helper method which looks for a library in the standard paths 272 * Helper method which looks for a library in the standard paths
273 * ("module" and "lib" resources). 273 * ("module" and "lib" resources).
274 * Made public for code that doesn't use KLibLoader itself, but still 274 * Made public for code that doesn't use KLibLoader itself, but still
275 * wants to open modules. 275 * wants to open modules.
276 * @param name of the library. If it is not a path, the function searches in 276 * @param name of the library. If it is not a path, the function searches in
277 * the "module" and "lib" resources. If there is no extension, 277 * the "module" and "lib" resources. If there is no extension,
278 * ".la" will be appended. 278 * ".la" will be appended.
279 * @param instance a KInstance used to get the standard paths 279 * @param instance a KInstance used to get the standard paths
280 */ 280 */
281 static QString findLibrary( const char * name/*US , const KInstance * instance = KGlobal::instance()*/ ); 281 static QString findLibrary( const char * name/*US , const KInstance * instance = KGlobal::instance()*/ );
282 282
283protected: 283protected:
284 KLibLoader( QObject* parent = 0, const char* name = 0 ); 284 KLibLoader( QObject* parent = 0, const char* name = 0 );
285 285
286private slots: 286private slots:
287 void slotLibraryDestroyed(); 287 void slotLibraryDestroyed();
288private: 288private:
289 void close_pending( KLibWrapPrivate * ); 289 void close_pending( KLibWrapPrivate * );
290 QAsciiDict<KLibWrapPrivate> m_libs; 290 Q3AsciiDict<KLibWrapPrivate> m_libs;
291 291
292 static KLibLoader* s_self; 292 static KLibLoader* s_self;
293 293
294protected: 294protected:
295 virtual void virtual_hook( int id, void* data ); 295 virtual void virtual_hook( int id, void* data );
296private: 296private:
297 KLibLoaderPrivate *d; 297 KLibLoaderPrivate *d;
298}; 298};
299 299
300/** 300/**
301 * If you develop a library that is to be loaded dynamically at runtime, then 301 * If you develop a library that is to be loaded dynamically at runtime, then
302 * you should return a pointer to your factory. The K_EXPORT_COMPONENT_FACTORY 302 * you should return a pointer to your factory. The K_EXPORT_COMPONENT_FACTORY
303 * macro is provided for this purpose: 303 * macro is provided for this purpose:
304 * <pre> 304 * <pre>
305 * K_EXPORT_COMPONENT_FACTORY( libkspread, KSpreadFactory ) 305 * K_EXPORT_COMPONENT_FACTORY( libkspread, KSpreadFactory )
306 * </pre> 306 * </pre>
307 * 307 *
308 * The first macro argument is the name of your library, the second specifies the name 308 * The first macro argument is the name of your library, the second specifies the name
309 * of your factory. 309 * of your factory.
310 * 310 *
311 * In the constructor of your factory you should create an instance of @ref KInstance 311 * In the constructor of your factory you should create an instance of @ref KInstance
312 * like this: 312 * like this:
313 * <pre> 313 * <pre>
314 * s_global = new KInstance( "kspread" ); 314 * s_global = new KInstance( "kspread" );
315 * </pre> 315 * </pre>
316 * This @ref KInstance is comparable to @ref KGlobal used by normal applications. 316 * This @ref KInstance is comparable to @ref KGlobal used by normal applications.
317 * It allows you to find resource files (images, XML, sound etc.) belonging 317 * It allows you to find resource files (images, XML, sound etc.) belonging
318 * to the library. 318 * to the library.
319 * 319 *
320 * If you want to load a library, use @ref KLibLoader. You can query @ref KLibLoader 320 * If you want to load a library, use @ref KLibLoader. You can query @ref KLibLoader
321 * directly for a pointer to the libraries factory by using the @ref KLibLoader::factory() 321 * directly for a pointer to the libraries factory by using the @ref KLibLoader::factory()
322 * function. 322 * function.
323 * 323 *
324 * The KLibFactory is used to create the components, the library has to offer. 324 * The KLibFactory is used to create the components, the library has to offer.
325 * The factory of KSpread for example will create instances of KSpreadDoc, 325 * The factory of KSpread for example will create instances of KSpreadDoc,
326 * while the Konqueror factory will create KonqView widgets. 326 * while the Konqueror factory will create KonqView widgets.
327 * All objects created by the factory must be derived from @ref QObject, since @ref QObject 327 * All objects created by the factory must be derived from @ref QObject, since @ref QObject
328 * offers type safe casting. 328 * offers type safe casting.
329 * 329 *
330 * KLibFactory is an abstract class. Reimplement the @ref 330 * KLibFactory is an abstract class. Reimplement the @ref
331 * createObject() method to give it functionality. 331 * createObject() method to give it functionality.
332 * 332 *
333 * @author Torben Weis <weis@kde.org> 333 * @author Torben Weis <weis@kde.org>
334 */ 334 */
335class KLibFactory : public QObject 335class KLibFactory : public QObject
336{ 336{
337 Q_OBJECT 337 Q_OBJECT
338public: 338public:
339 /** 339 /**
340 * Create a new factory. 340 * Create a new factory.
341 * @param parent the parent of the QObject, 0 for no parent 341 * @param parent the parent of the QObject, 0 for no parent
342 * @param name the name of the QObject, 0 for no name 342 * @param name the name of the QObject, 0 for no name
343 */ 343 */
344 KLibFactory( QObject* parent = 0, const char* name = 0 ); 344 KLibFactory( QObject* parent = 0, const char* name = 0 );
345 virtual ~KLibFactory(); 345 virtual ~KLibFactory();
346 346
347 /** 347 /**
348 * Creates a new object. The returned object has to be derived from 348 * Creates a new object. The returned object has to be derived from
349 * the requested classname. 349 * the requested classname.
350 * 350 *
351 * It is valid behavior to create different kinds of objects 351 * It is valid behavior to create different kinds of objects
352 * depending on the requested @p classname. For example a koffice 352 * depending on the requested @p classname. For example a koffice
353 * library may usually return a pointer to KoDocument. But 353 * library may usually return a pointer to KoDocument. But
354 * if asked for a "QWidget", it could create a wrapper widget, 354 * if asked for a "QWidget", it could create a wrapper widget,
355 * that encapsulates the Koffice specific features. 355 * that encapsulates the Koffice specific features.
356 * 356 *
357 * create() automatically emits a signal @ref objectCreated to tell 357 * create() automatically emits a signal @ref objectCreated to tell
358 * the library about its newly created object. This is very 358 * the library about its newly created object. This is very
359 * important for reference counting, and allows unloading the 359 * important for reference counting, and allows unloading the
360 * library automatically once all its objects have been destroyed. 360 * library automatically once all its objects have been destroyed.
361 * 361 *
362 * @param parent the parent of the QObject, 0 for no parent 362 * @param parent the parent of the QObject, 0 for no parent
363 * @param name the name of the QObject, 0 for no name 363 * @param name the name of the QObject, 0 for no name
364 * @param classname the name of the class 364 * @param classname the name of the class
365 * @param args a list of arguments 365 * @param args a list of arguments
366 */ 366 */
367 367
368 QObject* create( QObject* parent = 0, const char* name = 0, const char* classname = "QObject", const QStringList &args = QStringList() ); 368 QObject* create( QObject* parent = 0, const char* name = 0, const char* classname = "QObject", const QStringList &args = QStringList() );
369 369
370signals: 370signals:
371 /** 371 /**
372 * Emitted in #create 372 * Emitted in #create
373 * @param obj the new object 373 * @param obj the new object
374 */ 374 */
375 void objectCreated( QObject *obj ); 375 void objectCreated( QObject *obj );
376 376
377 377
378protected: 378protected:
379 379
380 /** 380 /**
381 * Creates a new object. The returned object has to be derived from 381 * Creates a new object. The returned object has to be derived from
382 * the requested classname. 382 * the requested classname.
383 * 383 *
384 * It is valid behavior to create different kinds of objects 384 * It is valid behavior to create different kinds of objects
385 * depending on the requested @p classname. For example a koffice 385 * depending on the requested @p classname. For example a koffice
386 * library may usually return a pointer to KoDocument. But 386 * library may usually return a pointer to KoDocument. But
387 * if asked for a "QWidget", it could create a wrapper widget, 387 * if asked for a "QWidget", it could create a wrapper widget,
388 * that encapsulates the Koffice specific features. 388 * that encapsulates the Koffice specific features.
389 * 389 *
390 * This function is called by #create() 390 * This function is called by #create()
391 * @param parent the parent of the QObject, 0 for no parent 391 * @param parent the parent of the QObject, 0 for no parent
392 * @param name the name of the QObject, 0 for no name 392 * @param name the name of the QObject, 0 for no name
393 * @param classname the name of the class 393 * @param classname the name of the class
394 * @param args a list of arguments 394 * @param args a list of arguments
395 */ 395 */
396 virtual QObject* createObject( QObject* parent = 0, const char* name = 0, const char* classname = "QObject", const QStringList &args = QStringList() ) = 0; 396 virtual QObject* createObject( QObject* parent = 0, const char* name = 0, const char* classname = "QObject", const QStringList &args = QStringList() ) = 0;
397 397
398 398
399protected: 399protected:
400 virtual void virtual_hook( int id, void* data ); 400 virtual void virtual_hook( int id, void* data );
401private: 401private:
402 KLibFactoryPrivate *d; 402 KLibFactoryPrivate *d;
403}; 403};
404 404
405#endif 405#endif
diff --git a/microkde/kdecore/klocale.cpp b/microkde/kdecore/klocale.cpp
index 1d8ae9f..dd310fa 100644
--- a/microkde/kdecore/klocale.cpp
+++ b/microkde/kdecore/klocale.cpp
@@ -1,1121 +1,1122 @@
1#include <qregexp.h> 1#include <qregexp.h>
2#include <qapplication.h> 2#include <qapplication.h>
3#include <QDesktopWidget>
3 4
4#include "kdebug.h" 5#include "kdebug.h"
5#include "kcalendarsystemgregorian.h" 6#include "kcalendarsystemgregorian.h"
6 7
7#include "klocale.h" 8#include "klocale.h"
8 9
9#include <qstringlist.h> 10#include <qstringlist.h>
10 11
11//#define COLLECT_TRANSLATION 12//#define COLLECT_TRANSLATION
12 13
13 14
14QDict<QString> *mLocaleDict = 0; 15Q3Dict<QString> *mLocaleDict = 0;
15void setLocaleDict( QDict<QString> * dict ) 16void setLocaleDict( Q3Dict<QString> * dict )
16{ 17{
17 mLocaleDict = dict; 18 mLocaleDict = dict;
18 19
19} 20}
20 21
21#ifdef COLLECT_TRANSLATION 22#ifdef COLLECT_TRANSLATION
22 23
23QStringList missingTrans; 24QStringList missingTrans;
24QStringList existingTrans1; 25QStringList existingTrans1;
25QStringList existingTrans2; 26QStringList existingTrans2;
26 27
27void addMissing(const char *text) 28void addMissing(const char *text)
28{ 29{
29 30
30 QString mis ( text ); 31 QString mis ( text );
31 if ( !missingTrans.contains( mis ) ) 32 if ( !missingTrans.contains( mis ) )
32 missingTrans.append(mis); 33 missingTrans.append(mis);
33 34
34} 35}
35void addExist(const char *text,QString trans ) 36void addExist(const char *text,QString trans )
36{ 37{
37 //return; 38 //return;
38 QString mis ( text ); 39 QString mis ( text );
39 if ( !existingTrans1.contains( mis ) ) { 40 if ( !existingTrans1.contains( mis ) ) {
40 existingTrans1.append(mis); 41 existingTrans1.append(mis);
41 existingTrans2.append(trans); 42 existingTrans2.append(trans);
42 43
43 } 44 }
44 45
45} 46}
46 47
47#include <qfile.h> 48#include <qfile.h>
48#include <qtextstream.h> 49#include <q3textstream.h>
49#include <qtextcodec.h> 50#include <qtextcodec.h>
50#endif 51#endif
51void dumpMissing() 52void dumpMissing()
52{ 53{
53#ifdef COLLECT_TRANSLATION 54#ifdef COLLECT_TRANSLATION
54 QString fileName = "/tmp/usernewtrans.txt"; 55 QString fileName = "/tmp/usernewtrans.txt";
55 QFile file( fileName ); 56 QFile file( fileName );
56 if (!file.open( IO_WriteOnly ) ) { 57 if (!file.open( QIODevice::WriteOnly ) ) {
57 return ; 58 return ;
58 } 59 }
59 QTextStream ts( &file ); 60 Q3TextStream ts( &file );
60 ts.setCodec( QTextCodec::codecForName("utf8") ); 61 ts.setCodec( QTextCodec::codecForName("utf8") );
61 62
62 int i; 63 int i;
63 for ( i = 0; i< missingTrans.count(); ++i ) { 64 for ( i = 0; i< missingTrans.count(); ++i ) {
64 65
65 QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" ); 66 QString text = missingTrans[i].replace( QRegExp("\n"),"\\n" );
66 ts << "{ \""<<text<< "\",\""<< text <<"\" },\n"; 67 ts << "{ \""<<text<< "\",\""<< text <<"\" },\n";
67 68
68 } 69 }
69 file.close(); 70 file.close();
70 { 71 {
71 QString fileName = "/tmp/usertrans.txt"; 72 QString fileName = "/tmp/usertrans.txt";
72 QFile file( fileName ); 73 QFile file( fileName );
73 if (!file.open( IO_WriteOnly ) ) { 74 if (!file.open( QIODevice::WriteOnly ) ) {
74 return ; 75 return ;
75 } 76 }
76 QTextStream ts( &file ); 77 Q3TextStream ts( &file );
77 ts.setCodec( QTextCodec::codecForName("utf8") ); 78 ts.setCodec( QTextCodec::codecForName("utf8") );
78 79
79 int i; 80 int i;
80 for ( i = 0; i< existingTrans1.count(); ++i ) { 81 for ( i = 0; i< existingTrans1.count(); ++i ) {
81 82
82 QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" ); 83 QString text = existingTrans1[i].replace( QRegExp("\n"),"\\n" );
83 QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" ); 84 QString text2 = existingTrans2[i].replace( QRegExp("\n"),"\\n" );
84 ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n"; 85 ts << "{ \""<<text<< "\",\""<< text2 <<"\" },\n";
85 86
86 } 87 }
87 file.close(); 88 file.close();
88 } 89 }
89#endif 90#endif
90} 91}
91QString i18n(const char *text) 92QString i18n(const char *text)
92{ 93{
93 if ( ! mLocaleDict ) { 94 if ( ! mLocaleDict ) {
94#ifdef COLLECT_TRANSLATION 95#ifdef COLLECT_TRANSLATION
95 addMissing( text ); 96 addMissing( text );
96#endif 97#endif
97 return QString( text ); 98 return QString( text );
98 } 99 }
99 else { 100 else {
100 QString* ret = mLocaleDict->find(QString(text)) ; 101 QString* ret = mLocaleDict->find(QString(text)) ;
101 if ( ret == 0 ) { 102 if ( ret == 0 ) {
102#ifdef COLLECT_TRANSLATION 103#ifdef COLLECT_TRANSLATION
103 addMissing( text ); 104 addMissing( text );
104#endif 105#endif
105 return QString( text ); 106 return QString( text );
106 } 107 }
107 else { 108 else {
108 if ( (*ret).isEmpty() ) { 109 if ( (*ret).isEmpty() ) {
109#ifdef COLLECT_TRANSLATION 110#ifdef COLLECT_TRANSLATION
110 addMissing( text ); 111 addMissing( text );
111#endif 112#endif
112 return QString( text ); 113 return QString( text );
113 } 114 }
114 else { 115 else {
115#ifdef COLLECT_TRANSLATION 116#ifdef COLLECT_TRANSLATION
116 addExist( text, *ret ); 117 addExist( text, *ret );
117#endif 118#endif
118 return (*ret); 119 return (*ret);
119 } 120 }
120 } 121 }
121 } 122 }
122 123
123} 124}
124 125
125QString i18n(const char *,const char *text) 126QString i18n(const char *,const char *text)
126{ 127{
127 return i18n( text ); 128 return i18n( text );
128} 129}
129 130
130QString i18n(const char *text1, const char *textn, int num) 131QString i18n(const char *text1, const char *textn, int num)
131{ 132{
132 if ( num == 1 ) return i18n( text1 ); 133 if ( num == 1 ) return i18n( text1 );
133 else { 134 else {
134 QString text = i18n( textn ); 135 QString text = i18n( textn );
135 int pos = text.find( "%n" ); 136 int pos = text.find( "%n" );
136 if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) ); 137 if ( pos >= 0 ) text.replace( pos, 2, QString::number( num ) );
137 return text; 138 return text;
138 } 139 }
139} 140}
140 141
141inline void put_it_in( QChar *buffer, uint& index, const QString &s ) 142inline void put_it_in( QChar *buffer, uint& index, const QString &s )
142{ 143{
143 for ( uint l = 0; l < s.length(); l++ ) 144 for ( uint l = 0; l < s.length(); l++ )
144 buffer[index++] = s.at( l ); 145 buffer[index++] = s.at( l );
145} 146}
146 147
147inline void put_it_in( QChar *buffer, uint& index, int number ) 148inline void put_it_in( QChar *buffer, uint& index, int number )
148{ 149{
149 buffer[index++] = number / 10 + '0'; 150 buffer[index++] = number / 10 + '0';
150 buffer[index++] = number % 10 + '0'; 151 buffer[index++] = number % 10 + '0';
151} 152}
152 153
153static int readInt(const QString &str, uint &pos) 154static int readInt(const QString &str, uint &pos)
154{ 155{
155 if (!str.at(pos).isDigit()) return -1; 156 if (!str.at(pos).isDigit()) return -1;
156 int result = 0; 157 int result = 0;
157 for (; str.length() > pos && str.at(pos).isDigit(); pos++) 158 for (; str.length() > pos && str.at(pos).isDigit(); pos++)
158 { 159 {
159 result *= 10; 160 result *= 10;
160 result += str.at(pos).digitValue(); 161 result += str.at(pos).digitValue();
161 } 162 }
162 163
163 return result; 164 return result;
164} 165}
165 166
166KLocale::KLocale() : mCalendarSystem( 0 ) 167KLocale::KLocale() : mCalendarSystem( 0 )
167{ 168{
168 169
169 m_decimalSymbol = "."; 170 m_decimalSymbol = ".";
170 m_positiveSign = ""; 171 m_positiveSign = "";
171 m_negativeSign = "-"; 172 m_negativeSign = "-";
172 m_thousandsSeparator = ","; 173 m_thousandsSeparator = ",";
173 174
174 175
175 176
176 177
177 mWeekStartsMonday = true; 178 mWeekStartsMonday = true;
178 mHourF24Format = true; 179 mHourF24Format = true;
179 mIntDateFormat = Default; 180 mIntDateFormat = Default;
180 mIntTimeFormat = Default; 181 mIntTimeFormat = Default;
181 mLanguage = 0; 182 mLanguage = 0;
182 mDateFormat = "%a %Y %b %d"; 183 mDateFormat = "%a %Y %b %d";
183 mDateFormatShort = "%Y-%m-%d"; 184 mDateFormatShort = "%Y-%m-%d";
184 mTimeZoneList << ("-11:00 US/Samoa") 185 mTimeZoneList << ("-11:00 US/Samoa")
185 << ("-10:00 US/Hawaii") 186 << ("-10:00 US/Hawaii")
186 << ("-09:00 US/Alaska") 187 << ("-09:00 US/Alaska")
187 << ("-08:00 US/Pacific") 188 << ("-08:00 US/Pacific")
188 << ("-07:00 US/Mountain") 189 << ("-07:00 US/Mountain")
189 << ("-06:00 US/Central") 190 << ("-06:00 US/Central")
190 << ("-05:00 US/Eastern") 191 << ("-05:00 US/Eastern")
191 << ("-04:00 Brazil/West") 192 << ("-04:00 Brazil/West")
192 << ("-03:00 Brazil/East") 193 << ("-03:00 Brazil/East")
193 << ("-02:00 Brazil/DeNoronha") 194 << ("-02:00 Brazil/DeNoronha")
194 << ("-01:00 Atlantic/Azores") 195 << ("-01:00 Atlantic/Azores")
195 << (" 00:00 Europe/London(UTC)") 196 << (" 00:00 Europe/London(UTC)")
196 << ("+01:00 Europe/Oslo(CET)") 197 << ("+01:00 Europe/Oslo(CET)")
197 << ("+02:00 Europe/Helsinki") 198 << ("+02:00 Europe/Helsinki")
198 << ("+03:00 Europe/Moscow") 199 << ("+03:00 Europe/Moscow")
199 << ("+04:00 Indian/Mauritius") 200 << ("+04:00 Indian/Mauritius")
200 << ("+05:00 Indian/Maldives") 201 << ("+05:00 Indian/Maldives")
201 << ("+06:00 Indian/Chagos") 202 << ("+06:00 Indian/Chagos")
202 << ("+07:00 Asia/Bangkok") 203 << ("+07:00 Asia/Bangkok")
203 << ("+08:00 Asia/Hongkong") 204 << ("+08:00 Asia/Hongkong")
204 << ("+09:00 Asia/Tokyo") 205 << ("+09:00 Asia/Tokyo")
205 << ("+10:00 Asia/Vladivostok") 206 << ("+10:00 Asia/Vladivostok")
206 << ("+11:00 Asia/Magadan") 207 << ("+11:00 Asia/Magadan")
207 << ("+12:00 Asia/Kamchatka") 208 << ("+12:00 Asia/Kamchatka")
208 // << (" xx:xx User defined offset") 209 // << (" xx:xx User defined offset")
209 << i18n (" Local Time"); 210 << i18n (" Local Time");
210 mSouthDaylight = false; 211 mSouthDaylight = false;
211 mTimeZoneOffset = 0; 212 mTimeZoneOffset = 0;
212 daylightEnabled = false; 213 daylightEnabled = false;
213} 214}
214 215
215void KLocale::setDateFormat( QString s ) 216void KLocale::setDateFormat( QString s )
216{ 217{
217 mDateFormat = s; 218 mDateFormat = s;
218} 219}
219 220
220void KLocale::setDateFormatShort( QString s ) 221void KLocale::setDateFormatShort( QString s )
221{ 222{
222 mDateFormatShort = s; 223 mDateFormatShort = s;
223} 224}
224 225
225void KLocale::setHore24Format ( bool b ) 226void KLocale::setHore24Format ( bool b )
226{ 227{
227 mHourF24Format = b; 228 mHourF24Format = b;
228} 229}
229void KLocale::setWeekStartMonday( bool b ) 230void KLocale::setWeekStartMonday( bool b )
230{ 231{
231 mWeekStartsMonday = b; 232 mWeekStartsMonday = b;
232} 233}
233 234
234KLocale::IntDateFormat KLocale::getIntDateFormat( ) 235KLocale::IntDateFormat KLocale::getIntDateFormat( )
235{ 236{
236 return mIntDateFormat; 237 return mIntDateFormat;
237 238
238} 239}
239void KLocale::setIntDateFormat( KLocale::IntDateFormat i ) 240void KLocale::setIntDateFormat( KLocale::IntDateFormat i )
240{ 241{
241 mIntDateFormat = i; 242 mIntDateFormat = i;
242} 243}
243KLocale::IntDateFormat KLocale::getIntTimeFormat( ) 244KLocale::IntDateFormat KLocale::getIntTimeFormat( )
244{ 245{
245 return mIntTimeFormat; 246 return mIntTimeFormat;
246 247
247} 248}
248void KLocale::setIntTimeFormat( KLocale::IntDateFormat i ) 249void KLocale::setIntTimeFormat( KLocale::IntDateFormat i )
249{ 250{
250 mIntTimeFormat = i; 251 mIntTimeFormat = i;
251} 252}
252 253
253void KLocale::setLanguage( int i ) 254void KLocale::setLanguage( int i )
254{ 255{
255 mLanguage = i; 256 mLanguage = i;
256} 257}
257int KLocale::language( ) 258int KLocale::language( )
258{ 259{
259 return mLanguage; 260 return mLanguage;
260} 261}
261QString KLocale::translate( const char *index ) const 262QString KLocale::translate( const char *index ) const
262{ 263{
263 return i18n( index ); 264 return i18n( index );
264} 265}
265 266
266QString KLocale::translate( const char *, const char *fallback) const 267QString KLocale::translate( const char *, const char *fallback) const
267{ 268{
268 return i18n( fallback ); 269 return i18n( fallback );
269} 270}
270 271
271int KLocale::weekNum ( const QDate & date ) 272int KLocale::weekNum ( const QDate & date )
272{ 273{
273 QDate seda = date; 274 QDate seda = date;
274 int weekNum = 0; 275 int weekNum = 0;
275 int dayofweek = seda.dayOfWeek(); // 1... 7 Mo .. So. Do = 4 276 int dayofweek = seda.dayOfWeek(); // 1... 7 Mo .. So. Do = 4
276 int daystoprevthursday = (dayofweek + 3) % 7 ; 277 int daystoprevthursday = (dayofweek + 3) % 7 ;
277 int dayofyear = seda.dayOfYear(); 278 int dayofyear = seda.dayOfYear();
278 int prevThursday = dayofyear - ( daystoprevthursday ); 279 int prevThursday = dayofyear - ( daystoprevthursday );
279 int subweeknum = 0; 280 int subweeknum = 0;
280 if ( prevThursday < 1 ) { 281 if ( prevThursday < 1 ) {
281 seda = seda.addDays( - daystoprevthursday ); 282 seda = seda.addDays( - daystoprevthursday );
282 dayofyear = seda.dayOfYear(); 283 dayofyear = seda.dayOfYear();
283 prevThursday = dayofyear; 284 prevThursday = dayofyear;
284 subweeknum = prevThursday / 7; 285 subweeknum = prevThursday / 7;
285 if ( prevThursday % 7 != 0 ) 286 if ( prevThursday % 7 != 0 )
286 ++subweeknum; 287 ++subweeknum;
287 } else { 288 } else {
288 if ( dayofyear >= 360 ) { //maybe week 1 289 if ( dayofyear >= 360 ) { //maybe week 1
289 seda = seda.addDays( 7 - daystoprevthursday ); 290 seda = seda.addDays( 7 - daystoprevthursday );
290 dayofyear = seda.dayOfYear(); 291 dayofyear = seda.dayOfYear();
291 if ( dayofyear < 360 && ( dayofweek < 4 || dayofweek == 7 && !mWeekStartsMonday ) ) 292 if ( dayofyear < 360 && ( dayofweek < 4 || dayofweek == 7 && !mWeekStartsMonday ) )
292 return 1; 293 return 1;
293 } 294 }
294 } 295 }
295 if ( ! weekNum ) { 296 if ( ! weekNum ) {
296 weekNum = prevThursday / 7; 297 weekNum = prevThursday / 7;
297 if ( prevThursday % 7 != 0 ) 298 if ( prevThursday % 7 != 0 )
298 ++weekNum; 299 ++weekNum;
299 if ( dayofweek < 4 ) 300 if ( dayofweek < 4 )
300 ++weekNum; 301 ++weekNum;
301 else if ( dayofweek == 7 && !mWeekStartsMonday ) 302 else if ( dayofweek == 7 && !mWeekStartsMonday )
302 ++weekNum; 303 ++weekNum;
303 if ( weekNum > subweeknum ) 304 if ( weekNum > subweeknum )
304 weekNum -= subweeknum; 305 weekNum -= subweeknum;
305 } 306 }
306 return weekNum; 307 return weekNum;
307} 308}
308QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const 309QString KLocale::formatTime(const QTime &pTime, bool includeSecs, IntDateFormat intIntDateFormat) const
309{ 310{
310 const QString rst = timeFormat(intIntDateFormat); 311 const QString rst = timeFormat(intIntDateFormat);
311 312
312 // only "pm/am" here can grow, the rest shrinks, but 313 // only "pm/am" here can grow, the rest shrinks, but
313 // I'm rather safe than sorry 314 // I'm rather safe than sorry
314 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30]; 315 QChar *buffer = new QChar[rst.length() * 3 / 2 + 30];
315 316
316 uint index = 0; 317 uint index = 0;
317 bool escape = false; 318 bool escape = false;
318 int number = 0; 319 int number = 0;
319 320
320 for ( uint format_index = 0; format_index < rst.length(); format_index++ ) 321 for ( uint format_index = 0; format_index < rst.length(); format_index++ )
321 { 322 {
322 if ( !escape ) 323 if ( !escape )
323 { 324 {
324 if ( rst.at( format_index ).unicode() == '%' ) 325 if ( rst.at( format_index ).unicode() == '%' )
325 escape = true; 326 escape = true;
326 else 327 else
327 buffer[index++] = rst.at( format_index ); 328 buffer[index++] = rst.at( format_index );
328 } 329 }
329 else 330 else
330 { 331 {
331 switch ( rst.at( format_index ).unicode() ) 332 switch ( rst.at( format_index ).unicode() )
332 { 333 {
333 case '%': 334 case '%':
334 buffer[index++] = '%'; 335 buffer[index++] = '%';
335 break; 336 break;
336 case 'H': 337 case 'H':
337 put_it_in( buffer, index, pTime.hour() ); 338 put_it_in( buffer, index, pTime.hour() );
338 break; 339 break;
339 case 'I': 340 case 'I':
340 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 ); 341 put_it_in( buffer, index, ( pTime.hour() + 11) % 12 + 1 );
341 break; 342 break;
342 case 'M': 343 case 'M':
343 put_it_in( buffer, index, pTime.minute() ); 344 put_it_in( buffer, index, pTime.minute() );
344 break; 345 break;
345 case 'S': 346 case 'S':
346 if (includeSecs) 347 if (includeSecs)
347 put_it_in( buffer, index, pTime.second() ); 348 put_it_in( buffer, index, pTime.second() );
348 else 349 else
349 { 350 {
350 // we remove the seperator sign before the seconds and 351 // we remove the seperator sign before the seconds and
351 // assume that works everywhere 352 // assume that works everywhere
352 --index; 353 --index;
353 break; 354 break;
354 } 355 }
355 break; 356 break;
356 case 'k': 357 case 'k':
357 number = pTime.hour(); 358 number = pTime.hour();
358 case 'l': 359 case 'l':
359 // to share the code 360 // to share the code
360 if ( rst.at( format_index ).unicode() == 'l' ) 361 if ( rst.at( format_index ).unicode() == 'l' )
361 number = (pTime.hour() + 11) % 12 + 1; 362 number = (pTime.hour() + 11) % 12 + 1;
362 if ( number / 10 ) 363 if ( number / 10 )
363 buffer[index++] = number / 10 + '0'; 364 buffer[index++] = number / 10 + '0';
364 buffer[index++] = number % 10 + '0'; 365 buffer[index++] = number % 10 + '0';
365 break; 366 break;
366 case 'p': 367 case 'p':
367 { 368 {
368 QString s; 369 QString s;
369 if ( pTime.hour() >= 12 ) 370 if ( pTime.hour() >= 12 )
370 put_it_in( buffer, index, i18n("pm") ); 371 put_it_in( buffer, index, i18n("pm") );
371 else 372 else
372 put_it_in( buffer, index, i18n("am") ); 373 put_it_in( buffer, index, i18n("am") );
373 break; 374 break;
374 } 375 }
375 default: 376 default:
376 buffer[index++] = rst.at( format_index ); 377 buffer[index++] = rst.at( format_index );
377 break; 378 break;
378 } 379 }
379 escape = false; 380 escape = false;
380 } 381 }
381 } 382 }
382 QString ret( buffer, index ); 383 QString ret( buffer, index );
383 delete [] buffer; 384 delete [] buffer;
384 return ret; 385 return ret;
385} 386}
386 387
387QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const 388QString KLocale::formatDate(const QDate &pDate, bool shortFormat, IntDateFormat intIntDateFormat) const
388{ 389{
389 const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat); 390 const QString rst = shortFormat?dateFormatShort(intIntDateFormat):dateFormat(intIntDateFormat);
390 391
391 // I'm rather safe than sorry 392 // I'm rather safe than sorry
392 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50]; 393 QChar *buffer = new QChar[rst.length() * 3 / 2 + 50];
393 394
394 unsigned int index = 0; 395 unsigned int index = 0;
395 bool escape = false; 396 bool escape = false;
396 int number = 0; 397 int number = 0;
397 398
398 for ( uint format_index = 0; format_index < rst.length(); ++format_index ) 399 for ( uint format_index = 0; format_index < rst.length(); ++format_index )
399 { 400 {
400 if ( !escape ) 401 if ( !escape )
401 { 402 {
402 if ( rst.at( format_index ).unicode() == '%' ) 403 if ( rst.at( format_index ).unicode() == '%' )
403 escape = true; 404 escape = true;
404 else 405 else
405 buffer[index++] = rst.at( format_index ); 406 buffer[index++] = rst.at( format_index );
406 } 407 }
407 else 408 else
408 { 409 {
409 switch ( rst.at( format_index ).unicode() ) 410 switch ( rst.at( format_index ).unicode() )
410 { 411 {
411 case '%': 412 case '%':
412 buffer[index++] = '%'; 413 buffer[index++] = '%';
413 break; 414 break;
414 case 'Y': 415 case 'Y':
415 put_it_in( buffer, index, pDate.year() / 100 ); 416 put_it_in( buffer, index, pDate.year() / 100 );
416 case 'y': 417 case 'y':
417 put_it_in( buffer, index, pDate.year() % 100 ); 418 put_it_in( buffer, index, pDate.year() % 100 );
418 break; 419 break;
419 case 'n': 420 case 'n':
420 number = pDate.month(); 421 number = pDate.month();
421 case 'e': 422 case 'e':
422 // to share the code 423 // to share the code
423 if ( rst.at( format_index ).unicode() == 'e' ) 424 if ( rst.at( format_index ).unicode() == 'e' )
424 number = pDate.day(); 425 number = pDate.day();
425 if ( number / 10 ) 426 if ( number / 10 )
426 buffer[index++] = number / 10 + '0'; 427 buffer[index++] = number / 10 + '0';
427 buffer[index++] = number % 10 + '0'; 428 buffer[index++] = number % 10 + '0';
428 break; 429 break;
429 case 'm': 430 case 'm':
430 put_it_in( buffer, index, pDate.month() ); 431 put_it_in( buffer, index, pDate.month() );
431 break; 432 break;
432 case 'b': 433 case 'b':
433 put_it_in( buffer, index, monthName(pDate.month(), true) ); 434 put_it_in( buffer, index, monthName(pDate.month(), true) );
434 break; 435 break;
435 case 'B': 436 case 'B':
436 put_it_in( buffer, index, monthName(pDate.month(), false) ); 437 put_it_in( buffer, index, monthName(pDate.month(), false) );
437 break; 438 break;
438 case 'd': 439 case 'd':
439 put_it_in( buffer, index, pDate.day() ); 440 put_it_in( buffer, index, pDate.day() );
440 break; 441 break;
441 case 'a': 442 case 'a':
442 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) ); 443 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), true) );
443 break; 444 break;
444 case 'A': 445 case 'A':
445 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) ); 446 put_it_in( buffer, index, weekDayName(pDate.dayOfWeek(), false) );
446 break; 447 break;
447 default: 448 default:
448 buffer[index++] = rst.at( format_index ); 449 buffer[index++] = rst.at( format_index );
449 break; 450 break;
450 } 451 }
451 escape = false; 452 escape = false;
452 } 453 }
453 } 454 }
454 QString ret( buffer, index ); 455 QString ret( buffer, index );
455 delete [] buffer; 456 delete [] buffer;
456 return ret; 457 return ret;
457} 458}
458 459
459QString KLocale::formatDateTime(const QDateTime &pDateTime, 460QString KLocale::formatDateTime(const QDateTime &pDateTime,
460 bool shortFormat, 461 bool shortFormat,
461 bool includeSeconds, 462 bool includeSeconds,
462 IntDateFormat intIntDateFormat) const 463 IntDateFormat intIntDateFormat) const
463{ 464{
464 QString format("%1 %2"); 465 QString format("%1 %2");
465 466
466 if ( intIntDateFormat == Default ) 467 if ( intIntDateFormat == Default )
467 format = "%1 %2"; 468 format = "%1 %2";
468 else if ( intIntDateFormat == Format1 ) 469 else if ( intIntDateFormat == Format1 )
469 format = "%1 %2"; 470 format = "%1 %2";
470 else if ( intIntDateFormat == ISODate ) 471 else if ( intIntDateFormat == Qt::ISODate )
471 format = "%1T%2"; 472 format = "%1T%2";
472 473
473 QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat )) 474 QString res = format.arg(formatDate( pDateTime.date(), shortFormat, intIntDateFormat ))
474 .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat )); 475 .arg(formatTime( pDateTime.time(), includeSeconds , intIntDateFormat ));
475 476
476 //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() ); 477 //qDebug("KLocale::formatDateTime transformed %s, into %s", pDateTime.toString().latin1(), res.latin1() );
477 478
478 return res; 479 return res;
479} 480}
480 481
481QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const 482QString KLocale::formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat) const
482{ 483{
483 return formatDateTime(pDateTime, true, true, intIntDateFormat); 484 return formatDateTime(pDateTime, true, true, intIntDateFormat);
484} 485}
485 486
486QDate KLocale::readDate(const QString &intstr, bool* ok) const 487QDate KLocale::readDate(const QString &intstr, bool* ok) const
487{ 488{
488 QDate date; 489 QDate date;
489 date = readDate(intstr, true, ok); 490 date = readDate(intstr, true, ok);
490 if (date.isValid()) return date; 491 if (date.isValid()) return date;
491 return readDate(intstr, false, ok); 492 return readDate(intstr, false, ok);
492} 493}
493 494
494QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const 495QDate KLocale::readDate(const QString &intstr, bool shortFormat, bool* ok) const
495{ 496{
496 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace(); 497 QString fmt = (shortFormat ? dateFormatShort() : dateFormat()).simplifyWhiteSpace();
497 return readDate( intstr, fmt, ok ); 498 return readDate( intstr, fmt, ok );
498} 499}
499 500
500QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const 501QDate KLocale::readDate(const QString &intstr, const QString &fmt, bool* ok) const
501{ 502{
502 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl; 503 //kdDebug(173) << "KLocale::readDate intstr=" << intstr << " fmt=" << fmt << endl;
503 QString str = intstr.simplifyWhiteSpace().lower(); 504 QString str = intstr.simplifyWhiteSpace().lower();
504 int day = -1, month = -1; 505 int day = -1, month = -1;
505 // allow the year to be omitted if not in the format 506 // allow the year to be omitted if not in the format
506 int year = QDate::currentDate().year(); 507 int year = QDate::currentDate().year();
507 uint strpos = 0; 508 uint strpos = 0;
508 uint fmtpos = 0; 509 uint fmtpos = 0;
509 510
510 while (fmt.length() > fmtpos || str.length() > strpos) 511 while (fmt.length() > fmtpos || str.length() > strpos)
511 { 512 {
512 if ( !(fmt.length() > fmtpos && str.length() > strpos) ) 513 if ( !(fmt.length() > fmtpos && str.length() > strpos) )
513 goto error; 514 goto error;
514 515
515 QChar c = fmt.at(fmtpos++); 516 QChar c = fmt.at(fmtpos++);
516 517
517 if (c != '%') { 518 if (c != '%') {
518 if (c.isSpace()) 519 if (c.isSpace())
519 strpos++; 520 strpos++;
520 else if (c != str.at(strpos++)) 521 else if (c != str.at(strpos++))
521 goto error; 522 goto error;
522 continue; 523 continue;
523 } 524 }
524 525
525 // remove space at the begining 526 // remove space at the begining
526 if (str.length() > strpos && str.at(strpos).isSpace()) 527 if (str.length() > strpos && str.at(strpos).isSpace())
527 strpos++; 528 strpos++;
528 529
529 c = fmt.at(fmtpos++); 530 c = fmt.at(fmtpos++);
530 switch (c) 531 switch (c.unicode())
531 { 532 {
532 case 'a': 533 case 'a':
533 case 'A': 534 case 'A':
534 // this will just be ignored 535 // this will just be ignored
535 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 536 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
536 for (int j = 1; j < 8; j++) { 537 for (int j = 1; j < 8; j++) {
537 QString s = weekDayName(j, c == 'a').lower(); 538 QString s = weekDayName(j, c == 'a').lower();
538 int len = s.length(); 539 int len = s.length();
539 if (str.mid(strpos, len) == s) 540 if (str.mid(strpos, len) == s)
540 strpos += len; 541 strpos += len;
541 } 542 }
542 break; 543 break;
543 } 544 }
544 case 'b': 545 case 'b':
545 case 'B': 546 case 'B':
546 { // Cristian Tache: porting to Win: Block added because of "j" redefinition 547 { // Cristian Tache: porting to Win: Block added because of "j" redefinition
547 for (int j = 1; j < 13; j++) { 548 for (int j = 1; j < 13; j++) {
548 QString s = monthName(j, c == 'b').lower(); 549 QString s = monthName(j, c == 'b').lower();
549 int len = s.length(); 550 int len = s.length();
550 if (str.mid(strpos, len) == s) { 551 if (str.mid(strpos, len) == s) {
551 month = j; 552 month = j;
552 strpos += len; 553 strpos += len;
553 } 554 }
554 } 555 }
555 break; 556 break;
556 } 557 }
557 case 'd': 558 case 'd':
558 case 'e': 559 case 'e':
559 day = readInt(str, strpos); 560 day = readInt(str, strpos);
560 if (day < 1 || day > 31) 561 if (day < 1 || day > 31)
561 goto error; 562 goto error;
562 563
563 break; 564 break;
564 565
565 case 'n': 566 case 'n':
566 case 'm': 567 case 'm':
567 month = readInt(str, strpos); 568 month = readInt(str, strpos);
568 if (month < 1 || month > 12) 569 if (month < 1 || month > 12)
569 goto error; 570 goto error;
570 571
571 break; 572 break;
572 573
573 case 'Y': 574 case 'Y':
574 case 'y': 575 case 'y':
575 year = readInt(str, strpos); 576 year = readInt(str, strpos);
576 if (year < 0) 577 if (year < 0)
577 goto error; 578 goto error;
578 // Qt treats a year in the range 0-100 as 1900-1999. 579 // Qt treats a year in the range 0-100 as 1900-1999.
579 // It is nicer for the user if we treat 0-68 as 2000-2068 580 // It is nicer for the user if we treat 0-68 as 2000-2068
580 if (year < 69) 581 if (year < 69)
581 year += 2000; 582 year += 2000;
582 else if (c == 'y') 583 else if (c == 'y')
583 year += 1900; 584 year += 1900;
584 585
585 break; 586 break;
586 } 587 }
587 } 588 }
588 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl; 589 //kdDebug(173) << "KLocale::readDate day=" << day << " month=" << month << " year=" << year << endl;
589 if ( year != -1 && month != -1 && day != -1 ) 590 if ( year != -1 && month != -1 && day != -1 )
590 { 591 {
591 if (ok) *ok = true; 592 if (ok) *ok = true;
592 return QDate(year, month, day); 593 return QDate(year, month, day);
593 } 594 }
594 error: 595 error:
595 if (ok) *ok = false; 596 if (ok) *ok = false;
596 return QDate(); // invalid date 597 return QDate(); // invalid date
597} 598}
598 599
599QTime KLocale::readTime(const QString &intstr, bool *ok) const 600QTime KLocale::readTime(const QString &intstr, bool *ok) const
600{ 601{
601 QTime _time; 602 QTime _time;
602 _time = readTime(intstr, false, ok); 603 _time = readTime(intstr, false, ok);
603 if (_time.isValid()) return _time; 604 if (_time.isValid()) return _time;
604 return readTime(intstr, true, ok); 605 return readTime(intstr, true, ok);
605} 606}
606 607
607QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const 608QTime KLocale::readTime(const QString &intstr, bool seconds, bool *ok) const
608{ 609{
609 QString str = intstr.simplifyWhiteSpace().lower(); 610 QString str = intstr.simplifyWhiteSpace().lower();
610 QString Format = timeFormat().simplifyWhiteSpace(); 611 QString Format = timeFormat().simplifyWhiteSpace();
611 if (!seconds) 612 if (!seconds)
612 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null); 613 Format.replace(QRegExp(QString::fromLatin1(".%S")), QString::null);
613 614
614 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds 615 int hour = -1, minute = -1, second = seconds ? -1 : 0; // don't require seconds
615 616
616 bool g_12h = false; 617 bool g_12h = false;
617 bool pm = false; 618 bool pm = false;
618 uint strpos = 0; 619 uint strpos = 0;
619 uint Formatpos = 0; 620 uint Formatpos = 0;
620 621
621 while (Format.length() > Formatpos || str.length() > strpos) 622 while (Format.length() > Formatpos || str.length() > strpos)
622 { 623 {
623 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error; 624 if ( !(Format.length() > Formatpos && str.length() > strpos) ) goto error;
624 625
625 QChar c = Format.at(Formatpos++); 626 QChar c = Format.at(Formatpos++);
626 627
627 if (c != '%') 628 if (c != '%')
628 { 629 {
629 if (c.isSpace()) 630 if (c.isSpace())
630 strpos++; 631 strpos++;
631 else if (c != str.at(strpos++)) 632 else if (c != str.at(strpos++))
632 goto error; 633 goto error;
633 continue; 634 continue;
634 } 635 }
635 636
636 // remove space at the begining 637 // remove space at the begining
637 if (str.length() > strpos && str.at(strpos).isSpace()) 638 if (str.length() > strpos && str.at(strpos).isSpace())
638 strpos++; 639 strpos++;
639 640
640 c = Format.at(Formatpos++); 641 c = Format.at(Formatpos++);
641 switch (c) 642 switch (c.unicode())
642 { 643 {
643 case 'p': 644 case 'p':
644 { 645 {
645 QString s; 646 QString s;
646 s = i18n("pm").lower(); 647 s = i18n("pm").lower();
647 int len = s.length(); 648 int len = s.length();
648 if (str.mid(strpos, len) == s) 649 if (str.mid(strpos, len) == s)
649 { 650 {
650 pm = true; 651 pm = true;
651 strpos += len; 652 strpos += len;
652 } 653 }
653 else 654 else
654 { 655 {
655 s = i18n("am").lower(); 656 s = i18n("am").lower();
656 len = s.length(); 657 len = s.length();
657 if (str.mid(strpos, len) == s) { 658 if (str.mid(strpos, len) == s) {
658 pm = false; 659 pm = false;
659 strpos += len; 660 strpos += len;
660 } 661 }
661 else 662 else
662 goto error; 663 goto error;
663 } 664 }
664 } 665 }
665 break; 666 break;
666 667
667 case 'k': 668 case 'k':
668 case 'H': 669 case 'H':
669 g_12h = false; 670 g_12h = false;
670 hour = readInt(str, strpos); 671 hour = readInt(str, strpos);
671 if (hour < 0 || hour > 23) 672 if (hour < 0 || hour > 23)
672 goto error; 673 goto error;
673 674
674 break; 675 break;
675 676
676 case 'l': 677 case 'l':
677 case 'I': 678 case 'I':
678 g_12h = true; 679 g_12h = true;
679 hour = readInt(str, strpos); 680 hour = readInt(str, strpos);
680 if (hour < 1 || hour > 12) 681 if (hour < 1 || hour > 12)
681 goto error; 682 goto error;
682 683
683 break; 684 break;
684 685
685 case 'M': 686 case 'M':
686 minute = readInt(str, strpos); 687 minute = readInt(str, strpos);
687 if (minute < 0 || minute > 59) 688 if (minute < 0 || minute > 59)
688 goto error; 689 goto error;
689 690
690 break; 691 break;
691 692
692 case 'S': 693 case 'S':
693 second = readInt(str, strpos); 694 second = readInt(str, strpos);
694 if (second < 0 || second > 59) 695 if (second < 0 || second > 59)
695 goto error; 696 goto error;
696 697
697 break; 698 break;
698 } 699 }
699 } 700 }
700 if (g_12h) 701 if (g_12h)
701 { 702 {
702 hour %= 12; 703 hour %= 12;
703 if (pm) hour += 12; 704 if (pm) hour += 12;
704 } 705 }
705 706
706 if (ok) *ok = true; 707 if (ok) *ok = true;
707 return QTime(hour, minute, second); 708 return QTime(hour, minute, second);
708 709
709 error: 710 error:
710 if (ok) *ok = false; 711 if (ok) *ok = false;
711 return QTime(-1, -1, -1); // return invalid date if it didn't work 712 return QTime(-1, -1, -1); // return invalid date if it didn't work
712 // This will be removed in the near future, since it gives a warning on stderr. 713 // This will be removed in the near future, since it gives a warning on stderr.
713 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime. 714 // The presence of the bool* (since KDE-3.0) removes the need for an invalid QTime.
714} 715}
715 716
716QDateTime KLocale::readDateTime(const QString &intstr, 717QDateTime KLocale::readDateTime(const QString &intstr,
717 IntDateFormat intIntDateFormat, 718 IntDateFormat intIntDateFormat,
718 bool* ok) const 719 bool* ok) const
719{ 720{
720 bool ok1, ok2; 721 bool ok1, ok2;
721 722
722 // AT the moment we can not read any other format then ISODate 723 // AT the moment we can not read any other format then ISODate
723 if ( intIntDateFormat != ISODate ) 724 if ( intIntDateFormat != ISODate )
724 { 725 {
725 qDebug("KLocale::readDateTime, only ISODate is supported."); 726 qDebug("KLocale::readDateTime, only ISODate is supported.");
726 return QDateTime(); 727 return QDateTime();
727 } 728 }
728 729
729 int pos = intstr.find("T"); 730 int pos = intstr.find("T");
730 QString date = intstr.left(pos); 731 QString date = intstr.left(pos);
731 QString time = intstr.mid(pos+1); 732 QString time = intstr.mid(pos+1);
732 733
733 QString dformat = dateFormat(intIntDateFormat); 734 QString dformat = dateFormat(intIntDateFormat);
734 QString tformat = timeFormat(intIntDateFormat); 735 QString tformat = timeFormat(intIntDateFormat);
735 736
736 QDate m_date = readDate(date, dformat, &ok1); 737 QDate m_date = readDate(date, dformat, &ok1);
737 QTime m_time = readTime(time, tformat, &ok2); 738 QTime m_time = readTime(time, !tformat.isEmpty(), &ok2);
738 739
739 QDateTime m_dt; 740 QDateTime m_dt;
740 741
741 if (ok) 742 if (ok)
742 { 743 {
743 if ((ok1 == false) || (ok2 == false)) 744 if ((ok1 == false) || (ok2 == false))
744 *ok = false; 745 *ok = false;
745 else 746 else
746 *ok = true; 747 *ok = true;
747 } 748 }
748 749
749 //only set values if both operations returned true. 750 //only set values if both operations returned true.
750 if ((ok1 == true) && (ok2 == true)) 751 if ((ok1 == true) && (ok2 == true))
751 { 752 {
752 m_dt.setDate(m_date); 753 m_dt.setDate(m_date);
753 m_dt.setTime(m_time); 754 m_dt.setTime(m_time);
754 } 755 }
755 756
756 //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); 757 //qDebug("KLocale::readDateTime() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
757 return m_dt; 758 return m_dt;
758} 759}
759 760
760QDate KLocale::readDate(const QString &intstr, 761QDate KLocale::readDate(const QString &intstr,
761 IntDateFormat intIntDateFormat, 762 IntDateFormat intIntDateFormat,
762 bool* ok) const 763 bool* ok) const
763{ 764{
764 bool ok1; 765 bool ok1;
765 766
766 QString dformat = dateFormat(intIntDateFormat); 767 QString dformat = dateFormat(intIntDateFormat);
767 768
768 QDate m_date = readDate(intstr, dformat, &ok1); 769 QDate m_date = readDate(intstr, dformat, &ok1);
769 770
770 if (ok) 771 if (ok)
771 *ok = ok1; 772 *ok = ok1;
772 773
773 //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2); 774 //qDebug("KLocale::readDate() transformed %s into %s (%s), %s (%s) : err1=%i, err2=%i", intstr.latin1(), date.latin1(), dformat.latin1(), time.latin1(), tformat.latin1(), ok1, ok2);
774 return m_date; 775 return m_date;
775} 776}
776 777
777 778
778bool KLocale::use12Clock() const 779bool KLocale::use12Clock() const
779{ 780{
780 return !mHourF24Format ;; 781 return !mHourF24Format ;;
781} 782}
782 783
783bool KLocale::weekStartsMonday() const 784bool KLocale::weekStartsMonday() const
784{ 785{
785 return mWeekStartsMonday; 786 return mWeekStartsMonday;
786} 787}
787 788
788int KLocale::weekStartDay() const 789int KLocale::weekStartDay() const
789{ 790{
790 if ( mWeekStartsMonday ) 791 if ( mWeekStartsMonday )
791 return 1; 792 return 1;
792 return 7; 793 return 7;
793} 794}
794 795
795QString KLocale::weekDayName(int i,bool shortName) const 796QString KLocale::weekDayName(int i,bool shortName) const
796{ 797{
797 if ( shortName ) 798 if ( shortName )
798 switch ( i ) 799 switch ( i )
799 { 800 {
800 case 1: return i18n("Monday", "Mon"); 801 case 1: return i18n("Monday", "Mon");
801 case 2: return i18n("Tuesday", "Tue"); 802 case 2: return i18n("Tuesday", "Tue");
802 case 3: return i18n("Wednesday", "Wed"); 803 case 3: return i18n("Wednesday", "Wed");
803 case 4: return i18n("Thursday", "Thu"); 804 case 4: return i18n("Thursday", "Thu");
804 case 5: return i18n("Friday", "Fri"); 805 case 5: return i18n("Friday", "Fri");
805 case 6: return i18n("Saturday", "Sat"); 806 case 6: return i18n("Saturday", "Sat");
806 case 7: return i18n("Sunday", "Sun"); 807 case 7: return i18n("Sunday", "Sun");
807 } 808 }
808 else 809 else
809 switch ( i ) 810 switch ( i )
810 { 811 {
811 case 1: return i18n("Monday"); 812 case 1: return i18n("Monday");
812 case 2: return i18n("Tuesday"); 813 case 2: return i18n("Tuesday");
813 case 3: return i18n("Wednesday"); 814 case 3: return i18n("Wednesday");
814 case 4: return i18n("Thursday"); 815 case 4: return i18n("Thursday");
815 case 5: return i18n("Friday"); 816 case 5: return i18n("Friday");
816 case 6: return i18n("Saturday"); 817 case 6: return i18n("Saturday");
817 case 7: return i18n("Sunday"); 818 case 7: return i18n("Sunday");
818 } 819 }
819 820
820 return QString::null; 821 return QString::null;
821} 822}
822 823
823QString KLocale::monthName(int i,bool shortName) const 824QString KLocale::monthName(int i,bool shortName) const
824{ 825{
825 if ( shortName ) 826 if ( shortName )
826 switch ( i ) 827 switch ( i )
827 { 828 {
828 case 1: return i18n("January", "Jan"); 829 case 1: return i18n("January", "Jan");
829 case 2: return i18n("February", "Feb"); 830 case 2: return i18n("February", "Feb");
830 case 3: return i18n("March", "Mar"); 831 case 3: return i18n("March", "Mar");
831 case 4: return i18n("April", "Apr"); 832 case 4: return i18n("April", "Apr");
832 case 5: return i18n("May short", "May"); 833 case 5: return i18n("May short", "May");
833 case 6: return i18n("June", "Jun"); 834 case 6: return i18n("June", "Jun");
834 case 7: return i18n("July", "Jul"); 835 case 7: return i18n("July", "Jul");
835 case 8: return i18n("August", "Aug"); 836 case 8: return i18n("August", "Aug");
836 case 9: return i18n("September", "Sep"); 837 case 9: return i18n("September", "Sep");
837 case 10: return i18n("October", "Oct"); 838 case 10: return i18n("October", "Oct");
838 case 11: return i18n("November", "Nov"); 839 case 11: return i18n("November", "Nov");
839 case 12: return i18n("December", "Dec"); 840 case 12: return i18n("December", "Dec");
840 } 841 }
841 else 842 else
842 switch (i) 843 switch (i)
843 { 844 {
844 case 1: return i18n("January"); 845 case 1: return i18n("January");
845 case 2: return i18n("February"); 846 case 2: return i18n("February");
846 case 3: return i18n("March"); 847 case 3: return i18n("March");
847 case 4: return i18n("April"); 848 case 4: return i18n("April");
848 case 5: return i18n("May long", "May"); 849 case 5: return i18n("May long", "May");
849 case 6: return i18n("June"); 850 case 6: return i18n("June");
850 case 7: return i18n("July"); 851 case 7: return i18n("July");
851 case 8: return i18n("August"); 852 case 8: return i18n("August");
852 case 9: return i18n("September"); 853 case 9: return i18n("September");
853 case 10: return i18n("October"); 854 case 10: return i18n("October");
854 case 11: return i18n("November"); 855 case 11: return i18n("November");
855 case 12: return i18n("December"); 856 case 12: return i18n("December");
856 } 857 }
857 858
858 return QString::null; 859 return QString::null;
859} 860}
860 861
861QString KLocale::country() const 862QString KLocale::country() const
862{ 863{
863 return QString::null; 864 return QString::null;
864} 865}
865 866
866QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const 867QString KLocale::dateFormat(IntDateFormat intIntDateFormat) const
867{ 868{
868 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 869 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
869 870
870 if ( dformat == ISODate ) 871 if ( dformat == ISODate )
871 return "%Y-%m-%d"; 872 return "%Y-%m-%d";
872 873
873 if ( QApplication::desktop()->width() < 480 ) { 874 if ( QApplication::desktop()->width() < 480 ) {
874 if ( dformat == Default ) 875 if ( dformat == Default )
875 return "%a %d %b %Y"; 876 return "%a %d %b %Y";
876 else if ( dformat == Format1 ) 877 else if ( dformat == Format1 )
877 return "%a %b %d %Y"; 878 return "%a %b %d %Y";
878 } else { 879 } else {
879 if ( dformat == Default ) 880 if ( dformat == Default )
880 return "%A %d %B %Y"; 881 return "%A %d %B %Y";
881 else if ( dformat == Format1 ) 882 else if ( dformat == Format1 )
882 return "%A %B %d %Y"; 883 return "%A %B %d %Y";
883 884
884 } 885 }
885 return mDateFormat ; 886 return mDateFormat ;
886} 887}
887 888
888QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const 889QString KLocale::dateFormatShort(IntDateFormat intIntDateFormat) const
889{ 890{
890 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat; 891 const IntDateFormat dformat = (intIntDateFormat == Undefined)?mIntDateFormat:intIntDateFormat;
891 892
892 if ( dformat == Default ) 893 if ( dformat == Default )
893 return "%d.%m.%Y"; 894 return "%d.%m.%Y";
894 else if ( dformat == Format1 ) 895 else if ( dformat == Format1 )
895 return "%m.%d.%Y"; 896 return "%m.%d.%Y";
896 else if ( dformat == ISODate ) // = Qt::ISODate 897 else if ( dformat == ISODate ) // = Qt::ISODate
897 return "%Y-%m-%d"; 898 return "%Y-%m-%d";
898 return mDateFormatShort ; 899 return mDateFormatShort ;
899 900
900} 901}
901 902
902 903
903QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const 904QString KLocale::timeFormat(IntDateFormat intIntTimeFormat) const
904{ 905{
905 const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat; 906 const IntDateFormat tformat = (intIntTimeFormat == Undefined)?mIntTimeFormat:intIntTimeFormat;
906 907
907 if ( tformat == Default ) 908 if ( tformat == Default )
908 if ( mHourF24Format) 909 if ( mHourF24Format)
909 return "%H:%M:%S"; 910 return "%H:%M:%S";
910 else 911 else
911 return "%I:%M:%S%p"; 912 return "%I:%M:%S%p";
912 913
913 else if ( tformat == Format1 ) 914 else if ( tformat == Format1 )
914 if ( mHourF24Format) 915 if ( mHourF24Format)
915 return "%H:%M:%S"; 916 return "%H:%M:%S";
916 else 917 else
917 return "%I:%M:%S%p"; 918 return "%I:%M:%S%p";
918 919
919 else if ( tformat == ISODate ) // = Qt::ISODate 920 else if ( tformat == ISODate ) // = Qt::ISODate
920 if ( mHourF24Format) 921 if ( mHourF24Format)
921 return "%H:%M:%S"; 922 return "%H:%M:%S";
922 else 923 else
923 return "%I:%M:%S%p"; 924 return "%I:%M:%S%p";
924 // to satisfy the compiler 925 // to satisfy the compiler
925 return "%H:%M:%S"; 926 return "%H:%M:%S";
926} 927}
927 928
928void KLocale::insertCatalogue ( const QString & ) 929void KLocale::insertCatalogue ( const QString & )
929{ 930{
930} 931}
931 932
932KCalendarSystem *KLocale::calendar() 933KCalendarSystem *KLocale::calendar()
933{ 934{
934 if ( !mCalendarSystem ) { 935 if ( !mCalendarSystem ) {
935 mCalendarSystem = new KCalendarSystemGregorian; 936 mCalendarSystem = new KCalendarSystemGregorian;
936 } 937 }
937 938
938 return mCalendarSystem; 939 return mCalendarSystem;
939} 940}
940 941
941int KLocale::timezoneOffset( QString timeZone ) 942int KLocale::timezoneOffset( QString timeZone )
942{ 943{
943 int ret = 1001; 944 int ret = 1001;
944 int index = mTimeZoneList.findIndex( timeZone ); 945 int index = mTimeZoneList.findIndex( timeZone );
945 if ( index < 24 ) 946 if ( index < 24 )
946 ret = ( index-11 ) * 60 ; 947 ret = ( index-11 ) * 60 ;
947 return ret; 948 return ret;
948} 949}
949 950
950QStringList KLocale::timeZoneList() const 951QStringList KLocale::timeZoneList() const
951{ 952{
952 return mTimeZoneList; 953 return mTimeZoneList;
953} 954}
954void KLocale::setTimezone( const QString &timeZone, bool oddTZ ) 955void KLocale::setTimezone( const QString &timeZone, bool oddTZ )
955{ 956{
956 mTimeZoneOffset = timezoneOffset( timeZone ); 957 mTimeZoneOffset = timezoneOffset( timeZone );
957 if ( oddTZ ) 958 if ( oddTZ )
958 mTimeZoneOffset += 30; 959 mTimeZoneOffset += 30;
959} 960}
960 961
961void KLocale::setDaylightSaving( bool b, int start , int end ) 962void KLocale::setDaylightSaving( bool b, int start , int end )
962{ 963{
963 daylightEnabled = b; 964 daylightEnabled = b;
964 daylightStart = start; 965 daylightStart = start;
965 daylightEnd = end; 966 daylightEnd = end;
966 mSouthDaylight = (end < start); 967 mSouthDaylight = (end < start);
967 // qDebug("klocale daylight %d %d %d ", b, start , end ); 968 // qDebug("klocale daylight %d %d %d ", b, start , end );
968} 969}
969 970
970int KLocale::localTimeOffset( const QDateTime &dt ) 971int KLocale::localTimeOffset( const QDateTime &dt )
971{ 972{
972 bool addDaylight = false; 973 bool addDaylight = false;
973 if ( daylightEnabled ) { 974 if ( daylightEnabled ) {
974 int d_end, d_start; 975 int d_end, d_start;
975 int dayofyear = dt.date().dayOfYear(); 976 int dayofyear = dt.date().dayOfYear();
976 int year = dt.date().year(); 977 int year = dt.date().year();
977 int add = 0; 978 int add = 0;
978 if ( QDate::leapYear(year) ) 979 if ( QDate::leapYear(year) )
979 add = 1; 980 add = 1;
980 QDate date ( year,1,1 ); 981 QDate date ( year,1,1 );
981 if ( daylightEnd > 59 ) 982 if ( daylightEnd > 59 )
982 d_end = daylightEnd +add; 983 d_end = daylightEnd +add;
983 else 984 else
984 d_end = daylightEnd; 985 d_end = daylightEnd;
985 if ( daylightStart > 59 ) 986 if ( daylightStart > 59 )
986 d_start = daylightStart +add; 987 d_start = daylightStart +add;
987 else 988 else
988 d_start = daylightStart; 989 d_start = daylightStart;
989 QDate s_date = date.addDays( d_start -1 ); 990 QDate s_date = date.addDays( d_start -1 );
990 QDate e_date = date.addDays( d_end -1 ); 991 QDate e_date = date.addDays( d_end -1 );
991 int dof = s_date.dayOfWeek(); 992 int dof = s_date.dayOfWeek();
992 if ( dof < 7 ) 993 if ( dof < 7 )
993 s_date = s_date.addDays( -dof ); 994 s_date = s_date.addDays( -dof );
994 dof = e_date.dayOfWeek(); 995 dof = e_date.dayOfWeek();
995 if ( dof < 7 ) 996 if ( dof < 7 )
996 e_date = e_date.addDays( -dof ); 997 e_date = e_date.addDays( -dof );
997 QTime startTime ( 3,0,0 ); 998 QTime startTime ( 3,0,0 );
998 QDateTime startDt( s_date, startTime ); 999 QDateTime startDt( s_date, startTime );
999 QDateTime endDt( e_date, startTime ); 1000 QDateTime endDt( e_date, startTime );
1000 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( )); 1001 //qDebug("dayligt saving start %s end %s ",startDt.toString().latin1(),endDt.toString().latin1( ));
1001 if ( mSouthDaylight ) { 1002 if ( mSouthDaylight ) {
1002 if ( ! ( endDt < dt && dt < startDt) ) 1003 if ( ! ( endDt < dt && dt < startDt) )
1003 addDaylight = true; 1004 addDaylight = true;
1004 } else { 1005 } else {
1005 if ( startDt < dt && dt < endDt ) 1006 if ( startDt < dt && dt < endDt )
1006 addDaylight = true; 1007 addDaylight = true;
1007 1008
1008 1009
1009 } 1010 }
1010 } 1011 }
1011 int addMin = 0; 1012 int addMin = 0;
1012 if ( addDaylight ) 1013 if ( addDaylight )
1013 addMin = 60; 1014 addMin = 60;
1014 return mTimeZoneOffset + addMin; 1015 return mTimeZoneOffset + addMin;
1015} 1016}
1016// ****************************************************************** 1017// ******************************************************************
1017// added LR 1018// added LR
1018QString KLocale::formatNumber(double num, int precision) const 1019QString KLocale::formatNumber(double num, int precision) const
1019{ 1020{
1020 bool neg = num < 0; 1021 bool neg = num < 0;
1021 if (precision == -1) precision = 2; 1022 if (precision == -1) precision = 2;
1022 QString res = QString::number(neg?-num:num, 'f', precision); 1023 QString res = QString::number(neg?-num:num, 'f', precision);
1023 int pos = res.find('.'); 1024 int pos = res.find('.');
1024 if (pos == -1) pos = res.length(); 1025 if (pos == -1) pos = res.length();
1025 else res.replace(pos, 1, decimalSymbol()); 1026 else res.replace(pos, 1, decimalSymbol());
1026 1027
1027 while (0 < (pos -= 3)) 1028 while (0 < (pos -= 3))
1028 res.insert(pos, thousandsSeparator()); // thousand sep 1029 res.insert(pos, thousandsSeparator()); // thousand sep
1029 1030
1030 // How can we know where we should put the sign? 1031 // How can we know where we should put the sign?
1031 res.prepend(neg?negativeSign():positiveSign()); 1032 res.prepend(neg?negativeSign():positiveSign());
1032 1033
1033 return res; 1034 return res;
1034} 1035}
1035QString KLocale::formatNumber(const QString &numStr) const 1036QString KLocale::formatNumber(const QString &numStr) const
1036{ 1037{
1037 return formatNumber(numStr.toDouble()); 1038 return formatNumber(numStr.toDouble());
1038} 1039}
1039double KLocale::readNumber(const QString &_str, bool * ok) const 1040double KLocale::readNumber(const QString &_str, bool * ok) const
1040{ 1041{
1041 QString str = _str.stripWhiteSpace(); 1042 QString str = _str.stripWhiteSpace();
1042 bool neg = str.find(negativeSign()) == 0; 1043 bool neg = str.find(negativeSign()) == 0;
1043 if (neg) 1044 if (neg)
1044 str.remove( 0, negativeSign().length() ); 1045 str.remove( 0, negativeSign().length() );
1045 1046
1046 /* will hold the scientific notation portion of the number. 1047 /* will hold the scientific notation portion of the number.
1047 Example, with 2.34E+23, exponentialPart == "E+23" 1048 Example, with 2.34E+23, exponentialPart == "E+23"
1048 */ 1049 */
1049 QString exponentialPart; 1050 QString exponentialPart;
1050 int EPos; 1051 int EPos;
1051 1052
1052 EPos = str.find('E', 0, false); 1053 EPos = str.find('E', 0, false);
1053 1054
1054 if (EPos != -1) 1055 if (EPos != -1)
1055 { 1056 {
1056 exponentialPart = str.mid(EPos); 1057 exponentialPart = str.mid(EPos);
1057 str = str.left(EPos); 1058 str = str.left(EPos);
1058 } 1059 }
1059 1060
1060 int pos = str.find(decimalSymbol()); 1061 int pos = str.find(decimalSymbol());
1061 QString major; 1062 QString major;
1062 QString minor; 1063 QString minor;
1063 if ( pos == -1 ) 1064 if ( pos == -1 )
1064 major = str; 1065 major = str;
1065 else 1066 else
1066 { 1067 {
1067 major = str.left(pos); 1068 major = str.left(pos);
1068 minor = str.mid(pos + decimalSymbol().length()); 1069 minor = str.mid(pos + decimalSymbol().length());
1069 } 1070 }
1070 1071
1071 // Remove thousand separators 1072 // Remove thousand separators
1072 int thlen = thousandsSeparator().length(); 1073 int thlen = thousandsSeparator().length();
1073 int lastpos = 0; 1074 int lastpos = 0;
1074 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 ) 1075 while ( ( pos = major.find( thousandsSeparator() ) ) > 0 )
1075 { 1076 {
1076 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N 1077 // e.g. 12,,345,,678,,922 Acceptable positions (from the end) are 5, 10, 15... i.e. (3+thlen)*N
1077 int fromEnd = major.length() - pos; 1078 int fromEnd = major.length() - pos;
1078 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error 1079 if ( fromEnd % (3+thlen) != 0 // Needs to be a multiple, otherwise it's an error
1079 || pos - lastpos > 3 // More than 3 digits between two separators -> error 1080 || pos - lastpos > 3 // More than 3 digits between two separators -> error
1080 || pos == 0 // Can't start with a separator 1081 || pos == 0 // Can't start with a separator
1081 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators 1082 || (lastpos>0 && pos-lastpos!=3)) // Must have exactly 3 digits between two separators
1082 { 1083 {
1083 if (ok) *ok = false; 1084 if (ok) *ok = false;
1084 return 0.0; 1085 return 0.0;
1085 } 1086 }
1086 1087
1087 lastpos = pos; 1088 lastpos = pos;
1088 major.remove( pos, thlen ); 1089 major.remove( pos, thlen );
1089 } 1090 }
1090 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator 1091 if (lastpos>0 && major.length()-lastpos!=3) // Must have exactly 3 digits after the last separator
1091 { 1092 {
1092 if (ok) *ok = false; 1093 if (ok) *ok = false;
1093 return 0.0; 1094 return 0.0;
1094 } 1095 }
1095 1096
1096 QString tot; 1097 QString tot;
1097 if (neg) tot = '-'; 1098 if (neg) tot = '-';
1098 1099
1099 tot += major + '.' + minor + exponentialPart; 1100 tot += major + '.' + minor + exponentialPart;
1100 1101
1101 return tot.toDouble(ok); 1102 return tot.toDouble(ok);
1102} 1103}
1103QString KLocale::decimalSymbol() const 1104QString KLocale::decimalSymbol() const
1104{ 1105{
1105 1106
1106 return m_decimalSymbol; 1107 return m_decimalSymbol;
1107} 1108}
1108 1109
1109QString KLocale::thousandsSeparator() const 1110QString KLocale::thousandsSeparator() const
1110{ 1111{
1111 1112
1112 return m_thousandsSeparator; 1113 return m_thousandsSeparator;
1113} 1114}
1114QString KLocale::positiveSign() const 1115QString KLocale::positiveSign() const
1115{ 1116{
1116 return m_positiveSign; 1117 return m_positiveSign;
1117} 1118}
1118 1119
1119QString KLocale::negativeSign() const 1120QString KLocale::negativeSign() const
1120{ 1121{
1121 return m_negativeSign; 1122 return m_negativeSign;
diff --git a/microkde/kdecore/klocale.h b/microkde/kdecore/klocale.h
index 58e0b39..840fc9d 100644
--- a/microkde/kdecore/klocale.h
+++ b/microkde/kdecore/klocale.h
@@ -1,119 +1,119 @@
1#ifndef MINIKDE_KLOCALE_H 1#ifndef MINIKDE_KLOCALE_H
2#define MINIKDE_KLOCALE_H 2#define MINIKDE_KLOCALE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5#include <qstringlist.h> 5#include <qstringlist.h>
6#include <qdatetime.h> 6#include <qdatetime.h>
7#include <qdict.h> 7#include <q3dict.h>
8 8
9#ifndef I18N_NOOP 9#ifndef I18N_NOOP
10#define I18N_NOOP(x) (x) 10#define I18N_NOOP(x) (x)
11#endif 11#endif
12 12
13class KCalendarSystem; 13class KCalendarSystem;
14void setLocaleDict( QDict<QString> * dict ); 14void setLocaleDict( Q3Dict<QString> * dict );
15QString i18n(const char *text); 15QString i18n(const char *text);
16QString i18n(const char *hint, const char *text); 16QString i18n(const char *hint, const char *text);
17QString i18n(const char *text1, const char *textn, int num); 17QString i18n(const char *text1, const char *textn, int num);
18 18
19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict 19// Qt3's uic generates i18n( "msg", "comment" ) calls which conflict
20// with our i18n method. we use uic -tr tr2i18n to redirect 20// with our i18n method. we use uic -tr tr2i18n to redirect
21// to the right i18n() function 21// to the right i18n() function
22inline QString tr2i18n(const char* message, const char* =0) { 22inline QString tr2i18n(const char* message, const char* =0) {
23 return i18n( message); 23 return i18n( message);
24} 24}
25 25
26class KLocale 26class KLocale
27{ 27{
28 public: 28 public:
29 KLocale(); 29 KLocale();
30 30
31 QString formatNumber(double num, int precision = -1) const; 31 QString formatNumber(double num, int precision = -1) const;
32 QString formatNumber(const QString &numStr) const; 32 QString formatNumber(const QString &numStr) const;
33 double readNumber(const QString &numStr, bool * ok = 0) const; 33 double readNumber(const QString &numStr, bool * ok = 0) const;
34 34
35 QString decimalSymbol() const; 35 QString decimalSymbol() const;
36 QString thousandsSeparator() const; 36 QString thousandsSeparator() const;
37 QString positiveSign() const; 37 QString positiveSign() const;
38 QString negativeSign() const; 38 QString negativeSign() const;
39 39
40 40
41 QString translate( const char *index ) const; 41 QString translate( const char *index ) const;
42 QString translate( const char *index, const char *fallback) const; 42 QString translate( const char *index, const char *fallback) const;
43 43
44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 }; 44 enum IntDateFormat { Undefined=-1, Default=0, Format1=1, ISODate=2, Userdefined=3 };
45 45
46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const; 46 QString formatDate(const QDate &pDate, bool shortFormat = false, IntDateFormat intIntDateFormat = Undefined) const;
47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 47 QString formatTime(const QTime &pTime, bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const; 48 QString formatDateTime(const QDateTime &pDateTime, IntDateFormat intIntDateFormat = Undefined) const;
49 QString formatDateTime(const QDateTime &pDateTime, 49 QString formatDateTime(const QDateTime &pDateTime,
50 bool shortFormat, 50 bool shortFormat,
51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const; 51 bool includeSecs = false, IntDateFormat intIntDateFormat = Undefined) const;
52 52
53 QDate readDate(const QString &str, bool* ok = 0) const; 53 QDate readDate(const QString &str, bool* ok = 0) const;
54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const; 54 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
55 QTime readTime(const QString &str, bool* ok = 0) const; 55 QTime readTime(const QString &str, bool* ok = 0) const;
56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 56 QDate readDate(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
57 57
58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const; 58 QDateTime readDateTime(const QString &intstr, IntDateFormat intIntDateFormat, bool* ok) const;
59 59
60 bool use12Clock() const; 60 bool use12Clock() const;
61 bool weekStartsMonday() const; 61 bool weekStartsMonday() const;
62 int weekStartDay() const; 62 int weekStartDay() const;
63 63
64 QString weekDayName(int,bool=false) const; 64 QString weekDayName(int,bool=false) const;
65 QString monthName(int,bool=false) const; 65 QString monthName(int,bool=false) const;
66 66
67 QString country() const; 67 QString country() const;
68 int weekNum ( const QDate & ); 68 int weekNum ( const QDate & );
69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const; 69 QString dateFormat(IntDateFormat intIntDateFormat = Undefined) const;
70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const; 70 QString dateFormatShort(IntDateFormat intIntDateFormat = Undefined) const;
71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const; 71 QString timeFormat(IntDateFormat intIntDateFormat = Undefined) const;
72 72
73 void insertCatalogue ( const QString & ); 73 void insertCatalogue ( const QString & );
74 74
75 KCalendarSystem *calendar(); 75 KCalendarSystem *calendar();
76 void setHore24Format ( bool ); 76 void setHore24Format ( bool );
77 void setWeekStartMonday( bool ); 77 void setWeekStartMonday( bool );
78 void setIntDateFormat( IntDateFormat ); 78 void setIntDateFormat( IntDateFormat );
79 void setIntTimeFormat( IntDateFormat ); 79 void setIntTimeFormat( IntDateFormat );
80 IntDateFormat getIntDateFormat( ); 80 IntDateFormat getIntDateFormat( );
81 IntDateFormat getIntTimeFormat( ); 81 IntDateFormat getIntTimeFormat( );
82 void setLanguage( int ); 82 void setLanguage( int );
83 int language(); 83 int language();
84 void setDateFormat( QString ); 84 void setDateFormat( QString );
85 void setDateFormatShort( QString ); 85 void setDateFormatShort( QString );
86 86
87 QString m_decimalSymbol; 87 QString m_decimalSymbol;
88 QString m_thousandsSeparator; 88 QString m_thousandsSeparator;
89 QString m_currencySymbol; 89 QString m_currencySymbol;
90 QString m_monetaryDecimalSymbol; 90 QString m_monetaryDecimalSymbol;
91 QString m_monetaryThousandsSeparator; 91 QString m_monetaryThousandsSeparator;
92 QString m_positiveSign; 92 QString m_positiveSign;
93 QString m_negativeSign; 93 QString m_negativeSign;
94 94
95 int timezoneOffset( QString ); 95 int timezoneOffset( QString );
96 QStringList timeZoneList() const; 96 QStringList timeZoneList() const;
97 void setDaylightSaving( bool, int , int ); 97 void setDaylightSaving( bool, int , int );
98 int localTimeOffset(const QDateTime &); 98 int localTimeOffset(const QDateTime &);
99 void setTimezone( const QString &timeZone , bool oddTZ); 99 void setTimezone( const QString &timeZone , bool oddTZ);
100 private: 100 private:
101 QTime readTime(const QString &str, bool seconds, bool *ok) const; 101 QTime readTime(const QString &str, bool seconds, bool *ok) const;
102 QDate readDate(const QString &str, bool shortFormat, bool *ok) const; 102 QDate readDate(const QString &str, bool shortFormat, bool *ok) const;
103 KCalendarSystem *mCalendarSystem; 103 KCalendarSystem *mCalendarSystem;
104 bool mWeekStartsMonday; 104 bool mWeekStartsMonday;
105 bool mHourF24Format; 105 bool mHourF24Format;
106 IntDateFormat mIntDateFormat; 106 IntDateFormat mIntDateFormat;
107 IntDateFormat mIntTimeFormat; 107 IntDateFormat mIntTimeFormat;
108 int mLanguage; 108 int mLanguage;
109 QString mDateFormat; 109 QString mDateFormat;
110 QString mDateFormatShort; 110 QString mDateFormatShort;
111 QStringList mTimeZoneList; 111 QStringList mTimeZoneList;
112 bool daylightEnabled; 112 bool daylightEnabled;
113 int mDaylightTZoffset; 113 int mDaylightTZoffset;
114 int mNondaylightTZoffset; 114 int mNondaylightTZoffset;
115 bool mSouthDaylight; 115 bool mSouthDaylight;
116 int daylightStart, daylightEnd, mTimeZoneOffset; 116 int daylightStart, daylightEnd, mTimeZoneOffset;
117}; 117};
118 118
119#endif 119#endif
diff --git a/microkde/kdecore/kmdcodec.cpp b/microkde/kdecore/kmdcodec.cpp
index bc03569..db11e52 100644
--- a/microkde/kdecore/kmdcodec.cpp
+++ b/microkde/kdecore/kmdcodec.cpp
@@ -1,1127 +1,1126 @@
1/* 1/*
2 Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org> 2 Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
3 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 3 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License (LGPL) 6 it under the terms of the GNU Lesser General Public License (LGPL)
7 version 2 as published by the Free Software Foundation. 7 version 2 as published by the Free Software Foundation.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public 14 You should have received a copy of the GNU Library General Public
15 License along with this program; if not, write to the Free Software 15 License along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 17
18 RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992. 18 RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992.
19 RSA Data Security, Inc. Created 1991. All rights reserved. 19 RSA Data Security, Inc. Created 1991. All rights reserved.
20 20
21 The KMD5 class is based on a C++ implementation of 21 The KMD5 class is based on a C++ implementation of
22 "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by 22 "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by
23 Mordechai T. Abzug,Copyright (c) 1995. This implementation 23 Mordechai T. Abzug,Copyright (c) 1995. This implementation
24 passes the test-suite as defined in RFC 1321. 24 passes the test-suite as defined in RFC 1321.
25 25
26 The encoding and decoding utilities in KCodecs with the exception of 26 The encoding and decoding utilities in KCodecs with the exception of
27 quoted-printable are based on the java implementation in HTTPClient 27 quoted-printable are based on the java implementation in HTTPClient
28 package by Ronald Tschal� Copyright (C) 1996-1999. 28 package by Ronald Tschal� Copyright (C) 1996-1999.
29 29
30 The quoted-printable codec as described in RFC 2045, section 6.7. is by 30 The quoted-printable codec as described in RFC 2045, section 6.7. is by
31 Rik Hemsley (C) 2001. 31 Rik Hemsley (C) 2001.
32*/ 32*/
33 33
34//US #include <config.h> 34//US #include <config.h>
35 35
36#include <stdio.h> 36#include <stdio.h>
37#include <string.h> 37#include <string.h>
38#include <stdlib.h> 38#include <stdlib.h>
39 39
40#include <kdebug.h> 40#include <kdebug.h>
41#include "kmdcodec.h" 41#include "kmdcodec.h"
42//Added by qt3to4:
43#include <Q3CString>
42 44
43#define KMD5_S11 7 45#define KMD5_S11 7
44#define KMD5_S12 12 46#define KMD5_S12 12
45#define KMD5_S13 17 47#define KMD5_S13 17
46#define KMD5_S14 22 48#define KMD5_S14 22
47#define KMD5_S21 5 49#define KMD5_S21 5
48#define KMD5_S22 9 50#define KMD5_S22 9
49#define KMD5_S23 14 51#define KMD5_S23 14
50#define KMD5_S24 20 52#define KMD5_S24 20
51#define KMD5_S31 4 53#define KMD5_S31 4
52#define KMD5_S32 11 54#define KMD5_S32 11
53#define KMD5_S33 16 55#define KMD5_S33 16
54#define KMD5_S34 23 56#define KMD5_S34 23
55#define KMD5_S41 6 57#define KMD5_S41 6
56#define KMD5_S42 10 58#define KMD5_S42 10
57#define KMD5_S43 15 59#define KMD5_S43 15
58#define KMD5_S44 21 60#define KMD5_S44 21
59 61
60const char KCodecs::Base64EncMap[64] = 62const char KCodecs::Base64EncMap[64] =
61{ 63{
62 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 64 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
63 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50, 65 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
64 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 66 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
65 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 67 0x59, 0x5A, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
66 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 68 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E,
67 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 69 0x6F, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76,
68 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33, 70 0x77, 0x78, 0x79, 0x7A, 0x30, 0x31, 0x32, 0x33,
69 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F 71 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x2B, 0x2F
70}; 72};
71 73
72const char KCodecs::Base64DecMap[128] = 74const char KCodecs::Base64DecMap[128] =
73{ 75{
74 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 76 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
75 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
76 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 78 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 79 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
78 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 80 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
79 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F, 81 0x00, 0x00, 0x00, 0x3E, 0x00, 0x00, 0x00, 0x3F,
80 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B, 82 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x3B,
81 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 83 0x3C, 0x3D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
82 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 84 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
83 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 85 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
84 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 86 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
85 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 87 0x17, 0x18, 0x19, 0x00, 0x00, 0x00, 0x00, 0x00,
86 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 88 0x00, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20,
87 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 89 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
88 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30, 90 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 0x30,
89 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00 91 0x31, 0x32, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00
90}; 92};
91 93
92const char KCodecs::UUEncMap[64] = 94const char KCodecs::UUEncMap[64] =
93{ 95{
94 0x60, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 96 0x60, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
95 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 97 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
96 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 98 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
97 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 99 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
98 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 100 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
99 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 101 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
100 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 102 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
101 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F 103 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F
102}; 104};
103 105
104const char KCodecs::UUDecMap[128] = 106const char KCodecs::UUDecMap[128] =
105{ 107{
106 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 110 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
109 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 111 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
110 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 112 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
111 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 113 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
112 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 114 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
113 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 115 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F,
114 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 116 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
115 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F, 117 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
116 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 118 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
117 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 119 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F,
118 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 121 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 122 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
121 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 123 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
122}; 124};
123 125
124const char KCodecs::hexChars[16] = 126const char KCodecs::hexChars[16] =
125{ 127{
126 '0', '1', '2', '3', '4', '5', '6', '7', 128 '0', '1', '2', '3', '4', '5', '6', '7',
127 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' 129 '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
128}; 130};
129 131
130const unsigned int KCodecs::maxQPLineLength = 70; 132const unsigned int KCodecs::maxQPLineLength = 70;
131 133
132 134
133/******************************** KCodecs ********************************/ 135/******************************** KCodecs ********************************/
134// strchr(3) for broken systems. 136// strchr(3) for broken systems.
135static int rikFindChar(register const char * _s, const char c) 137static int rikFindChar(register const char * _s, const char c)
136{ 138{
137 register const char * s = _s; 139 register const char * s = _s;
138 140
139 while (true) 141 while (true)
140 { 142 {
141 if ((0 == *s) || (c == *s)) break; ++s; 143 if ((0 == *s) || (c == *s)) break; ++s;
142 if ((0 == *s) || (c == *s)) break; ++s; 144 if ((0 == *s) || (c == *s)) break; ++s;
143 if ((0 == *s) || (c == *s)) break; ++s; 145 if ((0 == *s) || (c == *s)) break; ++s;
144 if ((0 == *s) || (c == *s)) break; ++s; 146 if ((0 == *s) || (c == *s)) break; ++s;
145 } 147 }
146 148
147 return s - _s; 149 return s - _s;
148} 150}
149 151
150QCString KCodecs::quotedPrintableEncode(const QByteArray& in, bool useCRLF) 152Q3CString KCodecs::quotedPrintableEncode(const QByteArray& in, bool useCRLF)
151{ 153{
152 QByteArray out; 154 QByteArray out;
153 quotedPrintableEncode (in, out, useCRLF); 155 quotedPrintableEncode (in, out, useCRLF);
154 return QCString (out.data(), out.size()+1); 156 return Q3CString (out.data(), out.size()+1);
155} 157}
156 158
157QCString KCodecs::quotedPrintableEncode(const QCString& str, bool useCRLF) 159Q3CString KCodecs::quotedPrintableEncode(const Q3CString& str, bool useCRLF)
158{ 160{
159 if (str.isEmpty()) 161 if (str.isEmpty())
160 return ""; 162 return "";
161 163
162 QByteArray in (str.length()); 164 QByteArray in (str.length());
163 memcpy (in.data(), str.data(), str.length()); 165 memcpy (in.data(), str.data(), str.length());
164 return quotedPrintableEncode(in, useCRLF); 166 return quotedPrintableEncode(in, useCRLF);
165} 167}
166 168
167void KCodecs::quotedPrintableEncode(const QByteArray& in, QByteArray& out, bool useCRLF) 169void KCodecs::quotedPrintableEncode(const QByteArray& in, QByteArray& out, bool useCRLF)
168{ 170{
169 out.resize (0); 171 out.resize (0);
170 if (in.isEmpty()) 172 if (in.isEmpty())
171 return; 173 return;
172 174
173 char *cursor; 175 char *cursor;
174 const char *data; 176 const char *data;
175 unsigned int lineLength; 177 unsigned int lineLength;
176 unsigned int pos; 178 unsigned int pos;
177 179
178 const unsigned int length = in.size(); 180 const unsigned int length = in.size();
179 const unsigned int end = length - 1; 181 const unsigned int end = length - 1;
180 182
181 183
182 // Reasonable guess for output size when we're encoding 184 // Reasonable guess for output size when we're encoding
183 // mostly-ASCII data. It doesn't really matter, because 185 // mostly-ASCII data. It doesn't really matter, because
184 // the underlying allocation routines are quite efficient, 186 // the underlying allocation routines are quite efficient,
185 // but it's nice to have 0 allocations in many cases. 187 // but it's nice to have 0 allocations in many cases.
186 out.resize ((length*12)/10); 188 out.resize ((length*12)/10);
187 cursor = out.data(); 189 cursor = out.data();
188 data = in.data(); 190 data = in.data();
189 lineLength = 0; 191 lineLength = 0;
190 pos = 0; 192 pos = 0;
191 193
192 for (unsigned int i = 0; i < length; i++) 194 for (unsigned int i = 0; i < length; i++)
193 { 195 {
194 unsigned char c (data[i]); 196 unsigned char c (data[i]);
195 197
196 // check if we have to enlarge the output buffer, use 198 // check if we have to enlarge the output buffer, use
197 // a safety margin of 16 byte 199 // a safety margin of 16 byte
198 pos = cursor-out.data(); 200 pos = cursor-out.data();
199 if (out.size()-pos < 16) { 201 if (out.size()-pos < 16) {
200 out.resize(out.size()+4096); 202 out.resize(out.size()+4096);
201 cursor = out.data()+pos; 203 cursor = out.data()+pos;
202 } 204 }
203 205
204 // Plain ASCII chars just go straight out. 206 // Plain ASCII chars just go straight out.
205 207
206 if ((c >= 33) && (c <= 126) && ('=' != c)) 208 if ((c >= 33) && (c <= 126) && ('=' != c))
207 { 209 {
208 *cursor++ = c; 210 *cursor++ = c;
209 ++lineLength; 211 ++lineLength;
210 } 212 }
211 213
212 // Spaces need some thought. We have to encode them at eol (or eof). 214 // Spaces need some thought. We have to encode them at eol (or eof).
213 215
214 else if (' ' == c) 216 else if (' ' == c)
215 { 217 {
216 if 218 if
217 ( 219 (
218 (i >= length) 220 (i >= length)
219 || 221 ||
220 ((i < end) && ((useCRLF && ('\r' == data[i + 1]) && ('\n' == data[i + 2])) 222 ((i < end) && ((useCRLF && ('\r' == data[i + 1]) && ('\n' == data[i + 2]))
221 || 223 ||
222 (!useCRLF && ('\n' == data[i + 1])))) 224 (!useCRLF && ('\n' == data[i + 1]))))
223 ) 225 )
224 { 226 {
225 *cursor++ = '='; 227 *cursor++ = '=';
226 *cursor++ = '2'; 228 *cursor++ = '2';
227 *cursor++ = '0'; 229 *cursor++ = '0';
228 230
229 lineLength += 3; 231 lineLength += 3;
230 } 232 }
231 else 233 else
232 { 234 {
233 *cursor++ = ' '; 235 *cursor++ = ' ';
234 ++lineLength; 236 ++lineLength;
235 } 237 }
236 } 238 }
237 // If we find a line break, just let it through. 239 // If we find a line break, just let it through.
238 else if ((useCRLF && ('\r' == c) && (i < end) && ('\n' == data[i + 1])) || 240 else if ((useCRLF && ('\r' == c) && (i < end) && ('\n' == data[i + 1])) ||
239 (!useCRLF && ('\n' == c))) 241 (!useCRLF && ('\n' == c)))
240 { 242 {
241 lineLength = 0; 243 lineLength = 0;
242 244
243 if (useCRLF) { 245 if (useCRLF) {
244 *cursor++ = '\r'; 246 *cursor++ = '\r';
245 *cursor++ = '\n'; 247 *cursor++ = '\n';
246 ++i; 248 ++i;
247 } else { 249 } else {
248 *cursor++ = '\n'; 250 *cursor++ = '\n';
249 } 251 }
250 } 252 }
251 253
252 // Anything else is converted to =XX. 254 // Anything else is converted to =XX.
253 255
254 else 256 else
255 { 257 {
256 *cursor++ = '='; 258 *cursor++ = '=';
257 *cursor++ = hexChars[c / 16]; 259 *cursor++ = hexChars[c / 16];
258 *cursor++ = hexChars[c % 16]; 260 *cursor++ = hexChars[c % 16];
259 261
260 lineLength += 3; 262 lineLength += 3;
261 } 263 }
262 264
263 // If we're approaching the maximum line length, do a soft line break. 265 // If we're approaching the maximum line length, do a soft line break.
264 266
265 if ((lineLength > maxQPLineLength) && (i < end)) 267 if ((lineLength > maxQPLineLength) && (i < end))
266 { 268 {
267 if (useCRLF) { 269 if (useCRLF) {
268 *cursor++ = '='; 270 *cursor++ = '=';
269 *cursor++ = '\r'; 271 *cursor++ = '\r';
270 *cursor++ = '\n'; 272 *cursor++ = '\n';
271 } else { 273 } else {
272 *cursor++ = '='; 274 *cursor++ = '=';
273 *cursor++ = '\n'; 275 *cursor++ = '\n';
274 } 276 }
275 277
276 lineLength = 0; 278 lineLength = 0;
277 } 279 }
278 } 280 }
279 281
280 out.truncate(cursor - out.data()); 282 out.truncate(cursor - out.data());
281} 283}
282 284
283QCString KCodecs::quotedPrintableDecode(const QByteArray & in) 285Q3CString KCodecs::quotedPrintableDecode(const QByteArray & in)
284{ 286{
285 QByteArray out; 287 QByteArray out;
286 quotedPrintableDecode (in, out); 288 quotedPrintableDecode (in, out);
287 return QCString (out.data(), out.size()+1); 289 return Q3CString (out.data(), out.size()+1);
288} 290}
289 291
290QCString KCodecs::quotedPrintableDecode(const QCString & str) 292Q3CString KCodecs::quotedPrintableDecode(const Q3CString & str)
291{ 293{
292 if (str.isEmpty()) 294 if (str.isEmpty())
293 return ""; 295 return "";
294 296
295 QByteArray in (str.length()); 297 QByteArray in (str.length());
296 memcpy (in.data(), str.data(), str.length()); 298 memcpy (in.data(), str.data(), str.length());
297 return quotedPrintableDecode (in); 299 return quotedPrintableDecode (in);
298} 300}
299 301
300void KCodecs::quotedPrintableDecode(const QByteArray& in, QByteArray& out) 302void KCodecs::quotedPrintableDecode(const QByteArray& in, QByteArray& out)
301{ 303{
302 // clear out the output buffer 304 // clear out the output buffer
303 out.resize (0); 305 out.resize (0);
304 if (in.isEmpty()) 306 if (in.isEmpty())
305 return; 307 return;
306 308
307 char *cursor; 309 char *cursor;
308 const char *data; 310 const char *data;
309 const unsigned int length = in.size(); 311 const unsigned int length = in.size();
310 312
311 data = in.data(); 313 data = in.data();
312 out.resize (length); 314 out.resize (length);
313 cursor = out.data(); 315 cursor = out.data();
314 316
315 for (unsigned int i = 0; i < length; i++) 317 for (unsigned int i = 0; i < length; i++)
316 { 318 {
317 char c(in.at(i)); 319 char c(in.at(i));
318 320
319 if ('=' == c) 321 if ('=' == c)
320 { 322 {
321 if (i < length - 2) 323 if (i < length - 2)
322 { 324 {
323 char c1 = in.at(i + 1); 325 char c1 = in.at(i + 1);
324 char c2 = in.at(i + 2); 326 char c2 = in.at(i + 2);
325 327
326 if (('\n' == c1) || ('\r' == c1 && '\n' == c2)) 328 if (('\n' == c1) || ('\r' == c1 && '\n' == c2))
327 { 329 {
328 // Soft line break. No output. 330 // Soft line break. No output.
329 if ('\r' == c1) 331 if ('\r' == c1)
330 i += 2; // CRLF line breaks 332 i += 2; // CRLF line breaks
331 else 333 else
332 i += 1; 334 i += 1;
333 } 335 }
334 else 336 else
335 { 337 {
336 // =XX encoded byte. 338 // =XX encoded byte.
337 339
338 int hexChar0 = rikFindChar(hexChars, c1); 340 int hexChar0 = rikFindChar(hexChars, c1);
339 int hexChar1 = rikFindChar(hexChars, c2); 341 int hexChar1 = rikFindChar(hexChars, c2);
340 342
341 if (hexChar0 < 16 && hexChar1 < 16) 343 if (hexChar0 < 16 && hexChar1 < 16)
342 { 344 {
343 *cursor++ = char((hexChar0 * 16) | hexChar1); 345 *cursor++ = char((hexChar0 * 16) | hexChar1);
344 i += 2; 346 i += 2;
345 } 347 }
346 } 348 }
347 } 349 }
348 } 350 }
349 else 351 else
350 { 352 {
351 *cursor++ = c; 353 *cursor++ = c;
352 } 354 }
353 } 355 }
354 356
355 out.truncate(cursor - out.data()); 357 out.truncate(cursor - out.data());
356} 358}
357 359
358QCString KCodecs::base64Encode( const QCString& str, bool insertLFs ) 360Q3CString KCodecs::base64Encode( const Q3CString& str, bool insertLFs )
359{ 361{
360 if ( str.isEmpty() ) 362 if ( str.isEmpty() )
361 return ""; 363 return "";
362 364
363 QByteArray in (str.length()); 365 QByteArray in (str.length());
364 memcpy( in.data(), str.data(), str.length() ); 366 memcpy( in.data(), str.data(), str.length() );
365 return base64Encode( in, insertLFs ); 367 return base64Encode( in, insertLFs );
366} 368}
367 369
368QCString KCodecs::base64Encode( const QByteArray& in, bool insertLFs ) 370Q3CString KCodecs::base64Encode( const QByteArray& in, bool insertLFs )
369{ 371{
370 QByteArray out; 372 QByteArray out;
371 base64Encode( in, out, insertLFs ); 373 base64Encode( in, out, insertLFs );
372 return QCString( out.data(), out.size()+1 ); 374 return Q3CString( out.data(), out.size()+1 );
373} 375}
374 376
375void KCodecs::base64Encode( const QByteArray& in, QByteArray& out, 377void KCodecs::base64Encode( const QByteArray& in, QByteArray& out,
376 bool insertLFs ) 378 bool insertLFs )
377{ 379{
378 // clear out the output buffer 380 // clear out the output buffer
379 out.resize (0); 381 out.resize (0);
380 if ( in.isEmpty() ) 382 if ( in.isEmpty() )
381 return; 383 return;
382 384
383 unsigned int sidx = 0; 385 unsigned int sidx = 0;
384 unsigned int didx = 0; 386 unsigned int didx = 0;
385 const char* data = in.data(); 387 const char* data = in.data();
386 const unsigned int len = in.size(); 388 const unsigned int len = in.size();
387 389
388 unsigned int out_len = ((len+2)/3)*4; 390 unsigned int out_len = ((len+2)/3)*4;
389 391
390 // Deal with the 76 characters or less per 392 // Deal with the 76 characters or less per
391 // line limit specified in RFC 2045 on a 393 // line limit specified in RFC 2045 on a
392 // pre request basis. 394 // pre request basis.
393 insertLFs = (insertLFs && out_len > 76); 395 insertLFs = (insertLFs && out_len > 76);
394 if ( insertLFs ) 396 if ( insertLFs )
395 out_len += ((out_len-1)/76); 397 out_len += ((out_len-1)/76);
396 398
397 int count = 0; 399 int count = 0;
398 out.resize( out_len ); 400 out.resize( out_len );
399 401
400 // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion 402 // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion
401 if ( len > 1 ) 403 if ( len > 1 )
402 { 404 {
403 while (sidx < len-2) 405 while (sidx < len-2)
404 { 406 {
405 if ( insertLFs ) 407 if ( insertLFs )
406 { 408 {
407 if ( count && (count%76) == 0 ) 409 if ( count && (count%76) == 0 )
408 out.at(didx++) = '\n'; 410 out[didx++] = '\n';
409 count += 4; 411 count += 4;
410 } 412 }
411 out.at(didx++) = Base64EncMap[(data[sidx] >> 2) & 077]; 413 out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077];
412 out.at(didx++) = Base64EncMap[(data[sidx+1] >> 4) & 017 | 414 out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 |
413 (data[sidx] << 4) & 077]; 415 (data[sidx] << 4) & 077];
414 out.at(didx++) = Base64EncMap[(data[sidx+2] >> 6) & 003 | 416 out[didx++] = Base64EncMap[(data[sidx+2] >> 6) & 003 |
415 (data[sidx+1] << 2) & 077]; 417 (data[sidx+1] << 2) & 077];
416 out.at(didx++) = Base64EncMap[data[sidx+2] & 077]; 418 out[didx++] = Base64EncMap[data[sidx+2] & 077];
417 sidx += 3; 419 sidx += 3;
418 } 420 }
419 } 421 }
420 422
421 if (sidx < len) 423 if (sidx < len)
422 { 424 {
423 if ( insertLFs && (count > 0) && (count%76) == 0 ) 425 if ( insertLFs && (count > 0) && (count%76) == 0 )
424 out.at(didx++) = '\n'; 426 out[didx++] = '\n';
425 427
426 out.at(didx++) = Base64EncMap[(data[sidx] >> 2) & 077]; 428 out[didx++] = Base64EncMap[(data[sidx] >> 2) & 077];
427 if (sidx < len-1) 429 if (sidx < len-1)
428 { 430 {
429 out.at(didx++) = Base64EncMap[(data[sidx+1] >> 4) & 017 | 431 out[didx++] = Base64EncMap[(data[sidx+1] >> 4) & 017 |
430 (data[sidx] << 4) & 077]; 432 (data[sidx] << 4) & 077];
431 out.at(didx++) = Base64EncMap[(data[sidx+1] << 2) & 077]; 433 out[didx++] = Base64EncMap[(data[sidx+1] << 2) & 077];
432 } 434 }
433 else 435 else
434 { 436 {
435 out.at(didx++) = Base64EncMap[(data[sidx] << 4) & 077]; 437 out[didx++] = Base64EncMap[(data[sidx] << 4) & 077];
436 } 438 }
437 } 439 }
438 440
439 // Add padding 441 // Add padding
440 while (didx < out.size()) 442 while (didx < out.size())
441 { 443 out[didx++] = '=';
442 out.at(didx) = '=';
443 didx++;
444 }
445} 444}
446 445
447QCString KCodecs::base64Decode( const QCString& str ) 446Q3CString KCodecs::base64Decode( const Q3CString& str )
448{ 447{
449 if ( str.isEmpty() ) 448 if ( str.isEmpty() )
450 return ""; 449 return "";
451 450
452 QByteArray in( str.length() ); 451 QByteArray in( str.length() );
453 memcpy( in.data(), str.data(), str.length() ); 452 memcpy( in.data(), str.data(), str.length() );
454 return base64Decode( in ); 453 return base64Decode( in );
455} 454}
456 455
457QCString KCodecs::base64Decode( const QByteArray& in ) 456Q3CString KCodecs::base64Decode( const QByteArray& in )
458{ 457{
459 QByteArray out; 458 QByteArray out;
460 base64Decode( in, out ); 459 base64Decode( in, out );
461 return QCString( out.data(), out.size()+1 ); 460 return Q3CString( out.data(), out.size()+1 );
462} 461}
463 462
464void KCodecs::base64Decode( const QByteArray& in, QByteArray& out ) 463void KCodecs::base64Decode( const QByteArray& in, QByteArray& out )
465{ 464{
466 out.resize(0); 465 out.resize(0);
467 if ( in.isEmpty() ) 466 if ( in.isEmpty() )
468 return; 467 return;
469 468
470 unsigned int count = 0; 469 unsigned int count = 0;
471 unsigned int len = in.size(), tail = len; 470 unsigned int len = in.size(), tail = len;
472 const char* data = in.data(); 471 const char* data = in.data();
473 472
474 // Deal with possible *nix "BEGIN" marker!! 473 // Deal with possible *nix "BEGIN" marker!!
475 while ( count < len && (data[count] == '\n' || data[count] == '\r' || 474 while ( count < len && (data[count] == '\n' || data[count] == '\r' ||
476 data[count] == '\t' || data[count] == ' ') ) 475 data[count] == '\t' || data[count] == ' ') )
477 count++; 476 count++;
478 477
479 if ( QString(data+count).left(5).lower() == "begin" ) 478 if ( QString(data+count).left(5).lower() == "begin" )
480 { 479 {
481 count += 5; 480 count += 5;
482 while ( count < len && data[count] != '\n' && data[count] != '\r' ) 481 while ( count < len && data[count] != '\n' && data[count] != '\r' )
483 count++; 482 count++;
484 483
485 while ( count < len && (data[count] == '\n' || data[count] == '\r') ) 484 while ( count < len && (data[count] == '\n' || data[count] == '\r') )
486 count ++; 485 count ++;
487 486
488 data += count; 487 data += count;
489 tail = (len -= count); 488 tail = (len -= count);
490 } 489 }
491 490
492 // Find the tail end of the actual encoded data even if 491 // Find the tail end of the actual encoded data even if
493 // there is/are trailing CR and/or LF. 492 // there is/are trailing CR and/or LF.
494 while ( data[tail-1] == '=' || data[tail-1] == '\n' || 493 while ( data[tail-1] == '=' || data[tail-1] == '\n' ||
495 data[tail-1] == '\r' ) 494 data[tail-1] == '\r' )
496 if ( data[--tail] != '=' ) len = tail; 495 if ( data[--tail] != '=' ) len = tail;
497 496
498 unsigned int outIdx = 0; 497 unsigned int outIdx = 0;
499 out.resize( (count=len) ); 498 out.resize( (count=len) );
500 for (unsigned int idx = 0; idx < count; idx++) 499 for (unsigned int idx = 0; idx < count; idx++)
501 { 500 {
502 // Adhere to RFC 2045 and ignore characters 501 // Adhere to RFC 2045 and ignore characters
503 // that are not part of the encoding table. 502 // that are not part of the encoding table.
504 unsigned char ch = data[idx]; 503 unsigned char ch = data[idx];
505 if ((ch > 47 && ch < 58) || (ch > 64 && ch < 91) || 504 if ((ch > 47 && ch < 58) || (ch > 64 && ch < 91) ||
506 (ch > 96 && ch < 123) || ch == '+' || ch == '/' || ch == '=') 505 (ch > 96 && ch < 123) || ch == '+' || ch == '/' || ch == '=')
507 { 506 {
508 out.at(outIdx++) = Base64DecMap[ch]; 507 out[outIdx++] = Base64DecMap[ch];
509 } 508 }
510 else 509 else
511 { 510 {
512 len--; 511 len--;
513 tail--; 512 tail--;
514 } 513 }
515 } 514 }
516 515
517 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl; 516 // kdDebug() << "Tail size = " << tail << ", Length size = " << len << endl;
518 517
519 // 4-byte to 3-byte conversion 518 // 4-byte to 3-byte conversion
520 len = (tail>(len/4)) ? tail-(len/4) : 0; 519 len = (tail>(len/4)) ? tail-(len/4) : 0;
521 unsigned int sidx = 0, didx = 0; 520 unsigned int sidx = 0, didx = 0;
522 if ( len > 1 ) 521 if ( len > 1 )
523 { 522 {
524 while (didx < len-2) 523 while (didx < len-2)
525 { 524 {
526 out.at(didx) = (((out.at(sidx) << 2) & 255) | ((out.at(sidx+1) >> 4) & 003)); 525 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
527 out.at(didx+1) = (((out.at(sidx+1) << 4) & 255) | ((out.at(sidx+2) >> 2) & 017)); 526 out[didx+1] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
528 out.at(didx+2) = (((out.at(sidx+2) << 6) & 255) | (out.at(sidx+3) & 077)); 527 out[didx+2] = (((out[sidx+2] << 6) & 255) | (out[sidx+3] & 077));
529 sidx += 4; 528 sidx += 4;
530 didx += 3; 529 didx += 3;
531 } 530 }
532 } 531 }
533 532
534 if (didx < len) 533 if (didx < len)
535 out.at(didx) = (((out.at(sidx) << 2) & 255) | ((out.at(sidx+1) >> 4) & 003)); 534 out[didx] = (((out[sidx] << 2) & 255) | ((out[sidx+1] >> 4) & 003));
536 535
537 if (++didx < len ) 536 if (++didx < len )
538 out.at(didx) = (((out.at(sidx+1) << 4) & 255) | ((out.at(sidx+2) >> 2) & 017)); 537 out[didx] = (((out[sidx+1] << 4) & 255) | ((out[sidx+2] >> 2) & 017));
539 538
540 // Resize the output buffer 539 // Resize the output buffer
541 if ( len == 0 || len < out.size() ) 540 if ( len == 0 || len < out.size() )
542 out.resize(len); 541 out.resize(len);
543} 542}
544 543
545QCString KCodecs::uuencode( const QCString& str ) 544Q3CString KCodecs::uuencode( const Q3CString& str )
546{ 545{
547 if ( str.isEmpty() ) 546 if ( str.isEmpty() )
548 return ""; 547 return "";
549 548
550 QByteArray in; 549 QByteArray in;
551 in.resize( str.length() ); 550 in.resize( str.length() );
552 memcpy( in.data(), str.data(), str.length() ); 551 memcpy( in.data(), str.data(), str.length() );
553 return uuencode( in ); 552 return uuencode( in );
554} 553}
555 554
556QCString KCodecs::uuencode( const QByteArray& in ) 555Q3CString KCodecs::uuencode( const QByteArray& in )
557{ 556{
558 QByteArray out; 557 QByteArray out;
559 uuencode( in, out ); 558 uuencode( in, out );
560 return QCString( out.data(), out.size()+1 ); 559 return Q3CString( out.data(), out.size()+1 );
561} 560}
562 561
563void KCodecs::uuencode( const QByteArray& in, QByteArray& out ) 562void KCodecs::uuencode( const QByteArray& in, QByteArray& out )
564{ 563{
565 out.resize( 0 ); 564 out.resize( 0 );
566 if( in.isEmpty() ) 565 if( in.isEmpty() )
567 return; 566 return;
568 567
569 unsigned int sidx = 0; 568 unsigned int sidx = 0;
570 unsigned int didx = 0; 569 unsigned int didx = 0;
571 unsigned int line_len = 45; 570 unsigned int line_len = 45;
572 571
573 const char nl[] = "\n"; 572 const char nl[] = "\n";
574 const char* data = in.data(); 573 const char* data = in.data();
575 const unsigned int nl_len = strlen(nl); 574 const unsigned int nl_len = strlen(nl);
576 const unsigned int len = in.size(); 575 const unsigned int len = in.size();
577 576
578 out.resize( (len+2)/3*4 + ((len+line_len-1)/line_len)*(nl_len+1) ); 577 out.resize( (len+2)/3*4 + ((len+line_len-1)/line_len)*(nl_len+1) );
579 // split into lines, adding line-length and line terminator 578 // split into lines, adding line-length and line terminator
580 while (sidx+line_len < len) 579 while (sidx+line_len < len)
581 { 580 {
582 // line length 581 // line length
583 out.at(didx++) = UUEncMap[line_len]; 582 out[didx++] = UUEncMap[line_len];
584 583
585 // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion 584 // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion
586 for (unsigned int end = sidx+line_len; sidx < end; sidx += 3) 585 for (unsigned int end = sidx+line_len; sidx < end; sidx += 3)
587 { 586 {
588 out.at(didx++) = UUEncMap[(data[sidx] >> 2) & 077]; 587 out[didx++] = UUEncMap[(data[sidx] >> 2) & 077];
589 out.at(didx++) = UUEncMap[(data[sidx+1] >> 4) & 017 | 588 out[didx++] = UUEncMap[(data[sidx+1] >> 4) & 017 |
590 (data[sidx] << 4) & 077]; 589 (data[sidx] << 4) & 077];
591 out.at(didx++) = UUEncMap[(data[sidx+2] >> 6) & 003 | 590 out[didx++] = UUEncMap[(data[sidx+2] >> 6) & 003 |
592 (data[sidx+1] << 2) & 077]; 591 (data[sidx+1] << 2) & 077];
593 out.at(didx++) = UUEncMap[data[sidx+2] & 077]; 592 out[didx++] = UUEncMap[data[sidx+2] & 077];
594 } 593 }
595 594
596 // line terminator 595 // line terminator
597 //for (unsigned int idx=0; idx < nl_len; idx++) 596 //for (unsigned int idx=0; idx < nl_len; idx++)
598 //out.at(didx++) = nl[idx]; 597 //out[didx++] = nl[idx];
599 memcpy(out.data()+didx, nl, nl_len); 598 memcpy(out.data()+didx, nl, nl_len);
600 didx += nl_len; 599 didx += nl_len;
601 } 600 }
602 601
603 // line length 602 // line length
604 out.at(didx++) = UUEncMap[len-sidx]; 603 out[didx++] = UUEncMap[len-sidx];
605 // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion 604 // 3-byte to 4-byte conversion + 0-63 to ascii printable conversion
606 while (sidx+2 < len) 605 while (sidx+2 < len)
607 { 606 {
608 out.at(didx++) = UUEncMap[(data[sidx] >> 2) & 077]; 607 out[didx++] = UUEncMap[(data[sidx] >> 2) & 077];
609 out.at(didx++) = UUEncMap[(data[sidx+1] >> 4) & 017 | 608 out[didx++] = UUEncMap[(data[sidx+1] >> 4) & 017 |
610 (data[sidx] << 4) & 077]; 609 (data[sidx] << 4) & 077];
611 out.at(didx++) = UUEncMap[(data[sidx+2] >> 6) & 003 | 610 out[didx++] = UUEncMap[(data[sidx+2] >> 6) & 003 |
612 (data[sidx+1] << 2) & 077]; 611 (data[sidx+1] << 2) & 077];
613 out.at(didx++) = UUEncMap[data[sidx+2] & 077]; 612 out[didx++] = UUEncMap[data[sidx+2] & 077];
614 sidx += 3; 613 sidx += 3;
615 } 614 }
616 615
617 if (sidx < len-1) 616 if (sidx < len-1)
618 { 617 {
619 out.at(didx++) = UUEncMap[(data[sidx] >> 2) & 077]; 618 out[didx++] = UUEncMap[(data[sidx] >> 2) & 077];
620 out.at(didx++) = UUEncMap[(data[sidx+1] >> 4) & 017 | 619 out[didx++] = UUEncMap[(data[sidx+1] >> 4) & 017 |
621 (data[sidx] << 4) & 077]; 620 (data[sidx] << 4) & 077];
622 out.at(didx++) = UUEncMap[(data[sidx+1] << 2) & 077]; 621 out[didx++] = UUEncMap[(data[sidx+1] << 2) & 077];
623 out.at(didx++) = UUEncMap[0]; 622 out[didx++] = UUEncMap[0];
624 } 623 }
625 else if (sidx < len) 624 else if (sidx < len)
626 { 625 {
627 out.at(didx++) = UUEncMap[(data[sidx] >> 2) & 077]; 626 out[didx++] = UUEncMap[(data[sidx] >> 2) & 077];
628 out.at(didx++) = UUEncMap[(data[sidx] << 4) & 077]; 627 out[didx++] = UUEncMap[(data[sidx] << 4) & 077];
629 out.at(didx++) = UUEncMap[0]; 628 out[didx++] = UUEncMap[0];
630 out.at(didx++) = UUEncMap[0]; 629 out[didx++] = UUEncMap[0];
631 } 630 }
632 631
633 // line terminator 632 // line terminator
634 memcpy(out.data()+didx, nl, nl_len); 633 memcpy(out.data()+didx, nl, nl_len);
635 didx += nl_len; 634 didx += nl_len;
636 635
637 // sanity check 636 // sanity check
638 if ( didx != out.size() ) 637 if ( didx != out.size() )
639 out.resize( 0 ); 638 out.resize( 0 );
640} 639}
641 640
642QCString KCodecs::uudecode( const QCString& str ) 641Q3CString KCodecs::uudecode( const Q3CString& str )
643{ 642{
644 if ( str.isEmpty() ) 643 if ( str.isEmpty() )
645 return ""; 644 return "";
646 645
647 QByteArray in; 646 QByteArray in;
648 in.resize( str.length() ); 647 in.resize( str.length() );
649 memcpy( in.data(), str.data(), str.length() ); 648 memcpy( in.data(), str.data(), str.length() );
650 return uudecode( in ); 649 return uudecode( in );
651} 650}
652 651
653QCString KCodecs::uudecode( const QByteArray& in ) 652Q3CString KCodecs::uudecode( const QByteArray& in )
654{ 653{
655 QByteArray out; 654 QByteArray out;
656 uudecode( in, out ); 655 uudecode( in, out );
657 return QCString( out.data(), out.size()+1 ); 656 return Q3CString( out.data(), out.size()+1 );
658} 657}
659 658
660void KCodecs::uudecode( const QByteArray& in, QByteArray& out ) 659void KCodecs::uudecode( const QByteArray& in, QByteArray& out )
661{ 660{
662 out.resize( 0 ); 661 out.resize( 0 );
663 if( in.isEmpty() ) 662 if( in.isEmpty() )
664 return; 663 return;
665 664
666 unsigned int sidx = 0; 665 unsigned int sidx = 0;
667 unsigned int didx = 0; 666 unsigned int didx = 0;
668 unsigned int len = in.size(); 667 unsigned int len = in.size();
669 unsigned int line_len, end; 668 unsigned int line_len, end;
670 const char* data = in.data(); 669 const char* data = in.data();
671 670
672 // Deal with *nix "BEGIN"/"END" separators!! 671 // Deal with *nix "BEGIN"/"END" separators!!
673 unsigned int count = 0; 672 unsigned int count = 0;
674 while ( count < len && (data[count] == '\n' || data[count] == '\r' || 673 while ( count < len && (data[count] == '\n' || data[count] == '\r' ||
675 data[count] == '\t' || data[count] == ' ') ) 674 data[count] == '\t' || data[count] == ' ') )
676 count ++; 675 count ++;
677 676
678 bool hasLF = false; 677 bool hasLF = false;
679 if ( QString( data+count).left(5).lower() == "begin" ) 678 if ( QString( data+count).left(5).lower() == "begin" )
680 { 679 {
681 count += 5; 680 count += 5;
682 while ( count < len && data[count] != '\n' && data[count] != '\r' ) 681 while ( count < len && data[count] != '\n' && data[count] != '\r' )
683 count ++; 682 count ++;
684 683
685 while ( count < len && (data[count] == '\n' || data[count] == '\r') ) 684 while ( count < len && (data[count] == '\n' || data[count] == '\r') )
686 count ++; 685 count ++;
687 686
688 data += count; 687 data += count;
689 len -= count; 688 len -= count;
690 hasLF = true; 689 hasLF = true;
691 } 690 }
692 691
693 out.resize( len/4*3 ); 692 out.resize( len/4*3 );
694 while ( sidx < len ) 693 while ( sidx < len )
695 { 694 {
696 // get line length (in number of encoded octets) 695 // get line length (in number of encoded octets)
697 line_len = UUDecMap[ (unsigned char) data[sidx++]]; 696 line_len = UUDecMap[ (unsigned char) data[sidx++]];
698 // ascii printable to 0-63 and 4-byte to 3-byte conversion 697 // ascii printable to 0-63 and 4-byte to 3-byte conversion
699 end = didx+line_len; 698 end = didx+line_len;
700 char A, B, C, D; 699 char A, B, C, D;
701 if (end > 2) { 700 if (end > 2) {
702 while (didx < end-2) 701 while (didx < end-2)
703 { 702 {
704 A = UUDecMap[(unsigned char) data[sidx]]; 703 A = UUDecMap[(unsigned char) data[sidx]];
705 B = UUDecMap[(unsigned char) data[sidx+1]]; 704 B = UUDecMap[(unsigned char) data[sidx+1]];
706 C = UUDecMap[(unsigned char) data[sidx+2]]; 705 C = UUDecMap[(unsigned char) data[sidx+2]];
707 D = UUDecMap[(unsigned char) data[sidx+3]]; 706 D = UUDecMap[(unsigned char) data[sidx+3]];
708 out.at(didx++) = ( ((A << 2) & 255) | ((B >> 4) & 003) ); 707 out[didx++] = ( ((A << 2) & 255) | ((B >> 4) & 003) );
709 out.at(didx++) = ( ((B << 4) & 255) | ((C >> 2) & 017) ); 708 out[didx++] = ( ((B << 4) & 255) | ((C >> 2) & 017) );
710 out.at(didx++) = ( ((C << 6) & 255) | (D & 077) ); 709 out[didx++] = ( ((C << 6) & 255) | (D & 077) );
711 sidx += 4; 710 sidx += 4;
712 } 711 }
713 } 712 }
714 713
715 if (didx < end) 714 if (didx < end)
716 { 715 {
717 A = UUDecMap[(unsigned char) data[sidx]]; 716 A = UUDecMap[(unsigned char) data[sidx]];
718 B = UUDecMap[(unsigned char) data[sidx+1]]; 717 B = UUDecMap[(unsigned char) data[sidx+1]];
719 out.at(didx++) = ( ((A << 2) & 255) | ((B >> 4) & 003) ); 718 out[didx++] = ( ((A << 2) & 255) | ((B >> 4) & 003) );
720 } 719 }
721 720
722 if (didx < end) 721 if (didx < end)
723 { 722 {
724 B = UUDecMap[(unsigned char) data[sidx+1]]; 723 B = UUDecMap[(unsigned char) data[sidx+1]];
725 C = UUDecMap[(unsigned char) data[sidx+2]]; 724 C = UUDecMap[(unsigned char) data[sidx+2]];
726 out.at(didx++) = ( ((B << 4) & 255) | ((C >> 2) & 017) ); 725 out[didx++] = ( ((B << 4) & 255) | ((C >> 2) & 017) );
727 } 726 }
728 727
729 // skip padding 728 // skip padding
730 while (sidx < len && data[sidx] != '\n' && data[sidx] != '\r') 729 while (sidx < len && data[sidx] != '\n' && data[sidx] != '\r')
731 sidx++; 730 sidx++;
732 731
733 // skip end of line 732 // skip end of line
734 while (sidx < len && (data[sidx] == '\n' || data[sidx] == '\r')) 733 while (sidx < len && (data[sidx] == '\n' || data[sidx] == '\r'))
735 sidx++; 734 sidx++;
736 735
737 // skip the "END" separator when present. 736 // skip the "END" separator when present.
738 if ( hasLF && QString( data+sidx).left(3).lower() == "end" ) 737 if ( hasLF && QString( data+sidx).left(3).lower() == "end" )
739 break; 738 break;
740 } 739 }
741 740
742 if ( didx < out.size() ) 741 if ( didx < out.size() )
743 out.resize( didx ); 742 out.resize( didx );
744} 743}
745 744
746/******************************** KMD5 ********************************/ 745/******************************** KMD5 ********************************/
747KMD5::KMD5() 746KMD5::KMD5()
748{ 747{
749 init(); 748 init();
750} 749}
751 750
752KMD5::KMD5(const char *in, int len) 751KMD5::KMD5(const char *in, int len)
753{ 752{
754 init(); 753 init();
755 update(in, len); 754 update(in, len);
756} 755}
757 756
758KMD5::KMD5(const QByteArray& in) 757KMD5::KMD5(const QByteArray& in)
759{ 758{
760 init(); 759 init();
761 update( in ); 760 update( in );
762} 761}
763 762
764KMD5::KMD5(const QCString& in) 763KMD5::KMD5(const Q3CString& in)
765{ 764{
766 init(); 765 init();
767 update( in ); 766 update( in );
768} 767}
769 768
770void KMD5::update(const QByteArray& in) 769void KMD5::update(const QByteArray& in)
771{ 770{
772 update(in.data(), int(in.size())); 771 update(in.data(), int(in.size()));
773} 772}
774 773
775void KMD5::update(const QCString& in) 774void KMD5::update(const Q3CString& in)
776{ 775{
777 update(in.data(), int(in.length())); 776 update(in.data(), int(in.length()));
778} 777}
779 778
780void KMD5::update(const unsigned char* in, int len) 779void KMD5::update(const unsigned char* in, int len)
781{ 780{
782 if (len < 0) 781 if (len < 0)
783 len = qstrlen(reinterpret_cast<const char*>(in)); 782 len = qstrlen(reinterpret_cast<const char*>(in));
784 783
785 if (!len) 784 if (!len)
786 return; 785 return;
787 786
788 if (m_finalized) { 787 if (m_finalized) {
789 kdWarning() << "KMD5::update called after state was finalized!" << endl; 788 kdWarning() << "KMD5::update called after state was finalized!" << endl;
790 return; 789 return;
791 } 790 }
792 791
793 Q_UINT32 in_index; 792 Q_UINT32 in_index;
794 Q_UINT32 buffer_index; 793 Q_UINT32 buffer_index;
795 Q_UINT32 buffer_space; 794 Q_UINT32 buffer_space;
796 Q_UINT32 in_length = static_cast<Q_UINT32>( len ); 795 Q_UINT32 in_length = static_cast<Q_UINT32>( len );
797 796
798 buffer_index = static_cast<Q_UINT32>((m_count[0] >> 3) & 0x3F); 797 buffer_index = static_cast<Q_UINT32>((m_count[0] >> 3) & 0x3F);
799 798
800 if ( (m_count[0] += (in_length << 3))<(in_length << 3) ) 799 if ( (m_count[0] += (in_length << 3))<(in_length << 3) )
801 m_count[1]++; 800 m_count[1]++;
802 801
803 m_count[1] += (in_length >> 29); 802 m_count[1] += (in_length >> 29);
804 buffer_space = 64 - buffer_index; 803 buffer_space = 64 - buffer_index;
805 804
806 if (in_length >= buffer_space) 805 if (in_length >= buffer_space)
807 { 806 {
808 memcpy (m_buffer + buffer_index, in, buffer_space); 807 memcpy (m_buffer + buffer_index, in, buffer_space);
809 transform (m_buffer); 808 transform (m_buffer);
810 809
811 for (in_index = buffer_space; in_index + 63 < in_length; 810 for (in_index = buffer_space; in_index + 63 < in_length;
812 in_index += 64) 811 in_index += 64)
813 transform (reinterpret_cast<const unsigned char*>(in+in_index)); 812 transform (reinterpret_cast<const unsigned char*>(in+in_index));
814 813
815 buffer_index = 0; 814 buffer_index = 0;
816 } 815 }
817 else 816 else
818 in_index=0; 817 in_index=0;
819 818
820 memcpy(m_buffer+buffer_index, in+in_index, in_length-in_index); 819 memcpy(m_buffer+buffer_index, in+in_index, in_length-in_index);
821} 820}
822 821
823bool KMD5::update(QIODevice& file) 822bool KMD5::update(QIODevice& file)
824{ 823{
825 char buffer[1024]; 824 char buffer[1024];
826 int len; 825 int len;
827 826
828 while ((len=file.readBlock(reinterpret_cast<char*>(buffer), sizeof(buffer))) > 0) 827 while ((len=file.readBlock(reinterpret_cast<char*>(buffer), sizeof(buffer))) > 0)
829 update(buffer, len); 828 update(buffer, len);
830 829
831 return file.atEnd(); 830 return file.atEnd();
832} 831}
833 832
834void KMD5::finalize () 833void KMD5::finalize ()
835{ 834{
836 if (m_finalized) return; 835 if (m_finalized) return;
837 836
838 Q_UINT8 bits[8]; 837 Q_UINT8 bits[8];
839 Q_UINT32 index, padLen; 838 Q_UINT32 index, padLen;
840 static unsigned char PADDING[64]= 839 static unsigned char PADDING[64]=
841 { 840 {
842 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 841 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
843 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 842 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
844 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 843 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
845 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 844 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
846 }; 845 };
847 846
848 encode (bits, m_count, 8); 847 encode (bits, m_count, 8);
849 //memcpy( bits, m_count, 8 ); 848 //memcpy( bits, m_count, 8 );
850 849
851 // Pad out to 56 mod 64. 850 // Pad out to 56 mod 64.
852 index = static_cast<Q_UINT32>((m_count[0] >> 3) & 0x3f); 851 index = static_cast<Q_UINT32>((m_count[0] >> 3) & 0x3f);
853 padLen = (index < 56) ? (56 - index) : (120 - index); 852 padLen = (index < 56) ? (56 - index) : (120 - index);
854 update (reinterpret_cast<const char*>(PADDING), padLen); 853 update (reinterpret_cast<const char*>(PADDING), padLen);
855 854
856 // Append length (before padding) 855 // Append length (before padding)
857 update (reinterpret_cast<const char*>(bits), 8); 856 update (reinterpret_cast<const char*>(bits), 8);
858 857
859 // Store state in digest 858 // Store state in digest
860 encode (m_digest, m_state, 16); 859 encode (m_digest, m_state, 16);
861 //memcpy( m_digest, m_state, 16 ); 860 //memcpy( m_digest, m_state, 16 );
862 861
863 // Fill sensitive information with zero's 862 // Fill sensitive information with zero's
864 memset ( (void *)m_buffer, 0, sizeof(*m_buffer)); 863 memset ( (void *)m_buffer, 0, sizeof(*m_buffer));
865 864
866 m_finalized = true; 865 m_finalized = true;
867} 866}
868 867
869 868
870bool KMD5::verify( const KMD5::Digest& digest) 869bool KMD5::verify( const KMD5::Digest& digest)
871{ 870{
872 finalize(); 871 finalize();
873 return (0 == memcmp(rawDigest(), digest, sizeof(KMD5::Digest))); 872 return (0 == memcmp(rawDigest(), digest, sizeof(KMD5::Digest)));
874} 873}
875 874
876bool KMD5::verify( const QCString& hexdigest) 875bool KMD5::verify( const Q3CString& hexdigest)
877{ 876{
878 finalize(); 877 finalize();
879 return (0 == strcmp(hexDigest().data(), hexdigest)); 878 return (0 == strcmp(hexDigest().data(), hexdigest));
880} 879}
881 880
882const KMD5::Digest& KMD5::rawDigest() 881const KMD5::Digest& KMD5::rawDigest()
883{ 882{
884 finalize(); 883 finalize();
885 return m_digest; 884 return m_digest;
886} 885}
887 886
888void KMD5::rawDigest( KMD5::Digest& bin ) 887void KMD5::rawDigest( KMD5::Digest& bin )
889{ 888{
890 finalize(); 889 finalize();
891 memcpy( bin, m_digest, 16 ); 890 memcpy( bin, m_digest, 16 );
892} 891}
893 892
894 893
895QCString KMD5::hexDigest() 894Q3CString KMD5::hexDigest()
896{ 895{
897 QCString s(33); 896 Q3CString s(33);
898 897
899 finalize(); 898 finalize();
900 sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", 899 sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
901 m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], 900 m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5],
902 m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], 901 m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11],
903 m_digest[12], m_digest[13], m_digest[14], m_digest[15]); 902 m_digest[12], m_digest[13], m_digest[14], m_digest[15]);
904 903
905 return s; 904 return s;
906} 905}
907 906
908void KMD5::hexDigest(QCString& s) 907void KMD5::hexDigest(Q3CString& s)
909{ 908{
910 finalize(); 909 finalize();
911 s.resize(33); 910 s.resize(33);
912 sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", 911 sprintf(s.data(), "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
913 m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5], 912 m_digest[0], m_digest[1], m_digest[2], m_digest[3], m_digest[4], m_digest[5],
914 m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11], 913 m_digest[6], m_digest[7], m_digest[8], m_digest[9], m_digest[10], m_digest[11],
915 m_digest[12], m_digest[13], m_digest[14], m_digest[15]); 914 m_digest[12], m_digest[13], m_digest[14], m_digest[15]);
916} 915}
917 916
918QCString KMD5::base64Digest() 917Q3CString KMD5::base64Digest()
919{ 918{
920 QByteArray ba(16); 919 QByteArray ba(16);
921 920
922 finalize(); 921 finalize();
923 memcpy(ba.data(), m_digest, 16); 922 memcpy(ba.data(), m_digest, 16);
924 return KCodecs::base64Encode(ba); 923 return KCodecs::base64Encode(ba);
925} 924}
926 925
927 926
928void KMD5::init() 927void KMD5::init()
929{ 928{
930 d = 0; 929 d = 0;
931 reset(); 930 reset();
932} 931}
933 932
934void KMD5::reset() 933void KMD5::reset()
935{ 934{
936 m_finalized = false; 935 m_finalized = false;
937 936
938 m_count[0] = 0; 937 m_count[0] = 0;
939 m_count[1] = 0; 938 m_count[1] = 0;
940 939
941 m_state[0] = 0x67452301; 940 m_state[0] = 0x67452301;
942 m_state[1] = 0xefcdab89; 941 m_state[1] = 0xefcdab89;
943 m_state[2] = 0x98badcfe; 942 m_state[2] = 0x98badcfe;
944 m_state[3] = 0x10325476; 943 m_state[3] = 0x10325476;
945 944
946 memset ( m_buffer, 0, sizeof(*m_buffer)); 945 memset ( m_buffer, 0, sizeof(*m_buffer));
947 memset ( m_digest, 0, sizeof(*m_digest)); 946 memset ( m_digest, 0, sizeof(*m_digest));
948} 947}
949 948
950void KMD5::transform( const unsigned char block[64] ) 949void KMD5::transform( const unsigned char block[64] )
951{ 950{
952 951
953 Q_UINT32 a = m_state[0], b = m_state[1], c = m_state[2], d = m_state[3], x[16]; 952 Q_UINT32 a = m_state[0], b = m_state[1], c = m_state[2], d = m_state[3], x[16];
954 953
955 decode (x, block, 64); 954 decode (x, block, 64);
956 //memcpy( x, block, 64 ); 955 //memcpy( x, block, 64 );
957 956
958//US Q_ASSERT(!m_finalized); // not just a user error, since the method is private 957//US Q_ASSERT(!m_finalized); // not just a user error, since the method is private
959 ASSERT(!m_finalized); // not just a user error, since the method is private 958 Q_ASSERT(!m_finalized); // not just a user error, since the method is private
960 959
961 /* Round 1 */ 960 /* Round 1 */
962 FF (a, b, c, d, x[ 0], KMD5_S11, 0xd76aa478); /* 1 */ 961 FF (a, b, c, d, x[ 0], KMD5_S11, 0xd76aa478); /* 1 */
963 FF (d, a, b, c, x[ 1], KMD5_S12, 0xe8c7b756); /* 2 */ 962 FF (d, a, b, c, x[ 1], KMD5_S12, 0xe8c7b756); /* 2 */
964 FF (c, d, a, b, x[ 2], KMD5_S13, 0x242070db); /* 3 */ 963 FF (c, d, a, b, x[ 2], KMD5_S13, 0x242070db); /* 3 */
965 FF (b, c, d, a, x[ 3], KMD5_S14, 0xc1bdceee); /* 4 */ 964 FF (b, c, d, a, x[ 3], KMD5_S14, 0xc1bdceee); /* 4 */
966 FF (a, b, c, d, x[ 4], KMD5_S11, 0xf57c0faf); /* 5 */ 965 FF (a, b, c, d, x[ 4], KMD5_S11, 0xf57c0faf); /* 5 */
967 FF (d, a, b, c, x[ 5], KMD5_S12, 0x4787c62a); /* 6 */ 966 FF (d, a, b, c, x[ 5], KMD5_S12, 0x4787c62a); /* 6 */
968 FF (c, d, a, b, x[ 6], KMD5_S13, 0xa8304613); /* 7 */ 967 FF (c, d, a, b, x[ 6], KMD5_S13, 0xa8304613); /* 7 */
969 FF (b, c, d, a, x[ 7], KMD5_S14, 0xfd469501); /* 8 */ 968 FF (b, c, d, a, x[ 7], KMD5_S14, 0xfd469501); /* 8 */
970 FF (a, b, c, d, x[ 8], KMD5_S11, 0x698098d8); /* 9 */ 969 FF (a, b, c, d, x[ 8], KMD5_S11, 0x698098d8); /* 9 */
971 FF (d, a, b, c, x[ 9], KMD5_S12, 0x8b44f7af); /* 10 */ 970 FF (d, a, b, c, x[ 9], KMD5_S12, 0x8b44f7af); /* 10 */
972 FF (c, d, a, b, x[10], KMD5_S13, 0xffff5bb1); /* 11 */ 971 FF (c, d, a, b, x[10], KMD5_S13, 0xffff5bb1); /* 11 */
973 FF (b, c, d, a, x[11], KMD5_S14, 0x895cd7be); /* 12 */ 972 FF (b, c, d, a, x[11], KMD5_S14, 0x895cd7be); /* 12 */
974 FF (a, b, c, d, x[12], KMD5_S11, 0x6b901122); /* 13 */ 973 FF (a, b, c, d, x[12], KMD5_S11, 0x6b901122); /* 13 */
975 FF (d, a, b, c, x[13], KMD5_S12, 0xfd987193); /* 14 */ 974 FF (d, a, b, c, x[13], KMD5_S12, 0xfd987193); /* 14 */
976 FF (c, d, a, b, x[14], KMD5_S13, 0xa679438e); /* 15 */ 975 FF (c, d, a, b, x[14], KMD5_S13, 0xa679438e); /* 15 */
977 FF (b, c, d, a, x[15], KMD5_S14, 0x49b40821); /* 16 */ 976 FF (b, c, d, a, x[15], KMD5_S14, 0x49b40821); /* 16 */
978 977
979 /* Round 2 */ 978 /* Round 2 */
980 GG (a, b, c, d, x[ 1], KMD5_S21, 0xf61e2562); /* 17 */ 979 GG (a, b, c, d, x[ 1], KMD5_S21, 0xf61e2562); /* 17 */
981 GG (d, a, b, c, x[ 6], KMD5_S22, 0xc040b340); /* 18 */ 980 GG (d, a, b, c, x[ 6], KMD5_S22, 0xc040b340); /* 18 */
982 GG (c, d, a, b, x[11], KMD5_S23, 0x265e5a51); /* 19 */ 981 GG (c, d, a, b, x[11], KMD5_S23, 0x265e5a51); /* 19 */
983 GG (b, c, d, a, x[ 0], KMD5_S24, 0xe9b6c7aa); /* 20 */ 982 GG (b, c, d, a, x[ 0], KMD5_S24, 0xe9b6c7aa); /* 20 */
984 GG (a, b, c, d, x[ 5], KMD5_S21, 0xd62f105d); /* 21 */ 983 GG (a, b, c, d, x[ 5], KMD5_S21, 0xd62f105d); /* 21 */
985 GG (d, a, b, c, x[10], KMD5_S22, 0x2441453); /* 22 */ 984 GG (d, a, b, c, x[10], KMD5_S22, 0x2441453); /* 22 */
986 GG (c, d, a, b, x[15], KMD5_S23, 0xd8a1e681); /* 23 */ 985 GG (c, d, a, b, x[15], KMD5_S23, 0xd8a1e681); /* 23 */
987 GG (b, c, d, a, x[ 4], KMD5_S24, 0xe7d3fbc8); /* 24 */ 986 GG (b, c, d, a, x[ 4], KMD5_S24, 0xe7d3fbc8); /* 24 */
988 GG (a, b, c, d, x[ 9], KMD5_S21, 0x21e1cde6); /* 25 */ 987 GG (a, b, c, d, x[ 9], KMD5_S21, 0x21e1cde6); /* 25 */
989 GG (d, a, b, c, x[14], KMD5_S22, 0xc33707d6); /* 26 */ 988 GG (d, a, b, c, x[14], KMD5_S22, 0xc33707d6); /* 26 */
990 GG (c, d, a, b, x[ 3], KMD5_S23, 0xf4d50d87); /* 27 */ 989 GG (c, d, a, b, x[ 3], KMD5_S23, 0xf4d50d87); /* 27 */
991 GG (b, c, d, a, x[ 8], KMD5_S24, 0x455a14ed); /* 28 */ 990 GG (b, c, d, a, x[ 8], KMD5_S24, 0x455a14ed); /* 28 */
992 GG (a, b, c, d, x[13], KMD5_S21, 0xa9e3e905); /* 29 */ 991 GG (a, b, c, d, x[13], KMD5_S21, 0xa9e3e905); /* 29 */
993 GG (d, a, b, c, x[ 2], KMD5_S22, 0xfcefa3f8); /* 30 */ 992 GG (d, a, b, c, x[ 2], KMD5_S22, 0xfcefa3f8); /* 30 */
994 GG (c, d, a, b, x[ 7], KMD5_S23, 0x676f02d9); /* 31 */ 993 GG (c, d, a, b, x[ 7], KMD5_S23, 0x676f02d9); /* 31 */
995 GG (b, c, d, a, x[12], KMD5_S24, 0x8d2a4c8a); /* 32 */ 994 GG (b, c, d, a, x[12], KMD5_S24, 0x8d2a4c8a); /* 32 */
996 995
997 /* Round 3 */ 996 /* Round 3 */
998 HH (a, b, c, d, x[ 5], KMD5_S31, 0xfffa3942); /* 33 */ 997 HH (a, b, c, d, x[ 5], KMD5_S31, 0xfffa3942); /* 33 */
999 HH (d, a, b, c, x[ 8], KMD5_S32, 0x8771f681); /* 34 */ 998 HH (d, a, b, c, x[ 8], KMD5_S32, 0x8771f681); /* 34 */
1000 HH (c, d, a, b, x[11], KMD5_S33, 0x6d9d6122); /* 35 */ 999 HH (c, d, a, b, x[11], KMD5_S33, 0x6d9d6122); /* 35 */
1001 HH (b, c, d, a, x[14], KMD5_S34, 0xfde5380c); /* 36 */ 1000 HH (b, c, d, a, x[14], KMD5_S34, 0xfde5380c); /* 36 */
1002 HH (a, b, c, d, x[ 1], KMD5_S31, 0xa4beea44); /* 37 */ 1001 HH (a, b, c, d, x[ 1], KMD5_S31, 0xa4beea44); /* 37 */
1003 HH (d, a, b, c, x[ 4], KMD5_S32, 0x4bdecfa9); /* 38 */ 1002 HH (d, a, b, c, x[ 4], KMD5_S32, 0x4bdecfa9); /* 38 */
1004 HH (c, d, a, b, x[ 7], KMD5_S33, 0xf6bb4b60); /* 39 */ 1003 HH (c, d, a, b, x[ 7], KMD5_S33, 0xf6bb4b60); /* 39 */
1005 HH (b, c, d, a, x[10], KMD5_S34, 0xbebfbc70); /* 40 */ 1004 HH (b, c, d, a, x[10], KMD5_S34, 0xbebfbc70); /* 40 */
1006 HH (a, b, c, d, x[13], KMD5_S31, 0x289b7ec6); /* 41 */ 1005 HH (a, b, c, d, x[13], KMD5_S31, 0x289b7ec6); /* 41 */
1007 HH (d, a, b, c, x[ 0], KMD5_S32, 0xeaa127fa); /* 42 */ 1006 HH (d, a, b, c, x[ 0], KMD5_S32, 0xeaa127fa); /* 42 */
1008 HH (c, d, a, b, x[ 3], KMD5_S33, 0xd4ef3085); /* 43 */ 1007 HH (c, d, a, b, x[ 3], KMD5_S33, 0xd4ef3085); /* 43 */
1009 HH (b, c, d, a, x[ 6], KMD5_S34, 0x4881d05); /* 44 */ 1008 HH (b, c, d, a, x[ 6], KMD5_S34, 0x4881d05); /* 44 */
1010 HH (a, b, c, d, x[ 9], KMD5_S31, 0xd9d4d039); /* 45 */ 1009 HH (a, b, c, d, x[ 9], KMD5_S31, 0xd9d4d039); /* 45 */
1011 HH (d, a, b, c, x[12], KMD5_S32, 0xe6db99e5); /* 46 */ 1010 HH (d, a, b, c, x[12], KMD5_S32, 0xe6db99e5); /* 46 */
1012 HH (c, d, a, b, x[15], KMD5_S33, 0x1fa27cf8); /* 47 */ 1011 HH (c, d, a, b, x[15], KMD5_S33, 0x1fa27cf8); /* 47 */
1013 HH (b, c, d, a, x[ 2], KMD5_S34, 0xc4ac5665); /* 48 */ 1012 HH (b, c, d, a, x[ 2], KMD5_S34, 0xc4ac5665); /* 48 */
1014 1013
1015 /* Round 4 */ 1014 /* Round 4 */
1016 II (a, b, c, d, x[ 0], KMD5_S41, 0xf4292244); /* 49 */ 1015 II (a, b, c, d, x[ 0], KMD5_S41, 0xf4292244); /* 49 */
1017 II (d, a, b, c, x[ 7], KMD5_S42, 0x432aff97); /* 50 */ 1016 II (d, a, b, c, x[ 7], KMD5_S42, 0x432aff97); /* 50 */
1018 II (c, d, a, b, x[14], KMD5_S43, 0xab9423a7); /* 51 */ 1017 II (c, d, a, b, x[14], KMD5_S43, 0xab9423a7); /* 51 */
1019 II (b, c, d, a, x[ 5], KMD5_S44, 0xfc93a039); /* 52 */ 1018 II (b, c, d, a, x[ 5], KMD5_S44, 0xfc93a039); /* 52 */
1020 II (a, b, c, d, x[12], KMD5_S41, 0x655b59c3); /* 53 */ 1019 II (a, b, c, d, x[12], KMD5_S41, 0x655b59c3); /* 53 */
1021 II (d, a, b, c, x[ 3], KMD5_S42, 0x8f0ccc92); /* 54 */ 1020 II (d, a, b, c, x[ 3], KMD5_S42, 0x8f0ccc92); /* 54 */
1022 II (c, d, a, b, x[10], KMD5_S43, 0xffeff47d); /* 55 */ 1021 II (c, d, a, b, x[10], KMD5_S43, 0xffeff47d); /* 55 */
1023 II (b, c, d, a, x[ 1], KMD5_S44, 0x85845dd1); /* 56 */ 1022 II (b, c, d, a, x[ 1], KMD5_S44, 0x85845dd1); /* 56 */
1024 II (a, b, c, d, x[ 8], KMD5_S41, 0x6fa87e4f); /* 57 */ 1023 II (a, b, c, d, x[ 8], KMD5_S41, 0x6fa87e4f); /* 57 */
1025 II (d, a, b, c, x[15], KMD5_S42, 0xfe2ce6e0); /* 58 */ 1024 II (d, a, b, c, x[15], KMD5_S42, 0xfe2ce6e0); /* 58 */
1026 II (c, d, a, b, x[ 6], KMD5_S43, 0xa3014314); /* 59 */ 1025 II (c, d, a, b, x[ 6], KMD5_S43, 0xa3014314); /* 59 */
1027 II (b, c, d, a, x[13], KMD5_S44, 0x4e0811a1); /* 60 */ 1026 II (b, c, d, a, x[13], KMD5_S44, 0x4e0811a1); /* 60 */
1028 II (a, b, c, d, x[ 4], KMD5_S41, 0xf7537e82); /* 61 */ 1027 II (a, b, c, d, x[ 4], KMD5_S41, 0xf7537e82); /* 61 */
1029 II (d, a, b, c, x[11], KMD5_S42, 0xbd3af235); /* 62 */ 1028 II (d, a, b, c, x[11], KMD5_S42, 0xbd3af235); /* 62 */
1030 II (c, d, a, b, x[ 2], KMD5_S43, 0x2ad7d2bb); /* 63 */ 1029 II (c, d, a, b, x[ 2], KMD5_S43, 0x2ad7d2bb); /* 63 */
1031 II (b, c, d, a, x[ 9], KMD5_S44, 0xeb86d391); /* 64 */ 1030 II (b, c, d, a, x[ 9], KMD5_S44, 0xeb86d391); /* 64 */
1032 1031
1033 m_state[0] += a; 1032 m_state[0] += a;
1034 m_state[1] += b; 1033 m_state[1] += b;
1035 m_state[2] += c; 1034 m_state[2] += c;
1036 m_state[3] += d; 1035 m_state[3] += d;
1037 1036
1038 memset ( static_cast<void *>(x), 0, sizeof(x) ); 1037 memset ( static_cast<void *>(x), 0, sizeof(x) );
1039} 1038}
1040 1039
1041inline Q_UINT32 KMD5::rotate_left (Q_UINT32 x, Q_UINT32 n) 1040inline Q_UINT32 KMD5::rotate_left (Q_UINT32 x, Q_UINT32 n)
1042{ 1041{
1043 return (x << n) | (x >> (32-n)) ; 1042 return (x << n) | (x >> (32-n)) ;
1044} 1043}
1045 1044
1046inline Q_UINT32 KMD5::F (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z) 1045inline Q_UINT32 KMD5::F (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z)
1047{ 1046{
1048 return (x & y) | (~x & z); 1047 return (x & y) | (~x & z);
1049} 1048}
1050 1049
1051inline Q_UINT32 KMD5::G (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z) 1050inline Q_UINT32 KMD5::G (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z)
1052{ 1051{
1053 return (x & z) | (y & ~z); 1052 return (x & z) | (y & ~z);
1054} 1053}
1055 1054
1056inline Q_UINT32 KMD5::H (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z) 1055inline Q_UINT32 KMD5::H (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z)
1057{ 1056{
1058 return x ^ y ^ z; 1057 return x ^ y ^ z;
1059} 1058}
1060 1059
1061inline Q_UINT32 KMD5::I (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z) 1060inline Q_UINT32 KMD5::I (Q_UINT32 x, Q_UINT32 y, Q_UINT32 z)
1062{ 1061{
1063 return y ^ (x | ~z); 1062 return y ^ (x | ~z);
1064} 1063}
1065 1064
1066void KMD5::FF ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, 1065void KMD5::FF ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d,
1067 Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ) 1066 Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac )
1068{ 1067{
1069 a += F(b, c, d) + x + ac; 1068 a += F(b, c, d) + x + ac;
1070 a = rotate_left (a, s) +b; 1069 a = rotate_left (a, s) +b;
1071} 1070}
1072 1071
1073void KMD5::GG ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, 1072void KMD5::GG ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d,
1074 Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac) 1073 Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac)
1075{ 1074{
1076 a += G(b, c, d) + x + ac; 1075 a += G(b, c, d) + x + ac;
1077 a = rotate_left (a, s) +b; 1076 a = rotate_left (a, s) +b;
1078} 1077}
1079 1078
1080void KMD5::HH ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, 1079void KMD5::HH ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d,
1081 Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ) 1080 Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac )
1082{ 1081{
1083 a += H(b, c, d) + x + ac; 1082 a += H(b, c, d) + x + ac;
1084 a = rotate_left (a, s) +b; 1083 a = rotate_left (a, s) +b;
1085} 1084}
1086 1085
1087void KMD5::II ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, 1086void KMD5::II ( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d,
1088 Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac ) 1087 Q_UINT32 x, Q_UINT32 s, Q_UINT32 ac )
1089{ 1088{
1090 a += I(b, c, d) + x + ac; 1089 a += I(b, c, d) + x + ac;
1091 a = rotate_left (a, s) +b; 1090 a = rotate_left (a, s) +b;
1092} 1091}
1093 1092
1094 1093
1095void KMD5::encode ( unsigned char* output, Q_UINT32 *in, Q_UINT32 len ) 1094void KMD5::encode ( unsigned char* output, Q_UINT32 *in, Q_UINT32 len )
1096{ 1095{
1097#if !defined(WORDS_BIGENDIAN) 1096#if !defined(WORDS_BIGENDIAN)
1098 memcpy(output, in, len); 1097 memcpy(output, in, len);
1099 1098
1100#else 1099#else
1101 Q_UINT32 i, j; 1100 Q_UINT32 i, j;
1102 for (i = 0, j = 0; j < len; i++, j += 4) 1101 for (i = 0, j = 0; j < len; i++, j += 4)
1103 { 1102 {
1104 output[j] = static_cast<Q_UINT8>((in[i] & 0xff)); 1103 output[j] = static_cast<Q_UINT8>((in[i] & 0xff));
1105 output[j+1] = static_cast<Q_UINT8>(((in[i] >> 8) & 0xff)); 1104 output[j+1] = static_cast<Q_UINT8>(((in[i] >> 8) & 0xff));
1106 output[j+2] = static_cast<Q_UINT8>(((in[i] >> 16) & 0xff)); 1105 output[j+2] = static_cast<Q_UINT8>(((in[i] >> 16) & 0xff));
1107 output[j+3] = static_cast<Q_UINT8>(((in[i] >> 24) & 0xff)); 1106 output[j+3] = static_cast<Q_UINT8>(((in[i] >> 24) & 0xff));
1108 } 1107 }
1109#endif 1108#endif
1110} 1109}
1111 1110
1112// Decodes in (Q_UINT8) into output (Q_UINT32). Assumes len is a 1111// Decodes in (Q_UINT8) into output (Q_UINT32). Assumes len is a
1113// multiple of 4. 1112// multiple of 4.
1114void KMD5::decode (Q_UINT32 *output, const unsigned char* in, Q_UINT32 len) 1113void KMD5::decode (Q_UINT32 *output, const unsigned char* in, Q_UINT32 len)
1115{ 1114{
1116#if !defined(WORDS_BIGENDIAN) 1115#if !defined(WORDS_BIGENDIAN)
1117 memcpy(output, in, len); 1116 memcpy(output, in, len);
1118 1117
1119#else 1118#else
1120 Q_UINT32 i, j; 1119 Q_UINT32 i, j;
1121 for (i = 0, j = 0; j < len; i++, j += 4) 1120 for (i = 0, j = 0; j < len; i++, j += 4)
1122 output[i] = static_cast<Q_UINT32>(in[j]) | 1121 output[i] = static_cast<Q_UINT32>(in[j]) |
1123 (static_cast<Q_UINT32>(in[j+1]) << 8) | 1122 (static_cast<Q_UINT32>(in[j+1]) << 8) |
1124 (static_cast<Q_UINT32>(in[j+2]) << 16) | 1123 (static_cast<Q_UINT32>(in[j+2]) << 16) |
1125 (static_cast<Q_UINT32>(in[j+3]) << 24); 1124 (static_cast<Q_UINT32>(in[j+3]) << 24);
1126#endif 1125#endif
1127} 1126}
diff --git a/microkde/kdecore/kmdcodec.h b/microkde/kdecore/kmdcodec.h
index 2c4d611..616b683 100644
--- a/microkde/kdecore/kmdcodec.h
+++ b/microkde/kdecore/kmdcodec.h
@@ -1,572 +1,574 @@
1/* 1/*
2 Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org> 2 Copyright (C) 2000-2001 Dawit Alemayehu <adawit@kde.org>
3 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org> 3 Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License (LGPL) 6 it under the terms of the GNU Lesser General Public License (LGPL)
7 version 2 as published by the Free Software Foundation. 7 version 2 as published by the Free Software Foundation.
8 8
9 This program is distributed in the hope that it will be useful, 9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details. 12 GNU General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public 14 You should have received a copy of the GNU Library General Public
15 License along with this program; if not, write to the Free Software 15 License along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 17
18 RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992. 18 RFC 1321 "MD5 Message-Digest Algorithm" Copyright (C) 1991-1992.
19 RSA Data Security, Inc. Created 1991. All rights reserved. 19 RSA Data Security, Inc. Created 1991. All rights reserved.
20 20
21 The KMD5 class is based on a C++ implementation of 21 The KMD5 class is based on a C++ implementation of
22 "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by 22 "RSA Data Security, Inc. MD5 Message-Digest Algorithm" by
23 Mordechai T. Abzug,Copyright (c) 1995. This implementation 23 Mordechai T. Abzug,Copyright (c) 1995. This implementation
24 passes the test-suite as defined in RFC 1321. 24 passes the test-suite as defined in RFC 1321.
25 25
26 The encoding and decoding utilities in KCodecs with the exception of 26 The encoding and decoding utilities in KCodecs with the exception of
27 quoted-printable are based on the java implementation in HTTPClient 27 quoted-printable are based on the java implementation in HTTPClient
28 package by Ronald Tschalär Copyright (C) 1996-1999. 28 package by Ronald Tschalär Copyright (C) 1996-1999.
29 29
30 The quoted-printable codec as described in RFC 2045, section 6.7. is by 30 The quoted-printable codec as described in RFC 2045, section 6.7. is by
31 Rik Hemsley (C) 2001. 31 Rik Hemsley (C) 2001.
32*/ 32*/
33 33
34#ifndef _KMDBASE_H 34#ifndef _KMDBASE_H
35#define _KMDBASE_H 35#define _KMDBASE_H
36 36
37#define KBase64 KCodecs 37#define KBase64 KCodecs
38 38
39#include <qglobal.h> 39#include <qglobal.h>
40#include <qstring.h> 40#include <qstring.h>
41#include <qiodevice.h> 41#include <qiodevice.h>
42//Added by qt3to4:
43#include <Q3CString>
42 44
43/** 45/**
44 * A wrapper class for the most commonly used encoding and 46 * A wrapper class for the most commonly used encoding and
45 * decoding algorithms. Currently there is support for encoding 47 * decoding algorithms. Currently there is support for encoding
46 * and decoding input using base64, uu and the quoted-printable 48 * and decoding input using base64, uu and the quoted-printable
47 * specifications. 49 * specifications.
48 * 50 *
49 * @sect Usage: 51 * @sect Usage:
50 * 52 *
51 * <PRE> 53 * <PRE>
52 * QCString input = "Aladdin:open sesame"; 54 * QCString input = "Aladdin:open sesame";
53 * QCString result = KCodecs::base64Encode(input); 55 * QCString result = KCodecs::base64Encode(input);
54 * cout << "Result: " << result.data() << endl; 56 * cout << "Result: " << result.data() << endl;
55 * 57 *
56 * Output should be 58 * Output should be
57 * Result: QWxhZGRpbjpvcGVuIHNlc2FtZQ== 59 * Result: QWxhZGRpbjpvcGVuIHNlc2FtZQ==
58 * </PRE> 60 * </PRE>
59 * 61 *
60 * The above example makes use of the convenience functions 62 * The above example makes use of the convenience functions
61 * (ones that accept/return null-terminated strings) to encode/decode 63 * (ones that accept/return null-terminated strings) to encode/decode
62 * a string. If what you need is to encode or decode binary data, then 64 * a string. If what you need is to encode or decode binary data, then
63 * it is highly recommended that you use the functions that take an input 65 * it is highly recommended that you use the functions that take an input
64 * and output QByteArray as arguments. These functions are specifically 66 * and output QByteArray as arguments. These functions are specifically
65 * tailored for encoding and decoding binary data. 67 * tailored for encoding and decoding binary data.
66 * 68 *
67 * @short A collection of commonly used encoding and decoding algorithms. 69 * @short A collection of commonly used encoding and decoding algorithms.
68 * @author Dawit Alemayehu <adawit@kde.org> 70 * @author Dawit Alemayehu <adawit@kde.org>
69 * @author Rik Hemsley <rik@kde.org> 71 * @author Rik Hemsley <rik@kde.org>
70 */ 72 */
71class KCodecs 73class KCodecs
72{ 74{
73public: 75public:
74 76
75 /** 77 /**
76 * Encodes the given data using the quoted-printable algorithm. 78 * Encodes the given data using the quoted-printable algorithm.
77 * 79 *
78 * @param in data to be encoded. 80 * @param in data to be encoded.
79 * @param useCRLF if true the input data is expected to have 81 * @param useCRLF if true the input data is expected to have
80 * CRLF line breaks and the output will have CRLF line 82 * CRLF line breaks and the output will have CRLF line
81 * breaks, too. 83 * breaks, too.
82 * @return quoted-printable encoded data. 84 * @return quoted-printable encoded data.
83 */ 85 */
84 static QCString quotedPrintableEncode(const QByteArray & in, 86 static Q3CString quotedPrintableEncode(const QByteArray & in,
85 bool useCRLF = true); 87 bool useCRLF = true);
86 88
87 /** 89 /**
88 * @overload 90 * @overload
89 * 91 *
90 * Same as above except it accepts a null terminated 92 * Same as above except it accepts a null terminated
91 * string instead an array. 93 * string instead an array.
92 * 94 *
93 * @param str data to be encoded. 95 * @param str data to be encoded.
94 * @param useCRLF if true the input data is expected to have 96 * @param useCRLF if true the input data is expected to have
95 * CRLF line breaks and the output will have CRLF line 97 * CRLF line breaks and the output will have CRLF line
96 * breaks, too. 98 * breaks, too.
97 * @return quoted-printable encoded data. 99 * @return quoted-printable encoded data.
98 */ 100 */
99 static QCString quotedPrintableEncode(const QCString & str, 101 static Q3CString quotedPrintableEncode(const Q3CString & str,
100 bool useCRLF = true); 102 bool useCRLF = true);
101 103
102 /** 104 /**
103 * Encodes the given data using the quoted-printable algorithm. 105 * Encodes the given data using the quoted-printable algorithm.
104 * 106 *
105 * Use this function if you want the result of the encoding 107 * Use this function if you want the result of the encoding
106 * to be placed in another array which cuts down the number 108 * to be placed in another array which cuts down the number
107 * of copy operation that have to be performed in the process. 109 * of copy operation that have to be performed in the process.
108 * This is also the preferred method for encoding binary data. 110 * This is also the preferred method for encoding binary data.
109 * 111 *
110 * NOTE: the output array is first reset and then resized 112 * NOTE: the output array is first reset and then resized
111 * appropriately before use, hence, all data stored in the 113 * appropriately before use, hence, all data stored in the
112 * output array will be lost. 114 * output array will be lost.
113 * 115 *
114 * @param in data to be encoded. 116 * @param in data to be encoded.
115 * @param out decoded data. 117 * @param out decoded data.
116 * @param useCRLF if true the input data is expected to have 118 * @param useCRLF if true the input data is expected to have
117 * CRLF line breaks and the output will have CRLF line 119 * CRLF line breaks and the output will have CRLF line
118 * breaks, too. 120 * breaks, too.
119 * @return quoted-printable encoded data. 121 * @return quoted-printable encoded data.
120 */ 122 */
121 static void quotedPrintableEncode(const QByteArray & in, QByteArray& out, 123 static void quotedPrintableEncode(const QByteArray & in, QByteArray& out,
122 bool useCRLF); 124 bool useCRLF);
123 125
124 /** 126 /**
125 * Decodes a quoted-printable encoded string. 127 * Decodes a quoted-printable encoded string.
126 * 128 *
127 * Accepts data with CRLF or standard unix line breaks. 129 * Accepts data with CRLF or standard unix line breaks.
128 * 130 *
129 * @param in the data to be decoded. 131 * @param in the data to be decoded.
130 * @return decoded data. 132 * @return decoded data.
131 */ 133 */
132 static QCString quotedPrintableDecode(const QByteArray & in); 134 static Q3CString quotedPrintableDecode(const QByteArray & in);
133 135
134 /** 136 /**
135 * @overload 137 * @overload
136 * 138 *
137 * Same as above except it accepts a null terminated 139 * Same as above except it accepts a null terminated
138 * string instead an array. 140 * string instead an array.
139 * 141 *
140 * @param str the data to be decoded. 142 * @param str the data to be decoded.
141 * @return decoded data. 143 * @return decoded data.
142 */ 144 */
143 static QCString quotedPrintableDecode(const QCString & str); 145 static Q3CString quotedPrintableDecode(const Q3CString & str);
144 146
145 /** 147 /**
146 * Decodes a quoted-printable encoded data. 148 * Decodes a quoted-printable encoded data.
147 * 149 *
148 * Accepts data with CRLF or standard unix line breaks. 150 * Accepts data with CRLF or standard unix line breaks.
149 * Use this function if you want the result of the decoding 151 * Use this function if you want the result of the decoding
150 * to be placed in another array which cuts down the number 152 * to be placed in another array which cuts down the number
151 * of copy operation that have to be performed in the process. 153 * of copy operation that have to be performed in the process.
152 * This is also the preferred method for decoding an encoded 154 * This is also the preferred method for decoding an encoded
153 * binary data. 155 * binary data.
154 * 156 *
155 * NOTE: the output array is first reset and then resized 157 * NOTE: the output array is first reset and then resized
156 * appropriately before use, hence, all data stored in the 158 * appropriately before use, hence, all data stored in the
157 * output array will be lost. 159 * output array will be lost.
158 * 160 *
159 * @param in data to be encoded. 161 * @param in data to be encoded.
160 * @param out decoded data. 162 * @param out decoded data.
161 * 163 *
162 * @return quoted-printable encoded data. 164 * @return quoted-printable encoded data.
163 */ 165 */
164 static void quotedPrintableDecode(const QByteArray & in, QByteArray& out); 166 static void quotedPrintableDecode(const QByteArray & in, QByteArray& out);
165 167
166 168
167 /** 169 /**
168 * Encodes the given data using the uuencode algorithm. 170 * Encodes the given data using the uuencode algorithm.
169 * 171 *
170 * The output is split into lines starting with the number of 172 * The output is split into lines starting with the number of
171 * encoded octets in the line and ending with a newline. No 173 * encoded octets in the line and ending with a newline. No
172 * line is longer than 45 octets (60 characters), excluding the 174 * line is longer than 45 octets (60 characters), excluding the
173 * line terminator. 175 * line terminator.
174 * 176 *
175 * @param in the data to be uuencoded 177 * @param in the data to be uuencoded
176 * @return a uuencoded data. 178 * @return a uuencoded data.
177 */ 179 */
178 static QCString uuencode( const QByteArray& in ); 180 static Q3CString uuencode( const QByteArray& in );
179 181
180 /** 182 /**
181 * @overload 183 * @overload
182 * 184 *
183 * Same as the above functions except it accepts 185 * Same as the above functions except it accepts
184 * a null terminated string instead an array. 186 * a null terminated string instead an array.
185 * 187 *
186 * @param str the string to be uuencoded. 188 * @param str the string to be uuencoded.
187 * @return the encoded string. 189 * @return the encoded string.
188 */ 190 */
189 static QCString uuencode( const QCString& str ); 191 static Q3CString uuencode( const Q3CString& str );
190 192
191 /** 193 /**
192 * Encodes the given data using the uuencode algorithm. 194 * Encodes the given data using the uuencode algorithm.
193 * 195 *
194 * Use this function if you want the result of the encoding 196 * Use this function if you want the result of the encoding
195 * to be placed in another array and cut down the number of 197 * to be placed in another array and cut down the number of
196 * copy operation that have to be performed in the process. 198 * copy operation that have to be performed in the process.
197 * This is the preffered method for encoding binary data. 199 * This is the preffered method for encoding binary data.
198 * 200 *
199 * NOTE: the output array is first reset and then resized 201 * NOTE: the output array is first reset and then resized
200 * appropriately before use, hence, all data stored in the 202 * appropriately before use, hence, all data stored in the
201 * output array will be lost. 203 * output array will be lost.
202 * 204 *
203 * @param in the data to be uuencoded. 205 * @param in the data to be uuencoded.
204 * @param out the container for the uudecoded data. 206 * @param out the container for the uudecoded data.
205 */ 207 */
206 static void uuencode( const QByteArray& in, QByteArray& out ); 208 static void uuencode( const QByteArray& in, QByteArray& out );
207 209
208 /** 210 /**
209 * Decodes the given data using the uuencode algorithm. 211 * Decodes the given data using the uuencode algorithm.
210 * 212 *
211 * Any 'begin' and 'end' lines like those generated by 213 * Any 'begin' and 'end' lines like those generated by
212 * the utilities in unix and unix-like OS will be 214 * the utilities in unix and unix-like OS will be
213 * automatically ignored. 215 * automatically ignored.
214 * 216 *
215 * @param in the data uuencoded data to be decoded. 217 * @param in the data uuencoded data to be decoded.
216 * @return a decoded string. 218 * @return a decoded string.
217 */ 219 */
218 static QCString uudecode( const QByteArray& in ); 220 static Q3CString uudecode( const QByteArray& in );
219 221
220 /** 222 /**
221 * @overload 223 * @overload
222 * 224 *
223 * Same as the above functions except it accepts 225 * Same as the above functions except it accepts
224 * a null terminated string instead an array. 226 * a null terminated string instead an array.
225 * 227 *
226 * @param str the string to be decoded. 228 * @param str the string to be decoded.
227 * @return a uudecoded string. 229 * @return a uudecoded string.
228 */ 230 */
229 static QCString uudecode( const QCString& str ); 231 static Q3CString uudecode( const Q3CString& str );
230 232
231 /** 233 /**
232 * Decodes the given data using the uudecode algorithm. 234 * Decodes the given data using the uudecode algorithm.
233 * 235 *
234 * Use this function if you want the result of the decoding 236 * Use this function if you want the result of the decoding
235 * to be placed in another array which cuts down the number 237 * to be placed in another array which cuts down the number
236 * of copy operation that have to be performed in the process. 238 * of copy operation that have to be performed in the process.
237 * This is the preferred method for decoding binary data. 239 * This is the preferred method for decoding binary data.
238 * 240 *
239 * Any 'begin' and 'end' lines like those generated by 241 * Any 'begin' and 'end' lines like those generated by
240 * the utilities in unix and unix-like OS will be 242 * the utilities in unix and unix-like OS will be
241 * automatically ignored. 243 * automatically ignored.
242 * 244 *
243 * NOTE: the output array is first reset and then resized 245 * NOTE: the output array is first reset and then resized
244 * appropriately before use, hence, all data stored in the 246 * appropriately before use, hence, all data stored in the
245 * output array will be lost. 247 * output array will be lost.
246 * 248 *
247 * @param in the uuencoded-data to be decoded. 249 * @param in the uuencoded-data to be decoded.
248 * @param out the container for the uudecoded data. 250 * @param out the container for the uudecoded data.
249 */ 251 */
250 static void uudecode( const QByteArray& in, QByteArray& out ); 252 static void uudecode( const QByteArray& in, QByteArray& out );
251 253
252 254
253 /** 255 /**
254 * Encodes the given data using the base64 algorithm. 256 * Encodes the given data using the base64 algorithm.
255 * 257 *
256 * The boolean argument determines if the encoded data is 258 * The boolean argument determines if the encoded data is
257 * going to be restricted to 76 characters or less per line 259 * going to be restricted to 76 characters or less per line
258 * as specified by RFC 2045. If @p insertLFs is true, then 260 * as specified by RFC 2045. If @p insertLFs is true, then
259 * there will be 76 characters or less per line. 261 * there will be 76 characters or less per line.
260 * 262 *
261 * @param in the data to be encoded. 263 * @param in the data to be encoded.
262 * @param insertLFs limit the number of characters per line. 264 * @param insertLFs limit the number of characters per line.
263 * 265 *
264 * @return a base64 encoded string. 266 * @return a base64 encoded string.
265 */ 267 */
266 static QCString base64Encode( const QByteArray& in, bool insertLFs = false); 268 static Q3CString base64Encode( const QByteArray& in, bool insertLFs = false);
267 269
268 /** 270 /**
269 * @overload 271 * @overload
270 * 272 *
271 * Same as the above functions except it accepts 273 * Same as the above functions except it accepts
272 * a null terminated string instead an array. 274 * a null terminated string instead an array.
273 * 275 *
274 * @param str the string to be encoded. 276 * @param str the string to be encoded.
275 * @param insertLFs limit the number of characters per line. 277 * @param insertLFs limit the number of characters per line.
276 * @return the decoded string. 278 * @return the decoded string.
277 */ 279 */
278 static QCString base64Encode( const QCString& str, bool insertLFs = false ); 280 static Q3CString base64Encode( const Q3CString& str, bool insertLFs = false );
279 281
280 /** 282 /**
281 * Encodes the given data using the base64 algorithm. 283 * Encodes the given data using the base64 algorithm.
282 * 284 *
283 * Use this function if you want the result of the encoding 285 * Use this function if you want the result of the encoding
284 * to be placed in another array which cuts down the number 286 * to be placed in another array which cuts down the number
285 * of copy operation that have to be performed in the process. 287 * of copy operation that have to be performed in the process.
286 * This is also the preferred method for encoding binary data. 288 * This is also the preferred method for encoding binary data.
287 * 289 *
288 * The boolean argument determines if the encoded data is going 290 * The boolean argument determines if the encoded data is going
289 * to be restricted to 76 characters or less per line as specified 291 * to be restricted to 76 characters or less per line as specified
290 * by RFC 2045. If @p insertLFs is true, then there will be 76 292 * by RFC 2045. If @p insertLFs is true, then there will be 76
291 * characters or less per line. 293 * characters or less per line.
292 * 294 *
293 * NOTE: the output array is first reset and then resized 295 * NOTE: the output array is first reset and then resized
294 * appropriately before use, hence, all data stored in the 296 * appropriately before use, hence, all data stored in the
295 * output array will be lost. 297 * output array will be lost.
296 * 298 *
297 * @param in the data to be encoded using base64. 299 * @param in the data to be encoded using base64.
298 * @param out the container for the encoded data. 300 * @param out the container for the encoded data.
299 * @param insertLFs limit the number of characters per line. 301 * @param insertLFs limit the number of characters per line.
300 */ 302 */
301 static void base64Encode( const QByteArray& in, QByteArray& out, 303 static void base64Encode( const QByteArray& in, QByteArray& out,
302 bool insertLFs = false ); 304 bool insertLFs = false );
303 305
304 /** 306 /**
305 * Decodes the given data that was encoded using the 307 * Decodes the given data that was encoded using the
306 * base64 algorithm. 308 * base64 algorithm.
307 * 309 *
308 * @param in the base64-encoded data to be decoded. 310 * @param in the base64-encoded data to be decoded.
309 * @return the decoded data. 311 * @return the decoded data.
310 */ 312 */
311 static QCString base64Decode( const QByteArray& in ); 313 static Q3CString base64Decode( const QByteArray& in );
312 314
313 /** 315 /**
314 * @overload 316 * @overload
315 * 317 *
316 * Same as the above functions except it accepts 318 * Same as the above functions except it accepts
317 * a null terminated string instead an array. 319 * a null terminated string instead an array.
318 * 320 *
319 * @param str the base64-encoded string. 321 * @param str the base64-encoded string.
320 * @return the decoded string. 322 * @return the decoded string.
321 */ 323 */
322 static QCString base64Decode( const QCString& str ); 324 static Q3CString base64Decode( const Q3CString& str );
323 325
324 /** 326 /**
325 * Decodes the given data that was encoded with the base64 327 * Decodes the given data that was encoded with the base64
326 * algorithm. 328 * algorithm.
327 * 329 *
328 * Use this function if you want the result of the decoding 330 * Use this function if you want the result of the decoding
329 * to be placed in another array which cuts down the number 331 * to be placed in another array which cuts down the number
330 * of copy operation that have to be performed in the process. 332 * of copy operation that have to be performed in the process.
331 * This is also the preferred method for decoding an encoded 333 * This is also the preferred method for decoding an encoded
332 * binary data. 334 * binary data.
333 * 335 *
334 * NOTE: the output array is first reset and then resized 336 * NOTE: the output array is first reset and then resized
335 * appropriately before use, hence, all data stored in the 337 * appropriately before use, hence, all data stored in the
336 * output array will be lost. 338 * output array will be lost.
337 * 339 *
338 * @param in the encoded data to be decoded. 340 * @param in the encoded data to be decoded.
339 * @param out the container for the decoded data. 341 * @param out the container for the decoded data.
340 */ 342 */
341 static void base64Decode( const QByteArray& in, QByteArray& out ); 343 static void base64Decode( const QByteArray& in, QByteArray& out );
342 344
343 345
344private: 346private:
345 KCodecs(); 347 KCodecs();
346 348
347private: 349private:
348 static const char UUEncMap[64]; 350 static const char UUEncMap[64];
349 static const char UUDecMap[128]; 351 static const char UUDecMap[128];
350 static const char Base64EncMap[64]; 352 static const char Base64EncMap[64];
351 static const char Base64DecMap[128]; 353 static const char Base64DecMap[128];
352 static const char hexChars[16]; 354 static const char hexChars[16];
353 static const unsigned int maxQPLineLength; 355 static const unsigned int maxQPLineLength;
354}; 356};
355 357
356class KMD5Private; 358class KMD5Private;
357/** 359/**
358 * Provides an easy to use C++ implementation of RSA's 360 * Provides an easy to use C++ implementation of RSA's
359 * MD5 algorithm. 361 * MD5 algorithm.
360 * 362 *
361 * The default constructor is designed to provide much the same 363 * The default constructor is designed to provide much the same
362 * functionality as the most commonly used C-implementation, while 364 * functionality as the most commonly used C-implementation, while
363 * the other three constructors are meant to further simplify the 365 * the other three constructors are meant to further simplify the
364 * process of obtaining a digest by calculating the result in a 366 * process of obtaining a digest by calculating the result in a
365 * single step. 367 * single step.
366 * 368 *
367 * KMD5 is state-based, that means you can add new contents with 369 * KMD5 is state-based, that means you can add new contents with
368 * update() as long as you didn't request the digest value yet. 370 * update() as long as you didn't request the digest value yet.
369 * After the digest value was requested, the object is "finalized" 371 * After the digest value was requested, the object is "finalized"
370 * and you have to call reset() to be able to do another calculation 372 * and you have to call reset() to be able to do another calculation
371 * with it. The reason for this behaviour is that upon requesting 373 * with it. The reason for this behaviour is that upon requesting
372 * the message digest KMD5 has to pad the received contents up to a 374 * the message digest KMD5 has to pad the received contents up to a
373 * 64 byte boundary to calculate its value. After this operation it 375 * 64 byte boundary to calculate its value. After this operation it
374 * is not possible to resume consuming data. 376 * is not possible to resume consuming data.
375 * 377 *
376 * @sect Usage: 378 * @sect Usage:
377 * 379 *
378 * A common usage of this class: 380 * A common usage of this class:
379 * 381 *
380 * <PRE> 382 * <PRE>
381 * const char* test1; 383 * const char* test1;
382 * KMD5::Digest rawResult; 384 * KMD5::Digest rawResult;
383 * 385 *
384 * test1 = "This is a simple test."; 386 * test1 = "This is a simple test.";
385 * KMD5 context (test1); 387 * KMD5 context (test1);
386 * cout << "Hex Digest output: " << context.hexDigest().data() << endl; 388 * cout << "Hex Digest output: " << context.hexDigest().data() << endl;
387 * </PRE> 389 * </PRE>
388 * 390 *
389 * To cut down on the unnecessary overhead of creating multiple KMD5 391 * To cut down on the unnecessary overhead of creating multiple KMD5
390 * objects, you can simply invoke @ref reset() to reuse the same object 392 * objects, you can simply invoke @ref reset() to reuse the same object
391 * in making another calculation: 393 * in making another calculation:
392 * 394 *
393 * <PRE> 395 * <PRE>
394 * context.reset (); 396 * context.reset ();
395 * context.update ("TWO"); 397 * context.update ("TWO");
396 * context.update ("THREE"); 398 * context.update ("THREE");
397 * cout << "Hex Digest output: " << context.hexDigest().data() << endl; 399 * cout << "Hex Digest output: " << context.hexDigest().data() << endl;
398 * </PRE> 400 * </PRE>
399 * 401 *
400 * @short An adapted C++ implementation of RSA Data Securities MD5 algorithm. 402 * @short An adapted C++ implementation of RSA Data Securities MD5 algorithm.
401 * @author Dirk Mueller <mueller@kde.org>, Dawit Alemayehu <adawit@kde.org> 403 * @author Dirk Mueller <mueller@kde.org>, Dawit Alemayehu <adawit@kde.org>
402 */ 404 */
403 405
404class KMD5 406class KMD5
405{ 407{
406public: 408public:
407 409
408 typedef unsigned char Digest[16]; 410 typedef unsigned char Digest[16];
409 411
410 KMD5(); 412 KMD5();
411 413
412 /** 414 /**
413 * Constructor that updates the digest for the given string. 415 * Constructor that updates the digest for the given string.
414 * 416 *
415 * @param in C string or binary data 417 * @param in C string or binary data
416 * @param len if negative, calculates the length by using 418 * @param len if negative, calculates the length by using
417 * strlen on the first parameter, otherwise 419 * strlen on the first parameter, otherwise
418 * it trusts the given length (does not stop on NUL byte). 420 * it trusts the given length (does not stop on NUL byte).
419 */ 421 */
420 KMD5(const char* in, int len = -1); 422 KMD5(const char* in, int len = -1);
421 423
422 /** 424 /**
423 * @overload 425 * @overload
424 * 426 *
425 * Same as above except it accepts a QByteArray as its argument. 427 * Same as above except it accepts a QByteArray as its argument.
426 */ 428 */
427 KMD5(const QByteArray& a ); 429 KMD5(const QByteArray& a );
428 430
429 /** 431 /**
430 * @overload 432 * @overload
431 * 433 *
432 * Same as above except it accepts a QByteArray as its argument. 434 * Same as above except it accepts a QByteArray as its argument.
433 */ 435 */
434 KMD5(const QCString& a ); 436 KMD5(const Q3CString& a );
435 437
436 /** 438 /**
437 * Updates the message to be digested. Be sure to add all data 439 * Updates the message to be digested. Be sure to add all data
438 * before you read the digest. After reading the digest, you 440 * before you read the digest. After reading the digest, you
439 * can <b>not</b> add more data! 441 * can <b>not</b> add more data!
440 * 442 *
441 * @param in message to be added to digest 443 * @param in message to be added to digest
442 * @param len the length of the given message. 444 * @param len the length of the given message.
443 */ 445 */
444 void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); } 446 void update(const char* in, int len = -1) { update(reinterpret_cast<const unsigned char*>(in), len); }
445 447
446 /** 448 /**
447 * @overload 449 * @overload
448 */ 450 */
449 void update(const unsigned char* in, int len = -1); 451 void update(const unsigned char* in, int len = -1);
450 452
451 /** 453 /**
452 * @overload 454 * @overload
453 * 455 *
454 * @param in message to be added to the digest (QByteArray). 456 * @param in message to be added to the digest (QByteArray).
455 */ 457 */
456 void update(const QByteArray& in ); 458 void update(const QByteArray& in );
457 459
458 /** 460 /**
459 * @overload 461 * @overload
460 * 462 *
461 * @param in message to be added to the digest (QByteArray). 463 * @param in message to be added to the digest (QByteArray).
462 */ 464 */
463 void update(const QCString& in ); 465 void update(const Q3CString& in );
464 466
465 /** 467 /**
466 * @overload 468 * @overload
467 * 469 *
468 * reads the data from an I/O device, i.e. from a file (QFile). 470 * reads the data from an I/O device, i.e. from a file (QFile).
469 * 471 *
470 * NOTE that the file must be open for reading. 472 * NOTE that the file must be open for reading.
471 * 473 *
472 * @param file a pointer to FILE as returned by calls like f{d,re}open 474 * @param file a pointer to FILE as returned by calls like f{d,re}open
473 * 475 *
474 * @returns false if an error occured during reading. 476 * @returns false if an error occured during reading.
475 */ 477 */
476 bool update(QIODevice& file); 478 bool update(QIODevice& file);
477 479
478 /** 480 /**
479 * Calling this function will reset the calculated message digest. 481 * Calling this function will reset the calculated message digest.
480 * Use this method to perform another message digest calculation 482 * Use this method to perform another message digest calculation
481 * without recreating the KMD5 object. 483 * without recreating the KMD5 object.
482 */ 484 */
483 void reset(); 485 void reset();
484 486
485 /** 487 /**
486 * @return the raw representation of the digest 488 * @return the raw representation of the digest
487 */ 489 */
488 const Digest& rawDigest (); 490 const Digest& rawDigest ();
489 491
490 /** 492 /**
491 * Fills the given array with the binary representation of the 493 * Fills the given array with the binary representation of the
492 * message digest. 494 * message digest.
493 * 495 *
494 * Use this method if you do not want to worry about making 496 * Use this method if you do not want to worry about making
495 * copy of the digest once you obtain it. 497 * copy of the digest once you obtain it.
496 * 498 *
497 * @param bin an array of 16 characters ( char[16] ) 499 * @param bin an array of 16 characters ( char[16] )
498 */ 500 */
499 void rawDigest( KMD5::Digest& bin ); 501 void rawDigest( KMD5::Digest& bin );
500 502
501 /** 503 /**
502 * Returns the value of the calculated message digest in 504 * Returns the value of the calculated message digest in
503 * a hexadecimal representation. 505 * a hexadecimal representation.
504 */ 506 */
505 QCString hexDigest (); 507 Q3CString hexDigest ();
506 508
507 /** 509 /**
508 * @overload 510 * @overload
509 */ 511 */
510 void hexDigest(QCString&); 512 void hexDigest(Q3CString&);
511 513
512 /** 514 /**
513 * Returns the value of the calculated message digest in 515 * Returns the value of the calculated message digest in
514 * a base64-encoded representation. 516 * a base64-encoded representation.
515 */ 517 */
516 QCString base64Digest (); 518 Q3CString base64Digest ();
517 519
518 /** 520 /**
519 * returns true if the calculated digest for the given 521 * returns true if the calculated digest for the given
520 * message matches the given one. 522 * message matches the given one.
521 */ 523 */
522 bool verify( const KMD5::Digest& digest); 524 bool verify( const KMD5::Digest& digest);
523 525
524 /** 526 /**
525 * @overload 527 * @overload
526 */ 528 */
527 bool verify(const QCString&); 529 bool verify(const Q3CString&);
528 530
529protected: 531protected:
530 /** 532 /**
531 * Performs the real update work. Note 533 * Performs the real update work. Note
532 * that length is implied to be 64. 534 * that length is implied to be 64.
533 */ 535 */
534 void transform( const unsigned char buffer[64] ); 536 void transform( const unsigned char buffer[64] );
535 537
536 /** 538 /**
537 * finalizes the digest 539 * finalizes the digest
538 */ 540 */
539 void finalize(); 541 void finalize();
540 542
541private: 543private:
542 KMD5(const KMD5& u); 544 KMD5(const KMD5& u);
543 KMD5& operator=(const KMD5& md); 545 KMD5& operator=(const KMD5& md);
544 546
545 void init(); 547 void init();
546 void encode( unsigned char* output, Q_UINT32 *in, Q_UINT32 len ); 548 void encode( unsigned char* output, Q_UINT32 *in, Q_UINT32 len );
547 void decode( Q_UINT32 *output, const unsigned char* in, Q_UINT32 len ); 549 void decode( Q_UINT32 *output, const unsigned char* in, Q_UINT32 len );
548 550
549 Q_UINT32 rotate_left( Q_UINT32 x, Q_UINT32 n ); 551 Q_UINT32 rotate_left( Q_UINT32 x, Q_UINT32 n );
550 Q_UINT32 F( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z ); 552 Q_UINT32 F( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );
551 Q_UINT32 G( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z ); 553 Q_UINT32 G( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );
552 Q_UINT32 H( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z ); 554 Q_UINT32 H( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );
553 Q_UINT32 I( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z ); 555 Q_UINT32 I( Q_UINT32 x, Q_UINT32 y, Q_UINT32 z );
554 void FF( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, 556 void FF( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,
555 Q_UINT32 s, Q_UINT32 ac ); 557 Q_UINT32 s, Q_UINT32 ac );
556 void GG( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, 558 void GG( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,
557 Q_UINT32 s, Q_UINT32 ac ); 559 Q_UINT32 s, Q_UINT32 ac );
558 void HH( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, 560 void HH( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,
559 Q_UINT32 s, Q_UINT32 ac ); 561 Q_UINT32 s, Q_UINT32 ac );
560 void II( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x, 562 void II( Q_UINT32& a, Q_UINT32 b, Q_UINT32 c, Q_UINT32 d, Q_UINT32 x,
561 Q_UINT32 s, Q_UINT32 ac ); 563 Q_UINT32 s, Q_UINT32 ac );
562 564
563private: 565private:
564 Q_UINT32 m_state[4]; 566 Q_UINT32 m_state[4];
565 Q_UINT32 m_count[2]; 567 Q_UINT32 m_count[2];
566 Q_UINT8 m_buffer[64]; 568 Q_UINT8 m_buffer[64];
567 Digest m_digest; 569 Digest m_digest;
568 bool m_finalized; 570 bool m_finalized;
569 571
570 KMD5Private* d; 572 KMD5Private* d;
571}; 573};
572#endif 574#endif
diff --git a/microkde/kdecore/kprefs.cpp b/microkde/kdecore/kprefs.cpp
index 0220a34..d4010fa 100644
--- a/microkde/kdecore/kprefs.cpp
+++ b/microkde/kdecore/kprefs.cpp
@@ -1,512 +1,514 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21// $Id$ 21// $Id$
22 22
23#include <qcolor.h> 23#include <qcolor.h>
24//Added by qt3to4:
25#include <Q3ValueList>
24 26
25#include <kconfig.h> 27#include <kconfig.h>
26#include <kstandarddirs.h> 28#include <kstandarddirs.h>
27#include <kglobal.h> 29#include <kglobal.h>
28#include <kdebug.h> 30#include <kdebug.h>
29 31
30#include "kprefs.h" 32#include "kprefs.h"
31 33
32class KPrefsItemBool : public KPrefsItem { 34class KPrefsItemBool : public KPrefsItem {
33 public: 35 public:
34 KPrefsItemBool(const QString &group,const QString &name,bool *,bool defaultValue=true); 36 KPrefsItemBool(const QString &group,const QString &name,bool *,bool defaultValue=true);
35 virtual ~KPrefsItemBool() {} 37 virtual ~KPrefsItemBool() {}
36 38
37 void setDefault(); 39 void setDefault();
38 void readConfig(KConfig *); 40 void readConfig(KConfig *);
39 void writeConfig(KConfig *); 41 void writeConfig(KConfig *);
40 42
41 private: 43 private:
42 bool *mReference; 44 bool *mReference;
43 bool mDefault; 45 bool mDefault;
44}; 46};
45 47
46class KPrefsItemInt : public KPrefsItem { 48class KPrefsItemInt : public KPrefsItem {
47 public: 49 public:
48 KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0); 50 KPrefsItemInt(const QString &group,const QString &name,int *,int defaultValue=0);
49 virtual ~KPrefsItemInt() {} 51 virtual ~KPrefsItemInt() {}
50 52
51 void setDefault(); 53 void setDefault();
52 void readConfig(KConfig *); 54 void readConfig(KConfig *);
53 void writeConfig(KConfig *); 55 void writeConfig(KConfig *);
54 56
55 private: 57 private:
56 int *mReference; 58 int *mReference;
57 int mDefault; 59 int mDefault;
58}; 60};
59 61
60 62
61class KPrefsItemColor : public KPrefsItem { 63class KPrefsItemColor : public KPrefsItem {
62 public: 64 public:
63 KPrefsItemColor(const QString &group,const QString &name,QColor *, 65 KPrefsItemColor(const QString &group,const QString &name,QColor *,
64 const QColor &defaultValue=QColor(128,128,128)); 66 const QColor &defaultValue=QColor(128,128,128));
65 virtual ~KPrefsItemColor() {} 67 virtual ~KPrefsItemColor() {}
66 68
67 void setDefault(); 69 void setDefault();
68 void readConfig(KConfig *); 70 void readConfig(KConfig *);
69 void writeConfig(KConfig *); 71 void writeConfig(KConfig *);
70 72
71 private: 73 private:
72 QColor *mReference; 74 QColor *mReference;
73 QColor mDefault; 75 QColor mDefault;
74}; 76};
75 77
76class KPrefsItemSize : public KPrefsItem { 78class KPrefsItemSize : public KPrefsItem {
77 public: 79 public:
78 KPrefsItemSize(const QString &group,const QString &name,QSize *, 80 KPrefsItemSize(const QString &group,const QString &name,QSize *,
79 const QSize &defaultValue=QSize()); 81 const QSize &defaultValue=QSize());
80 ~KPrefsItemSize() {} 82 ~KPrefsItemSize() {}
81 83
82 void setDefault(); 84 void setDefault();
83 void readConfig(KConfig *); 85 void readConfig(KConfig *);
84 void writeConfig(KConfig *); 86 void writeConfig(KConfig *);
85 87
86 private: 88 private:
87 QSize *mReference; 89 QSize *mReference;
88 QSize mDefault; 90 QSize mDefault;
89}; 91};
90 92
91 93
92class KPrefsItemFont : public KPrefsItem { 94class KPrefsItemFont : public KPrefsItem {
93 public: 95 public:
94 KPrefsItemFont(const QString &group,const QString &name,QFont *, 96 KPrefsItemFont(const QString &group,const QString &name,QFont *,
95 const QFont &defaultValue=QFont("helvetica",12)); 97 const QFont &defaultValue=QFont("helvetica",12));
96 virtual ~KPrefsItemFont() {} 98 virtual ~KPrefsItemFont() {}
97 99
98 void setDefault(); 100 void setDefault();
99 void readConfig(KConfig *); 101 void readConfig(KConfig *);
100 void writeConfig(KConfig *); 102 void writeConfig(KConfig *);
101 103
102 private: 104 private:
103 QFont *mReference; 105 QFont *mReference;
104 QFont mDefault; 106 QFont mDefault;
105}; 107};
106 108
107 109
108class KPrefsItemString : public KPrefsItem { 110class KPrefsItemString : public KPrefsItem {
109 public: 111 public:
110 KPrefsItemString(const QString &group,const QString &name,QString *, 112 KPrefsItemString(const QString &group,const QString &name,QString *,
111 const QString &defaultValue="", bool isPassword=false); 113 const QString &defaultValue="", bool isPassword=false);
112 virtual ~KPrefsItemString() {} 114 virtual ~KPrefsItemString() {}
113 115
114 void setDefault(); 116 void setDefault();
115 void readConfig(KConfig *); 117 void readConfig(KConfig *);
116 void writeConfig(KConfig *); 118 void writeConfig(KConfig *);
117 119
118 private: 120 private:
119 QString *mReference; 121 QString *mReference;
120 QString mDefault; 122 QString mDefault;
121 bool mPassword; 123 bool mPassword;
122}; 124};
123 125
124 126
125class KPrefsItemStringList : public KPrefsItem { 127class KPrefsItemStringList : public KPrefsItem {
126 public: 128 public:
127 KPrefsItemStringList(const QString &group,const QString &name,QStringList *, 129 KPrefsItemStringList(const QString &group,const QString &name,QStringList *,
128 const QStringList &defaultValue=QStringList()); 130 const QStringList &defaultValue=QStringList());
129 virtual ~KPrefsItemStringList() {} 131 virtual ~KPrefsItemStringList() {}
130 132
131 void setDefault(); 133 void setDefault();
132 void readConfig(KConfig *); 134 void readConfig(KConfig *);
133 void writeConfig(KConfig *); 135 void writeConfig(KConfig *);
134 136
135 private: 137 private:
136 QStringList *mReference; 138 QStringList *mReference;
137 QStringList mDefault; 139 QStringList mDefault;
138}; 140};
139 141
140 142
141class KPrefsItemIntList : public KPrefsItem { 143class KPrefsItemIntList : public KPrefsItem {
142 public: 144 public:
143 KPrefsItemIntList(const QString &group,const QString &name,QValueList<int> *, 145 KPrefsItemIntList(const QString &group,const QString &name,Q3ValueList<int> *,
144 const QValueList<int> &defaultValue=QValueList<int>()); 146 const Q3ValueList<int> &defaultValue=Q3ValueList<int>());
145 virtual ~KPrefsItemIntList() {} 147 virtual ~KPrefsItemIntList() {}
146 148
147 void setDefault(); 149 void setDefault();
148 void readConfig(KConfig *); 150 void readConfig(KConfig *);
149 void writeConfig(KConfig *); 151 void writeConfig(KConfig *);
150 152
151 private: 153 private:
152 QValueList<int> *mReference; 154 Q3ValueList<int> *mReference;
153 QValueList<int> mDefault; 155 Q3ValueList<int> mDefault;
154}; 156};
155 157
156 158
157KPrefsItemBool::KPrefsItemBool(const QString &group,const QString &name, 159KPrefsItemBool::KPrefsItemBool(const QString &group,const QString &name,
158 bool *reference,bool defaultValue) : 160 bool *reference,bool defaultValue) :
159 KPrefsItem(group,name) 161 KPrefsItem(group,name)
160{ 162{
161 mReference = reference; 163 mReference = reference;
162 mDefault = defaultValue; 164 mDefault = defaultValue;
163} 165}
164 166
165void KPrefsItemBool::setDefault() 167void KPrefsItemBool::setDefault()
166{ 168{
167 *mReference = mDefault; 169 *mReference = mDefault;
168} 170}
169 171
170void KPrefsItemBool::writeConfig(KConfig *config) 172void KPrefsItemBool::writeConfig(KConfig *config)
171{ 173{
172 config->setGroup(mGroup); 174 config->setGroup(mGroup);
173 config->writeEntry(mName,*mReference); 175 config->writeEntry(mName,*mReference);
174} 176}
175 177
176 178
177void KPrefsItemBool::readConfig(KConfig *config) 179void KPrefsItemBool::readConfig(KConfig *config)
178{ 180{
179 config->setGroup(mGroup); 181 config->setGroup(mGroup);
180 *mReference = config->readBoolEntry(mName,mDefault); 182 *mReference = config->readBoolEntry(mName,mDefault);
181} 183}
182 184
183 185
184KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name, 186KPrefsItemInt::KPrefsItemInt(const QString &group,const QString &name,
185 int *reference,int defaultValue) : 187 int *reference,int defaultValue) :
186 KPrefsItem(group,name) 188 KPrefsItem(group,name)
187{ 189{
188 mReference = reference; 190 mReference = reference;
189 mDefault = defaultValue; 191 mDefault = defaultValue;
190} 192}
191 193
192void KPrefsItemInt::setDefault() 194void KPrefsItemInt::setDefault()
193{ 195{
194 *mReference = mDefault; 196 *mReference = mDefault;
195} 197}
196 198
197void KPrefsItemInt::writeConfig(KConfig *config) 199void KPrefsItemInt::writeConfig(KConfig *config)
198{ 200{
199 config->setGroup(mGroup); 201 config->setGroup(mGroup);
200 config->writeEntry(mName,*mReference); 202 config->writeEntry(mName,*mReference);
201} 203}
202 204
203void KPrefsItemInt::readConfig(KConfig *config) 205void KPrefsItemInt::readConfig(KConfig *config)
204{ 206{
205 config->setGroup(mGroup); 207 config->setGroup(mGroup);
206 *mReference = config->readNumEntry(mName,mDefault); 208 *mReference = config->readNumEntry(mName,mDefault);
207} 209}
208 210
209 211
210KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name, 212KPrefsItemColor::KPrefsItemColor(const QString &group,const QString &name,
211 QColor *reference,const QColor &defaultValue) : 213 QColor *reference,const QColor &defaultValue) :
212 KPrefsItem(group,name) 214 KPrefsItem(group,name)
213{ 215{
214 mReference = reference; 216 mReference = reference;
215 mDefault = defaultValue; 217 mDefault = defaultValue;
216} 218}
217 219
218void KPrefsItemColor::setDefault() 220void KPrefsItemColor::setDefault()
219{ 221{
220 *mReference = mDefault; 222 *mReference = mDefault;
221} 223}
222 224
223void KPrefsItemColor::writeConfig(KConfig *config) 225void KPrefsItemColor::writeConfig(KConfig *config)
224{ 226{
225 config->setGroup(mGroup); 227 config->setGroup(mGroup);
226 config->writeEntry(mName,*mReference); 228 config->writeEntry(mName,*mReference);
227} 229}
228 230
229void KPrefsItemColor::readConfig(KConfig *config) 231void KPrefsItemColor::readConfig(KConfig *config)
230{ 232{
231 config->setGroup(mGroup); 233 config->setGroup(mGroup);
232 *mReference = config->readColorEntry(mName,&mDefault); 234 *mReference = config->readColorEntry(mName,&mDefault);
233 235
234} 236}
235 237
236 238
237KPrefsItemSize::KPrefsItemSize(const QString &group,const QString &name, 239KPrefsItemSize::KPrefsItemSize(const QString &group,const QString &name,
238 QSize *reference,const QSize &defaultValue) : 240 QSize *reference,const QSize &defaultValue) :
239 KPrefsItem(group,name) 241 KPrefsItem(group,name)
240{ 242{
241 mReference = reference; 243 mReference = reference;
242 mDefault = defaultValue; 244 mDefault = defaultValue;
243} 245}
244 246
245void KPrefsItemSize::setDefault() 247void KPrefsItemSize::setDefault()
246{ 248{
247 *mReference = mDefault; 249 *mReference = mDefault;
248} 250}
249 251
250void KPrefsItemSize::writeConfig(KConfig *config) 252void KPrefsItemSize::writeConfig(KConfig *config)
251{ 253{
252 config->setGroup(mGroup); 254 config->setGroup(mGroup);
253 config->writeEntry(mName,*mReference); 255 config->writeEntry(mName,*mReference);
254} 256}
255 257
256void KPrefsItemSize::readConfig(KConfig *config) 258void KPrefsItemSize::readConfig(KConfig *config)
257{ 259{
258 config->setGroup(mGroup); 260 config->setGroup(mGroup);
259 *mReference = config->readSizeEntry(mName,&mDefault); 261 *mReference = config->readSizeEntry(mName,&mDefault);
260 262
261} 263}
262 264
263 265
264KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name, 266KPrefsItemFont::KPrefsItemFont(const QString &group,const QString &name,
265 QFont *reference,const QFont &defaultValue) : 267 QFont *reference,const QFont &defaultValue) :
266 KPrefsItem(group,name) 268 KPrefsItem(group,name)
267{ 269{
268 mReference = reference; 270 mReference = reference;
269 mDefault = defaultValue; 271 mDefault = defaultValue;
270} 272}
271 273
272void KPrefsItemFont::setDefault() 274void KPrefsItemFont::setDefault()
273{ 275{
274 *mReference = mDefault; 276 *mReference = mDefault;
275} 277}
276 278
277void KPrefsItemFont::writeConfig(KConfig *config) 279void KPrefsItemFont::writeConfig(KConfig *config)
278{ 280{
279 config->setGroup(mGroup); 281 config->setGroup(mGroup);
280 config->writeEntry(mName,*mReference); 282 config->writeEntry(mName,*mReference);
281} 283}
282 284
283void KPrefsItemFont::readConfig(KConfig *config) 285void KPrefsItemFont::readConfig(KConfig *config)
284{ 286{
285 config->setGroup(mGroup); 287 config->setGroup(mGroup);
286 *mReference = config->readFontEntry(mName,&mDefault); 288 *mReference = config->readFontEntry(mName,&mDefault);
287} 289}
288 290
289 291
290QString endecryptStr( const QString &aStr ) 292QString endecryptStr( const QString &aStr )
291{ 293{
292 QString result; 294 QString result;
293 uint i; 295 uint i;
294 for ( i = 0; i < aStr.length(); i++) 296 for ( i = 0; i < aStr.length(); i++)
295 result += (aStr.at(i).unicode() < 0x20) ? 297 result += (aStr.at(i).unicode() < 0x20) ?
296 aStr.at(i) : 298 aStr.at(i) :
297 QChar(0x1001F - aStr.at(i).unicode()); 299 QChar(0x1001F - aStr.at(i).unicode());
298 return result; 300 return result;
299} 301}
300 302
301 303
302KPrefsItemString::KPrefsItemString(const QString &group,const QString &name, 304KPrefsItemString::KPrefsItemString(const QString &group,const QString &name,
303 QString *reference,const QString &defaultValue, 305 QString *reference,const QString &defaultValue,
304 bool isPassword) : 306 bool isPassword) :
305 KPrefsItem(group,name) 307 KPrefsItem(group,name)
306{ 308{
307 mReference = reference; 309 mReference = reference;
308 mDefault = defaultValue; 310 mDefault = defaultValue;
309 mPassword = isPassword; 311 mPassword = isPassword;
310} 312}
311 313
312void KPrefsItemString::setDefault() 314void KPrefsItemString::setDefault()
313{ 315{
314 *mReference = mDefault; 316 *mReference = mDefault;
315} 317}
316 318
317void KPrefsItemString::writeConfig(KConfig *config) 319void KPrefsItemString::writeConfig(KConfig *config)
318{ 320{
319 config->setGroup(mGroup); 321 config->setGroup(mGroup);
320 if ( mPassword ) 322 if ( mPassword )
321 config->writeEntry(mName, endecryptStr( *mReference ) ); 323 config->writeEntry(mName, endecryptStr( *mReference ) );
322 else 324 else
323 config->writeEntry(mName,*mReference); 325 config->writeEntry(mName,*mReference);
324} 326}
325 327
326void KPrefsItemString::readConfig(KConfig *config) 328void KPrefsItemString::readConfig(KConfig *config)
327{ 329{
328 config->setGroup(mGroup); 330 config->setGroup(mGroup);
329 331
330 QString value; 332 QString value;
331 if ( mPassword ) { 333 if ( mPassword ) {
332 value = config->readEntry( mName, endecryptStr( mDefault ) ); 334 value = config->readEntry( mName, endecryptStr( mDefault ) );
333 *mReference = endecryptStr( value ); 335 *mReference = endecryptStr( value );
334 } else { 336 } else {
335 *mReference = config->readEntry( mName, mDefault ); 337 *mReference = config->readEntry( mName, mDefault );
336 } 338 }
337} 339}
338 340
339 341
340KPrefsItemStringList::KPrefsItemStringList(const QString &group,const QString &name, 342KPrefsItemStringList::KPrefsItemStringList(const QString &group,const QString &name,
341 QStringList *reference,const QStringList &defaultValue) : 343 QStringList *reference,const QStringList &defaultValue) :
342 KPrefsItem(group,name) 344 KPrefsItem(group,name)
343{ 345{
344 mReference = reference; 346 mReference = reference;
345 mDefault = defaultValue; 347 mDefault = defaultValue;
346} 348}
347 349
348void KPrefsItemStringList::setDefault() 350void KPrefsItemStringList::setDefault()
349{ 351{
350 *mReference = mDefault; 352 *mReference = mDefault;
351} 353}
352 354
353void KPrefsItemStringList::writeConfig(KConfig *config) 355void KPrefsItemStringList::writeConfig(KConfig *config)
354{ 356{
355 config->setGroup(mGroup); 357 config->setGroup(mGroup);
356 config->writeEntry(mName,*mReference); 358 config->writeEntry(mName,*mReference);
357} 359}
358 360
359void KPrefsItemStringList::readConfig(KConfig *config) 361void KPrefsItemStringList::readConfig(KConfig *config)
360{ 362{
361 config->setGroup(mGroup); 363 config->setGroup(mGroup);
362 *mReference = config->readListEntry(mName); 364 *mReference = config->readListEntry(mName);
363} 365}
364 366
365 367
366KPrefsItemIntList::KPrefsItemIntList(const QString &group,const QString &name, 368KPrefsItemIntList::KPrefsItemIntList(const QString &group,const QString &name,
367 QValueList<int> *reference,const QValueList<int> &defaultValue) : 369 Q3ValueList<int> *reference,const Q3ValueList<int> &defaultValue) :
368 KPrefsItem(group,name) 370 KPrefsItem(group,name)
369{ 371{
370 mReference = reference; 372 mReference = reference;
371 mDefault = defaultValue; 373 mDefault = defaultValue;
372} 374}
373 375
374void KPrefsItemIntList::setDefault() 376void KPrefsItemIntList::setDefault()
375{ 377{
376 *mReference = mDefault; 378 *mReference = mDefault;
377} 379}
378 380
379void KPrefsItemIntList::writeConfig(KConfig *config) 381void KPrefsItemIntList::writeConfig(KConfig *config)
380{ 382{
381 config->setGroup(mGroup); 383 config->setGroup(mGroup);
382 config->writeEntry(mName,*mReference); 384 config->writeEntry(mName,*mReference);
383} 385}
384 386
385void KPrefsItemIntList::readConfig(KConfig *config) 387void KPrefsItemIntList::readConfig(KConfig *config)
386{ 388{
387 config->setGroup(mGroup); 389 config->setGroup(mGroup);
388 *mReference = config->readIntListEntry(mName); 390 *mReference = config->readIntListEntry(mName);
389} 391}
390 392
391 393
392QString *KPrefs::mCurrentGroup = 0; 394QString *KPrefs::mCurrentGroup = 0;
393 395
394KPrefs::KPrefs(const QString &configname) 396KPrefs::KPrefs(const QString &configname)
395{ 397{
396 if (!configname.isEmpty()) { 398 if (!configname.isEmpty()) {
397 //qDebug("KPrefs::KPrefs %s",configname.latin1() ); 399 //qDebug("KPrefs::KPrefs %s",configname.latin1() );
398 mConfig = new KConfig(locateLocal("config",configname)); 400 mConfig = new KConfig(locateLocal("config",configname));
399 } else { 401 } else {
400 qDebug("KPrefs::Global config "); 402 qDebug("KPrefs::Global config ");
401 mConfig = KGlobal::config(); 403 mConfig = KGlobal::config();
402 } 404 }
403 405
404 mItems.setAutoDelete(true); 406 mItems.setAutoDelete(true);
405 407
406 // Set default group 408 // Set default group
407 if (mCurrentGroup == 0) mCurrentGroup = new QString("No Group"); 409 if (mCurrentGroup == 0) mCurrentGroup = new QString("No Group");
408} 410}
409 411
410KPrefs::~KPrefs() 412KPrefs::~KPrefs()
411{ 413{
412 if (mConfig != KGlobal::config()) { 414 if (mConfig != KGlobal::config()) {
413 delete mConfig; 415 delete mConfig;
414 } 416 }
415} 417}
416 418
417void KPrefs::setCurrentGroup(const QString &group) 419void KPrefs::setCurrentGroup(const QString &group)
418{ 420{
419 if (mCurrentGroup) delete mCurrentGroup; 421 if (mCurrentGroup) delete mCurrentGroup;
420 mCurrentGroup = new QString(group); 422 mCurrentGroup = new QString(group);
421} 423}
422 424
423KConfig *KPrefs::config() const 425KConfig *KPrefs::config() const
424{ 426{
425 return mConfig; 427 return mConfig;
426} 428}
427 429
428void KPrefs::setDefaults() 430void KPrefs::setDefaults()
429{ 431{
430 KPrefsItem *item; 432 KPrefsItem *item;
431 for(item = mItems.first();item;item = mItems.next()) { 433 for(item = mItems.first();item;item = mItems.next()) {
432 item->setDefault(); 434 item->setDefault();
433 } 435 }
434 436
435 usrSetDefaults(); 437 usrSetDefaults();
436} 438}
437 439
438void KPrefs::readConfig() 440void KPrefs::readConfig()
439{ 441{
440 KPrefsItem *item; 442 KPrefsItem *item;
441 for(item = mItems.first();item;item = mItems.next()) { 443 for(item = mItems.first();item;item = mItems.next()) {
442 item->readConfig(mConfig); 444 item->readConfig(mConfig);
443 } 445 }
444 446
445 usrReadConfig(); 447 usrReadConfig();
446 //qDebug("KPrefs::readConfig: %s", mConfig->getFileName().latin1()); 448 //qDebug("KPrefs::readConfig: %s", mConfig->getFileName().latin1());
447} 449}
448 450
449void KPrefs::writeConfig() 451void KPrefs::writeConfig()
450{ 452{
451 KPrefsItem *item; 453 KPrefsItem *item;
452 for(item = mItems.first();item;item = mItems.next()) { 454 for(item = mItems.first();item;item = mItems.next()) {
453 item->writeConfig(mConfig); 455 item->writeConfig(mConfig);
454 } 456 }
455 457
456 usrWriteConfig(); 458 usrWriteConfig();
457 //qDebug("KPrefs::WriteConfig: %s", mConfig->getFileName().latin1()); 459 //qDebug("KPrefs::WriteConfig: %s", mConfig->getFileName().latin1());
458 mConfig->sync(); 460 mConfig->sync();
459} 461}
460 462
461 463
462void KPrefs::addItem(KPrefsItem *item) 464void KPrefs::addItem(KPrefsItem *item)
463{ 465{
464 mItems.append(item); 466 mItems.append(item);
465} 467}
466 468
467void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue) 469void KPrefs::addItemBool(const QString &key,bool *reference,bool defaultValue)
468{ 470{
469 addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue)); 471 addItem(new KPrefsItemBool(*mCurrentGroup,key,reference,defaultValue));
470} 472}
471 473
472void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue) 474void KPrefs::addItemInt(const QString &key,int *reference,int defaultValue)
473{ 475{
474 addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue)); 476 addItem(new KPrefsItemInt(*mCurrentGroup,key,reference,defaultValue));
475} 477}
476 478
477void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue) 479void KPrefs::addItemColor(const QString &key,QColor *reference,const QColor &defaultValue)
478{ 480{
479 addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue)); 481 addItem(new KPrefsItemColor(*mCurrentGroup,key,reference,defaultValue));
480} 482}
481 483
482void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue) 484void KPrefs::addItemFont(const QString &key,QFont *reference,const QFont &defaultValue)
483{ 485{
484 addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue)); 486 addItem(new KPrefsItemFont(*mCurrentGroup,key,reference,defaultValue));
485} 487}
486 488
487void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue) 489void KPrefs::addItemSize(const QString &key,QSize *reference,const QSize &defaultValue)
488{ 490{
489 addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue)); 491 addItem(new KPrefsItemSize(*mCurrentGroup,key,reference,defaultValue));
490} 492}
491 493
492void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue) 494void KPrefs::addItemString(const QString &key,QString *reference,const QString &defaultValue)
493{ 495{
494 addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false)); 496 addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,false));
495} 497}
496 498
497void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue) 499void KPrefs::addItemPassword(const QString &key,QString *reference,const QString &defaultValue)
498{ 500{
499 addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true)); 501 addItem(new KPrefsItemString(*mCurrentGroup,key,reference,defaultValue,true));
500} 502}
501 503
502void KPrefs::addItemStringList(const QString &key,QStringList *reference, 504void KPrefs::addItemStringList(const QString &key,QStringList *reference,
503 const QStringList &defaultValue) 505 const QStringList &defaultValue)
504{ 506{
505 addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue)); 507 addItem(new KPrefsItemStringList(*mCurrentGroup,key,reference,defaultValue));
506} 508}
507 509
508void KPrefs::addItemIntList(const QString &key,QValueList<int> *reference, 510void KPrefs::addItemIntList(const QString &key,Q3ValueList<int> *reference,
509 const QValueList<int> &defaultValue) 511 const Q3ValueList<int> &defaultValue)
510{ 512{
511 addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue)); 513 addItem(new KPrefsItemIntList(*mCurrentGroup,key,reference,defaultValue));
512} 514}
diff --git a/microkde/kdecore/kprefs.h b/microkde/kdecore/kprefs.h
index 95d2724..d9d1572 100644
--- a/microkde/kdecore/kprefs.h
+++ b/microkde/kdecore/kprefs.h
@@ -1,316 +1,318 @@
1/* 1/*
2 This file is part of KOrganizer. 2 This file is part of KOrganizer.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef _KPREFS_H 20#ifndef _KPREFS_H
21#define _KPREFS_H 21#define _KPREFS_H
22// $Id$ 22// $Id$
23 23
24#include <qptrlist.h> 24#include <q3ptrlist.h>
25#include <qcolor.h> 25#include <qcolor.h>
26#include <qfont.h> 26#include <qfont.h>
27#include <qsize.h> 27#include <qsize.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29//Added by qt3to4:
30#include <Q3ValueList>
29 31
30class KConfig; 32class KConfig;
31 33
32/** 34/**
33 @short Class for storing a preferences setting 35 @short Class for storing a preferences setting
34 @author Cornelius Schumacher 36 @author Cornelius Schumacher
35 @see KPref 37 @see KPref
36 38
37 This class represents one preferences setting as used by @ref KPrefs. 39 This class represents one preferences setting as used by @ref KPrefs.
38 Subclasses of KPrefsItem implement storage functions for a certain type of 40 Subclasses of KPrefsItem implement storage functions for a certain type of
39 setting. Normally you don't have to use this class directly. Use the special 41 setting. Normally you don't have to use this class directly. Use the special
40 addItem() functions of KPrefs instead. If you subclass this class you will 42 addItem() functions of KPrefs instead. If you subclass this class you will
41 have to register instances with the function KPrefs::addItem(). 43 have to register instances with the function KPrefs::addItem().
42*/ 44*/
43class KPrefsItem { 45class KPrefsItem {
44 public: 46 public:
45 /** 47 /**
46 Constructor. 48 Constructor.
47 49
48 @param group Config file group. 50 @param group Config file group.
49 @param name Config file key. 51 @param name Config file key.
50 */ 52 */
51 KPrefsItem(const QString &group,const QString &name) : 53 KPrefsItem(const QString &group,const QString &name) :
52 mGroup(group),mName(name) {} 54 mGroup(group),mName(name) {}
53 /** 55 /**
54 Destructor. 56 Destructor.
55 */ 57 */
56 virtual ~KPrefsItem() {} 58 virtual ~KPrefsItem() {}
57 59
58 /** 60 /**
59 This function is called by @ref KPrefs to set this setting to its default 61 This function is called by @ref KPrefs to set this setting to its default
60 value. 62 value.
61 */ 63 */
62 virtual void setDefault() = 0; 64 virtual void setDefault() = 0;
63 /** 65 /**
64 This function is called by @ref KPrefs to read the value for this setting 66 This function is called by @ref KPrefs to read the value for this setting
65 from a config file. 67 from a config file.
66 value. 68 value.
67 */ 69 */
68 virtual void readConfig(KConfig *) = 0; 70 virtual void readConfig(KConfig *) = 0;
69 /** 71 /**
70 This function is called by @ref KPrefs to write the value of this setting 72 This function is called by @ref KPrefs to write the value of this setting
71 to a config file. 73 to a config file.
72 */ 74 */
73 virtual void writeConfig(KConfig *) = 0; 75 virtual void writeConfig(KConfig *) = 0;
74 76
75 protected: 77 protected:
76 QString mGroup; 78 QString mGroup;
77 QString mName; 79 QString mName;
78}; 80};
79 81
80/** 82/**
81 @short Class for handling preferences settings for an application. 83 @short Class for handling preferences settings for an application.
82 @author Cornelius Schumacher 84 @author Cornelius Schumacher
83 @see KPrefsItem 85 @see KPrefsItem
84 86
85 This class provides an interface to preferences settings. Preferences items 87 This class provides an interface to preferences settings. Preferences items
86 can be registered by the addItem() function corresponding to the data type of 88 can be registered by the addItem() function corresponding to the data type of
87 the seetting. KPrefs then handles reading and writing of config files and 89 the seetting. KPrefs then handles reading and writing of config files and
88 setting of default values. 90 setting of default values.
89 91
90 Normally you will subclass KPrefs, add data members for the preferences 92 Normally you will subclass KPrefs, add data members for the preferences
91 settings and register the members in the constructor of the subclass. 93 settings and register the members in the constructor of the subclass.
92 94
93 Example: 95 Example:
94 <pre> 96 <pre>
95 class MyPrefs : public KPrefs { 97 class MyPrefs : public KPrefs {
96 public: 98 public:
97 MyPrefs() 99 MyPrefs()
98 { 100 {
99 setCurrentGroup("MyGroup"); 101 setCurrentGroup("MyGroup");
100 addItemBool("MySetting1",&mMyBool,false); 102 addItemBool("MySetting1",&mMyBool,false);
101 addItemColor("MySetting2",&mMyColor,QColor(1,2,3)); 103 addItemColor("MySetting2",&mMyColor,QColor(1,2,3));
102 104
103 setCurrentGroup("MyOtherGroup"); 105 setCurrentGroup("MyOtherGroup");
104 addItemFont("MySetting3",&mMyFont,QFont("helvetica",12)); 106 addItemFont("MySetting3",&mMyFont,QFont("helvetica",12));
105 } 107 }
106 108
107 bool mMyBool; 109 bool mMyBool;
108 QColor mMyColor; 110 QColor mMyColor;
109 QFont mMyFont; 111 QFont mMyFont;
110 } 112 }
111 </pre> 113 </pre>
112 114
113 It might be convenient in many cases to make this subclass of KPrefs a 115 It might be convenient in many cases to make this subclass of KPrefs a
114 singleton for global access from all over the application without passing 116 singleton for global access from all over the application without passing
115 references to the KPrefs object around. 117 references to the KPrefs object around.
116 118
117 You can set all values to default values by calling @ref setDefaults(), write 119 You can set all values to default values by calling @ref setDefaults(), write
118 the data to the configuration file by calling @ref writeConfig() and read the 120 the data to the configuration file by calling @ref writeConfig() and read the
119 data from the configuration file by calling @ref readConfig(). 121 data from the configuration file by calling @ref readConfig().
120 122
121 If you have items, which are not covered by the existing addItem() functions 123 If you have items, which are not covered by the existing addItem() functions
122 you can add customized code for reading, writing and default setting by 124 you can add customized code for reading, writing and default setting by
123 implementing the functions @ref usrSetDefaults(), @ref usrReadConfig() and 125 implementing the functions @ref usrSetDefaults(), @ref usrReadConfig() and
124 @ref usrWriteConfig(). 126 @ref usrWriteConfig().
125 127
126 Internally preferences settings are stored in instances of subclasses of 128 Internally preferences settings are stored in instances of subclasses of
127 @ref KPrefsItem. You can also add KPrefsItem subclasses for your own types 129 @ref KPrefsItem. You can also add KPrefsItem subclasses for your own types
128 and call the generic @ref addItem() to register them. 130 and call the generic @ref addItem() to register them.
129*/ 131*/
130 132
131class KPrefs { 133class KPrefs {
132 public: 134 public:
133 /** 135 /**
134 Constructor. 136 Constructor.
135 137
136 @param configname name of config file. If no name is given, the default 138 @param configname name of config file. If no name is given, the default
137 config file as returned by kapp()->config() is used. 139 config file as returned by kapp()->config() is used.
138 */ 140 */
139 KPrefs(const QString &configname=QString::null); 141 KPrefs(const QString &configname=QString::null);
140 /** 142 /**
141 Destructor 143 Destructor
142 */ 144 */
143 virtual ~KPrefs(); 145 virtual ~KPrefs();
144 146
145 /** 147 /**
146 Set preferences to default values. All registered items are set to their 148 Set preferences to default values. All registered items are set to their
147 default values. 149 default values.
148 */ 150 */
149 void setDefaults(); 151 void setDefaults();
150 152
151 /** 153 /**
152 Read preferences from config file. All registered items are set to the 154 Read preferences from config file. All registered items are set to the
153 values read from disk. 155 values read from disk.
154 */ 156 */
155 void readConfig(); 157 void readConfig();
156 158
157 /** 159 /**
158 Write preferences to config file. The values of all registered items are 160 Write preferences to config file. The values of all registered items are
159 written to disk. 161 written to disk.
160 */ 162 */
161 void writeConfig(); 163 void writeConfig();
162 164
163 /** 165 /**
164 Set the config file group for subsequent addItem() calls. It is valid 166 Set the config file group for subsequent addItem() calls. It is valid
165 until setCurrentGroup() is called with a new argument. Call this before 167 until setCurrentGroup() is called with a new argument. Call this before
166 you add any items. The default value is "No Group". 168 you add any items. The default value is "No Group".
167 */ 169 */
168 static void setCurrentGroup(const QString &group); 170 static void setCurrentGroup(const QString &group);
169 171
170 /** 172 /**
171 Register a custom @ref KPrefsItem. 173 Register a custom @ref KPrefsItem.
172 */ 174 */
173 void addItem(KPrefsItem *); 175 void addItem(KPrefsItem *);
174 176
175 /** 177 /**
176 Register an item of type bool. 178 Register an item of type bool.
177 179
178 @param key Key used in config file. 180 @param key Key used in config file.
179 @param reference Pointer to the variable, which is set by readConfig() 181 @param reference Pointer to the variable, which is set by readConfig()
180 and setDefaults() calls and read by writeConfig() calls. 182 and setDefaults() calls and read by writeConfig() calls.
181 @param defaultValue Default value, which is used by setDefaults() and 183 @param defaultValue Default value, which is used by setDefaults() and
182 when the config file does not yet contain the key of 184 when the config file does not yet contain the key of
183 this item. 185 this item.
184 */ 186 */
185 void addItemBool(const QString &key,bool *reference, 187 void addItemBool(const QString &key,bool *reference,
186 bool defaultValue=false); 188 bool defaultValue=false);
187 /** 189 /**
188 Register an item of type int. 190 Register an item of type int.
189 191
190 @param key Key used in config file. 192 @param key Key used in config file.
191 @param reference Pointer to the variable, which is set by readConfig() 193 @param reference Pointer to the variable, which is set by readConfig()
192 and setDefaults() calls and read by writeConfig() calls. 194 and setDefaults() calls and read by writeConfig() calls.
193 @param defaultValue Default value, which is used by setDefaults() and 195 @param defaultValue Default value, which is used by setDefaults() and
194 when the config file does not yet contain the key of 196 when the config file does not yet contain the key of
195 this item. 197 this item.
196 */ 198 */
197 void addItemInt(const QString &key,int *reference, 199 void addItemInt(const QString &key,int *reference,
198 int defaultValue=0); 200 int defaultValue=0);
199 /** 201 /**
200 Register an item of type QColor. 202 Register an item of type QColor.
201 203
202 @param key Key used in config file. 204 @param key Key used in config file.
203 @param reference Pointer to the variable, which is set by readConfig() 205 @param reference Pointer to the variable, which is set by readConfig()
204 and setDefaults() calls and read by writeConfig() calls. 206 and setDefaults() calls and read by writeConfig() calls.
205 @param defaultValue Default value, which is used by setDefaults() and 207 @param defaultValue Default value, which is used by setDefaults() and
206 when the config file does not yet contain the key of 208 when the config file does not yet contain the key of
207 this item. 209 this item.
208 */ 210 */
209 void addItemColor(const QString &key,QColor *reference, 211 void addItemColor(const QString &key,QColor *reference,
210 const QColor &defaultValue=QColor(128,128,128)); 212 const QColor &defaultValue=QColor(128,128,128));
211 213
212 /** 214 /**
213 Register an item of type QSize. 215 Register an item of type QSize.
214 216
215 @param key Key used in config file. 217 @param key Key used in config file.
216 @param reference Pointer to the variable, which is set by readConfig() 218 @param reference Pointer to the variable, which is set by readConfig()
217 and setDefaults() calls and read by writeConfig() calls. 219 and setDefaults() calls and read by writeConfig() calls.
218 @param defaultValue Default value, which is used by setDefaults() and 220 @param defaultValue Default value, which is used by setDefaults() and
219 when the config file does not yet contain the key of 221 when the config file does not yet contain the key of
220 this item. 222 this item.
221 */ 223 */
222 void addItemSize(const QString &key,QSize *reference, 224 void addItemSize(const QString &key,QSize *reference,
223 const QSize &defaultValue=QSize()); 225 const QSize &defaultValue=QSize());
224 226
225 /** 227 /**
226 Register an item of type QFont. 228 Register an item of type QFont.
227 229
228 @param key Key used in config file. 230 @param key Key used in config file.
229 @param reference Pointer to the variable, which is set by readConfig() 231 @param reference Pointer to the variable, which is set by readConfig()
230 and setDefaults() calls and read by writeConfig() calls. 232 and setDefaults() calls and read by writeConfig() calls.
231 @param defaultValue Default value, which is used by setDefaults() and 233 @param defaultValue Default value, which is used by setDefaults() and
232 when the config file does not yet contain the key of 234 when the config file does not yet contain the key of
233 this item. 235 this item.
234 */ 236 */
235 void addItemFont(const QString &key,QFont *reference, 237 void addItemFont(const QString &key,QFont *reference,
236 const QFont &defaultValue=QFont("helvetica",12)); 238 const QFont &defaultValue=QFont("helvetica",12));
237 /** 239 /**
238 Register an item of type QString. 240 Register an item of type QString.
239 241
240 @param key Key used in config file. 242 @param key Key used in config file.
241 @param reference Pointer to the variable, which is set by readConfig() 243 @param reference Pointer to the variable, which is set by readConfig()
242 and setDefaults() calls and read by writeConfig() calls. 244 and setDefaults() calls and read by writeConfig() calls.
243 @param defaultValue Default value, which is used by setDefaults() and 245 @param defaultValue Default value, which is used by setDefaults() and
244 when the config file does not yet contain the key of 246 when the config file does not yet contain the key of
245 this item. 247 this item.
246 */ 248 */
247 void addItemString(const QString &key,QString *reference, 249 void addItemString(const QString &key,QString *reference,
248 const QString &defaultValue=""); 250 const QString &defaultValue="");
249 /** 251 /**
250 Register a password item of type QString. The string value is written 252 Register a password item of type QString. The string value is written
251 encrypted to the config file. Note that the current encryption scheme 253 encrypted to the config file. Note that the current encryption scheme
252 is very weak. 254 is very weak.
253 255
254 @param key Key used in config file. 256 @param key Key used in config file.
255 @param reference Pointer to the variable, which is set by readConfig() 257 @param reference Pointer to the variable, which is set by readConfig()
256 and setDefaults() calls and read by writeConfig() calls. 258 and setDefaults() calls and read by writeConfig() calls.
257 @param defaultValue Default value, which is used by setDefaults() and 259 @param defaultValue Default value, which is used by setDefaults() and
258 when the config file does not yet contain the key of 260 when the config file does not yet contain the key of
259 this item. 261 this item.
260 */ 262 */
261 void addItemPassword(const QString &key,QString *reference, 263 void addItemPassword(const QString &key,QString *reference,
262 const QString &defaultValue=""); 264 const QString &defaultValue="");
263 /** 265 /**
264 Register an item of type QStringList. 266 Register an item of type QStringList.
265 267
266 @param key Key used in config file. 268 @param key Key used in config file.
267 @param reference Pointer to the variable, which is set by readConfig() 269 @param reference Pointer to the variable, which is set by readConfig()
268 and setDefaults() calls and read by writeConfig() calls. 270 and setDefaults() calls and read by writeConfig() calls.
269 @param defaultValue Default value, which is used by setDefaults() and 271 @param defaultValue Default value, which is used by setDefaults() and
270 when the config file does not yet contain the key of 272 when the config file does not yet contain the key of
271 this item. 273 this item.
272 */ 274 */
273 void addItemStringList(const QString &key,QStringList *reference, 275 void addItemStringList(const QString &key,QStringList *reference,
274 const QStringList &defaultValue=QStringList()); 276 const QStringList &defaultValue=QStringList());
275 277
276 /** 278 /**
277 Register an item of type QValueList<int>. 279 Register an item of type QValueList<int>.
278 280
279 @param key Key used in config file. 281 @param key Key used in config file.
280 @param reference Pointer to the variable, which is set by readConfig() 282 @param reference Pointer to the variable, which is set by readConfig()
281 and setDefaults() calls and read by writeConfig() calls. 283 and setDefaults() calls and read by writeConfig() calls.
282 @param defaultValue Default value, which is used by setDefaults() and 284 @param defaultValue Default value, which is used by setDefaults() and
283 when the config file does not yet contain the key of 285 when the config file does not yet contain the key of
284 this item. 286 this item.
285 */ 287 */
286 void addItemIntList(const QString &key,QValueList<int> *reference, 288 void addItemIntList(const QString &key,Q3ValueList<int> *reference,
287 const QValueList<int> &defaultValue=QValueList<int>()); 289 const Q3ValueList<int> &defaultValue=Q3ValueList<int>());
288 290
289 protected: 291 protected:
290 /** 292 /**
291 Implemented by subclasses that use special defaults. 293 Implemented by subclasses that use special defaults.
292 */ 294 */
293 virtual void usrSetDefaults() {}; 295 virtual void usrSetDefaults() {};
294 /** 296 /**
295 Implemented by subclasses that read special config values. 297 Implemented by subclasses that read special config values.
296 */ 298 */
297 virtual void usrReadConfig() {}; 299 virtual void usrReadConfig() {};
298 /** 300 /**
299 Implemented by subclasses that write special config values. 301 Implemented by subclasses that write special config values.
300 */ 302 */
301 virtual void usrWriteConfig() {}; 303 virtual void usrWriteConfig() {};
302 304
303 /** 305 /**
304 Return the @ref KConfig object used for reading and writing the settings. 306 Return the @ref KConfig object used for reading and writing the settings.
305 */ 307 */
306 KConfig *config() const; 308 KConfig *config() const;
307 309
308 private: 310 private:
309 static QString *mCurrentGroup; 311 static QString *mCurrentGroup;
310 312
311 KConfig *mConfig; // pointer to KConfig object 313 KConfig *mConfig; // pointer to KConfig object
312 314
313 QPtrList<KPrefsItem> mItems; 315 Q3PtrList<KPrefsItem> mItems;
314}; 316};
315 317
316#endif 318#endif
diff --git a/microkde/kdecore/kshortcut.h b/microkde/kdecore/kshortcut.h
index 4813734..244d590 100644
--- a/microkde/kdecore/kshortcut.h
+++ b/microkde/kdecore/kshortcut.h
@@ -182,665 +182,665 @@ class KKey
182 182
183 /** 183 /**
184 * @internal 184 * @internal
185 */ 185 */
186 //USbool isValidNative() const; 186 //USbool isValidNative() const;
187 187
188 /** 188 /**
189 * @internal 189 * @internal
190 */ 190 */
191 //USuint sym() const; 191 //USuint sym() const;
192 /** 192 /**
193 * @internal 193 * @internal
194 */ 194 */
195 //USuint modFlags() const; 195 //USuint modFlags() const;
196 196
197 // Comparison Methods 197 // Comparison Methods
198 /** 198 /**
199 * Compares this key with the given KKey object. Returns a negative 199 * Compares this key with the given KKey object. Returns a negative
200 * number if the given KKey is larger, 0 if they are equal and 200 * number if the given KKey is larger, 0 if they are equal and
201 * a positive number this KKey is larger. The returned value 201 * a positive number this KKey is larger. The returned value
202 * is the difference between the symbol or, if the symbols 202 * is the difference between the symbol or, if the symbols
203 * are equal, the difference between the encoded modifiers. 203 * are equal, the difference between the encoded modifiers.
204 * @param key the key to compare with this key 204 * @param key the key to compare with this key
205 * @return a negative number if the given KKey is larger, 0 if 205 * @return a negative number if the given KKey is larger, 0 if
206 * they are equal and a positive number this KKey is larger 206 * they are equal and a positive number this KKey is larger
207 */ 207 */
208 //USint compare( const KKey& key ) const; 208 //USint compare( const KKey& key ) const;
209 209
210 /** 210 /**
211 * Compares the symbol and modifiers of both keys. 211 * Compares the symbol and modifiers of both keys.
212 * @see compare() 212 * @see compare()
213 */ 213 */
214 //USbool operator == ( const KKey& key ) const 214 //USbool operator == ( const KKey& key ) const
215 //US { return compare( key ) == 0; } 215 //US { return compare( key ) == 0; }
216 /** 216 /**
217 * Compares the symbol and modifiers of both keys. 217 * Compares the symbol and modifiers of both keys.
218 * @see compare() 218 * @see compare()
219 */ 219 */
220 //USbool operator != ( const KKey& key ) const 220 //USbool operator != ( const KKey& key ) const
221 //US { return compare( key ) != 0; } 221 //US { return compare( key ) != 0; }
222 /** 222 /**
223 * Compares the symbol and modifiers of both keys. 223 * Compares the symbol and modifiers of both keys.
224 * @see compare() 224 * @see compare()
225 */ 225 */
226 //USbool operator < ( const KKey& key ) const 226 //USbool operator < ( const KKey& key ) const
227 //US { return compare( key ) < 0; } 227 //US { return compare( key ) < 0; }
228 228
229 // Conversion methods. 229 // Conversion methods.
230 /** 230 /**
231 * Returns the qt key code. 231 * Returns the qt key code.
232 * @return the qt key code or 0 if there is no key set. 232 * @return the qt key code or 0 if there is no key set.
233 * @see Qt::Key 233 * @see Qt::Key
234 */ 234 */
235 //USint keyCodeQt() const; 235 //USint keyCodeQt() const;
236 236
237 /** 237 /**
238 * Returns a human-readable representation of the key in the form 238 * Returns a human-readable representation of the key in the form
239 * "modifier+key". 239 * "modifier+key".
240 * @return the string representation of the key 240 * @return the string representation of the key
241 */ 241 */
242 //USQString toString() const; 242 //USQString toString() const;
243 243
244 /** 244 /**
245 * @internal 245 * @internal
246 */ 246 */
247//US QString toStringInternal() const; 247//US QString toStringInternal() const;
248 248
249 // Operation methods 249 // Operation methods
250 /** 250 /**
251 * @internal 251 * @internal
252 */ 252 */
253 //USvoid simplify(); 253 //USvoid simplify();
254 254
255 /** 255 /**
256 * Returns a null key. 256 * Returns a null key.
257 * @return the null key 257 * @return the null key
258 * @see isNull() 258 * @see isNull()
259 * @see clear() 259 * @see clear()
260 */ 260 */
261 //USstatic KKey& null(); 261 //USstatic KKey& null();
262 262
263 /** 263 /**
264 * Returns a user-readable representation of the given modifiers. 264 * Returns a user-readable representation of the given modifiers.
265 * @param f the modifiers to convert 265 * @param f the modifiers to convert
266 * @return the string representation of the modifiers 266 * @return the string representation of the modifiers
267 */ 267 */
268 //USstatic QString modFlagLabel( ModFlag f ); 268 //USstatic QString modFlagLabel( ModFlag f );
269 269
270//US private: 270//US private:
271 /* 271 /*
272 * Under X11, m_key will hold an X11 key symbol. 272 * Under X11, m_key will hold an X11 key symbol.
273 * For Qt/Embedded, it will hold the Qt key code. 273 * For Qt/Embedded, it will hold the Qt key code.
274 */ 274 */
275 /** 275 /**
276 * Returns the native key symbol value key. Under X11, this is the X 276 * Returns the native key symbol value key. Under X11, this is the X
277 * keycode. Under Qt/Embedded, this is the Qt keycode. 277 * keycode. Under Qt/Embedded, this is the Qt keycode.
278 * @see /usr/include/X11/keysymdef.h 278 * @see /usr/include/X11/keysymdef.h
279 * @see qnamespace.h 279 * @see qnamespace.h
280 */ 280 */
281 //USuint m_sym; 281 //USuint m_sym;
282 /** 282 /**
283 * m_mod holds the 283 * m_mod holds the
284 */ 284 */
285 //USuint m_mod; 285 //USuint m_mod;
286 286
287//US private: 287//US private:
288 //USfriend class KKeyNative; 288 //USfriend class KKeyNative;
289//US}; 289//US};
290 290
291/** 291/**
292* A KKeySequence object holds a sequence of up to 4 keys. 292* A KKeySequence object holds a sequence of up to 4 keys.
293* Ex: Ctrl+X,I 293* Ex: Ctrl+X,I
294* @see KKey 294* @see KKey
295* @see KShortcut 295* @see KShortcut
296*/ 296*/
297 297
298//USclass KKeySequence 298//USclass KKeySequence
299//US{ 299//US{
300//US public: 300//US public:
301 /// Defines the maximum length of the key sequence 301 /// Defines the maximum length of the key sequence
302//US enum { MAX_KEYS = 4 }; 302//US enum { MAX_KEYS = 4 };
303 303
304 /** 304 /**
305 * Create a new null key sequence. 305 * Create a new null key sequence.
306 * @see isNull() 306 * @see isNull()
307 * @see null() 307 * @see null()
308 * @see clear() 308 * @see clear()
309 */ 309 */
310 //USKKeySequence(); 310 //USKKeySequence();
311 311
312 /** 312 /**
313 * Copies the given qt key sequence. 313 * Copies the given qt key sequence.
314 * @param keySeq the qt key sequence to copy 314 * @param keySeq the qt key sequence to copy
315 */ 315 */
316 //USKKeySequence( const QKeySequence& keySeq ); 316 //USKKeySequence( const QKeySequence& keySeq );
317 317
318 /** 318 /**
319 * Create a new key sequence that only contains the given key. 319 * Create a new key sequence that only contains the given key.
320 * @param key the key to add 320 * @param key the key to add
321 */ 321 */
322 //USKKeySequence( const KKey& key ); 322 //USKKeySequence( const KKey& key );
323 323
324 /** 324 /**
325 * Create a new key sequence that only contains the given key. 325 * Create a new key sequence that only contains the given key.
326 * @param key the key to add 326 * @param key the key to add
327 */ 327 */
328 //USKKeySequence( const KKeyNative& key ); 328 //USKKeySequence( const KKeyNative& key );
329 329
330 /** 330 /**
331 * Copies the given key sequence. 331 * Copies the given key sequence.
332 * @param keySeq the key sequence to copy 332 * @param keySeq the key sequence to copy
333 */ 333 */
334 //USKKeySequence( const KKeySequence& keySeq ); 334 //USKKeySequence( const KKeySequence& keySeq );
335 335
336 /** 336 /**
337 * Creates a new key sequence that contains the given key sequence. 337 * Creates a new key sequence that contains the given key sequence.
338 * The description consists of comma-separated keys as 338 * The description consists of comma-separated keys as
339 * required by @ref KKey::KKey(const QString&). 339 * required by @ref KKey::KKey(const QString&).
340 * @param keySeq the description of the key 340 * @param keySeq the description of the key
341 * @see KKeyServer::Sym::init() 341 * @see KKeyServer::Sym::init()
342 * @see KKey::KKey(const QString&) 342 * @see KKey::KKey(const QString&)
343 */ 343 */
344 //USKKeySequence( const QString& keySeq ); 344 //USKKeySequence( const QString& keySeq );
345 345
346 //US~KKeySequence(); 346 //US~KKeySequence();
347 347
348 /** 348 /**
349 * Clears the key sequence. The key sequence is null after calling this 349 * Clears the key sequence. The key sequence is null after calling this
350 * function. 350 * function.
351 * @see isNull() 351 * @see isNull()
352 */ 352 */
353 //USvoid clear(); 353 //USvoid clear();
354 354
355 /** 355 /**
356 * Copies the given qt key sequence over this key sequence. 356 * Copies the given qt key sequence over this key sequence.
357 * @param keySeq the qt key sequence to copy 357 * @param keySeq the qt key sequence to copy
358 * @return true if successful, false otherwise 358 * @return true if successful, false otherwise
359 */ 359 */
360 //USbool init( const QKeySequence& keySeq ); 360 //USbool init( const QKeySequence& keySeq );
361 361
362 /** 362 /**
363 * Initializes the key sequence to only contain the given key. 363 * Initializes the key sequence to only contain the given key.
364 * @param key the key to set 364 * @param key the key to set
365 * @return true if successful, false otherwise 365 * @return true if successful, false otherwise
366 */ 366 */
367 //USbool init( const KKey& key ); 367 //USbool init( const KKey& key );
368 368
369 /** 369 /**
370 * Initializes the key sequence to only contain the given key. 370 * Initializes the key sequence to only contain the given key.
371 * @param key the key to set 371 * @param key the key to set
372 * @return true if successful, false otherwise 372 * @return true if successful, false otherwise
373 */ 373 */
374 //USbool init( const KKeyNative& key ); 374 //USbool init( const KKeyNative& key );
375 375
376 /** 376 /**
377 * Copies the given key sequence over this key sequence. 377 * Copies the given key sequence over this key sequence.
378 * @param keySeq the key sequence to copy 378 * @param keySeq the key sequence to copy
379 * @return true if successful, false otherwise 379 * @return true if successful, false otherwise
380 */ 380 */
381 //USbool init( const KKeySequence& keySeq ); 381 //USbool init( const KKeySequence& keySeq );
382 382
383 /** 383 /**
384 * Initializes this key sequence to contain the given key sequence. 384 * Initializes this key sequence to contain the given key sequence.
385 * The description consists of comma-separated keys as 385 * The description consists of comma-separated keys as
386 * required by @ref KKey::KKey(const QString&). 386 * required by @ref KKey::KKey(const QString&).
387 * @param key the description of the key 387 * @param key the description of the key
388 * @return true if successful, false otherwise 388 * @return true if successful, false otherwise
389 * @see KKeyServer::Sym::init() 389 * @see KKeyServer::Sym::init()
390 * @see KKey::KKey(const QString&) 390 * @see KKey::KKey(const QString&)
391 */ 391 */
392 //USbool init( const QString& key ); 392 //USbool init( const QString& key );
393 393
394 /** 394 /**
395 * Copy the given key sequence into this sequence. 395 * Copy the given key sequence into this sequence.
396 */ 396 */
397 //USKKeySequence& operator =( const KKeySequence& seq ) 397 //USKKeySequence& operator =( const KKeySequence& seq )
398 //US { init( seq ); return *this; } 398 //US { init( seq ); return *this; }
399 399
400 /** 400 /**
401 * Returns the number of key strokes of this sequence. 401 * Returns the number of key strokes of this sequence.
402 * @return the number of key strokes 402 * @return the number of key strokes
403 * @see MAX_KEYS 403 * @see MAX_KEYS
404 */ 404 */
405 //USuint count() const; 405 //USuint count() const;
406 406
407 /** 407 /**
408 * Return the @p i'th key of this sequence, or a null key if there 408 * Return the @p i'th key of this sequence, or a null key if there
409 * are less then i keys. 409 * are less then i keys.
410 * @param i the key to retrieve 410 * @param i the key to retrieve
411 * @return the @p i'th key, or @ref KKey::null() if there are less 411 * @return the @p i'th key, or @ref KKey::null() if there are less
412 * than i keys 412 * than i keys
413 * @see MAX_KEYS 413 * @see MAX_KEYS
414 */ 414 */
415 //USconst KKey& key( uint i ) const; 415 //USconst KKey& key( uint i ) const;
416 416
417 /** 417 /**
418 * @internal 418 * @internal
419 */ 419 */
420 //USbool isTriggerOnRelease() const; 420 //USbool isTriggerOnRelease() const;
421 421
422 /** 422 /**
423 * Sets the @p i'th key of the sequence. You can not introduce gaps 423 * Sets the @p i'th key of the sequence. You can not introduce gaps
424 * in a sequence, so you must use an @p i <= @ref count(). Also note that 424 * in a sequence, so you must use an @p i <= @ref count(). Also note that
425 * the maximum length of a key sequence is @ref MAX_KEYS. 425 * the maximum length of a key sequence is @ref MAX_KEYS.
426 * @param i the position of the new key (<= @ref count(), <= @ref MAX_KEYS) 426 * @param i the position of the new key (<= @ref count(), <= @ref MAX_KEYS)
427 * @param key the key to set 427 * @param key the key to set
428 * @return true if successful, false otherwise 428 * @return true if successful, false otherwise
429 */ 429 */
430 //USbool setKey( uint i, const KKey& key ); 430 //USbool setKey( uint i, const KKey& key );
431 431
432 /** 432 /**
433 * @internal 433 * @internal
434 */ 434 */
435 //USvoid setTriggerOnRelease( bool ); 435 //USvoid setTriggerOnRelease( bool );
436 436
437 /** 437 /**
438 * Returns true if the key sequence is null (after @ref clear() or empty 438 * Returns true if the key sequence is null (after @ref clear() or empty
439 * constructor). 439 * constructor).
440 * @return true if the key sequence is null 440 * @return true if the key sequence is null
441 * @see clear() 441 * @see clear()
442 * @see null() 442 * @see null()
443 */ 443 */
444//US bool isNull() const; 444//US bool isNull() const;
445 445
446 /** 446 /**
447 * Returns true if this key sequence begins with the given sequence. 447 * Returns true if this key sequence begins with the given sequence.
448 * @param keySeq the key sequence to search 448 * @param keySeq the key sequence to search
449 * @return true if this key sequence begins with the given sequence 449 * @return true if this key sequence begins with the given sequence
450 */ 450 */
451 //USbool startsWith( const KKeySequence& keySeq ) const; 451 //USbool startsWith( const KKeySequence& keySeq ) const;
452 452
453 /** 453 /**
454 * Compares this object with the given key sequence. Returns a negative 454 * Compares this object with the given key sequence. Returns a negative
455 * number if the given KKeySequence is larger, 0 if they are equal and 455 * number if the given KKeySequence is larger, 0 if they are equal and
456 * a positive number this KKeySequence is larger. Key sequences are 456 * a positive number this KKeySequence is larger. Key sequences are
457 * compared by comparing the individual keys, starting from the beginning 457 * compared by comparing the individual keys, starting from the beginning
458 * until an unequal key has been found. If a sequence contains more 458 * until an unequal key has been found. If a sequence contains more
459 * keys, it is considered larger. 459 * keys, it is considered larger.
460 * @param keySeq the key sequence to compare to 460 * @param keySeq the key sequence to compare to
461 * @return a negative number if the given KKeySequence is larger, 0 if 461 * @return a negative number if the given KKeySequence is larger, 0 if
462 * they are equal and a positive number this KKeySequence is larger 462 * they are equal and a positive number this KKeySequence is larger
463 * @see KKey::sequence 463 * @see KKey::sequence
464 */ 464 */
465 //USint compare( const KKeySequence& keySeq ) const; 465 //USint compare( const KKeySequence& keySeq ) const;
466 466
467 /** 467 /**
468 * Compares the keys of both sequences. 468 * Compares the keys of both sequences.
469 * @see compare() 469 * @see compare()
470 */ 470 */
471 //USbool operator == ( const KKeySequence& seq ) const 471 //USbool operator == ( const KKeySequence& seq ) const
472 //US { return compare( seq ) == 0; } 472 //US { return compare( seq ) == 0; }
473 473
474 /** 474 /**
475 * Compares the keys of both sequences. 475 * Compares the keys of both sequences.
476 * @see compare() 476 * @see compare()
477 */ 477 */
478 //USbool operator != ( const KKeySequence& seq ) const 478 //USbool operator != ( const KKeySequence& seq ) const
479 //US { return compare( seq ) != 0; } 479 //US { return compare( seq ) != 0; }
480 480
481 /** 481 /**
482 * Compares the keys of both sequences. 482 * Compares the keys of both sequences.
483 * @see compare() 483 * @see compare()
484 */ 484 */
485 //USbool operator < ( const KKeySequence& seq ) const 485 //USbool operator < ( const KKeySequence& seq ) const
486 //US { return compare( seq ) < 0; } 486 //US { return compare( seq ) < 0; }
487 // TODO: consider adding Qt::SequenceMatch matches(...) methods for QKeySequence equivalence 487 // TODO: consider adding Qt::SequenceMatch matches(...) methods for QKeySequence equivalence
488 488
489 /** 489 /**
490 * Converts this key sequence to a QKeySequence. 490 * Converts this key sequence to a QKeySequence.
491 * @return the QKeySequence 491 * @return the QKeySequence
492 */ 492 */
493 //USQKeySequence qt() const; 493 //USQKeySequence qt() const;
494 494
495 /** 495 /**
496 * Returns the qt key code of the first key. 496 * Returns the qt key code of the first key.
497 * @return the qt key code of the first key 497 * @return the qt key code of the first key
498 * @see Qt::Key 498 * @see Qt::Key
499 * @see KKey::keyCodeQt() 499 * @see KKey::keyCodeQt()
500 */ 500 */
501 //USint keyCodeQt() const; 501 //USint keyCodeQt() const;
502 502
503 /** 503 /**
504 * Returns the key sequence as a number of key presses as 504 * Returns the key sequence as a number of key presses as
505 * returned by @ref KKey::toString(), seperated by commas. 505 * returned by @ref KKey::toString(), seperated by commas.
506 * @return the string represenation of this key sequence 506 * @return the string represenation of this key sequence
507 * @see KKey::toString() 507 * @see KKey::toString()
508 */ 508 */
509 //USQString toString() const; 509 //USQString toString() const;
510 510
511 /** 511 /**
512 * @internal 512 * @internal
513 */ 513 */
514//US QString toStringInternal() const; 514//US QString toStringInternal() const;
515 515
516 /** 516 /**
517 * Returns a null key sequence. 517 * Returns a null key sequence.
518 * @return the null key sequence 518 * @return the null key sequence
519 * @see isNull() 519 * @see isNull()
520 * @see clear() 520 * @see clear()
521 */ 521 */
522 //USstatic KKeySequence& null(); 522 //USstatic KKeySequence& null();
523 523
524//US protected: 524//US protected:
525 //USuchar m_nKeys; 525 //USuchar m_nKeys;
526 //USuchar m_bTriggerOnRelease; 526 //USuchar m_bTriggerOnRelease;
527 // BCI: m_rgvar should be renamed to m_rgkey for KDE 4.0 527 // BCI: m_rgvar should be renamed to m_rgkey for KDE 4.0
528 //USKKey m_rgvar[MAX_KEYS]; 528 //USKKey m_rgvar[MAX_KEYS];
529 529
530//US private: 530//US private:
531 //USclass KKeySequencePrivate* d; 531 //USclass KKeySequencePrivate* d;
532 //USfriend class KKeyNative; 532 //USfriend class KKeyNative;
533//US}; 533//US};
534 534
535/** 535/**
536* The KShortcut class is used to represent a keyboard shortcut to an action. 536* The KShortcut class is used to represent a keyboard shortcut to an action.
537* A shortcut is normally a single key with modifiers, such as Ctrl+V. 537* A shortcut is normally a single key with modifiers, such as Ctrl+V.
538* A KShortcut object may also contain an alternate key which will also 538* A KShortcut object may also contain an alternate key which will also
539* activate the action it's associated to, as long as no other actions have 539* activate the action it's associated to, as long as no other actions have
540* defined that key as their primary key. Ex: Ctrl+V;Shift+Insert. 540* defined that key as their primary key. Ex: Ctrl+V;Shift+Insert.
541*/ 541*/
542 542
543class KShortcut 543class KShortcut
544{ 544{
545 public: 545 public:
546 /** 546 /**
547 * The maximum number of key sequences that can be contained in 547 * The maximum number of key sequences that can be contained in
548 * a KShortcut. 548 * a KShortcut.
549 */ 549 */
550 enum { MAX_SEQUENCES = 2 }; 550 enum { MAX_SEQUENCES = 2 };
551 551
552 /** 552 /**
553 * Creates a new null shortcut. 553 * Creates a new null shortcut.
554 * @see null() 554 * @see null()
555 * @see isNull() 555 * @see isNull()
556 * @see clear() 556 * @see clear()
557 */ 557 */
558 KShortcut() {} 558 KShortcut() {}
559 559
560 /** 560 /**
561 * Creates a new shortcut with the given Qt key code 561 * Creates a new shortcut with the given Qt key code
562 * as the only key sequence. 562 * as the only key sequence.
563 * @param keyQt the qt keycode 563 * @param keyQt the qt keycode
564 * @see Qt::Key 564 * @see Qt::Key
565 */ 565 */
566 KShortcut( int keyQt ) {} 566 KShortcut( int /*keyQt */) {}
567 567
568 /** 568 /**
569 * Creates a new shortcut that contains only the given qt key 569 * Creates a new shortcut that contains only the given qt key
570 * sequence. 570 * sequence.
571 * @param keySeq the qt key sequence to add 571 * @param keySeq the qt key sequence to add
572 */ 572 */
573 //USKShortcut( const QKeySequence& keySeq ) {} 573 //USKShortcut( const QKeySequence& keySeq ) {}
574 574
575 /** 575 /**
576 * Creates a new shortcut that contains only the given key 576 * Creates a new shortcut that contains only the given key
577 * in its only sequence. 577 * in its only sequence.
578 * @param key the key to add 578 * @param key the key to add
579 */ 579 */
580 //USKShortcut( const KKey& key ); 580 //USKShortcut( const KKey& key );
581 581
582 /** 582 /**
583 * Creates a new shortcut that contains only the given key 583 * Creates a new shortcut that contains only the given key
584 * sequence. 584 * sequence.
585 * @param keySeq the key sequence to add 585 * @param keySeq the key sequence to add
586 */ 586 */
587 //USKShortcut( const KKeySequence& keySeq ); 587 //USKShortcut( const KKeySequence& keySeq );
588 588
589 /** 589 /**
590 * Copies the given shortcut. 590 * Copies the given shortcut.
591 * @param shortcut the shortcut to add 591 * @param shortcut the shortcut to add
592 */ 592 */
593 //USKShortcut( const KShortcut& shortcut ); 593 //USKShortcut( const KShortcut& shortcut );
594 594
595 /** 595 /**
596 * Creates a new key sequence that contains the given key sequence. 596 * Creates a new key sequence that contains the given key sequence.
597 * The description consists of semicolon-separated keys as 597 * The description consists of semicolon-separated keys as
598 * used in @ref KKeySequence::KKeySequence(const QString&). 598 * used in @ref KKeySequence::KKeySequence(const QString&).
599 * @param shortcut the description of the key 599 * @param shortcut the description of the key
600 * @see KKeySequence::KKeySequence(const QString&) 600 * @see KKeySequence::KKeySequence(const QString&)
601 */ 601 */
602 KShortcut( const char* shortcut ) {} 602 KShortcut( const char* /*shortcut */) {}
603 603
604 /** 604 /**
605 * Creates a new key sequence that contains the given key sequence. 605 * Creates a new key sequence that contains the given key sequence.
606 * The description consists of semicolon-separated keys as 606 * The description consists of semicolon-separated keys as
607 * used in @ref KKeySequence::KKeySequence(const QString&). 607 * used in @ref KKeySequence::KKeySequence(const QString&).
608 * @param shortcut the description of the key 608 * @param shortcut the description of the key
609 * @see KKeySequence::KKeySequence(const QString&) 609 * @see KKeySequence::KKeySequence(const QString&)
610 */ 610 */
611 KShortcut( const QString& shortcut ) {} 611 KShortcut( const QString& /*shortcut */) {}
612 ~KShortcut() {} 612 ~KShortcut() {}
613 613
614 /** 614 /**
615 * Clears the shortcut. The shortcut is null after calling this 615 * Clears the shortcut. The shortcut is null after calling this
616 * function. 616 * function.
617 * @see isNull() 617 * @see isNull()
618 */ 618 */
619 //USvoid clear(); 619 //USvoid clear();
620 620
621 /** 621 /**
622 * Initializes the shortcut with the given Qt key code 622 * Initializes the shortcut with the given Qt key code
623 * as the only key sequence. 623 * as the only key sequence.
624 * @param keyQt the qt keycode 624 * @param keyQt the qt keycode
625 * @see Qt::Key 625 * @see Qt::Key
626 */ 626 */
627 //USbool init( int keyQt ); 627 //USbool init( int keyQt );
628 628
629 /** 629 /**
630 * Initializes the shortcut with the given qt key sequence. 630 * Initializes the shortcut with the given qt key sequence.
631 * @param keySeq the qt key sequence to add 631 * @param keySeq the qt key sequence to add
632 */ 632 */
633 //USbool init( const QKeySequence& keySeq ); 633 //USbool init( const QKeySequence& keySeq );
634 634
635 /** 635 /**
636 * Initializes the shortcut with the given key as its only sequence. 636 * Initializes the shortcut with the given key as its only sequence.
637 * @param key the key to add 637 * @param key the key to add
638 */ 638 */
639 //USbool init( const KKey& key ); 639 //USbool init( const KKey& key );
640 640
641 /** 641 /**
642 * Initializes the shortcut with the given qt key sequence. 642 * Initializes the shortcut with the given qt key sequence.
643 * @param keySeq the qt key sequence to add 643 * @param keySeq the qt key sequence to add
644 */ 644 */
645 //USbool init( const KKeySequence& keySeq ); 645 //USbool init( const KKeySequence& keySeq );
646 646
647 /** 647 /**
648 * Copies the given shortcut. 648 * Copies the given shortcut.
649 * @param shortcut the shortcut to add 649 * @param shortcut the shortcut to add
650 */ 650 */
651 //USbool init( const KShortcut& shortcut ); 651 //USbool init( const KShortcut& shortcut );
652 652
653 /** 653 /**
654 * Initializes the key sequence with the given key sequence. 654 * Initializes the key sequence with the given key sequence.
655 * The description consists of semicolon-separated keys as 655 * The description consists of semicolon-separated keys as
656 * used in @ref KKeySequence::KKeySequence(const QString&). 656 * used in @ref KKeySequence::KKeySequence(const QString&).
657 * @param shortcut the description of the key 657 * @param shortcut the description of the key
658 * @see KKeySequence::KKeySequence(const QString&) 658 * @see KKeySequence::KKeySequence(const QString&)
659 */ 659 */
660 //USbool init( const QString& shortcut ); 660 //USbool init( const QString& shortcut );
661 661
662 /** 662 /**
663 * Copies the given shortcut over this shortcut. 663 * Copies the given shortcut over this shortcut.
664 */ 664 */
665 //USKShortcut& operator =( const KShortcut& cut ) 665 //USKShortcut& operator =( const KShortcut& cut )
666 //US { init( cut ); return *this; } 666 //US { init( cut ); return *this; }
667 667
668 /** 668 /**
669 * Returns the number of sequences that are in this 669 * Returns the number of sequences that are in this
670 * shortcut. 670 * shortcut.
671 * @return the number of sequences 671 * @return the number of sequences
672 * @ref MAX_SEQUENCES 672 * @ref MAX_SEQUENCES
673 */ 673 */
674 //USuint count() const; 674 //USuint count() const;
675 675
676 /** 676 /**
677 * Returns the @p i'th key sequence of this shortcut. 677 * Returns the @p i'th key sequence of this shortcut.
678 * @param i the number of the key sequence to retrieve 678 * @param i the number of the key sequence to retrieve
679 * @return the @p i'th sequence or @ref KKeySequence::null() if 679 * @return the @p i'th sequence or @ref KKeySequence::null() if
680 * there are less than @p i key sequences 680 * there are less than @p i key sequences
681 * @ref MAX_SEQUENCES 681 * @ref MAX_SEQUENCES
682 */ 682 */
683 //USconst KKeySequence& seq( uint i ) const; 683 //USconst KKeySequence& seq( uint i ) const;
684 684
685 /** 685 /**
686 * Returns the key code of the first key sequence, or 686 * Returns the key code of the first key sequence, or
687 * null if there is no first key sequence. 687 * null if there is no first key sequence.
688 * @return the key code of the first sequence's first key 688 * @return the key code of the first sequence's first key
689 * @see Qt::Key 689 * @see Qt::Key
690 * @see KKeySequence::keyCodeQt() 690 * @see KKeySequence::keyCodeQt()
691 */ 691 */
692 //USint keyCodeQt() const; 692 //USint keyCodeQt() const;
693 693
694 /** 694 /**
695 * Returns true if the shortcut is null (after @ref clear() or empty 695 * Returns true if the shortcut is null (after @ref clear() or empty
696 * constructor). 696 * constructor).
697 * @return true if the shortcut is null 697 * @return true if the shortcut is null
698 * @see clear() 698 * @see clear()
699 * @see null() 699 * @see null()
700 */ 700 */
701 bool isNull() const { return true; } 701 bool isNull() const { return true; }
702 702
703 /** 703 /**
704 * Compares this object with the given shortcut. Returns a negative 704 * Compares this object with the given shortcut. Returns a negative
705 * number if the given shortcut is larger, 0 if they are equal and 705 * number if the given shortcut is larger, 0 if they are equal and
706 * a positive number this shortcut is larger. Shortcuts are 706 * a positive number this shortcut is larger. Shortcuts are
707 * compared by comparing the individual key sequences, starting from the 707 * compared by comparing the individual key sequences, starting from the
708 * beginning until an unequal key sequences has been found. If a shortcut 708 * beginning until an unequal key sequences has been found. If a shortcut
709 * contains more key sequences, it is considered larger. 709 * contains more key sequences, it is considered larger.
710 * @param shortcut the shortcut to compare to 710 * @param shortcut the shortcut to compare to
711 * @return a negative number if the given KShortcut is larger, 0 if 711 * @return a negative number if the given KShortcut is larger, 0 if
712 * they are equal and a positive number this KShortcut is larger 712 * they are equal and a positive number this KShortcut is larger
713 * @see KKey::compare() 713 * @see KKey::compare()
714 * @see KKeyShortcut::compare() 714 * @see KKeyShortcut::compare()
715 */ 715 */
716 //USint compare( const KShortcut& shortcut ) const; 716 //USint compare( const KShortcut& shortcut ) const;
717 717
718 /** 718 /**
719 * Compares the sequences of both shortcuts. 719 * Compares the sequences of both shortcuts.
720 * @see compare() 720 * @see compare()
721 */ 721 */
722 //USbool operator == ( const KShortcut& cut ) const 722 //USbool operator == ( const KShortcut& cut ) const
723 //US { return compare( cut ) == 0; } 723 //US { return compare( cut ) == 0; }
724 724
725 /** 725 /**
726 * Compares the sequences of both shortcuts. 726 * Compares the sequences of both shortcuts.
727 * @see compare() 727 * @see compare()
728 */ 728 */
729 //USbool operator != ( const KShortcut& cut ) const 729 //USbool operator != ( const KShortcut& cut ) const
730 //US { return compare( cut ) != 0; } 730 //US { return compare( cut ) != 0; }
731 731
732 /** 732 /**
733 * Compares the sequences of both shortcuts. 733 * Compares the sequences of both shortcuts.
734 * @see compare() 734 * @see compare()
735 */ 735 */
736 //USbool operator < ( const KShortcut& cut ) const 736 //USbool operator < ( const KShortcut& cut ) const
737 //US { return compare( cut ) < 0; } 737 //US { return compare( cut ) < 0; }
738 738
739 /** 739 /**
740 * Checks whether this shortcut contains a sequence that starts 740 * Checks whether this shortcut contains a sequence that starts
741 * with the given key. 741 * with the given key.
742 * @param key the key to check 742 * @param key the key to check
743 * @return true if a key sequence starts with the key 743 * @return true if a key sequence starts with the key
744 */ 744 */
745 //USbool contains( const KKey& key ) const; 745 //USbool contains( const KKey& key ) const;
746 746
747 /** 747 /**
748 * Checks whether this shortcut contains a sequence that starts 748 * Checks whether this shortcut contains a sequence that starts
749 * with the given key. 749 * with the given key.
750 * @param key the key to check 750 * @param key the key to check
751 * @return true if a key sequence starts with the key 751 * @return true if a key sequence starts with the key
752 */ 752 */
753 //USbool contains( const KKeyNative& key ) const; 753 //USbool contains( const KKeyNative& key ) const;
754 754
755 /** 755 /**
756 * Checks whether this shortcut contains the given sequence. 756 * Checks whether this shortcut contains the given sequence.
757 * @param keySeq the key sequence to check 757 * @param keySeq the key sequence to check
758 * @return true if the shortcut has the given key sequence 758 * @return true if the shortcut has the given key sequence
759 */ 759 */
760 //USbool contains( const KKeySequence& keySeq ) const; 760 //USbool contains( const KKeySequence& keySeq ) const;
761 761
762 /** 762 /**
763 * Sets the @p i'th key sequence of the shortcut. You can not introduce 763 * Sets the @p i'th key sequence of the shortcut. You can not introduce
764 * gaps in the list of sequences, so you must use an @i <= @ref count(). 764 * gaps in the list of sequences, so you must use an @i <= @ref count().
765 * Also note that the maximum number of key sequences is @ref MAX_SEQUENCES. 765 * Also note that the maximum number of key sequences is @ref MAX_SEQUENCES.
766 * @param i the position of the new key sequence(<= @ref count(), 766 * @param i the position of the new key sequence(<= @ref count(),
767 * <= @ref MAX_SEQUENCES) 767 * <= @ref MAX_SEQUENCES)
768 * @param keySeq the key sequence to set 768 * @param keySeq the key sequence to set
769 * @return true if successful, false otherwise 769 * @return true if successful, false otherwise
770 */ 770 */
771 //USbool setSeq( uint i, const KKeySequence& keySeq ); 771 //USbool setSeq( uint i, const KKeySequence& keySeq );
772 772
773 /** 773 /**
774 * Appends the given key sequence. 774 * Appends the given key sequence.
775 * @param keySeq the key sequence to add 775 * @param keySeq the key sequence to add
776 * @return true if successful, false otherwise 776 * @return true if successful, false otherwise
777 * @see setSeq() 777 * @see setSeq()
778 * @see MAX_SEQUENCES 778 * @see MAX_SEQUENCES
779 */ 779 */
780 //USbool append( const KKeySequence& keySeq ); 780 //USbool append( const KKeySequence& keySeq );
781 781
782 /** 782 /**
783 * Appends the given key 783 * Appends the given key
784 * @param spec the key to add 784 * @param spec the key to add
785 * @return true if successful, false otherwise 785 * @return true if successful, false otherwise
786 * @see setSeq() 786 * @see setSeq()
787 * @see MAX_SEQUENCES 787 * @see MAX_SEQUENCES
788 * @since 3.2 788 * @since 3.2
789 */ 789 */
790 //USbool append( const KKey& spec ); 790 //USbool append( const KKey& spec );
791 791
792 /** 792 /**
793 * Appends the sequences from the given shortcut. 793 * Appends the sequences from the given shortcut.
794 * @param cut the shortcut to append 794 * @param cut the shortcut to append
795 * @return true if successful, false otherwise 795 * @return true if successful, false otherwise
796 * @see MAX_SEQUENCES 796 * @see MAX_SEQUENCES
797 * @since 3.2 797 * @since 3.2
798 */ 798 */
799 //USbool append( const KShortcut& cut ); 799 //USbool append( const KShortcut& cut );
800 800
801 /** 801 /**
802 * Converts this shortcut to a key sequence. The first key sequence 802 * Converts this shortcut to a key sequence. The first key sequence
803 * will be taken. 803 * will be taken.
804 */ 804 */
805 //USoperator QKeySequence () const; 805 //USoperator QKeySequence () const;
806 806
807 /** 807 /**
808 * Returns a description of the shortcut as semicolon-separated 808 * Returns a description of the shortcut as semicolon-separated
809 * ket sequences, as returned by @ref KKeySequence::toString(). 809 * ket sequences, as returned by @ref KKeySequence::toString().
810 * @return the string represenation of this shortcut 810 * @return the string represenation of this shortcut
811 * @see KKey::toString() 811 * @see KKey::toString()
812 * @see KKeySequence::toString() 812 * @see KKeySequence::toString()
813 */ 813 */
814 //USQString toString() const; 814 //USQString toString() const;
815 815
816 /** 816 /**
817 * @internal 817 * @internal
818 */ 818 */
819 QString toStringInternal( const KShortcut* pcutDefault = 0 ) const 819 QString toStringInternal( const KShortcut* /*pcutDefault*/ = 0 ) const
820 { 820 {
821 return "EMPTY IMPL."; 821 return "EMPTY IMPL.";
822 } 822 }
823 823
824 /** 824 /**
825 * Returns a null shortcut. 825 * Returns a null shortcut.
826 * @return the null shortcut 826 * @return the null shortcut
827 * @see isNull() 827 * @see isNull()
828 * @see clear() 828 * @see clear()
829 */ 829 */
830 //USstatic KShortcut& null(); 830 //USstatic KShortcut& null();
831 831
832//US protected: 832//US protected:
833 //USuint m_nSeqs; 833 //USuint m_nSeqs;
834 //USKKeySequence m_rgseq[MAX_SEQUENCES]; 834 //USKKeySequence m_rgseq[MAX_SEQUENCES];
835 835
836//US private: 836//US private:
837 //USclass KShortcutPrivate* d; 837 //USclass KShortcutPrivate* d;
838 //USfriend class KKeyNative; 838 //USfriend class KKeyNative;
839 839
840//US#ifndef KDE_NO_COMPAT 840//US#ifndef KDE_NO_COMPAT
841//US public: 841//US public:
842 //USoperator int () const { return keyCodeQt(); } 842 //USoperator int () const { return keyCodeQt(); }
843//US#endif 843//US#endif
844}; 844};
845 845
846#endif // __KSHORTCUT_H 846#endif // __KSHORTCUT_H
diff --git a/microkde/kdecore/kstandarddirs.cpp b/microkde/kdecore/kstandarddirs.cpp
index d5bfefd..f10934b 100644
--- a/microkde/kdecore/kstandarddirs.cpp
+++ b/microkde/kdecore/kstandarddirs.cpp
@@ -1,1595 +1,1597 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> 2 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org>
3 Copyright (C) 1999 Stephan Kulow <coolo@kde.org> 3 Copyright (C) 1999 Stephan Kulow <coolo@kde.org>
4 Copyright (C) 1999 Waldo Bastian <bastian@kde.org> 4 Copyright (C) 1999 Waldo Bastian <bastian@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation. 8 License version 2 as published by the Free Software Foundation.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21/* 21/*
22 * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> 22 * Author: Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org>
23 * Version:$Id$ 23 * Version:$Id$
24 * Generated:Thu Mar 5 16:05:28 EST 1998 24 * Generated:Thu Mar 5 16:05:28 EST 1998
25 */ 25 */
26 26
27//US #include "config.h" 27//US #include "config.h"
28 28
29#include <stdlib.h> 29#include <stdlib.h>
30#include <assert.h> 30#include <assert.h>
31//US#include <errno.h> 31//US#include <errno.h>
32//US #ifdef HAVE_SYS_STAT_H 32//US #ifdef HAVE_SYS_STAT_H
33//US #include <sys/stat.h> 33//US #include <sys/stat.h>
34//US #endif 34//US #endif
35//US#include <sys/types.h> 35//US#include <sys/types.h>
36//US#include <dirent.h> 36//US#include <dirent.h>
37//US#include <pwd.h> 37//US#include <pwd.h>
38 38
39#include <qregexp.h> 39#include <qregexp.h>
40#include <qasciidict.h> 40#include <q3asciidict.h>
41#include <qdict.h> 41#include <q3dict.h>
42#include <qdir.h> 42#include <qdir.h>
43#include <qfileinfo.h> 43#include <qfileinfo.h>
44#include <qstring.h> 44#include <qstring.h>
45#include <qmessagebox.h> 45#include <qmessagebox.h>
46#include <qapplication.h> 46#include <qapplication.h>
47 47
48#include <qstringlist.h> 48#include <qstringlist.h>
49//Added by qt3to4:
50#include <Q3CString>
49 51
50#include "kstandarddirs.h" 52#include "kstandarddirs.h"
51#include "kconfig.h" 53#include "kconfig.h"
52#include "kdebug.h" 54#include "kdebug.h"
53//US #include "kinstance.h" 55//US #include "kinstance.h"
54#include "kshell.h" 56#include "kshell.h"
55//US#include <sys/param.h> 57//US#include <sys/param.h>
56//US#include <unistd.h> 58//US#include <unistd.h>
57 59
58//US 60//US
59QString KStandardDirs::mAppDir = QString::null; 61QString KStandardDirs::mAppDir = QString::null;
60 62
61 63
62template class QDict<QStringList>; 64template class Q3Dict<QStringList>;
63 65
64#if 0 66#if 0
65#include <qtextedit.h> 67#include <q3textedit.h>
66void ddd( QString op ) 68void ddd( QString op )
67{ 69{
68 static QTextEdit * dot = 0; 70 static Q3TextEdit * dot = 0;
69 if ( ! dot ) 71 if ( ! dot )
70 dot = new QTextEdit(); 72 dot = new Q3TextEdit();
71 73
72 dot->show(); 74 dot->show();
73 75
74 dot->append( op ); 76 dot->append( op );
75 77
76} 78}
77#endif 79#endif
78class KStandardDirs::KStandardDirsPrivate 80class KStandardDirs::KStandardDirsPrivate
79{ 81{
80public: 82public:
81 KStandardDirsPrivate() 83 KStandardDirsPrivate()
82 : restrictionsActive(false), 84 : restrictionsActive(false),
83 dataRestrictionActive(false) 85 dataRestrictionActive(false)
84 { } 86 { }
85 87
86 bool restrictionsActive; 88 bool restrictionsActive;
87 bool dataRestrictionActive; 89 bool dataRestrictionActive;
88 QAsciiDict<bool> restrictions; 90 Q3AsciiDict<bool> restrictions;
89 QStringList xdgdata_prefixes; 91 QStringList xdgdata_prefixes;
90 QStringList xdgconf_prefixes; 92 QStringList xdgconf_prefixes;
91}; 93};
92 94
93static const char* const types[] = {"html", "icon", "apps", "sound", 95static const char* const types[] = {"html", "icon", "apps", "sound",
94 "data", "locale", "services", "mime", 96 "data", "locale", "services", "mime",
95 "servicetypes", "config", "exe", "tmp", 97 "servicetypes", "config", "exe", "tmp",
96 "wallpaper", "lib", "pixmap", "templates", 98 "wallpaper", "lib", "pixmap", "templates",
97 "module", "qtplugins", 99 "module", "qtplugins",
98 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 }; 100 "xdgdata-apps", "xdgdata-dirs", "xdgconf-menu", 0 };
99 101
100static int tokenize( QStringList& token, const QString& str, 102static int tokenize( QStringList& token, const QString& str,
101 const QString& delim ); 103 const QString& delim );
102 104
103KStandardDirs::KStandardDirs( ) : addedCustoms(false) 105KStandardDirs::KStandardDirs( ) : addedCustoms(false)
104{ 106{
105 d = new KStandardDirsPrivate; 107 d = new KStandardDirsPrivate;
106 dircache.setAutoDelete(true); 108 dircache.setAutoDelete(true);
107 relatives.setAutoDelete(true); 109 relatives.setAutoDelete(true);
108 absolutes.setAutoDelete(true); 110 absolutes.setAutoDelete(true);
109 savelocations.setAutoDelete(true); 111 savelocations.setAutoDelete(true);
110 addKDEDefaults(); 112 addKDEDefaults();
111} 113}
112 114
113KStandardDirs::~KStandardDirs() 115KStandardDirs::~KStandardDirs()
114{ 116{
115 delete d; 117 delete d;
116} 118}
117 119
118bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const 120bool KStandardDirs::isRestrictedResource(const char *type, const QString& relPath) const
119{ 121{
120 if (!d || !d->restrictionsActive) 122 if (!d || !d->restrictionsActive)
121 return false; 123 return false;
122 124
123 if (d->restrictions[type]) 125 if (d->restrictions[type])
124 return true; 126 return true;
125 127
126 if (strcmp(type, "data")==0) 128 if (strcmp(type, "data")==0)
127 { 129 {
128 applyDataRestrictions(relPath); 130 applyDataRestrictions(relPath);
129 if (d->dataRestrictionActive) 131 if (d->dataRestrictionActive)
130 { 132 {
131 d->dataRestrictionActive = false; 133 d->dataRestrictionActive = false;
132 return true; 134 return true;
133 } 135 }
134 } 136 }
135 return false; 137 return false;
136} 138}
137 139
138void KStandardDirs::applyDataRestrictions(const QString &relPath) const 140void KStandardDirs::applyDataRestrictions(const QString &relPath) const
139{ 141{
140 QString key; 142 QString key;
141 int i = relPath.find('/'); 143 int i = relPath.find('/');
142 if (i != -1) 144 if (i != -1)
143 key = "data_"+relPath.left(i); 145 key = "data_"+relPath.left(i);
144 else 146 else
145 key = "data_"+relPath; 147 key = "data_"+relPath;
146 148
147 if (d && d->restrictions[key.latin1()]) 149 if (d && d->restrictions[key.latin1()])
148 d->dataRestrictionActive = true; 150 d->dataRestrictionActive = true;
149} 151}
150 152
151 153
152QStringList KStandardDirs::allTypes() const 154QStringList KStandardDirs::allTypes() const
153{ 155{
154 QStringList list; 156 QStringList list;
155 for (int i = 0; types[i] != 0; ++i) 157 for (int i = 0; types[i] != 0; ++i)
156 list.append(QString::fromLatin1(types[i])); 158 list.append(QString::fromLatin1(types[i]));
157 return list; 159 return list;
158} 160}
159 161
160void KStandardDirs::addPrefix( const QString& _dir ) 162void KStandardDirs::addPrefix( const QString& _dir )
161{ 163{
162 if (_dir.isNull()) 164 if (_dir.isNull())
163 return; 165 return;
164 166
165 QString dir = _dir; 167 QString dir = _dir;
166 if (dir.at(dir.length() - 1) != '/') 168 if (dir.at(dir.length() - 1) != '/')
167 dir += '/'; 169 dir += '/';
168 170
169 if (!prefixes.contains(dir)) { 171 if (!prefixes.contains(dir)) {
170 prefixes.append(dir); 172 prefixes.append(dir);
171 dircache.clear(); 173 dircache.clear();
172 } 174 }
173} 175}
174 176
175void KStandardDirs::addXdgConfigPrefix( const QString& _dir ) 177void KStandardDirs::addXdgConfigPrefix( const QString& _dir )
176{ 178{
177 if (_dir.isNull()) 179 if (_dir.isNull())
178 return; 180 return;
179 181
180 QString dir = _dir; 182 QString dir = _dir;
181 if (dir.at(dir.length() - 1) != '/') 183 if (dir.at(dir.length() - 1) != '/')
182 dir += '/'; 184 dir += '/';
183 185
184 if (!d->xdgconf_prefixes.contains(dir)) { 186 if (!d->xdgconf_prefixes.contains(dir)) {
185 d->xdgconf_prefixes.append(dir); 187 d->xdgconf_prefixes.append(dir);
186 dircache.clear(); 188 dircache.clear();
187 } 189 }
188} 190}
189 191
190void KStandardDirs::addXdgDataPrefix( const QString& _dir ) 192void KStandardDirs::addXdgDataPrefix( const QString& _dir )
191{ 193{
192 if (_dir.isNull()) 194 if (_dir.isNull())
193 return; 195 return;
194 196
195 QString dir = _dir; 197 QString dir = _dir;
196 if (dir.at(dir.length() - 1) != '/') 198 if (dir.at(dir.length() - 1) != '/')
197 dir += '/'; 199 dir += '/';
198 200
199 if (!d->xdgdata_prefixes.contains(dir)) { 201 if (!d->xdgdata_prefixes.contains(dir)) {
200 d->xdgdata_prefixes.append(dir); 202 d->xdgdata_prefixes.append(dir);
201 dircache.clear(); 203 dircache.clear();
202 } 204 }
203} 205}
204 206
205 207
206QString KStandardDirs::kfsstnd_prefixes() 208QString KStandardDirs::kfsstnd_prefixes()
207{ 209{
208 return prefixes.join(":"); 210 return prefixes.join(":");
209} 211}
210 212
211bool KStandardDirs::addResourceType( const char *type, 213bool KStandardDirs::addResourceType( const char *type,
212 const QString& relativename ) 214 const QString& relativename )
213{ 215{
214 if (relativename.isNull()) 216 if (relativename.isNull())
215 return false; 217 return false;
216 218
217 QStringList *rels = relatives.find(type); 219 QStringList *rels = relatives.find(type);
218 if (!rels) { 220 if (!rels) {
219 rels = new QStringList(); 221 rels = new QStringList();
220 relatives.insert(type, rels); 222 relatives.insert(type, rels);
221 } 223 }
222 QString copy = relativename; 224 QString copy = relativename;
223 if (copy.at(copy.length() - 1) != '/') 225 if (copy.at(copy.length() - 1) != '/')
224 copy += '/'; 226 copy += '/';
225 if (!rels->contains(copy)) { 227 if (!rels->contains(copy)) {
226 rels->prepend(copy); 228 rels->prepend(copy);
227 dircache.remove(type); // clean the cache 229 dircache.remove(type); // clean the cache
228 return true; 230 return true;
229 } 231 }
230 return false; 232 return false;
231} 233}
232 234
233bool KStandardDirs::addResourceDir( const char *type, 235bool KStandardDirs::addResourceDir( const char *type,
234 const QString& absdir) 236 const QString& absdir)
235{ 237{
236 QStringList *paths = absolutes.find(type); 238 QStringList *paths = absolutes.find(type);
237 if (!paths) { 239 if (!paths) {
238 paths = new QStringList(); 240 paths = new QStringList();
239 absolutes.insert(type, paths); 241 absolutes.insert(type, paths);
240 } 242 }
241 QString copy = absdir; 243 QString copy = absdir;
242 if (copy.at(copy.length() - 1) != '/') 244 if (copy.at(copy.length() - 1) != '/')
243 copy += '/'; 245 copy += '/';
244 246
245 if (!paths->contains(copy)) { 247 if (!paths->contains(copy)) {
246 paths->append(copy); 248 paths->append(copy);
247 dircache.remove(type); // clean the cache 249 dircache.remove(type); // clean the cache
248 return true; 250 return true;
249 } 251 }
250 return false; 252 return false;
251} 253}
252 254
253QString KStandardDirs::findResource( const char *type, 255QString KStandardDirs::findResource( const char *type,
254 const QString& filename ) const 256 const QString& filename ) const
255{ 257{
256 if (filename.at(0) == '/') 258 if (filename.at(0) == '/')
257 return filename; // absolute dirs are absolute dirs, right? :-/ 259 return filename; // absolute dirs are absolute dirs, right? :-/
258 260
259#if 0 261#if 0
260kdDebug() << "Find resource: " << type << endl; 262kdDebug() << "Find resource: " << type << endl;
261for (QStringList::ConstIterator pit = prefixes.begin(); 263for (QStringList::ConstIterator pit = prefixes.begin();
262 pit != prefixes.end(); 264 pit != prefixes.end();
263 pit++) 265 pit++)
264{ 266{
265 kdDebug() << "Prefix: " << *pit << endl; 267 kdDebug() << "Prefix: " << *pit << endl;
266} 268}
267#endif 269#endif
268 270
269 QString dir = findResourceDir(type, filename); 271 QString dir = findResourceDir(type, filename);
270 if (dir.isNull()) 272 if (dir.isNull())
271 return dir; 273 return dir;
272 else return dir + filename; 274 else return dir + filename;
273} 275}
274/*US 276/*US
275static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash) 277static Q_UINT32 updateHash(const QString &file, Q_UINT32 hash)
276{ 278{
277 QCString cFile = QFile::encodeName(file); 279 QCString cFile = QFile::encodeName(file);
278//US struct stat buff; 280//US struct stat buff;
279//US if ((access(cFile, R_OK) == 0) && 281//US if ((access(cFile, R_OK) == 0) &&
280//US (stat( cFile, &buff ) == 0) && 282//US (stat( cFile, &buff ) == 0) &&
281//US (S_ISREG( buff.st_mode ))) 283//US (S_ISREG( buff.st_mode )))
282 QFileInfo pathfnInfo(cFile); 284 QFileInfo pathfnInfo(cFile);
283 if (( pathfnInfo.isReadable() == true ) && 285 if (( pathfnInfo.isReadable() == true ) &&
284 ( pathfnInfo.isFile()) ) 286 ( pathfnInfo.isFile()) )
285 { 287 {
286//US hash = hash + (Q_UINT32) buff.st_ctime; 288//US hash = hash + (Q_UINT32) buff.st_ctime;
287 hash = hash + (Q_UINT32) pathfnInfo.lastModified(); 289 hash = hash + (Q_UINT32) pathfnInfo.lastModified();
288 } 290 }
289 return hash; 291 return hash;
290} 292}
291*/ 293*/
292/*US 294/*US
293Q_UINT32 KStandardDirs::calcResourceHash( const char *type, 295Q_UINT32 KStandardDirs::calcResourceHash( const char *type,
294 const QString& filename, bool deep) const 296 const QString& filename, bool deep) const
295{ 297{
296 Q_UINT32 hash = 0; 298 Q_UINT32 hash = 0;
297 299
298 if (filename.at(0) == '/') 300 if (filename.at(0) == '/')
299 { 301 {
300 // absolute dirs are absolute dirs, right? :-/ 302 // absolute dirs are absolute dirs, right? :-/
301 return updateHash(filename, hash); 303 return updateHash(filename, hash);
302 } 304 }
303 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 305 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
304 applyDataRestrictions(filename); 306 applyDataRestrictions(filename);
305 QStringList candidates = resourceDirs(type); 307 QStringList candidates = resourceDirs(type);
306 QString fullPath; 308 QString fullPath;
307 309
308 for (QStringList::ConstIterator it = candidates.begin(); 310 for (QStringList::ConstIterator it = candidates.begin();
309 it != candidates.end(); it++) 311 it != candidates.end(); it++)
310 { 312 {
311 hash = updateHash(*it + filename, hash); 313 hash = updateHash(*it + filename, hash);
312 if (!deep && hash) 314 if (!deep && hash)
313 return hash; 315 return hash;
314 } 316 }
315 return hash; 317 return hash;
316} 318}
317*/ 319*/
318 320
319QStringList KStandardDirs::findDirs( const char *type, 321QStringList KStandardDirs::findDirs( const char *type,
320 const QString& reldir ) const 322 const QString& reldir ) const
321{ 323{
322 QStringList list; 324 QStringList list;
323 325
324 checkConfig(); 326 checkConfig();
325 327
326 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 328 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
327 applyDataRestrictions(reldir); 329 applyDataRestrictions(reldir);
328 QStringList candidates = resourceDirs(type); 330 QStringList candidates = resourceDirs(type);
329 QDir testdir; 331 QDir testdir;
330 332
331 for (QStringList::ConstIterator it = candidates.begin(); 333 for (QStringList::ConstIterator it = candidates.begin();
332 it != candidates.end(); it++) { 334 it != candidates.end(); it++) {
333 testdir.setPath(*it + reldir); 335 testdir.setPath(*it + reldir);
334 if (testdir.exists()) 336 if (testdir.exists())
335 list.append(testdir.absPath() + '/'); 337 list.append(testdir.absPath() + '/');
336 } 338 }
337 339
338 return list; 340 return list;
339} 341}
340 342
341QString KStandardDirs::findResourceDir( const char *type, 343QString KStandardDirs::findResourceDir( const char *type,
342 const QString& filename) const 344 const QString& filename) const
343{ 345{
344#ifndef NDEBUG 346#ifndef NDEBUG
345 if (filename.isEmpty()) { 347 if (filename.isEmpty()) {
346 kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl; 348 kdWarning() << "filename for type " << type << " in KStandardDirs::findResourceDir is not supposed to be empty!!" << endl;
347 return QString::null; 349 return QString::null;
348 } 350 }
349#endif 351#endif
350 352
351 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 353 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
352 applyDataRestrictions(filename); 354 applyDataRestrictions(filename);
353 QStringList candidates = resourceDirs(type); 355 QStringList candidates = resourceDirs(type);
354 QString fullPath; 356 QString fullPath;
355#ifdef DESKTOP_VERSION 357#ifdef DESKTOP_VERSION
356#ifdef _WIN32_ 358#ifdef _WIN32_
357 candidates.prepend( qApp->applicationDirPath () +"\\"); 359 candidates.prepend( qApp->applicationDirPath () +"\\");
358#else 360#else
359 candidates.prepend( qApp->applicationDirPath () +"/"); 361 candidates.prepend( qApp->applicationDirPath () +"/");
360#endif 362#endif
361#endif 363#endif
362 for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++) 364 for (QStringList::ConstIterator it = candidates.begin(); it != candidates.end(); it++)
363 { 365 {
364 //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1()); 366 //qDebug("looking for dir %s - file %s", (*it).latin1(), filename.latin1());
365 if (exists(*it + filename)) 367 if (exists(*it + filename))
366 return *it; 368 return *it;
367 } 369 }
368 370
369#ifndef NDEBUG 371#ifndef NDEBUG
370 if(false && type != "locale") 372 if(false && type != "locale")
371 qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1()); 373 qDebug("KStdDirs::findResDir(): can't find %s ", filename.latin1());
372 374
373#endif 375#endif
374 376
375 return QString::null; 377 return QString::null;
376} 378}
377 379
378bool KStandardDirs::exists(const QString &fullPath) 380bool KStandardDirs::exists(const QString &fullPath)
379{ 381{
380//US struct stat buff; 382//US struct stat buff;
381 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 383 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
382 384
383//US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable()) 385//US if (access(QFile::encodeName(fullPath), R_OK) == 0 && fullPathInfo.isReadable())
384 if (fullPathInfo.isReadable()) 386 if (fullPathInfo.isReadable())
385 { 387 {
386 if (fullPath.at(fullPath.length() - 1) != '/') { 388 if (fullPath.at(fullPath.length() - 1) != '/') {
387 //US if (S_ISREG( buff.st_mode )) 389 //US if (S_ISREG( buff.st_mode ))
388 if (fullPathInfo.isFile()) 390 if (fullPathInfo.isFile())
389 return true; 391 return true;
390 } 392 }
391 else { 393 else {
392 //US if (S_ISDIR( buff.st_mode )) 394 //US if (S_ISDIR( buff.st_mode ))
393 if (fullPathInfo.isDir()) 395 if (fullPathInfo.isDir())
394 return true; 396 return true;
395 } 397 }
396 } 398 }
397 return false; 399 return false;
398} 400}
399 401
400static void lookupDirectory(const QString& path, const QString &relPart, 402static void lookupDirectory(const QString& path, const QString &relPart,
401 const QRegExp &regexp, 403 const QRegExp &regexp,
402 QStringList& list, 404 QStringList& list,
403 QStringList& relList, 405 QStringList& relList,
404 bool recursive, bool uniq) 406 bool recursive, bool uniq)
405{ 407{
406 QString pattern = regexp.pattern(); 408 QString pattern = regexp.pattern();
407 if (recursive || pattern.contains('?') || pattern.contains('*')) 409 if (recursive || pattern.contains('?') || pattern.contains('*'))
408 { 410 {
409 // We look for a set of files. 411 // We look for a set of files.
410//US DIR *dp = opendir( QFile::encodeName(path)); 412//US DIR *dp = opendir( QFile::encodeName(path));
411 QDir dp(QFile::encodeName(path)); 413 QDir dp(QFile::encodeName(path));
412 414
413 if (!dp.exists()) 415 if (!dp.exists())
414 return; 416 return;
415 static int iii = 0; 417 static int iii = 0;
416 ++iii; 418 ++iii;
417 if ( iii == 5 ) 419 if ( iii == 5 )
418 abort(); 420 abort();
419 assert(path.at(path.length() - 1) == '/'); 421 assert(path.at(path.length() - 1) == '/');
420 422
421//US struct dirent *ep; 423//US struct dirent *ep;
422//US struct stat buff; 424//US struct stat buff;
423 425
424 QString _dot("."); 426 QString _dot(".");
425 QString _dotdot(".."); 427 QString _dotdot("..");
426 428
427//US while( ( ep = readdir( dp ) ) != 0L ) 429//US while( ( ep = readdir( dp ) ) != 0L )
428 QStringList direntries = dp.entryList(); 430 QStringList direntries = dp.entryList();
429 QStringList::Iterator it = direntries.begin(); 431 QStringList::Iterator it = direntries.begin();
430 432
431 while ( it != list.end() ) // for each file... 433 while ( it != list.end() ) // for each file...
432 { 434 {
433 435
434//US QString fn( QFile::decodeName(ep->d_name)); 436//US QString fn( QFile::decodeName(ep->d_name));
435 QString fn = (*it); // dp.entryList already decodes 437 QString fn = (*it); // dp.entryList already decodes
436 it++; 438 it++;
437 if ( fn.isNull() ) 439 if ( fn.isNull() )
438 break; 440 break;
439 441
440 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' ) 442 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1).latin1() == '~' )
441 continue; 443 continue;
442 444
443/*US 445/*US
444 if (!recursive && !regexp.exactMatch(fn)) 446 if (!recursive && !regexp.exactMatch(fn))
445 continue; // No match 447 continue; // No match
446*/ 448*/
447//US this should do the same: 449//US this should do the same:
448 int pos = regexp.match(fn); 450 int pos = regexp.exactMatch(fn);
449 if (!recursive && !pos == 0) 451 if (!recursive && !pos == 0)
450 continue; // No match 452 continue; // No match
451 453
452 QString pathfn = path + fn; 454 QString pathfn = path + fn;
453/*US 455/*US
454 if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) { 456 if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) {
455 kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; 457 kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl;
456 continue; // Couldn't stat (e.g. no read permissions) 458 continue; // Couldn't stat (e.g. no read permissions)
457 } 459 }
458 460
459 if ( recursive ) 461 if ( recursive )
460 { 462 {
461 if ( S_ISDIR( buff.st_mode )) { 463 if ( S_ISDIR( buff.st_mode )) {
462 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); 464 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq);
463 } 465 }
464*/ 466*/
465//US replacement: 467//US replacement:
466 QFileInfo pathfnInfo(QFile::encodeName(pathfn)); 468 QFileInfo pathfnInfo(QFile::encodeName(pathfn));
467 if ( pathfnInfo.isReadable() == false ) 469 if ( pathfnInfo.isReadable() == false )
468 { 470 {
469//US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl; 471//US kdDebug() << "Error stat'ing " << pathfn << " : " << perror << endl;
470 continue; // Couldn't stat (e.g. no read permissions) 472 continue; // Couldn't stat (e.g. no read permissions)
471 } 473 }
472 474
473 if ( recursive ) 475 if ( recursive )
474 { 476 {
475 if ( pathfnInfo.isDir()) { 477 if ( pathfnInfo.isDir()) {
476 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq); 478 lookupDirectory(pathfn + '/', relPart + fn + '/', regexp, list, relList, recursive, uniq);
477 } 479 }
478 480
479 481
480/*US 482/*US
481 if (!regexp.exactMatch(fn)) 483 if (!regexp.exactMatch(fn))
482 continue; // No match 484 continue; // No match
483*/ 485*/
484//US this should do the same: 486//US this should do the same:
485 pos = regexp.match(fn); 487 pos = regexp.exactMatch(fn);
486 if (!pos == 0) 488 if (!pos == 0)
487 continue; // No match 489 continue; // No match
488 } 490 }
489 491
490//US if ( S_ISREG( buff.st_mode)) 492//US if ( S_ISREG( buff.st_mode))
491 if ( pathfnInfo.isFile()) 493 if ( pathfnInfo.isFile())
492 { 494 {
493 if (!uniq || !relList.contains(relPart + fn)) 495 if (!uniq || !relList.contains(relPart + fn))
494 { 496 {
495 list.append( pathfn ); 497 list.append( pathfn );
496 relList.append( relPart + fn ); 498 relList.append( relPart + fn );
497 } 499 }
498 } 500 }
499 } 501 }
500//US closedir( dp ); 502//US closedir( dp );
501 } 503 }
502 else 504 else
503 { 505 {
504 // We look for a single file. 506 // We look for a single file.
505 QString fn = pattern; 507 QString fn = pattern;
506 QString pathfn = path + fn; 508 QString pathfn = path + fn;
507//US struct stat buff; 509//US struct stat buff;
508 QFileInfo pathfnInfo(QFile::encodeName(pathfn)); 510 QFileInfo pathfnInfo(QFile::encodeName(pathfn));
509 511
510 512
511//US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 ) 513//US if ( stat( QFile::encodeName(pathfn), &buff ) != 0 )
512 if ( pathfnInfo.isReadable() == false ) 514 if ( pathfnInfo.isReadable() == false )
513 return; // File not found 515 return; // File not found
514 516
515//US if ( S_ISREG( buff.st_mode)) 517//US if ( S_ISREG( buff.st_mode))
516 if ( pathfnInfo.isFile()) 518 if ( pathfnInfo.isFile())
517 { 519 {
518 if (!uniq || !relList.contains(relPart + fn)) 520 if (!uniq || !relList.contains(relPart + fn))
519 { 521 {
520 list.append( pathfn ); 522 list.append( pathfn );
521 relList.append( relPart + fn ); 523 relList.append( relPart + fn );
522 } 524 }
523 } 525 }
524 } 526 }
525} 527}
526 528
527static void lookupPrefix(const QString& prefix, const QString& relpath, 529static void lookupPrefix(const QString& prefix, const QString& relpath,
528 const QString& relPart, 530 const QString& relPart,
529 const QRegExp &regexp, 531 const QRegExp &regexp,
530 QStringList& list, 532 QStringList& list,
531 QStringList& relList, 533 QStringList& relList,
532 bool recursive, bool uniq) 534 bool recursive, bool uniq)
533{ 535{
534 if (relpath.isNull()) { 536 if (relpath.isNull()) {
535 lookupDirectory(prefix, relPart, regexp, list, 537 lookupDirectory(prefix, relPart, regexp, list,
536 relList, recursive, uniq); 538 relList, recursive, uniq);
537 return; 539 return;
538 } 540 }
539 QString path; 541 QString path;
540 QString rest; 542 QString rest;
541 543
542 if (relpath.length()) 544 if (relpath.length())
543 { 545 {
544 int slash = relpath.find('/'); 546 int slash = relpath.find('/');
545 if (slash < 0) 547 if (slash < 0)
546 rest = relpath.left(relpath.length() - 1); 548 rest = relpath.left(relpath.length() - 1);
547 else { 549 else {
548 path = relpath.left(slash); 550 path = relpath.left(slash);
549 rest = relpath.mid(slash + 1); 551 rest = relpath.mid(slash + 1);
550 } 552 }
551 } 553 }
552 assert(prefix.at(prefix.length() - 1) == '/'); 554 assert(prefix.at(prefix.length() - 1) == '/');
553 555
554//US struct stat buff; 556//US struct stat buff;
555 557
556 if (path.contains('*') || path.contains('?')) { 558 if (path.contains('*') || path.contains('?')) {
557 QRegExp pathExp(path, true, true); 559 QRegExp pathExp(path, true, true);
558 //USDIR *dp = opendir( QFile::encodeName(prefix) ); 560 //USDIR *dp = opendir( QFile::encodeName(prefix) );
559 QDir dp(QFile::encodeName(prefix)); 561 QDir dp(QFile::encodeName(prefix));
560 562
561 //USif (!dp) 563 //USif (!dp)
562 if (!dp.exists()) 564 if (!dp.exists())
563 { 565 {
564 return; 566 return;
565 } 567 }
566 568
567 //USstruct dirent *ep; 569 //USstruct dirent *ep;
568 570
569 QString _dot("."); 571 QString _dot(".");
570 QString _dotdot(".."); 572 QString _dotdot("..");
571 573
572 //USwhile( ( ep = readdir( dp ) ) != 0L ) 574 //USwhile( ( ep = readdir( dp ) ) != 0L )
573 QStringList direntries = dp.entryList(); 575 QStringList direntries = dp.entryList();
574 QStringList::Iterator it = direntries.begin(); 576 QStringList::Iterator it = direntries.begin();
575 577
576 while ( it != list.end() ) // for each file... 578 while ( it != list.end() ) // for each file...
577 { 579 {
578//US QString fn( QFile::decodeName(ep->d_name)); 580//US QString fn( QFile::decodeName(ep->d_name));
579 QString fn = (*it); // dp.entryList() already encodes the strings 581 QString fn = (*it); // dp.entryList() already encodes the strings
580 it++; 582 it++;
581 583
582 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~') 584 if (fn == _dot || fn == _dotdot || fn.at(fn.length() - 1) == '~')
583 continue; 585 continue;
584 586
585#ifdef DESKTOP_VERSION 587#ifdef DESKTOP_VERSION
586 588
587 if (pathExp.search(fn) == -1) 589 if (pathExp.search(fn) == -1)
588 continue; // No match 590 continue; // No match
589 591
590#else 592#else
591//US this should do the same: 593//US this should do the same:
592 if (pathExp.find(fn, 0) == -1) 594 if (pathExp.find(fn, 0) == -1)
593 continue; // No match 595 continue; // No match
594#endif 596#endif
595 QString rfn = relPart+fn; 597 QString rfn = relPart+fn;
596 fn = prefix + fn; 598 fn = prefix + fn;
597//US if ( stat( QFile::encodeName(fn), &buff ) != 0 ) 599//US if ( stat( QFile::encodeName(fn), &buff ) != 0 )
598 QFileInfo fnInfo(QFile::encodeName(fn)); 600 QFileInfo fnInfo(QFile::encodeName(fn));
599 if ( fnInfo.isReadable() == false ) 601 if ( fnInfo.isReadable() == false )
600 { 602 {
601//US kdDebug() << "Error statting " << fn << " : " << perror << endl; 603//US kdDebug() << "Error statting " << fn << " : " << perror << endl;
602 continue; // Couldn't stat (e.g. no permissions) 604 continue; // Couldn't stat (e.g. no permissions)
603 } 605 }
604 //US if ( S_ISDIR( buff.st_mode )) 606 //US if ( S_ISDIR( buff.st_mode ))
605 if ( fnInfo.isDir() ) 607 if ( fnInfo.isDir() )
606 608
607 lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq); 609 lookupPrefix(fn + '/', rest, rfn + '/', regexp, list, relList, recursive, uniq);
608 } 610 }
609 611
610 //USclosedir( dp ); 612 //USclosedir( dp );
611 } else { 613 } else {
612 // Don't stat, if the dir doesn't exist we will find out 614 // Don't stat, if the dir doesn't exist we will find out
613 // when we try to open it. 615 // when we try to open it.
614 lookupPrefix(prefix + path + '/', rest, 616 lookupPrefix(prefix + path + '/', rest,
615 relPart + path + '/', regexp, list, 617 relPart + path + '/', regexp, list,
616 relList, recursive, uniq); 618 relList, recursive, uniq);
617 } 619 }
618} 620}
619 621
620QStringList 622QStringList
621KStandardDirs::findAllResources( const char *type, 623KStandardDirs::findAllResources( const char *type,
622 const QString& filter, 624 const QString& filter,
623 bool recursive, 625 bool recursive,
624 bool uniq, 626 bool uniq,
625 QStringList &relList) const 627 QStringList &relList) const
626{ 628{
627 QStringList list; 629 QStringList list;
628 if (filter.at(0) == '/') // absolute paths we return 630 if (filter.at(0) == '/') // absolute paths we return
629 { 631 {
630 list.append( filter); 632 list.append( filter);
631 return list; 633 return list;
632 } 634 }
633 635
634 QString filterPath; 636 QString filterPath;
635 QString filterFile; 637 QString filterFile;
636 638
637 if (filter.length()) 639 if (filter.length())
638 { 640 {
639 int slash = filter.findRev('/'); 641 int slash = filter.findRev('/');
640 if (slash < 0) 642 if (slash < 0)
641 filterFile = filter; 643 filterFile = filter;
642 else { 644 else {
643 filterPath = filter.left(slash + 1); 645 filterPath = filter.left(slash + 1);
644 filterFile = filter.mid(slash + 1); 646 filterFile = filter.mid(slash + 1);
645 } 647 }
646 } 648 }
647 checkConfig(); 649 checkConfig();
648 650
649 if (d && d->restrictionsActive && (strcmp(type, "data")==0)) 651 if (d && d->restrictionsActive && (strcmp(type, "data")==0))
650 applyDataRestrictions(filter); 652 applyDataRestrictions(filter);
651 QStringList candidates = resourceDirs(type); 653 QStringList candidates = resourceDirs(type);
652 if (filterFile.isEmpty()) 654 if (filterFile.isEmpty())
653 filterFile = "*"; 655 filterFile = "*";
654 656
655 QRegExp regExp(filterFile, true, true); 657 QRegExp regExp(filterFile, true, true);
656 for (QStringList::ConstIterator it = candidates.begin(); 658 for (QStringList::ConstIterator it = candidates.begin();
657 it != candidates.end(); it++) 659 it != candidates.end(); it++)
658 { 660 {
659 lookupPrefix(*it, filterPath, "", regExp, list, 661 lookupPrefix(*it, filterPath, "", regExp, list,
660 relList, recursive, uniq); 662 relList, recursive, uniq);
661 } 663 }
662 return list; 664 return list;
663} 665}
664 666
665QStringList 667QStringList
666KStandardDirs::findAllResources( const char *type, 668KStandardDirs::findAllResources( const char *type,
667 const QString& filter, 669 const QString& filter,
668 bool recursive, 670 bool recursive,
669 bool uniq) const 671 bool uniq) const
670{ 672{
671 QStringList relList; 673 QStringList relList;
672 return findAllResources(type, filter, recursive, uniq, relList); 674 return findAllResources(type, filter, recursive, uniq, relList);
673} 675}
674 676
675QString 677QString
676KStandardDirs::realPath(const QString &dirname) 678KStandardDirs::realPath(const QString &dirname)
677{ 679{
678#ifdef _WIN32_ 680#ifdef _WIN32_
679 return dirname; 681 return dirname;
680#else 682#else
681//US char realpath_buffer[MAXPATHLEN + 1]; 683//US char realpath_buffer[MAXPATHLEN + 1];
682//US memset(realpath_buffer, 0, MAXPATHLEN + 1); 684//US memset(realpath_buffer, 0, MAXPATHLEN + 1);
683 char realpath_buffer[250 + 1]; 685 char realpath_buffer[250 + 1];
684 memset(realpath_buffer, 0, 250 + 1); 686 memset(realpath_buffer, 0, 250 + 1);
685 687
686 /* If the path contains symlinks, get the real name */ 688 /* If the path contains symlinks, get the real name */
687 if (realpath( QFile::encodeName(dirname).data(), realpath_buffer) != 0) { 689 if (realpath( QFile::encodeName(dirname).data(), realpath_buffer) != 0) {
688 // succes, use result from realpath 690 // succes, use result from realpath
689 int len = strlen(realpath_buffer); 691 int len = strlen(realpath_buffer);
690 realpath_buffer[len] = '/'; 692 realpath_buffer[len] = '/';
691 realpath_buffer[len+1] = 0; 693 realpath_buffer[len+1] = 0;
692 return QFile::decodeName(realpath_buffer); 694 return QFile::decodeName(realpath_buffer);
693 } 695 }
694 696
695 return dirname; 697 return dirname;
696#endif 698#endif
697} 699}
698/*US 700/*US
699void KStandardDirs::createSpecialResource(const char *type) 701void KStandardDirs::createSpecialResource(const char *type)
700{ 702{
701 char hostname[256]; 703 char hostname[256];
702 hostname[0] = 0; 704 hostname[0] = 0;
703 gethostname(hostname, 255); 705 gethostname(hostname, 255);
704 QString dir = QString("%1%2-%3").arg(localkdedir()).arg(type).arg(hostname); 706 QString dir = QString("%1%2-%3").arg(localkdedir()).arg(type).arg(hostname);
705 char link[1024]; 707 char link[1024];
706 link[1023] = 0; 708 link[1023] = 0;
707 int result = readlink(QFile::encodeName(dir).data(), link, 1023); 709 int result = readlink(QFile::encodeName(dir).data(), link, 1023);
708 if ((result == -1) && (errno == ENOENT)) 710 if ((result == -1) && (errno == ENOENT))
709 { 711 {
710 QString srv = findExe(QString::fromLatin1("lnusertemp"), KDEDIR+QString::fromLatin1("/bin")); 712 QString srv = findExe(QString::fromLatin1("lnusertemp"), KDEDIR+QString::fromLatin1("/bin"));
711 if (srv.isEmpty()) 713 if (srv.isEmpty())
712 srv = findExe(QString::fromLatin1("lnusertemp")); 714 srv = findExe(QString::fromLatin1("lnusertemp"));
713 if (!srv.isEmpty()) 715 if (!srv.isEmpty())
714 { 716 {
715 system(QFile::encodeName(srv)+" "+type); 717 system(QFile::encodeName(srv)+" "+type);
716 result = readlink(QFile::encodeName(dir).data(), link, 1023); 718 result = readlink(QFile::encodeName(dir).data(), link, 1023);
717 } 719 }
718 } 720 }
719 if (result > 0) 721 if (result > 0)
720 { 722 {
721 link[result] = 0; 723 link[result] = 0;
722 if (link[0] == '/') 724 if (link[0] == '/')
723 dir = QFile::decodeName(link); 725 dir = QFile::decodeName(link);
724 else 726 else
725 dir = QDir::cleanDirPath(dir+QFile::decodeName(link)); 727 dir = QDir::cleanDirPath(dir+QFile::decodeName(link));
726 } 728 }
727 addResourceDir(type, dir+'/'); 729 addResourceDir(type, dir+'/');
728} 730}
729*/ 731*/
730 732
731QStringList KStandardDirs::resourceDirs(const char *type) const 733QStringList KStandardDirs::resourceDirs(const char *type) const
732{ 734{
733 QStringList *candidates = dircache.find(type); 735 QStringList *candidates = dircache.find(type);
734 736
735 if (!candidates) { // filling cache 737 if (!candidates) { // filling cache
736/*US 738/*US
737 if (strcmp(type, "socket") == 0) 739 if (strcmp(type, "socket") == 0)
738 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 740 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
739 else if (strcmp(type, "tmp") == 0) 741 else if (strcmp(type, "tmp") == 0)
740 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 742 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
741 else if (strcmp(type, "cache") == 0) 743 else if (strcmp(type, "cache") == 0)
742 const_cast<KStandardDirs *>(this)->createSpecialResource(type); 744 const_cast<KStandardDirs *>(this)->createSpecialResource(type);
743*/ 745*/
744 QDir testdir; 746 QDir testdir;
745 747
746 candidates = new QStringList(); 748 candidates = new QStringList();
747 QStringList *dirs; 749 QStringList *dirs;
748 750
749 bool restrictionActive = false; 751 bool restrictionActive = false;
750 if (d && d->restrictionsActive) 752 if (d && d->restrictionsActive)
751 { 753 {
752 if (d->dataRestrictionActive) 754 if (d->dataRestrictionActive)
753 restrictionActive = true; 755 restrictionActive = true;
754 else if (d->restrictions["all"]) 756 else if (d->restrictions["all"])
755 restrictionActive = true; 757 restrictionActive = true;
756 else if (d->restrictions[type]) 758 else if (d->restrictions[type])
757 restrictionActive = true; 759 restrictionActive = true;
758 d->dataRestrictionActive = false; // Reset 760 d->dataRestrictionActive = false; // Reset
759 } 761 }
760 762
761 dirs = relatives.find(type); 763 dirs = relatives.find(type);
762 if (dirs) 764 if (dirs)
763 { 765 {
764 bool local = true; 766 bool local = true;
765 const QStringList *prefixList = 0; 767 const QStringList *prefixList = 0;
766 if (strncmp(type, "xdgdata-", 8) == 0) 768 if (strncmp(type, "xdgdata-", 8) == 0)
767 prefixList = &(d->xdgdata_prefixes); 769 prefixList = &(d->xdgdata_prefixes);
768 else if (strncmp(type, "xdgconf-", 8) == 0) 770 else if (strncmp(type, "xdgconf-", 8) == 0)
769 prefixList = &(d->xdgconf_prefixes); 771 prefixList = &(d->xdgconf_prefixes);
770 else 772 else
771 prefixList = &prefixes; 773 prefixList = &prefixes;
772 774
773 for (QStringList::ConstIterator pit = prefixList->begin(); 775 for (QStringList::ConstIterator pit = prefixList->begin();
774 pit != prefixList->end(); 776 pit != prefixList->end();
775 pit++) 777 pit++)
776 { 778 {
777 for (QStringList::ConstIterator it = dirs->begin(); 779 for (QStringList::ConstIterator it = dirs->begin();
778 it != dirs->end(); ++it) { 780 it != dirs->end(); ++it) {
779 QString path = realPath(*pit + *it); 781 QString path = realPath(*pit + *it);
780 testdir.setPath(path); 782 testdir.setPath(path);
781 if (local && restrictionActive) 783 if (local && restrictionActive)
782 continue; 784 continue;
783 if ((local || testdir.exists()) && !candidates->contains(path)) 785 if ((local || testdir.exists()) && !candidates->contains(path))
784 candidates->append(path); 786 candidates->append(path);
785 } 787 }
786 local = false; 788 local = false;
787 } 789 }
788 } 790 }
789 dirs = absolutes.find(type); 791 dirs = absolutes.find(type);
790 if (dirs) 792 if (dirs)
791 for (QStringList::ConstIterator it = dirs->begin(); 793 for (QStringList::ConstIterator it = dirs->begin();
792 it != dirs->end(); ++it) 794 it != dirs->end(); ++it)
793 { 795 {
794 testdir.setPath(*it); 796 testdir.setPath(*it);
795 if (testdir.exists()) 797 if (testdir.exists())
796 { 798 {
797 QString filename = realPath(*it); 799 QString filename = realPath(*it);
798 if (!candidates->contains(filename)) 800 if (!candidates->contains(filename))
799 candidates->append(filename); 801 candidates->append(filename);
800 } 802 }
801 } 803 }
802 dircache.insert(type, candidates); 804 dircache.insert(type, candidates);
803 } 805 }
804 806
805#if 0 807#if 0
806 kdDebug() << "found dirs for resource " << type << ":" << endl; 808 kdDebug() << "found dirs for resource " << type << ":" << endl;
807 for (QStringList::ConstIterator pit = candidates->begin(); 809 for (QStringList::ConstIterator pit = candidates->begin();
808 pit != candidates->end(); 810 pit != candidates->end();
809 pit++) 811 pit++)
810 { 812 {
811 fprintf(stderr, "%s\n", (*pit).latin1()); 813 fprintf(stderr, "%s\n", (*pit).latin1());
812 } 814 }
813#endif 815#endif
814 816
815 817
816 return *candidates; 818 return *candidates;
817} 819}
818 820
819/*US 821/*US
820QString KStandardDirs::findExe( const QString& appname, 822QString KStandardDirs::findExe( const QString& appname,
821 const QString& pstr, bool ignore) 823 const QString& pstr, bool ignore)
822{ 824{
823 QFileInfo info; 825 QFileInfo info;
824 826
825 // absolute path ? 827 // absolute path ?
826 if (appname.startsWith(QString::fromLatin1("/"))) 828 if (appname.startsWith(QString::fromLatin1("/")))
827 { 829 {
828 info.setFile( appname ); 830 info.setFile( appname );
829 if( info.exists() && ( ignore || info.isExecutable() ) 831 if( info.exists() && ( ignore || info.isExecutable() )
830 && info.isFile() ) { 832 && info.isFile() ) {
831 return appname; 833 return appname;
832 } 834 }
833 return QString::null; 835 return QString::null;
834 } 836 }
835 837
836//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname); 838//US QString p = QString("%1/%2").arg(__KDE_BINDIR).arg(appname);
837 QString p = QString("%1/%2").arg(appname).arg(appname); 839 QString p = QString("%1/%2").arg(appname).arg(appname);
838 qDebug("KStandardDirs::findExe this is probably wrong"); 840 qDebug("KStandardDirs::findExe this is probably wrong");
839 841
840 info.setFile( p ); 842 info.setFile( p );
841 if( info.exists() && ( ignore || info.isExecutable() ) 843 if( info.exists() && ( ignore || info.isExecutable() )
842 && ( info.isFile() || info.isSymLink() ) ) { 844 && ( info.isFile() || info.isSymLink() ) ) {
843 return p; 845 return p;
844 } 846 }
845 847
846 QStringList tokens; 848 QStringList tokens;
847 p = pstr; 849 p = pstr;
848 850
849 if( p.isNull() ) { 851 if( p.isNull() ) {
850 p = getenv( "PATH" ); 852 p = getenv( "PATH" );
851 } 853 }
852 854
853 tokenize( tokens, p, ":\b" ); 855 tokenize( tokens, p, ":\b" );
854 856
855 // split path using : or \b as delimiters 857 // split path using : or \b as delimiters
856 for( unsigned i = 0; i < tokens.count(); i++ ) { 858 for( unsigned i = 0; i < tokens.count(); i++ ) {
857 p = tokens[ i ]; 859 p = tokens[ i ];
858 860
859 if ( p[ 0 ] == '~' ) 861 if ( p[ 0 ] == '~' )
860 { 862 {
861 int len = p.find( '/' ); 863 int len = p.find( '/' );
862 if ( len == -1 ) 864 if ( len == -1 )
863 len = p.length(); 865 len = p.length();
864 if ( len == 1 ) 866 if ( len == 1 )
865 p.replace( 0, 1, QDir::homeDirPath() ); 867 p.replace( 0, 1, QDir::homeDirPath() );
866 else 868 else
867 { 869 {
868 QString user = p.mid( 1, len - 1 ); 870 QString user = p.mid( 1, len - 1 );
869 struct passwd *dir = getpwnam( user.local8Bit().data() ); 871 struct passwd *dir = getpwnam( user.local8Bit().data() );
870 if ( dir && strlen( dir->pw_dir ) ) 872 if ( dir && strlen( dir->pw_dir ) )
871 p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) ); 873 p.replace( 0, len, QString::fromLocal8Bit( dir->pw_dir ) );
872 } 874 }
873 } 875 }
874 876
875 p += "/"; 877 p += "/";
876 p += appname; 878 p += appname;
877 879
878 // Check for executable in this tokenized path 880 // Check for executable in this tokenized path
879 info.setFile( p ); 881 info.setFile( p );
880 882
881 if( info.exists() && ( ignore || info.isExecutable() ) 883 if( info.exists() && ( ignore || info.isExecutable() )
882 && ( info.isFile() || info.isSymLink() ) ) { 884 && ( info.isFile() || info.isSymLink() ) ) {
883 return p; 885 return p;
884 } 886 }
885 } 887 }
886 888
887 // If we reach here, the executable wasn't found. 889 // If we reach here, the executable wasn't found.
888 // So return empty string. 890 // So return empty string.
889 891
890 return QString::null; 892 return QString::null;
891} 893}
892 894
893int KStandardDirs::findAllExe( QStringList& list, const QString& appname, 895int KStandardDirs::findAllExe( QStringList& list, const QString& appname,
894 const QString& pstr, bool ignore ) 896 const QString& pstr, bool ignore )
895{ 897{
896 QString p = pstr; 898 QString p = pstr;
897 QFileInfo info; 899 QFileInfo info;
898 QStringList tokens; 900 QStringList tokens;
899 901
900 if( p.isNull() ) { 902 if( p.isNull() ) {
901 p = getenv( "PATH" ); 903 p = getenv( "PATH" );
902 } 904 }
903 905
904 list.clear(); 906 list.clear();
905 tokenize( tokens, p, ":\b" ); 907 tokenize( tokens, p, ":\b" );
906 908
907 for ( unsigned i = 0; i < tokens.count(); i++ ) { 909 for ( unsigned i = 0; i < tokens.count(); i++ ) {
908 p = tokens[ i ]; 910 p = tokens[ i ];
909 p += "/"; 911 p += "/";
910 p += appname; 912 p += appname;
911 913
912 info.setFile( p ); 914 info.setFile( p );
913 915
914 if( info.exists() && (ignore || info.isExecutable()) 916 if( info.exists() && (ignore || info.isExecutable())
915 && info.isFile() ) { 917 && info.isFile() ) {
916 list.append( p ); 918 list.append( p );
917 } 919 }
918 920
919 } 921 }
920 922
921 return list.count(); 923 return list.count();
922} 924}
923*/ 925*/
924 926
925static int tokenize( QStringList& tokens, const QString& str, 927static int tokenize( QStringList& tokens, const QString& str,
926 const QString& delim ) 928 const QString& delim )
927{ 929{
928 int len = str.length(); 930 int len = str.length();
929 QString token = ""; 931 QString token = "";
930 932
931 for( int index = 0; index < len; index++) 933 for( int index = 0; index < len; index++)
932 { 934 {
933 if ( delim.find( str[ index ] ) >= 0 ) 935 if ( delim.find( str[ index ] ) >= 0 )
934 { 936 {
935 tokens.append( token ); 937 tokens.append( token );
936 token = ""; 938 token = "";
937 } 939 }
938 else 940 else
939 { 941 {
940 token += str[ index ]; 942 token += str[ index ];
941 } 943 }
942 } 944 }
943 if ( token.length() > 0 ) 945 if ( token.length() > 0 )
944 { 946 {
945 tokens.append( token ); 947 tokens.append( token );
946 } 948 }
947 949
948 return tokens.count(); 950 return tokens.count();
949} 951}
950 952
951QString KStandardDirs::kde_default(const char *type) { 953QString KStandardDirs::kde_default(const char *type) {
952 if (!strcmp(type, "data")) 954 if (!strcmp(type, "data"))
953 return "apps/"; 955 return "apps/";
954 if (!strcmp(type, "html")) 956 if (!strcmp(type, "html"))
955 return "share/doc/HTML/"; 957 return "share/doc/HTML/";
956 if (!strcmp(type, "icon")) 958 if (!strcmp(type, "icon"))
957 return "share/icons/"; 959 return "share/icons/";
958 if (!strcmp(type, "config")) 960 if (!strcmp(type, "config"))
959 return "config/"; 961 return "config/";
960 if (!strcmp(type, "pixmap")) 962 if (!strcmp(type, "pixmap"))
961 return "share/pixmaps/"; 963 return "share/pixmaps/";
962 if (!strcmp(type, "apps")) 964 if (!strcmp(type, "apps"))
963 return "share/applnk/"; 965 return "share/applnk/";
964 if (!strcmp(type, "sound")) 966 if (!strcmp(type, "sound"))
965 return "share/sounds/"; 967 return "share/sounds/";
966 if (!strcmp(type, "locale")) 968 if (!strcmp(type, "locale"))
967 return "share/locale/"; 969 return "share/locale/";
968 if (!strcmp(type, "services")) 970 if (!strcmp(type, "services"))
969 return "share/services/"; 971 return "share/services/";
970 if (!strcmp(type, "servicetypes")) 972 if (!strcmp(type, "servicetypes"))
971 return "share/servicetypes/"; 973 return "share/servicetypes/";
972 if (!strcmp(type, "mime")) 974 if (!strcmp(type, "mime"))
973 return "share/mimelnk/"; 975 return "share/mimelnk/";
974 if (!strcmp(type, "cgi")) 976 if (!strcmp(type, "cgi"))
975 return "cgi-bin/"; 977 return "cgi-bin/";
976 if (!strcmp(type, "wallpaper")) 978 if (!strcmp(type, "wallpaper"))
977 return "share/wallpapers/"; 979 return "share/wallpapers/";
978 if (!strcmp(type, "templates")) 980 if (!strcmp(type, "templates"))
979 return "share/templates/"; 981 return "share/templates/";
980 if (!strcmp(type, "exe")) 982 if (!strcmp(type, "exe"))
981 return "bin/"; 983 return "bin/";
982 if (!strcmp(type, "lib")) 984 if (!strcmp(type, "lib"))
983 return "lib/"; 985 return "lib/";
984 if (!strcmp(type, "module")) 986 if (!strcmp(type, "module"))
985 return "lib/kde3/"; 987 return "lib/kde3/";
986 if (!strcmp(type, "qtplugins")) 988 if (!strcmp(type, "qtplugins"))
987 return "lib/kde3/plugins"; 989 return "lib/kde3/plugins";
988 if (!strcmp(type, "xdgdata-apps")) 990 if (!strcmp(type, "xdgdata-apps"))
989 return "applications/"; 991 return "applications/";
990 if (!strcmp(type, "xdgdata-dirs")) 992 if (!strcmp(type, "xdgdata-dirs"))
991 return "desktop-directories/"; 993 return "desktop-directories/";
992 if (!strcmp(type, "xdgconf-menu")) 994 if (!strcmp(type, "xdgconf-menu"))
993 return "menus/"; 995 return "menus/";
994 if (!strcmp(type, "tmp")) 996 if (!strcmp(type, "tmp"))
995 return "tmp/"; 997 return "tmp/";
996 998
997 qFatal("unknown resource type %s", type); 999 qFatal("unknown resource type %s", type);
998 return QString::null; 1000 return QString::null;
999} 1001}
1000 1002
1001QString KStandardDirs::saveLocation(const char *type, 1003QString KStandardDirs::saveLocation(const char *type,
1002 const QString& suffix, 1004 const QString& suffix,
1003 bool create) const 1005 bool create) const
1004{ 1006{
1005 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() ); 1007 //qDebug("KStandardDirs::saveLocation called %s %s", type,suffix.latin1() );
1006 //return ""; 1008 //return "";
1007 checkConfig(); 1009 checkConfig();
1008 1010
1009 QString *pPath = savelocations.find(type); 1011 QString *pPath = savelocations.find(type);
1010 if (!pPath) 1012 if (!pPath)
1011 { 1013 {
1012 QStringList *dirs = relatives.find(type); 1014 QStringList *dirs = relatives.find(type);
1013 if (!dirs && ( 1015 if (!dirs && (
1014 (strcmp(type, "socket") == 0) || 1016 (strcmp(type, "socket") == 0) ||
1015 (strcmp(type, "tmp") == 0) || 1017 (strcmp(type, "tmp") == 0) ||
1016 (strcmp(type, "cache") == 0) )) 1018 (strcmp(type, "cache") == 0) ))
1017 { 1019 {
1018 (void) resourceDirs(type); // Generate socket|tmp|cache resource. 1020 (void) resourceDirs(type); // Generate socket|tmp|cache resource.
1019 dirs = relatives.find(type); // Search again. 1021 dirs = relatives.find(type); // Search again.
1020 } 1022 }
1021 if (dirs) 1023 if (dirs)
1022 { 1024 {
1023 // Check for existance of typed directory + suffix 1025 // Check for existance of typed directory + suffix
1024 if (strncmp(type, "xdgdata-", 8) == 0) 1026 if (strncmp(type, "xdgdata-", 8) == 0)
1025 pPath = new QString(realPath(localxdgdatadir() + dirs->last())); 1027 pPath = new QString(realPath(localxdgdatadir() + dirs->last()));
1026 else if (strncmp(type, "xdgconf-", 8) == 0) 1028 else if (strncmp(type, "xdgconf-", 8) == 0)
1027 pPath = new QString(realPath(localxdgconfdir() + dirs->last())); 1029 pPath = new QString(realPath(localxdgconfdir() + dirs->last()));
1028 else 1030 else
1029 pPath = new QString(realPath(localkdedir() + dirs->last())); 1031 pPath = new QString(realPath(localkdedir() + dirs->last()));
1030 } 1032 }
1031 else { 1033 else {
1032 dirs = absolutes.find(type); 1034 dirs = absolutes.find(type);
1033 if (!dirs) 1035 if (!dirs)
1034 qFatal("KStandardDirs: The resource type %s is not registered", type); 1036 qFatal("KStandardDirs: The resource type %s is not registered", type);
1035 pPath = new QString(realPath(dirs->last())); 1037 pPath = new QString(realPath(dirs->last()));
1036 } 1038 }
1037 1039
1038 savelocations.insert(type, pPath); 1040 savelocations.insert(type, pPath);
1039 } 1041 }
1040 1042
1041 QString fullPath = *pPath + suffix; 1043 QString fullPath = *pPath + suffix;
1042//US struct stat st; 1044//US struct stat st;
1043//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode))) 1045//US if (stat(QFile::encodeName(fullPath), &st) != 0 || !(S_ISDIR(st.st_mode)))
1044 QFileInfo fullPathInfo(QFile::encodeName(fullPath)); 1046 QFileInfo fullPathInfo(QFile::encodeName(fullPath));
1045 if (fullPathInfo.isReadable() || !fullPathInfo.isDir()) 1047 if (fullPathInfo.isReadable() || !fullPathInfo.isDir())
1046 1048
1047 1049
1048 { 1050 {
1049 if(!create) { 1051 if(!create) {
1050#ifndef NDEBUG 1052#ifndef NDEBUG
1051 qDebug("save location %s doesn't exist", fullPath.latin1()); 1053 qDebug("save location %s doesn't exist", fullPath.latin1());
1052#endif 1054#endif
1053 return fullPath; 1055 return fullPath;
1054 } 1056 }
1055 if(!makeDir(fullPath, 0700)) { 1057 if(!makeDir(fullPath, 0700)) {
1056 qWarning("failed to create %s", fullPath.latin1()); 1058 qWarning("failed to create %s", fullPath.latin1());
1057 return fullPath; 1059 return fullPath;
1058 } 1060 }
1059 dircache.remove(type); 1061 dircache.remove(type);
1060 } 1062 }
1061 return fullPath; 1063 return fullPath;
1062} 1064}
1063 1065
1064QString KStandardDirs::relativeLocation(const char *type, const QString &absPath) 1066QString KStandardDirs::relativeLocation(const char *type, const QString &absPath)
1065{ 1067{
1066 QString fullPath = absPath; 1068 QString fullPath = absPath;
1067 int i = absPath.findRev('/'); 1069 int i = absPath.findRev('/');
1068 if (i != -1) 1070 if (i != -1)
1069 { 1071 {
1070 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize 1072 fullPath = realPath(absPath.left(i+1))+absPath.mid(i+1); // Normalize
1071 } 1073 }
1072 1074
1073 QStringList candidates = resourceDirs(type); 1075 QStringList candidates = resourceDirs(type);
1074 1076
1075 for (QStringList::ConstIterator it = candidates.begin(); 1077 for (QStringList::ConstIterator it = candidates.begin();
1076 it != candidates.end(); it++) 1078 it != candidates.end(); it++)
1077 if (fullPath.startsWith(*it)) 1079 if (fullPath.startsWith(*it))
1078 { 1080 {
1079 return fullPath.mid((*it).length()); 1081 return fullPath.mid((*it).length());
1080 } 1082 }
1081 1083
1082 return absPath; 1084 return absPath;
1083} 1085}
1084 1086
1085 1087
1086bool KStandardDirs::makeDir(const QString& dir2, int mode) 1088bool KStandardDirs::makeDir(const QString& dir2, int mode)
1087{ 1089{
1088 QString dir = QDir::convertSeparators( dir2 ); 1090 QString dir = QDir::convertSeparators( dir2 );
1089#if 0 1091#if 0
1090 //LR 1092 //LR
1091 1093
1092 // we want an absolute path 1094 // we want an absolute path
1093 if (dir.at(0) != '/') 1095 if (dir.at(0) != '/')
1094 return false; 1096 return false;
1095 1097
1096 QString target = dir; 1098 QString target = dir;
1097 uint len = target.length(); 1099 uint len = target.length();
1098 1100
1099 // append trailing slash if missing 1101 // append trailing slash if missing
1100 if (dir.at(len - 1) != '/') 1102 if (dir.at(len - 1) != '/')
1101 target += '/'; 1103 target += '/';
1102 1104
1103 QString base(""); 1105 QString base("");
1104 uint i = 1; 1106 uint i = 1;
1105 1107
1106 while( i < len ) 1108 while( i < len )
1107 { 1109 {
1108//US struct stat st; 1110//US struct stat st;
1109 int pos = target.find('/', i); 1111 int pos = target.find('/', i);
1110 base += target.mid(i - 1, pos - i + 1); 1112 base += target.mid(i - 1, pos - i + 1);
1111 QCString baseEncoded = QFile::encodeName(base); 1113 Q3CString baseEncoded = QFile::encodeName(base);
1112 // bail out if we encountered a problem 1114 // bail out if we encountered a problem
1113//US if (stat(baseEncoded, &st) != 0) 1115//US if (stat(baseEncoded, &st) != 0)
1114 QFileInfo baseEncodedInfo(baseEncoded); 1116 QFileInfo baseEncodedInfo(baseEncoded);
1115 if (!baseEncodedInfo.exists()) 1117 if (!baseEncodedInfo.exists())
1116 { 1118 {
1117 // Directory does not exist.... 1119 // Directory does not exist....
1118 // Or maybe a dangling symlink ? 1120 // Or maybe a dangling symlink ?
1119//US if (lstat(baseEncoded, &st) == 0) 1121//US if (lstat(baseEncoded, &st) == 0)
1120 if (baseEncodedInfo.isSymLink()) { 1122 if (baseEncodedInfo.isSymLink()) {
1121//US (void)unlink(baseEncoded); // try removing 1123//US (void)unlink(baseEncoded); // try removing
1122 QFile(baseEncoded).remove(); 1124 QFile(baseEncoded).remove();
1123 } 1125 }
1124 1126
1125 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0) 1127 //US if ( mkdir(baseEncoded, (mode_t) mode) != 0)
1126 QDir dirObj; 1128 QDir dirObj;
1127 if ( dirObj.mkdir(baseEncoded) != true ) 1129 if ( dirObj.mkdir(baseEncoded) != true )
1128 { 1130 {
1129 //US perror("trying to create local folder"); 1131 //US perror("trying to create local folder");
1130 return false; // Couldn't create it :-( 1132 return false; // Couldn't create it :-(
1131 } 1133 }
1132 } 1134 }
1133 i = pos + 1; 1135 i = pos + 1;
1134 } 1136 }
1135 return true; 1137 return true;
1136#endif 1138#endif
1137 1139
1138 // ******************************************** 1140 // ********************************************
1139 // new code for WIN32 1141 // new code for WIN32
1140 QDir dirObj; 1142 QDir dirObj;
1141 1143
1142 1144
1143 // we want an absolute path 1145 // we want an absolute path
1144#ifndef _WIN32_ 1146#ifndef _WIN32_
1145 if (dir.at(0) != '/') 1147 if (dir.at(0) != '/')
1146 return false; 1148 return false;
1147#endif 1149#endif
1148 1150
1149 QString target = dir; 1151 QString target = dir;
1150 uint len = target.length(); 1152 uint len = target.length();
1151#ifndef _WIN32_ 1153#ifndef _WIN32_
1152 // append trailing slash if missing 1154 // append trailing slash if missing
1153 if (dir.at(len - 1) != '/') 1155 if (dir.at(len - 1) != '/')
1154 target += '/'; 1156 target += '/';
1155#endif 1157#endif
1156 1158
1157 QString base(""); 1159 QString base("");
1158 uint i = 1; 1160 uint i = 1;
1159 1161
1160 while( i < len ) 1162 while( i < len )
1161 { 1163 {
1162//US struct stat st; 1164//US struct stat st;
1163#ifndef _WIN32_ 1165#ifndef _WIN32_
1164 int pos = target.find('/', i); 1166 int pos = target.find('/', i);
1165#else 1167#else
1166 int pos = target.find('\\', i); 1168 int pos = target.find('\\', i);
1167#endif 1169#endif
1168 if ( pos < 0 ) 1170 if ( pos < 0 )
1169 return true; 1171 return true;
1170 base += target.mid(i - 1, pos - i + 1); 1172 base += target.mid(i - 1, pos - i + 1);
1171 //QMessageBox::information( 0,"cap111", base, 1 ); 1173 //QMessageBox::information( 0,"cap111", base, 1 );
1172/*US 1174/*US
1173 QCString baseEncoded = QFile::encodeName(base); 1175 QCString baseEncoded = QFile::encodeName(base);
1174 // bail out if we encountered a problem 1176 // bail out if we encountered a problem
1175 if (stat(baseEncoded, &st) != 0) 1177 if (stat(baseEncoded, &st) != 0)
1176 { 1178 {
1177 // Directory does not exist.... 1179 // Directory does not exist....
1178 // Or maybe a dangling symlink ? 1180 // Or maybe a dangling symlink ?
1179 if (lstat(baseEncoded, &st) == 0) 1181 if (lstat(baseEncoded, &st) == 0)
1180 (void)unlink(baseEncoded); // try removing 1182 (void)unlink(baseEncoded); // try removing
1181 1183
1182 1184
1183 if ( mkdir(baseEncoded, (mode_t) mode) != 0) { 1185 if ( mkdir(baseEncoded, (mode_t) mode) != 0) {
1184 perror("trying to create local folder"); 1186 perror("trying to create local folder");
1185 return false; // Couldn't create it :-( 1187 return false; // Couldn't create it :-(
1186 } 1188 }
1187 } 1189 }
1188*/ 1190*/
1189 1191
1190 if (dirObj.exists(base) == false) 1192 if (dirObj.exists(base) == false)
1191 { 1193 {
1192 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1()); 1194 //qDebug("KStandardDirs::makeDir try to create : %s" , base.latin1());
1193 if (dirObj.mkdir(base) != true) 1195 if (dirObj.mkdir(base) != true)
1194 { 1196 {
1195 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1()); 1197 qDebug("KStandardDirs::makeDir could not create: %s" , base.latin1());
1196 return false; 1198 return false;
1197 } 1199 }
1198 } 1200 }
1199 1201
1200 i = pos + 1; 1202 i = pos + 1;
1201 } 1203 }
1202 return true; 1204 return true;
1203 1205
1204} 1206}
1205 1207
1206QString readEnvPath(const char *env) 1208QString readEnvPath(const char *env)
1207{ 1209{
1208 //#ifdef _WIN32_ 1210 //#ifdef _WIN32_
1209 // return ""; 1211 // return "";
1210 //#else 1212 //#else
1211 QCString c_path; 1213 Q3CString c_path;
1212 if ( getenv(env) != NULL ) 1214 if ( getenv(env) != NULL )
1213 c_path = QString ( getenv(env) ); 1215 c_path = QString ( getenv(env) );
1214 if (c_path.isEmpty()) 1216 if (c_path.isEmpty())
1215 return QString::null; 1217 return QString::null;
1216 return QFile::decodeName(c_path); 1218 return QFile::decodeName(c_path);
1217 //#endif 1219 //#endif
1218 1220
1219} 1221}
1220 1222
1221void KStandardDirs::addKDEDefaults() 1223void KStandardDirs::addKDEDefaults()
1222{ 1224{
1223 1225
1224 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called "); 1226 //qDebug("ERROR: KStandardDirs::addKDEDefaults() called ");
1225 //return; 1227 //return;
1226 QStringList kdedirList; 1228 QStringList kdedirList;
1227 1229
1228 // begin KDEDIRS 1230 // begin KDEDIRS
1229 QString kdedirs = readEnvPath("MICROKDEDIRS"); 1231 QString kdedirs = readEnvPath("MICROKDEDIRS");
1230 if (!kdedirs.isEmpty()) 1232 if (!kdedirs.isEmpty())
1231 { 1233 {
1232 tokenize(kdedirList, kdedirs, ":"); 1234 tokenize(kdedirList, kdedirs, ":");
1233 } 1235 }
1234 else 1236 else
1235 { 1237 {
1236 QString kdedir = readEnvPath("MICROKDEDIR"); 1238 QString kdedir = readEnvPath("MICROKDEDIR");
1237 if (!kdedir.isEmpty()) 1239 if (!kdedir.isEmpty())
1238 { 1240 {
1239 kdedir = KShell::tildeExpand(kdedir); 1241 kdedir = KShell::tildeExpand(kdedir);
1240 kdedirList.append(kdedir); 1242 kdedirList.append(kdedir);
1241 } 1243 }
1242 } 1244 }
1243//US kdedirList.append(KDEDIR); 1245//US kdedirList.append(KDEDIR);
1244//US for embedded, add qtopia dir as kdedir 1246//US for embedded, add qtopia dir as kdedir
1245 1247
1246#ifndef DESKTOP_VERSION 1248#ifndef DESKTOP_VERSION
1247 QString tmp = readEnvPath("QPEDIR"); 1249 QString tmp = readEnvPath("QPEDIR");
1248 if (!tmp.isEmpty()) 1250 if (!tmp.isEmpty())
1249 kdedirList.append(tmp); 1251 kdedirList.append(tmp);
1250 1252
1251 tmp = readEnvPath("QTDIR"); 1253 tmp = readEnvPath("QTDIR");
1252 if (!tmp.isEmpty()) 1254 if (!tmp.isEmpty())
1253 kdedirList.append(tmp); 1255 kdedirList.append(tmp);
1254 1256
1255 tmp = readEnvPath("OPIEDIR"); 1257 tmp = readEnvPath("OPIEDIR");
1256 if (!tmp.isEmpty()) 1258 if (!tmp.isEmpty())
1257 kdedirList.append(tmp); 1259 kdedirList.append(tmp);
1258 1260
1259#endif 1261#endif
1260 1262
1261#ifdef __KDE_EXECPREFIX 1263#ifdef __KDE_EXECPREFIX
1262 QString execPrefix(__KDE_EXECPREFIX); 1264 QString execPrefix(__KDE_EXECPREFIX);
1263 if (execPrefix!="NONE") 1265 if (execPrefix!="NONE")
1264 kdedirList.append(execPrefix); 1266 kdedirList.append(execPrefix);
1265#endif 1267#endif
1266 1268
1267 QString localKdeDir; 1269 QString localKdeDir;
1268 1270
1269//US if (getuid()) 1271//US if (getuid())
1270 if (true) 1272 if (true)
1271 { 1273 {
1272 localKdeDir = readEnvPath("MICROKDEHOME"); 1274 localKdeDir = readEnvPath("MICROKDEHOME");
1273 if (!localKdeDir.isEmpty()) 1275 if (!localKdeDir.isEmpty())
1274 { 1276 {
1275#ifdef _WIN32_ 1277#ifdef _WIN32_
1276 if (localKdeDir.at(localKdeDir.length()-1) != '\\') 1278 if (localKdeDir.at(localKdeDir.length()-1) != '\\')
1277 localKdeDir += '\\'; 1279 localKdeDir += '\\';
1278#else 1280#else
1279 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1281 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1280 localKdeDir += '/'; 1282 localKdeDir += '/';
1281#endif 1283#endif
1282 //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 ); 1284 //QMessageBox::information( 0,"localKdeDir",localKdeDir, 1 );
1283 } 1285 }
1284 else 1286 else
1285 { 1287 {
1286 QString confFile; 1288 QString confFile;
1287#ifdef DESKTOP_VERSION 1289#ifdef DESKTOP_VERSION
1288 confFile = qApp->applicationDirPath ()+ "/.microkdehome" ; 1290 confFile = qApp->applicationDirPath ()+ "/.microkdehome" ;
1289 QFileInfo fi ( confFile ); 1291 QFileInfo fi ( confFile );
1290 if ( !fi.exists() ) 1292 if ( !fi.exists() )
1291 confFile = QDir::homeDirPath() + "/.microkdehome"; 1293 confFile = QDir::homeDirPath() + "/.microkdehome";
1292 else 1294 else
1293 qDebug("Loading path info from " + confFile ); 1295 qDebug("Loading path info from " + confFile );
1294 1296
1295#else 1297#else
1296 confFile = QDir::homeDirPath() + "/.microkdehome"; 1298 confFile = QDir::homeDirPath() + "/.microkdehome";
1297#endif 1299#endif
1298 KConfig cfg ( confFile ); 1300 KConfig cfg ( confFile );
1299 cfg.setGroup("Global"); 1301 cfg.setGroup("Global");
1300 localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" ); 1302 localKdeDir = cfg.readEntry( "MICROKDEHOME", QDir::homeDirPath() + "/kdepim/" );
1301#ifdef DESKTOP_VERSION 1303#ifdef DESKTOP_VERSION
1302 if ( localKdeDir.startsWith( "LOCAL:" ) ) { 1304 if ( localKdeDir.startsWith( "LOCAL:" ) ) {
1303#ifdef _WIN32_ 1305#ifdef _WIN32_
1304 localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 ); 1306 localKdeDir = qApp->applicationDirPath () + "\\"+ localKdeDir.mid( 6 );
1305#else 1307#else
1306 localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 ); 1308 localKdeDir = qApp->applicationDirPath () + "/"+ localKdeDir.mid( 6 );
1307#endif 1309#endif
1308 qDebug("Using local conf dir %s ",localKdeDir.latin1() ); 1310 qDebug("Using local conf dir %s ",localKdeDir.latin1() );
1309 // <stdlib.h> 1311 // <stdlib.h>
1310#ifdef _WIN32_ 1312#ifdef _WIN32_
1311 QString envSt = "LOCALMICROKDEHOME="+localKdeDir; 1313 QString envSt = "LOCALMICROKDEHOME="+localKdeDir;
1312 _putenv( envSt.latin1()); 1314 _putenv( envSt.latin1());
1313#else 1315#else
1314 setenv( "LOCALMICROKDEHOME", localKdeDir.latin1(), 1 ); 1316 setenv( "LOCALMICROKDEHOME", localKdeDir.latin1(), 1 );
1315#endif 1317#endif
1316 } 1318 }
1317#endif 1319#endif
1318 } 1320 }
1319 } 1321 }
1320 else 1322 else
1321 { 1323 {
1322 // We treat root different to prevent root messing up the 1324 // We treat root different to prevent root messing up the
1323 // file permissions in the users home directory. 1325 // file permissions in the users home directory.
1324 localKdeDir = readEnvPath("MICROKDEROOTHOME"); 1326 localKdeDir = readEnvPath("MICROKDEROOTHOME");
1325 if (!localKdeDir.isEmpty()) 1327 if (!localKdeDir.isEmpty())
1326 { 1328 {
1327 if (localKdeDir.at(localKdeDir.length()-1) != '/') 1329 if (localKdeDir.at(localKdeDir.length()-1) != '/')
1328 localKdeDir += '/'; 1330 localKdeDir += '/';
1329 } 1331 }
1330 else 1332 else
1331 { 1333 {
1332//US struct passwd *pw = getpwuid(0); 1334//US struct passwd *pw = getpwuid(0);
1333//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/"; 1335//US localKdeDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.microkde/";
1334 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed"); 1336 qDebug("KStandardDirs::addKDEDefaults: 1 has to be fixed");
1335 } 1337 }
1336 1338
1337 } 1339 }
1338 1340
1339//US localKdeDir = appDir(); 1341//US localKdeDir = appDir();
1340 1342
1341//US 1343//US
1342// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1()); 1344// qDebug("KStandardDirs::addKDEDefaults: localKdeDir=%s", localKdeDir.latin1());
1343 if (localKdeDir != "-/") 1345 if (localKdeDir != "-/")
1344 { 1346 {
1345 localKdeDir = KShell::tildeExpand(localKdeDir); 1347 localKdeDir = KShell::tildeExpand(localKdeDir);
1346 addPrefix(localKdeDir); 1348 addPrefix(localKdeDir);
1347 } 1349 }
1348 1350
1349 for (QStringList::ConstIterator it = kdedirList.begin(); 1351 for (QStringList::ConstIterator it = kdedirList.begin();
1350 it != kdedirList.end(); it++) 1352 it != kdedirList.end(); it++)
1351 { 1353 {
1352 QString dir = KShell::tildeExpand(*it); 1354 QString dir = KShell::tildeExpand(*it);
1353 addPrefix(dir); 1355 addPrefix(dir);
1354 } 1356 }
1355 // end KDEDIRS 1357 // end KDEDIRS
1356 1358
1357 // begin XDG_CONFIG_XXX 1359 // begin XDG_CONFIG_XXX
1358 QStringList xdgdirList; 1360 QStringList xdgdirList;
1359 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS"); 1361 QString xdgdirs = readEnvPath("XDG_CONFIG_DIRS");
1360 if (!xdgdirs.isEmpty()) 1362 if (!xdgdirs.isEmpty())
1361 { 1363 {
1362 tokenize(xdgdirList, xdgdirs, ":"); 1364 tokenize(xdgdirList, xdgdirs, ":");
1363 } 1365 }
1364 else 1366 else
1365 { 1367 {
1366 xdgdirList.clear(); 1368 xdgdirList.clear();
1367 xdgdirList.append("/etc/xdg"); 1369 xdgdirList.append("/etc/xdg");
1368 } 1370 }
1369 1371
1370 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME"); 1372 QString localXdgDir = readEnvPath("XDG_CONFIG_HOME");
1371 if (!localXdgDir.isEmpty()) 1373 if (!localXdgDir.isEmpty())
1372 { 1374 {
1373 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1375 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1374 localXdgDir += '/'; 1376 localXdgDir += '/';
1375 } 1377 }
1376 else 1378 else
1377 { 1379 {
1378//US if (getuid()) 1380//US if (getuid())
1379 if (true) 1381 if (true)
1380 { 1382 {
1381 localXdgDir = QDir::homeDirPath() + "/.config/"; 1383 localXdgDir = QDir::homeDirPath() + "/.config/";
1382 } 1384 }
1383 else 1385 else
1384 { 1386 {
1385//US struct passwd *pw = getpwuid(0); 1387//US struct passwd *pw = getpwuid(0);
1386//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/"; 1388//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.config/";
1387 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed"); 1389 qDebug("KStandardDirs::addKDEDefaults: 2 has to be fixed");
1388 } 1390 }
1389 } 1391 }
1390 1392
1391 localXdgDir = KShell::tildeExpand(localXdgDir); 1393 localXdgDir = KShell::tildeExpand(localXdgDir);
1392 addXdgConfigPrefix(localXdgDir); 1394 addXdgConfigPrefix(localXdgDir);
1393 1395
1394 for (QStringList::ConstIterator it = xdgdirList.begin(); 1396 for (QStringList::ConstIterator it = xdgdirList.begin();
1395 it != xdgdirList.end(); it++) 1397 it != xdgdirList.end(); it++)
1396 { 1398 {
1397 QString dir = KShell::tildeExpand(*it); 1399 QString dir = KShell::tildeExpand(*it);
1398 addXdgConfigPrefix(dir); 1400 addXdgConfigPrefix(dir);
1399 } 1401 }
1400 // end XDG_CONFIG_XXX 1402 // end XDG_CONFIG_XXX
1401 1403
1402 // begin XDG_DATA_XXX 1404 // begin XDG_DATA_XXX
1403 xdgdirs = readEnvPath("XDG_DATA_DIRS"); 1405 xdgdirs = readEnvPath("XDG_DATA_DIRS");
1404 if (!xdgdirs.isEmpty()) 1406 if (!xdgdirs.isEmpty())
1405 { 1407 {
1406 tokenize(xdgdirList, xdgdirs, ":"); 1408 tokenize(xdgdirList, xdgdirs, ":");
1407 } 1409 }
1408 else 1410 else
1409 { 1411 {
1410 xdgdirList.clear(); 1412 xdgdirList.clear();
1411 for (QStringList::ConstIterator it = kdedirList.begin(); 1413 for (QStringList::ConstIterator it = kdedirList.begin();
1412 it != kdedirList.end(); it++) 1414 it != kdedirList.end(); it++)
1413 { 1415 {
1414 QString dir = *it; 1416 QString dir = *it;
1415 if (dir.at(dir.length()-1) != '/') 1417 if (dir.at(dir.length()-1) != '/')
1416 dir += '/'; 1418 dir += '/';
1417 xdgdirList.append(dir+"share/"); 1419 xdgdirList.append(dir+"share/");
1418 } 1420 }
1419 1421
1420 xdgdirList.append("/usr/local/share/"); 1422 xdgdirList.append("/usr/local/share/");
1421 xdgdirList.append("/usr/share/"); 1423 xdgdirList.append("/usr/share/");
1422 } 1424 }
1423 1425
1424 localXdgDir = readEnvPath("XDG_DATA_HOME"); 1426 localXdgDir = readEnvPath("XDG_DATA_HOME");
1425 if (!localXdgDir.isEmpty()) 1427 if (!localXdgDir.isEmpty())
1426 { 1428 {
1427 if (localXdgDir.at(localXdgDir.length()-1) != '/') 1429 if (localXdgDir.at(localXdgDir.length()-1) != '/')
1428 localXdgDir += '/'; 1430 localXdgDir += '/';
1429 } 1431 }
1430 else 1432 else
1431 { 1433 {
1432//US if (getuid()) 1434//US if (getuid())
1433 if (true) 1435 if (true)
1434 { 1436 {
1435 localXdgDir = QDir::homeDirPath() + "/.local/share/"; 1437 localXdgDir = QDir::homeDirPath() + "/.local/share/";
1436 } 1438 }
1437 else 1439 else
1438 { 1440 {
1439//US struct passwd *pw = getpwuid(0); 1441//US struct passwd *pw = getpwuid(0);
1440//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/"; 1442//US localXdgDir = QFile::decodeName((pw && pw->pw_dir) ? pw->pw_dir : "/root") + "/.local/share/";
1441 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed"); 1443 qDebug("KStandardDirs::addKDEDefaults: 3 has to be fixed");
1442 } 1444 }
1443 } 1445 }
1444 1446
1445 localXdgDir = KShell::tildeExpand(localXdgDir); 1447 localXdgDir = KShell::tildeExpand(localXdgDir);
1446 addXdgDataPrefix(localXdgDir); 1448 addXdgDataPrefix(localXdgDir);
1447 1449
1448 for (QStringList::ConstIterator it = xdgdirList.begin(); 1450 for (QStringList::ConstIterator it = xdgdirList.begin();
1449 it != xdgdirList.end(); it++) 1451 it != xdgdirList.end(); it++)
1450 { 1452 {
1451 QString dir = KShell::tildeExpand(*it); 1453 QString dir = KShell::tildeExpand(*it);
1452 1454
1453 addXdgDataPrefix(dir); 1455 addXdgDataPrefix(dir);
1454 } 1456 }
1455 // end XDG_DATA_XXX 1457 // end XDG_DATA_XXX
1456 1458
1457 1459
1458 uint index = 0; 1460 uint index = 0;
1459 while (types[index] != 0) { 1461 while (types[index] != 0) {
1460 addResourceType(types[index], kde_default(types[index])); 1462 addResourceType(types[index], kde_default(types[index]));
1461 index++; 1463 index++;
1462 } 1464 }
1463 1465
1464 addResourceDir("home", QDir::homeDirPath()); 1466 addResourceDir("home", QDir::homeDirPath());
1465} 1467}
1466 1468
1467void KStandardDirs::checkConfig() const 1469void KStandardDirs::checkConfig() const
1468{ 1470{
1469/*US 1471/*US
1470 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config) 1472 if (!addedCustoms && KGlobal::_instance && KGlobal::_instance->_config)
1471 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config); 1473 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::_instance->_config);
1472*/ 1474*/
1473 if (!addedCustoms && KGlobal::config()) 1475 if (!addedCustoms && KGlobal::config())
1474 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config()); 1476 const_cast<KStandardDirs*>(this)->addCustomized(KGlobal::config());
1475} 1477}
1476 1478
1477bool KStandardDirs::addCustomized(KConfig *config) 1479bool KStandardDirs::addCustomized(KConfig *config)
1478{ 1480{
1479 if (addedCustoms) // there are already customized entries 1481 if (addedCustoms) // there are already customized entries
1480 return false; // we just quite and hope they are the right ones 1482 return false; // we just quite and hope they are the right ones
1481 1483
1482 // save the numbers of config directories. If this changes, 1484 // save the numbers of config directories. If this changes,
1483 // we will return true to give KConfig a chance to reparse 1485 // we will return true to give KConfig a chance to reparse
1484 uint configdirs = resourceDirs("config").count(); 1486 uint configdirs = resourceDirs("config").count();
1485 1487
1486 // reading the prefixes in 1488 // reading the prefixes in
1487 QString oldGroup = config->group(); 1489 QString oldGroup = config->group();
1488 config->setGroup("Directories"); 1490 config->setGroup("Directories");
1489 1491
1490 QStringList list; 1492 QStringList list;
1491 QStringList::ConstIterator it; 1493 QStringList::ConstIterator it;
1492 list = config->readListEntry("prefixes"); 1494 list = config->readListEntry("prefixes");
1493 for (it = list.begin(); it != list.end(); it++) 1495 for (it = list.begin(); it != list.end(); it++)
1494 addPrefix(*it); 1496 addPrefix(*it);
1495 1497
1496 // iterating over all entries in the group Directories 1498 // iterating over all entries in the group Directories
1497 // to find entries that start with dir_$type 1499 // to find entries that start with dir_$type
1498/*US 1500/*US
1499 QMap<QString, QString> entries = config->entryMap("Directories"); 1501 QMap<QString, QString> entries = config->entryMap("Directories");
1500 1502
1501 QMap<QString, QString>::ConstIterator it2; 1503 QMap<QString, QString>::ConstIterator it2;
1502 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1504 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1503 { 1505 {
1504 QString key = it2.key(); 1506 QString key = it2.key();
1505 if (key.left(4) == "dir_") { 1507 if (key.left(4) == "dir_") {
1506 // generate directory list, there may be more than 1. 1508 // generate directory list, there may be more than 1.
1507 QStringList dirs = QStringList::split(',', *it2); 1509 QStringList dirs = QStringList::split(',', *it2);
1508 QStringList::Iterator sIt(dirs.begin()); 1510 QStringList::Iterator sIt(dirs.begin());
1509 QString resType = key.mid(4, key.length()); 1511 QString resType = key.mid(4, key.length());
1510 for (; sIt != dirs.end(); ++sIt) { 1512 for (; sIt != dirs.end(); ++sIt) {
1511 addResourceDir(resType.latin1(), *sIt); 1513 addResourceDir(resType.latin1(), *sIt);
1512 } 1514 }
1513 } 1515 }
1514 } 1516 }
1515 1517
1516 // Process KIOSK restrictions. 1518 // Process KIOSK restrictions.
1517 config->setGroup("KDE Resource Restrictions"); 1519 config->setGroup("KDE Resource Restrictions");
1518 entries = config->entryMap("KDE Resource Restrictions"); 1520 entries = config->entryMap("KDE Resource Restrictions");
1519 for (it2 = entries.begin(); it2 != entries.end(); it2++) 1521 for (it2 = entries.begin(); it2 != entries.end(); it2++)
1520 { 1522 {
1521 QString key = it2.key(); 1523 QString key = it2.key();
1522 if (!config->readBoolEntry(key, true)) 1524 if (!config->readBoolEntry(key, true))
1523 { 1525 {
1524 d->restrictionsActive = true; 1526 d->restrictionsActive = true;
1525 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do 1527 d->restrictions.insert(key.latin1(), &d->restrictionsActive); // Anything will do
1526 dircache.remove(key.latin1()); 1528 dircache.remove(key.latin1());
1527 } 1529 }
1528 } 1530 }
1529*/ 1531*/
1530 // save it for future calls - that will return 1532 // save it for future calls - that will return
1531 addedCustoms = true; 1533 addedCustoms = true;
1532 config->setGroup(oldGroup); 1534 config->setGroup(oldGroup);
1533 1535
1534 // return true if the number of config dirs changed 1536 // return true if the number of config dirs changed
1535 return (resourceDirs("config").count() != configdirs); 1537 return (resourceDirs("config").count() != configdirs);
1536} 1538}
1537 1539
1538QString KStandardDirs::localkdedir() const 1540QString KStandardDirs::localkdedir() const
1539{ 1541{
1540 // Return the prefix to use for saving 1542 // Return the prefix to use for saving
1541 return prefixes.first(); 1543 return prefixes.first();
1542} 1544}
1543 1545
1544QString KStandardDirs::localxdgdatadir() const 1546QString KStandardDirs::localxdgdatadir() const
1545{ 1547{
1546 // Return the prefix to use for saving 1548 // Return the prefix to use for saving
1547 return d->xdgdata_prefixes.first(); 1549 return d->xdgdata_prefixes.first();
1548} 1550}
1549 1551
1550QString KStandardDirs::localxdgconfdir() const 1552QString KStandardDirs::localxdgconfdir() const
1551{ 1553{
1552 // Return the prefix to use for saving 1554 // Return the prefix to use for saving
1553 return d->xdgconf_prefixes.first(); 1555 return d->xdgconf_prefixes.first();
1554} 1556}
1555 1557
1556void KStandardDirs::setAppDir( const QString &appDir ) 1558void KStandardDirs::setAppDir( const QString &appDir )
1557{ 1559{
1558 mAppDir = appDir; 1560 mAppDir = appDir;
1559 1561
1560 if ( mAppDir.right( 1 ) != "/" ) 1562 if ( mAppDir.right( 1 ) != "/" )
1561 mAppDir += "/"; 1563 mAppDir += "/";
1562} 1564}
1563 1565
1564QString KStandardDirs::appDir() 1566QString KStandardDirs::appDir()
1565{ 1567{
1566 return mAppDir; 1568 return mAppDir;
1567} 1569}
1568 1570
1569// just to make code more readable without macros 1571// just to make code more readable without macros
1570QString locate( const char *type, 1572QString locate( const char *type,
1571 const QString& filename/*US , const KInstance* inst*/ ) 1573 const QString& filename/*US , const KInstance* inst*/ )
1572{ 1574{
1573//US return inst->dirs()->findResource(type, filename); 1575//US return inst->dirs()->findResource(type, filename);
1574 return KGlobal::dirs()->findResource(type, filename); 1576 return KGlobal::dirs()->findResource(type, filename);
1575} 1577}
1576 1578
1577QString locateLocal( const char *type, 1579QString locateLocal( const char *type,
1578 const QString& filename/*US , const KInstance* inst*/ ) 1580 const QString& filename/*US , const KInstance* inst*/ )
1579{ 1581{
1580 1582
1581 QString path = locateLocal(type, filename, true /*US, inst*/); 1583 QString path = locateLocal(type, filename, true /*US, inst*/);
1582 1584
1583 1585
1584/* 1586/*
1585 static int ccc = 0; 1587 static int ccc = 0;
1586 ++ccc; 1588 ++ccc;
1587 if ( ccc > 13 ) 1589 if ( ccc > 13 )
1588 abort(); 1590 abort();
1589*/ 1591*/
1590 //qDebug("locatelocal: %s" , path.latin1()); 1592 //qDebug("locatelocal: %s" , path.latin1());
1591 return path; 1593 return path;
1592 1594
1593/*US why do we put all files into one directory. It is quit complicated. 1595/*US why do we put all files into one directory. It is quit complicated.
1594why not staying with the original directorystructure ? 1596why not staying with the original directorystructure ?
1595 1597
diff --git a/microkde/kdecore/kstandarddirs.h b/microkde/kdecore/kstandarddirs.h
index 901384e..f0e28fc 100644
--- a/microkde/kdecore/kstandarddirs.h
+++ b/microkde/kdecore/kstandarddirs.h
@@ -1,685 +1,685 @@
1/* 1/*
2 This file is part of the KDE libraries 2 This file is part of the KDE libraries
3 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org> 3 Copyright (C) 1999 Sirtaj Singh Kang <taj@kde.org>
4 Stephan Kulow <coolo@kde.org> 4 Stephan Kulow <coolo@kde.org>
5 Waldo Bastian <bastian@kde.org> 5 Waldo Bastian <bastian@kde.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef SSK_KSTDDIRS_H 23#ifndef SSK_KSTDDIRS_H
24#define SSK_KSTDDIRS_H 24#define SSK_KSTDDIRS_H
25 25
26#include <qstring.h> 26#include <qstring.h>
27#include <qdict.h> 27#include <q3dict.h>
28#include <qstringlist.h> 28#include <qstringlist.h>
29#include <kglobal.h> 29#include <kglobal.h>
30 30
31class KConfig; 31class KConfig;
32class KStandardDirsPrivate; 32class KStandardDirsPrivate;
33 33
34 34
35/** 35/**
36 * @short Site-independent access to standard KDE directories. 36 * @short Site-independent access to standard KDE directories.
37 * @author Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org> 37 * @author Stephan Kulow <coolo@kde.org> and Sirtaj Singh Kang <taj@kde.org>
38 * @version $Id$ 38 * @version $Id$
39 * 39 *
40 * This is one of the most central classes in kdelibs as 40 * This is one of the most central classes in kdelibs as
41 * it provides a basic service: It knows where the files 41 * it provides a basic service: It knows where the files
42 * reside on the user's hard disk. And it's meant to be the 42 * reside on the user's hard disk. And it's meant to be the
43 * only one that knows -- to make the real location as 43 * only one that knows -- to make the real location as
44 * transparent as possible to both the user and the applications. 44 * transparent as possible to both the user and the applications.
45 * 45 *
46 * To this end it insulates the application from all information 46 * To this end it insulates the application from all information
47 * and applications always refer to a file with a resource type 47 * and applications always refer to a file with a resource type
48 * (e.g. icon) and a filename (e.g. khexdit.xpm). In an ideal world 48 * (e.g. icon) and a filename (e.g. khexdit.xpm). In an ideal world
49 * the application would make no assumption where this file is and 49 * the application would make no assumption where this file is and
50 * leave it up to @ref KStandardDirs::findResource("apps", "Home.desktop") 50 * leave it up to @ref KStandardDirs::findResource("apps", "Home.desktop")
51 * to apply this knowledge to return /opt/kde/share/applnk/Home.desktop 51 * to apply this knowledge to return /opt/kde/share/applnk/Home.desktop
52 * or ::locate("data", "kgame/background.jpg") to return 52 * or ::locate("data", "kgame/background.jpg") to return
53 * /opt/kde/share/apps/kgame/background.jpg 53 * /opt/kde/share/apps/kgame/background.jpg
54 * 54 *
55 * The main idea behind KStandardDirs is that there are several 55 * The main idea behind KStandardDirs is that there are several
56 * toplevel prefixes below which the files lie. One of these prefixes is 56 * toplevel prefixes below which the files lie. One of these prefixes is
57 * the one where the user installed kdelibs, one is where the 57 * the one where the user installed kdelibs, one is where the
58 * application was installed, and one is $HOME/.kde, but there 58 * application was installed, and one is $HOME/.kde, but there
59 * may be even more. Under these prefixes there are several well 59 * may be even more. Under these prefixes there are several well
60 * defined suffixes where specific resource types are to be found. 60 * defined suffixes where specific resource types are to be found.
61 * For example, for the resource type "html" the suffixes could be 61 * For example, for the resource type "html" the suffixes could be
62 * share/doc/HTML and share/doc/kde/HTML. 62 * share/doc/HTML and share/doc/kde/HTML.
63 * So the search algorithm basicly appends to each prefix each registered 63 * So the search algorithm basicly appends to each prefix each registered
64 * suffix and tries to locate the file there. 64 * suffix and tries to locate the file there.
65 * To make the thing even more complex, it's also possible to register 65 * To make the thing even more complex, it's also possible to register
66 * absolute paths that KStandardDirs looks up after not finding anything 66 * absolute paths that KStandardDirs looks up after not finding anything
67 * in the former steps. They can be useful if the user wants to provide 67 * in the former steps. They can be useful if the user wants to provide
68 * specific directories that aren't in his $HOME/.kde directory for, 68 * specific directories that aren't in his $HOME/.kde directory for,
69 * for example, icons. 69 * for example, icons.
70 * 70 *
71 * @sect Standard resources that kdelibs allocates are: 71 * @sect Standard resources that kdelibs allocates are:
72 * 72 *
73 * @li apps - Applications menu (.desktop files). 73 * @li apps - Applications menu (.desktop files).
74 * @li cache - Cached information (e.g. favicons, web-pages) 74 * @li cache - Cached information (e.g. favicons, web-pages)
75 * @li cgi - CGIs to run from kdehelp. 75 * @li cgi - CGIs to run from kdehelp.
76 * @li config - Configuration files. 76 * @li config - Configuration files.
77 * @li data - Where applications store data. 77 * @li data - Where applications store data.
78 * @li exe - Executables in $prefix/bin. @ref findExe() for a function that takes $PATH into account. 78 * @li exe - Executables in $prefix/bin. @ref findExe() for a function that takes $PATH into account.
79 * @li html - HTML documentation. 79 * @li html - HTML documentation.
80 * @li icon - Icons, see @ref KIconLoader. 80 * @li icon - Icons, see @ref KIconLoader.
81 * @li lib - Libraries. 81 * @li lib - Libraries.
82 * @li locale - Translation files for @ref KLocale. 82 * @li locale - Translation files for @ref KLocale.
83 * @li mime - Mime types. 83 * @li mime - Mime types.
84 * @li module - Module (dynamically loaded library). 84 * @li module - Module (dynamically loaded library).
85 * @li qtplugins - Qt plugins (dynamically loaded objects for Qt) 85 * @li qtplugins - Qt plugins (dynamically loaded objects for Qt)
86 * @li services - Services. 86 * @li services - Services.
87 * @li servicetypes - Service types. 87 * @li servicetypes - Service types.
88 * @li scripts - Application scripting additions. 88 * @li scripts - Application scripting additions.
89 * @li sound - Application sounds. 89 * @li sound - Application sounds.
90 * @li templates - Templates 90 * @li templates - Templates
91 * @li wallpaper - Wallpapers. 91 * @li wallpaper - Wallpapers.
92 * @li tmp - Temporary files (specfic for both current host and current user) 92 * @li tmp - Temporary files (specfic for both current host and current user)
93 * @li socket - UNIX Sockets (specific for both current host and current user) 93 * @li socket - UNIX Sockets (specific for both current host and current user)
94 * 94 *
95 * A type that is added by the class @ref KApplication if you use it, is 95 * A type that is added by the class @ref KApplication if you use it, is
96 * appdata. This one makes the use of the type data a bit easier as it 96 * appdata. This one makes the use of the type data a bit easier as it
97 * appends the name of the application. 97 * appends the name of the application.
98 * So while you had to ::locate("data", "appname/filename") so you can 98 * So while you had to ::locate("data", "appname/filename") so you can
99 * also write ::locate("appdata", "filename") if your KApplication instance 99 * also write ::locate("appdata", "filename") if your KApplication instance
100 * is called "appname" (as set via KApplication's constructor or KAboutData, if 100 * is called "appname" (as set via KApplication's constructor or KAboutData, if
101 * you use the global KStandardDirs object @ref KGlobal::dirs()). 101 * you use the global KStandardDirs object @ref KGlobal::dirs()).
102 * Please note though that you cannot use the "appdata" 102 * Please note though that you cannot use the "appdata"
103 * type if you intend to use it in an applet for Kicker because 'appname' would 103 * type if you intend to use it in an applet for Kicker because 'appname' would
104 * be "Kicker" instead of the applet's name. Therefore, for applets, you've got 104 * be "Kicker" instead of the applet's name. Therefore, for applets, you've got
105 * to work around this by using ::locate("data", "appletname/filename"). 105 * to work around this by using ::locate("data", "appletname/filename").
106 * 106 *
107 * @sect KStandardDirs supports the following environment variables: 107 * @sect KStandardDirs supports the following environment variables:
108 * 108 *
109 * @li KDEDIRS: This may set an additional number of directory prefixes to 109 * @li KDEDIRS: This may set an additional number of directory prefixes to
110 * search for resources. The directories should be seperated 110 * search for resources. The directories should be seperated
111 * by ':'. The directories are searched in the order they are 111 * by ':'. The directories are searched in the order they are
112 * specified. 112 * specified.
113 * @li KDEDIR: Used for backwards compatibility. As KDEDIRS but only a single 113 * @li KDEDIR: Used for backwards compatibility. As KDEDIRS but only a single
114 * directory may be specified. If KDEDIRS is set KDEDIR is 114 * directory may be specified. If KDEDIRS is set KDEDIR is
115 * ignored. 115 * ignored.
116 * @li KDEHOME: The directory where changes are saved to. This directory is 116 * @li KDEHOME: The directory where changes are saved to. This directory is
117 * used to search for resources first. If KDEHOME is not 117 * used to search for resources first. If KDEHOME is not
118 * specified it defaults to "$HOME/.kde" 118 * specified it defaults to "$HOME/.kde"
119 * @li KDEROOTHOME: Like KDEHOME, but used for the root user. 119 * @li KDEROOTHOME: Like KDEHOME, but used for the root user.
120 * If KDEROOTHOME is not set it defaults to the .kde directory in the 120 * If KDEROOTHOME is not set it defaults to the .kde directory in the
121 * home directory of root, usually "/root/.kde". 121 * home directory of root, usually "/root/.kde".
122 * Note that the setting of $HOME is ignored in this case. 122 * Note that the setting of $HOME is ignored in this case.
123 * 123 *
124 * @see KGlobalSettings 124 * @see KGlobalSettings
125 */ 125 */
126class KStandardDirs 126class KStandardDirs
127{ 127{
128public: 128public:
129 /** 129 /**
130 * KStandardDirs' constructor. It just initializes the caches. 130 * KStandardDirs' constructor. It just initializes the caches.
131 **/ 131 **/
132 KStandardDirs( ); 132 KStandardDirs( );
133 133
134 /** 134 /**
135 * KStandardDirs' destructor. 135 * KStandardDirs' destructor.
136 */ 136 */
137 virtual ~KStandardDirs(); 137 virtual ~KStandardDirs();
138 138
139 /** 139 /**
140 * Adds another search dir to front of the @p fsstnd list. 140 * Adds another search dir to front of the @p fsstnd list.
141 * 141 *
142 * @li When compiling kdelibs, the prefix is added to this. 142 * @li When compiling kdelibs, the prefix is added to this.
143 * @li KDEDIRS or KDEDIR is taking into account 143 * @li KDEDIRS or KDEDIR is taking into account
144 * @li Additional dirs may be loaded from kdeglobals. 144 * @li Additional dirs may be loaded from kdeglobals.
145 * 145 *
146 * @param dir The directory to append relative paths to. 146 * @param dir The directory to append relative paths to.
147 */ 147 */
148 void addPrefix( const QString& dir ); 148 void addPrefix( const QString& dir );
149 149
150 /** 150 /**
151 * Adds another search dir to front of the XDG_CONFIG_XXX list 151 * Adds another search dir to front of the XDG_CONFIG_XXX list
152 * of prefixes. 152 * of prefixes.
153 * This prefix is only used for resources that start with "xdgconf-" 153 * This prefix is only used for resources that start with "xdgconf-"
154 * 154 *
155 * @param dir The directory to append relative paths to. 155 * @param dir The directory to append relative paths to.
156 */ 156 */
157 void addXdgConfigPrefix( const QString& dir ); 157 void addXdgConfigPrefix( const QString& dir );
158 158
159 /** 159 /**
160 * Adds another search dir to front of the XDG_DATA_XXX list 160 * Adds another search dir to front of the XDG_DATA_XXX list
161 * of prefixes. 161 * of prefixes.
162 * This prefix is only used for resources that start with "xdgdata-" 162 * This prefix is only used for resources that start with "xdgdata-"
163 * 163 *
164 * @param dir The directory to append relative paths to. 164 * @param dir The directory to append relative paths to.
165 */ 165 */
166 void addXdgDataPrefix( const QString& dir ); 166 void addXdgDataPrefix( const QString& dir );
167 167
168 /** 168 /**
169 * Adds suffixes for types. 169 * Adds suffixes for types.
170 * 170 *
171 * You may add as many as you need, but it is advised that there 171 * You may add as many as you need, but it is advised that there
172 * is exactly one to make writing definite. 172 * is exactly one to make writing definite.
173 * All basic types (@ref kde_default) are added by @ref addKDEDefaults(), 173 * All basic types (@ref kde_default) are added by @ref addKDEDefaults(),
174 * but for those you can add more relative paths as well. 174 * but for those you can add more relative paths as well.
175 * 175 *
176 * The later a suffix is added, the higher its priority. Note, that the 176 * The later a suffix is added, the higher its priority. Note, that the
177 * suffix should end with / but doesn't have to start with one (as prefixes 177 * suffix should end with / but doesn't have to start with one (as prefixes
178 * should end with one). So adding a suffix for app_pics would look 178 * should end with one). So adding a suffix for app_pics would look
179 * like KGlobal::dirs()->addResourceType("app_pics", "share/app/pics"); 179 * like KGlobal::dirs()->addResourceType("app_pics", "share/app/pics");
180 * 180 *
181 * @param type Specifies a short descriptive string to access 181 * @param type Specifies a short descriptive string to access
182 * files of this type. 182 * files of this type.
183 * @param relativename Specifies a directory relative to the root 183 * @param relativename Specifies a directory relative to the root
184 * of the KFSSTND. 184 * of the KFSSTND.
185 * @return true if successful, false otherwise. 185 * @return true if successful, false otherwise.
186 */ 186 */
187 bool addResourceType( const char *type, 187 bool addResourceType( const char *type,
188 const QString& relativename ); 188 const QString& relativename );
189 189
190 /** 190 /**
191 * Adds absolute path at the end of the search path for 191 * Adds absolute path at the end of the search path for
192 * particular types (for example in case of icons where 192 * particular types (for example in case of icons where
193 * the user specifies extra paths). 193 * the user specifies extra paths).
194 * 194 *
195 * You shouldn't need this 195 * You shouldn't need this
196 * function in 99% of all cases besides adding user-given 196 * function in 99% of all cases besides adding user-given
197 * paths. 197 * paths.
198 * 198 *
199 * @param type Specifies a short descriptive string to access files 199 * @param type Specifies a short descriptive string to access files
200 * of this type. 200 * of this type.
201 * @param absdir Points to directory where to look for this specific 201 * @param absdir Points to directory where to look for this specific
202 * type. Non-existant directories may be saved but pruned. 202 * type. Non-existant directories may be saved but pruned.
203 * @return true if successful, false otherwise. 203 * @return true if successful, false otherwise.
204 */ 204 */
205 bool addResourceDir( const char *type, 205 bool addResourceDir( const char *type,
206 const QString& absdir); 206 const QString& absdir);
207 207
208 /** 208 /**
209 * Tries to find a resource in the following order: 209 * Tries to find a resource in the following order:
210 * @li All PREFIX/\<relativename> paths (most recent first). 210 * @li All PREFIX/\<relativename> paths (most recent first).
211 * @li All absolute paths (most recent first). 211 * @li All absolute paths (most recent first).
212 * 212 *
213 * The filename should be a filename relative to the base dir 213 * The filename should be a filename relative to the base dir
214 * for resources. So is a way to get the path to libkdecore.la 214 * for resources. So is a way to get the path to libkdecore.la
215 * to findResource("lib", "libkdecore.la"). KStandardDirs will 215 * to findResource("lib", "libkdecore.la"). KStandardDirs will
216 * then look into the subdir lib of all elements of all prefixes 216 * then look into the subdir lib of all elements of all prefixes
217 * ($KDEDIRS) for a file libkdecore.la and return the path to 217 * ($KDEDIRS) for a file libkdecore.la and return the path to
218 * the first one it finds (e.g. /opt/kde/lib/libkdecore.la) 218 * the first one it finds (e.g. /opt/kde/lib/libkdecore.la)
219 * 219 *
220 * @param type The type of the wanted resource 220 * @param type The type of the wanted resource
221 * @param filename A relative filename of the resource. 221 * @param filename A relative filename of the resource.
222 * 222 *
223 * @return A full path to the filename specified in the second 223 * @return A full path to the filename specified in the second
224 * argument, or QString::null if not found. 224 * argument, or QString::null if not found.
225 */ 225 */
226 QString findResource( const char *type, 226 QString findResource( const char *type,
227 const QString& filename ) const; 227 const QString& filename ) const;
228 228
229 /** 229 /**
230 * Checks whether a resource is restricted as part of the KIOSK 230 * Checks whether a resource is restricted as part of the KIOSK
231 * framework. When a resource is restricted it means that user- 231 * framework. When a resource is restricted it means that user-
232 * specific files in the resource are ignored. 232 * specific files in the resource are ignored.
233 * 233 *
234 * E.g. by restricting the "wallpaper" resource, only system-wide 234 * E.g. by restricting the "wallpaper" resource, only system-wide
235 * installed wallpapers will be found by this class. Wallpapers 235 * installed wallpapers will be found by this class. Wallpapers
236 * installed under the $KDEHOME directory will be ignored. 236 * installed under the $KDEHOME directory will be ignored.
237 * 237 *
238 * @param type The type of the resource to check 238 * @param type The type of the resource to check
239 * @param relPath A relative path in the resource. 239 * @param relPath A relative path in the resource.
240 * 240 *
241 * @return True if the resource is restricted. 241 * @return True if the resource is restricted.
242 * @since 3.1 242 * @since 3.1
243 */ 243 */
244 bool isRestrictedResource( const char *type, 244 bool isRestrictedResource( const char *type,
245 const QString& relPath=QString::null ) const; 245 const QString& relPath=QString::null ) const;
246 246
247 /** 247 /**
248 * Returns a number that identifies this version of the resource. 248 * Returns a number that identifies this version of the resource.
249 * When a change is made to the resource this number will change. 249 * When a change is made to the resource this number will change.
250 * 250 *
251 * @param type The type of the wanted resource 251 * @param type The type of the wanted resource
252 * @param filename A relative filename of the resource. 252 * @param filename A relative filename of the resource.
253 * @param deep If true, all resources are taken into account 253 * @param deep If true, all resources are taken into account
254 * otherwise only the one returned by findResource(). 254 * otherwise only the one returned by findResource().
255 * 255 *
256 * @return A number identifying the current version of the 256 * @return A number identifying the current version of the
257 * resource. 257 * resource.
258 */ 258 */
259/*US 259/*US
260 Q_UINT32 calcResourceHash( const char *type, 260 Q_UINT32 calcResourceHash( const char *type,
261 const QString& filename, bool deep) const; 261 const QString& filename, bool deep) const;
262*/ 262*/
263 /** 263 /**
264 * Tries to find all directories whose names consist of the 264 * Tries to find all directories whose names consist of the
265 * specified type and a relative path. So would 265 * specified type and a relative path. So would
266 * findDirs("apps", "Settings") return 266 * findDirs("apps", "Settings") return
267 * @li /opt/kde/share/applnk/Settings/ 267 * @li /opt/kde/share/applnk/Settings/
268 * @li /home/joe/.kde/share/applnk/Settings/ 268 * @li /home/joe/.kde/share/applnk/Settings/
269 * 269 *
270 * Note that it appends / to the end of the directories, 270 * Note that it appends / to the end of the directories,
271 * so you can use this right away as directory names. 271 * so you can use this right away as directory names.
272 * 272 *
273 * @param type The type of the base directory. 273 * @param type The type of the base directory.
274 * @param reldir Relative directory. 274 * @param reldir Relative directory.
275 * 275 *
276 * @return A list of matching directories, or an empty 276 * @return A list of matching directories, or an empty
277 * list if the resource specified is not found. 277 * list if the resource specified is not found.
278 */ 278 */
279 QStringList findDirs( const char *type, 279 QStringList findDirs( const char *type,
280 const QString& reldir ) const; 280 const QString& reldir ) const;
281 281
282 /** 282 /**
283 * Tries to find the directory the file is in. 283 * Tries to find the directory the file is in.
284 * It works the same as @ref findResource(), but it doesn't 284 * It works the same as @ref findResource(), but it doesn't
285 * return the filename but the name of the directory. 285 * return the filename but the name of the directory.
286 * 286 *
287 * This way the application can access a couple of files 287 * This way the application can access a couple of files
288 * that have been installed into the same directory without 288 * that have been installed into the same directory without
289 * having to look for each file. 289 * having to look for each file.
290 * 290 *
291 * findResourceDir("lib", "libkdecore.la") would return the 291 * findResourceDir("lib", "libkdecore.la") would return the
292 * path of the subdir libkdecore.la is found first in 292 * path of the subdir libkdecore.la is found first in
293 * (e.g. /opt/kde/lib/) 293 * (e.g. /opt/kde/lib/)
294 * 294 *
295 * @param type The type of the wanted resource 295 * @param type The type of the wanted resource
296 * @param filename A relative filename of the resource. 296 * @param filename A relative filename of the resource.
297 * @return The directory where the file specified in the second 297 * @return The directory where the file specified in the second
298 * argument is located, or QString::null if the type 298 * argument is located, or QString::null if the type
299 * of resource specified is unknown or the resource 299 * of resource specified is unknown or the resource
300 * cannot be found. 300 * cannot be found.
301 */ 301 */
302 QString findResourceDir( const char *type, 302 QString findResourceDir( const char *type,
303 const QString& filename) const; 303 const QString& filename) const;
304 304
305 305
306 /** 306 /**
307 * Tries to find all resources with the specified type. 307 * Tries to find all resources with the specified type.
308 * 308 *
309 * The function will look into all specified directories 309 * The function will look into all specified directories
310 * and return all filenames in these directories. 310 * and return all filenames in these directories.
311 * 311 *
312 * @param type The type of resource to locate directories for. 312 * @param type The type of resource to locate directories for.
313 * @param filter Only accept filenames that fit to filter. The filter 313 * @param filter Only accept filenames that fit to filter. The filter
314 * may consist of an optional directory and a @ref QRegExp 314 * may consist of an optional directory and a @ref QRegExp
315 * wildcard expression. E.g. "images\*.jpg". Use QString::null 315 * wildcard expression. E.g. "images\*.jpg". Use QString::null
316 * if you do not want a filter. 316 * if you do not want a filter.
317 * @param recursive Specifies if the function should decend 317 * @param recursive Specifies if the function should decend
318 * into subdirectories. 318 * into subdirectories.
319 * @param uniq If specified, only return items which have 319 * @param uniq If specified, only return items which have
320 * unique suffixes - suppressing duplicated filenames. 320 * unique suffixes - suppressing duplicated filenames.
321 * 321 *
322 * @return A list of directories matching the resource specified, 322 * @return A list of directories matching the resource specified,
323 * or an empty list if the resource type is unknown. 323 * or an empty list if the resource type is unknown.
324 */ 324 */
325 QStringList findAllResources( const char *type, 325 QStringList findAllResources( const char *type,
326 const QString& filter = QString::null, 326 const QString& filter = QString::null,
327 bool recursive = false, 327 bool recursive = false,
328 bool uniq = false) const; 328 bool uniq = false) const;
329 329
330 /** 330 /**
331 * Tries to find all resources with the specified type. 331 * Tries to find all resources with the specified type.
332 * 332 *
333 * The function will look into all specified directories 333 * The function will look into all specified directories
334 * and return all filenames (full and relative paths) in 334 * and return all filenames (full and relative paths) in
335 * these directories. 335 * these directories.
336 * 336 *
337 * @param type The type of resource to locate directories for. 337 * @param type The type of resource to locate directories for.
338 * @param filter Only accept filenames that fit to filter. The filter 338 * @param filter Only accept filenames that fit to filter. The filter
339 * may consist of an optional directory and a @ref QRegExp 339 * may consist of an optional directory and a @ref QRegExp
340 * wildcard expression. E.g. "images\*.jpg". Use QString::null 340 * wildcard expression. E.g. "images\*.jpg". Use QString::null
341 * if you do not want a filter. 341 * if you do not want a filter.
342 * @param recursive Specifies if the function should decend 342 * @param recursive Specifies if the function should decend
343 * into subdirectories. 343 * into subdirectories.
344 * @param uniq If specified, only return items which have 344 * @param uniq If specified, only return items which have
345 * unique suffixes. 345 * unique suffixes.
346 * @param list Of relative paths for the given type. 346 * @param list Of relative paths for the given type.
347 * @param relPaths The list to store the relative paths into 347 * @param relPaths The list to store the relative paths into
348 * These can be used later to ::locate() the file 348 * These can be used later to ::locate() the file
349 * 349 *
350 * @return A list of directories matching the resource specified, 350 * @return A list of directories matching the resource specified,
351 * or an empty list if the resource type is unknown. 351 * or an empty list if the resource type is unknown.
352 */ 352 */
353 QStringList findAllResources( const char *type, 353 QStringList findAllResources( const char *type,
354 const QString& filter, 354 const QString& filter,
355 bool recursive, 355 bool recursive,
356 bool uniq, 356 bool uniq,
357 QStringList &relPaths) const; 357 QStringList &relPaths) const;
358 358
359 /** 359 /**
360 * Finds the executable in the system path. 360 * Finds the executable in the system path.
361 * 361 *
362 * A valid executable must 362 * A valid executable must
363 * be a file and have its executable bit set. 363 * be a file and have its executable bit set.
364 * 364 *
365 * @param appname The name of the executable file for which to search. 365 * @param appname The name of the executable file for which to search.
366 * @param pathstr The path which will be searched. If this is 366 * @param pathstr The path which will be searched. If this is
367 * null (default), the $PATH environment variable will 367 * null (default), the $PATH environment variable will
368 * be searched. 368 * be searched.
369 * @param ignoreExecBitIf true, an existing file will be returned 369 * @param ignoreExecBitIf true, an existing file will be returned
370 * even if its executable bit is not set. 370 * even if its executable bit is not set.
371 * 371 *
372 * @return The path of the executable. If it was not found, 372 * @return The path of the executable. If it was not found,
373 * it will return QString::null. 373 * it will return QString::null.
374 * @see findAllExe() 374 * @see findAllExe()
375 */ 375 */
376/*US 376/*US
377 static QString findExe( const QString& appname, 377 static QString findExe( const QString& appname,
378 const QString& pathstr=QString::null, 378 const QString& pathstr=QString::null,
379 bool ignoreExecBit=false ); 379 bool ignoreExecBit=false );
380*/ 380*/
381 381
382 /** 382 /**
383 * Finds all occurences of an executable in the system path. 383 * Finds all occurences of an executable in the system path.
384 * 384 *
385 * @param listWill be filled with the pathnames of all the 385 * @param listWill be filled with the pathnames of all the
386 * executables found. Will be empty if the executable 386 * executables found. Will be empty if the executable
387 * was not found. 387 * was not found.
388 * @param appnameThe name of the executable for which to 388 * @param appnameThe name of the executable for which to
389 * search. 389 * search.
390 * @param pathstrThe path list which will be searched. If this 390 * @param pathstrThe path list which will be searched. If this
391 * is 0 (default), the $PATH environment variable will 391 * is 0 (default), the $PATH environment variable will
392 * be searched. 392 * be searched.
393 * @param ignoreExecBit If true, an existing file will be returned 393 * @param ignoreExecBit If true, an existing file will be returned
394 * even if its executable bit is not set. 394 * even if its executable bit is not set.
395 * 395 *
396 * @return The number of executables found, 0 if none were found. 396 * @return The number of executables found, 0 if none were found.
397 * 397 *
398 * @seefindExe() 398 * @seefindExe()
399 */ 399 */
400 static int findAllExe( QStringList& list, const QString& appname, 400 static int findAllExe( QStringList& list, const QString& appname,
401 const QString& pathstr=QString::null, 401 const QString& pathstr=QString::null,
402 bool ignoreExecBit=false ); 402 bool ignoreExecBit=false );
403 403
404 /** 404 /**
405 * This function adds the defaults that are used by the current 405 * This function adds the defaults that are used by the current
406 * KDE version. 406 * KDE version.
407 * 407 *
408 * It's a series of @ref addResourceTypes() 408 * It's a series of @ref addResourceTypes()
409 * and @ref addPrefix() calls. 409 * and @ref addPrefix() calls.
410 * You normally wouldn't call this function because it's called 410 * You normally wouldn't call this function because it's called
411 * for you from @ref KGlobal. 411 * for you from @ref KGlobal.
412 */ 412 */
413 void addKDEDefaults(); 413 void addKDEDefaults();
414 414
415 /** 415 /**
416 * Reads customized entries out of the given config object and add 416 * Reads customized entries out of the given config object and add
417 * them via @ref addResourceDirs(). 417 * them via @ref addResourceDirs().
418 * 418 *
419 * @param config The object the entries are read from. This should 419 * @param config The object the entries are read from. This should
420 * contain global config files 420 * contain global config files
421 * @return true if new config paths have been added 421 * @return true if new config paths have been added
422 * from @p config. 422 * from @p config.
423 **/ 423 **/
424 bool addCustomized(KConfig *config); 424 bool addCustomized(KConfig *config);
425 425
426 /** 426 /**
427 * This function is used internally by almost all other function as 427 * This function is used internally by almost all other function as
428 * it serves and fills the directories cache. 428 * it serves and fills the directories cache.
429 * 429 *
430 * @param type The type of resource 430 * @param type The type of resource
431 * @return The list of possible directories for the specified @p type. 431 * @return The list of possible directories for the specified @p type.
432 * The function updates the cache if possible. If the resource 432 * The function updates the cache if possible. If the resource
433 * type specified is unknown, it will return an empty list. 433 * type specified is unknown, it will return an empty list.
434 * Note, that the directories are assured to exist beside the save 434 * Note, that the directories are assured to exist beside the save
435 * location, which may not exist, but is returned anyway. 435 * location, which may not exist, but is returned anyway.
436 */ 436 */
437 QStringList resourceDirs(const char *type) const; 437 QStringList resourceDirs(const char *type) const;
438 438
439 /** 439 /**
440 * This function will return a list of all the types that KStandardDirs 440 * This function will return a list of all the types that KStandardDirs
441 * supports. 441 * supports.
442 * 442 *
443 * @return All types that KDE supports 443 * @return All types that KDE supports
444 */ 444 */
445 QStringList allTypes() const; 445 QStringList allTypes() const;
446 446
447 /** 447 /**
448 * Finds a location to save files into for the given type 448 * Finds a location to save files into for the given type
449 * in the user's home directory. 449 * in the user's home directory.
450 * 450 *
451 * @param type The type of location to return. 451 * @param type The type of location to return.
452 * @param suffix A subdirectory name. 452 * @param suffix A subdirectory name.
453 * Makes it easier for you to create subdirectories. 453 * Makes it easier for you to create subdirectories.
454 * You can't pass filenames here, you _have_ to pass 454 * You can't pass filenames here, you _have_ to pass
455 * directory names only and add possible filename in 455 * directory names only and add possible filename in
456 * that directory yourself. A directory name always has a 456 * that directory yourself. A directory name always has a
457 * trailing slash ('/'). 457 * trailing slash ('/').
458 * @param create If set, saveLocation() will create the directories 458 * @param create If set, saveLocation() will create the directories
459 * needed (including those given by @p suffix). 459 * needed (including those given by @p suffix).
460 * 460 *
461 * @return A path where resources of the specified type should be 461 * @return A path where resources of the specified type should be
462 * saved, or QString::null if the resource type is unknown. 462 * saved, or QString::null if the resource type is unknown.
463 */ 463 */
464 QString saveLocation(const char *type, 464 QString saveLocation(const char *type,
465 const QString& suffix = QString::null, 465 const QString& suffix = QString::null,
466 bool create = true) const; 466 bool create = true) const;
467 467
468 /** 468 /**
469 * Converts an absolute path to a path relative to a certain 469 * Converts an absolute path to a path relative to a certain
470 * resource. 470 * resource.
471 * 471 *
472 * If "abs = ::locate(resource, rel)" 472 * If "abs = ::locate(resource, rel)"
473 * then "rel = relativeLocation(resource, abs)" and vice versa. 473 * then "rel = relativeLocation(resource, abs)" and vice versa.
474 * 474 *
475 * @param type The type of resource. 475 * @param type The type of resource.
476 * 476 *
477 * @param absPath An absolute path to make relative. 477 * @param absPath An absolute path to make relative.
478 * 478 *
479 * @return A relative path relative to resource @p type that 479 * @return A relative path relative to resource @p type that
480 * will find @p absPath. If no such relative path exists, absPath 480 * will find @p absPath. If no such relative path exists, absPath
481 * will be returned unchanged. 481 * will be returned unchanged.
482 */ 482 */
483 QString relativeLocation(const char *type, const QString &absPath); 483 QString relativeLocation(const char *type, const QString &absPath);
484 484
485 /** 485 /**
486 * Recursively creates still-missing directories in the given path. 486 * Recursively creates still-missing directories in the given path.
487 * 487 *
488 * The resulting permissions will depend on the current umask setting. 488 * The resulting permissions will depend on the current umask setting.
489 * permission = mode & ~umask. 489 * permission = mode & ~umask.
490 * 490 *
491 * @param dir Absolute path of the directory to be made. 491 * @param dir Absolute path of the directory to be made.
492 * @param mode Directory permissions. 492 * @param mode Directory permissions.
493 * @return true if successful, false otherwise 493 * @return true if successful, false otherwise
494 */ 494 */
495 static bool makeDir(const QString& dir, int mode = 0755); 495 static bool makeDir(const QString& dir, int mode = 0755);
496 496
497 /** 497 /**
498 * This returns a default relative path for the standard KDE 498 * This returns a default relative path for the standard KDE
499 * resource types. Below is a list of them so you get an idea 499 * resource types. Below is a list of them so you get an idea
500 * of what this is all about. 500 * of what this is all about.
501 * 501 *
502 * @li data - share/apps 502 * @li data - share/apps
503 * @li html - share/doc/HTML 503 * @li html - share/doc/HTML
504 * @li icon - share/icon 504 * @li icon - share/icon
505 * @li config - share/config 505 * @li config - share/config
506 * @li pixmap - share/pixmaps 506 * @li pixmap - share/pixmaps
507 * @li apps - share/applnk 507 * @li apps - share/applnk
508 * @li sound - share/sounds 508 * @li sound - share/sounds
509 * @li locale - share/locale 509 * @li locale - share/locale
510 * @li services - share/services 510 * @li services - share/services
511 * @li servicetypes - share/servicetypes 511 * @li servicetypes - share/servicetypes
512 * @li mime - share/mimelnk 512 * @li mime - share/mimelnk
513 * @li wallpaper - share/wallpapers 513 * @li wallpaper - share/wallpapers
514 * @li templates - share/templates 514 * @li templates - share/templates
515 * @li exe - bin 515 * @li exe - bin
516 * @li lib - lib 516 * @li lib - lib
517 * 517 *
518 * @returns Static default for the specified resource. You 518 * @returns Static default for the specified resource. You
519 * should probably be using locate() or locateLocal() 519 * should probably be using locate() or locateLocal()
520 * instead. 520 * instead.
521 * @see locate() 521 * @see locate()
522 * @see locateLocal() 522 * @see locateLocal()
523 */ 523 */
524 static QString kde_default(const char *type); 524 static QString kde_default(const char *type);
525 525
526 /** 526 /**
527 * @internal (for use by sycoca only) 527 * @internal (for use by sycoca only)
528 */ 528 */
529 QString kfsstnd_prefixes(); 529 QString kfsstnd_prefixes();
530 530
531 /** 531 /**
532 * Returns the toplevel directory in which KStandardDirs 532 * Returns the toplevel directory in which KStandardDirs
533 * will store things. Most likely $HOME/.kde 533 * will store things. Most likely $HOME/.kde
534 * Don't use this function if you can use locateLocal 534 * Don't use this function if you can use locateLocal
535 * @return the toplevel directory 535 * @return the toplevel directory
536 */ 536 */
537 QString localkdedir() const; 537 QString localkdedir() const;
538 538
539 /** 539 /**
540 * @return $XDG_DATA_HOME 540 * @return $XDG_DATA_HOME
541 * See also http://www.freedesktop.org/standards/basedir/draft/basedir-spec/basedir-spec.html 541 * See also http://www.freedesktop.org/standards/basedir/draft/basedir-spec/basedir-spec.html
542 */ 542 */
543 QString localxdgdatadir() const; 543 QString localxdgdatadir() const;
544 544
545 /** 545 /**
546 * @return $XDG_CONFIG_HOME 546 * @return $XDG_CONFIG_HOME
547 * See also http://www.freedesktop.org/standards/basedir/draft/basedir-spec/basedir-spec.html 547 * See also http://www.freedesktop.org/standards/basedir/draft/basedir-spec/basedir-spec.html
548 */ 548 */
549 QString localxdgconfdir() const; 549 QString localxdgconfdir() const;
550 550
551 /** 551 /**
552 * Checks for existence and accessability. 552 * Checks for existence and accessability.
553 * Faster than creating a QFileInfo first. 553 * Faster than creating a QFileInfo first.
554 * @param fullPath the path to check 554 * @param fullPath the path to check
555 * @return true if the directory exists 555 * @return true if the directory exists
556 */ 556 */
557 static bool exists(const QString &fullPath); 557 static bool exists(const QString &fullPath);
558 558
559 /** 559 /**
560 * Expands all symbolic links and resolves references to 560 * Expands all symbolic links and resolves references to
561 * '/./', '/../' and extra '/' characters in @p dirname 561 * '/./', '/../' and extra '/' characters in @p dirname
562 * and returns the canonicalized absolute pathname. 562 * and returns the canonicalized absolute pathname.
563 * The resulting path will have no symbolic link, '/./' 563 * The resulting path will have no symbolic link, '/./'
564 * or '/../' components. 564 * or '/../' components.
565 * @since 3.1 565 * @since 3.1
566 */ 566 */
567 static QString realPath(const QString &dirname); 567 static QString realPath(const QString &dirname);
568 568
569 static void setAppDir( const QString & ); 569 static void setAppDir( const QString & );
570 static QString appDir(); 570 static QString appDir();
571 571
572 private: 572 private:
573 573
574 QStringList prefixes; 574 QStringList prefixes;
575 575
576 // Directory dictionaries 576 // Directory dictionaries
577 QDict<QStringList> absolutes; 577 Q3Dict<QStringList> absolutes;
578 QDict<QStringList> relatives; 578 Q3Dict<QStringList> relatives;
579 579
580 mutable QDict<QStringList> dircache; 580 mutable Q3Dict<QStringList> dircache;
581 mutable QDict<QString> savelocations; 581 mutable Q3Dict<QString> savelocations;
582 582
583 // Disallow assignment and copy-construction 583 // Disallow assignment and copy-construction
584 KStandardDirs( const KStandardDirs& ); 584 KStandardDirs( const KStandardDirs& );
585 KStandardDirs& operator= ( const KStandardDirs& ); 585 KStandardDirs& operator= ( const KStandardDirs& );
586 586
587 bool addedCustoms; 587 bool addedCustoms;
588 588
589 class KStandardDirsPrivate; 589 class KStandardDirsPrivate;
590 KStandardDirsPrivate *d; 590 KStandardDirsPrivate *d;
591//US 591//US
592 static QString mAppDir; 592 static QString mAppDir;
593 593
594 void checkConfig() const; 594 void checkConfig() const;
595 void applyDataRestrictions(const QString &) const; 595 void applyDataRestrictions(const QString &) const;
596 //US void createSpecialResource(const char*); 596 //US void createSpecialResource(const char*);
597}; 597};
598 598
599/** 599/**
600 * \addtogroup locates Locate Functions 600 * \addtogroup locates Locate Functions
601 * @{ 601 * @{
602 * On The Usage Of 'locate' and 'locateLocal' 602 * On The Usage Of 'locate' and 'locateLocal'
603 * 603 *
604 * Typical KDE applications use resource files in one out of 604 * Typical KDE applications use resource files in one out of
605 * three ways: 605 * three ways:
606 * 606 *
607 * 1) A resource file is read but is never written. A system 607 * 1) A resource file is read but is never written. A system
608 * default is supplied but the user can override this 608 * default is supplied but the user can override this
609 * default in his local .kde directory: 609 * default in his local .kde directory:
610 * 610 *
611 * \code 611 * \code
612 * // Code example 612 * // Code example
613 * myFile = locate("appdata", "groups.lst"); 613 * myFile = locate("appdata", "groups.lst");
614 * myData = myReadGroups(myFile); // myFile may be null 614 * myData = myReadGroups(myFile); // myFile may be null
615 * \endcode 615 * \endcode
616 * 616 *
617 * 2) A resource file is read and written. If the user has no 617 * 2) A resource file is read and written. If the user has no
618 * local version of the file the system default is used. 618 * local version of the file the system default is used.
619 * The resource file is always written to the users local 619 * The resource file is always written to the users local
620 * .kde directory. 620 * .kde directory.
621 * 621 *
622 * \code 622 * \code
623 * // Code example 623 * // Code example
624 * myFile = locate("appdata", "groups.lst") 624 * myFile = locate("appdata", "groups.lst")
625 * myData = myReadGroups(myFile); 625 * myData = myReadGroups(myFile);
626 * ... 626 * ...
627 * doSomething(myData); 627 * doSomething(myData);
628 * ... 628 * ...
629 * myFile = locateLocal("appdata", "groups.lst"); 629 * myFile = locateLocal("appdata", "groups.lst");
630 * myWriteGroups(myFile, myData); 630 * myWriteGroups(myFile, myData);
631 * \endcode 631 * \endcode
632 * 632 *
633 * 3) A resource file is read and written. No system default 633 * 3) A resource file is read and written. No system default
634 * is used if the user has no local version of the file. 634 * is used if the user has no local version of the file.
635 * The resource file is always written to the users local 635 * The resource file is always written to the users local
636 * .kde directory. 636 * .kde directory.
637 * 637 *
638 * \code 638 * \code
639 * // Code example 639 * // Code example
640 * myFile = locateLocal("appdata", "groups.lst"); 640 * myFile = locateLocal("appdata", "groups.lst");
641 * myData = myReadGroups(myFile); 641 * myData = myReadGroups(myFile);
642 * ... 642 * ...
643 * doSomething(myData); 643 * doSomething(myData);
644 * ... 644 * ...
645 * myFile = locateLocal("appdata", "groups.lst"); 645 * myFile = locateLocal("appdata", "groups.lst");
646 * myWriteGroups(myFile, myData); 646 * myWriteGroups(myFile, myData);
647 * \endcode 647 * \endcode
648 **/ 648 **/
649 649
650 650
651/*! 651/*!
652 * \relates KStandardDirs 652 * \relates KStandardDirs
653 * This function is just for convenience. It simply calls 653 * This function is just for convenience. It simply calls
654 *instance->dirs()->\link KStandardDirs::findResource() findResource\endlink(type, filename). 654 *instance->dirs()->\link KStandardDirs::findResource() findResource\endlink(type, filename).
655 **/ 655 **/
656QString locate( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance()*/ ); 656QString locate( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance()*/ );
657 657
658/*! 658/*!
659 * \relates KStandardDirs 659 * \relates KStandardDirs
660 * This function is much like locate. However it returns a 660 * This function is much like locate. However it returns a
661 * filename suitable for writing to. No check is made if the 661 * filename suitable for writing to. No check is made if the
662 * specified filename actually exists. Missing directories 662 * specified filename actually exists. Missing directories
663 * are created. If filename is only a directory, without a 663 * are created. If filename is only a directory, without a
664 * specific file, filename must have a trailing slash. 664 * specific file, filename must have a trailing slash.
665 * 665 *
666 **/ 666 **/
667QString locateLocal( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance() */ ); 667QString locateLocal( const char *type, const QString& filename /*US , const KInstance* instance = KGlobal::instance() */ );
668 668
669/*! 669/*!
670 * \relates KStandardDirs 670 * \relates KStandardDirs
671 * This function is much like locate. No check is made if the 671 * This function is much like locate. No check is made if the
672 * specified filename actually exists. Missing directories 672 * specified filename actually exists. Missing directories
673 * are created if @p createDir is true. If filename is only 673 * are created if @p createDir is true. If filename is only
674 * a directory, without a specific file, 674 * a directory, without a specific file,
675 * filename must have a trailing slash. 675 * filename must have a trailing slash.
676 * 676 *
677 **/ 677 **/
678QString locateLocal( const char *type, const QString& filename, bool createDir /*US , const KInstance* instance = KGlobal::instance() */); 678QString locateLocal( const char *type, const QString& filename, bool createDir /*US , const KInstance* instance = KGlobal::instance() */);
679 679
680QString readEnvPath(const char *env); 680QString readEnvPath(const char *env);
681 681
682 682
683/*! @} */ 683/*! @} */
684 684
685#endif // SSK_KSTDDIRS_H 685#endif // SSK_KSTDDIRS_H
diff --git a/microkde/kdeui/kaction.cpp b/microkde/kdeui/kaction.cpp
index d38a6d5..c2df381 100644
--- a/microkde/kdeui/kaction.cpp
+++ b/microkde/kdeui/kaction.cpp
@@ -1,1215 +1,1218 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org> 3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org> 4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org> 5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org> 6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org> 7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org> 8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 (C) 2002 Joseph Wenninger <jowenn@kde.org> 9 (C) 2002 Joseph Wenninger <jowenn@kde.org>
10 10
11 This library is free software; you can redistribute it and/or 11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public 12 modify it under the terms of the GNU Library General Public
13 License version 2 as published by the Free Software Foundation. 13 License version 2 as published by the Free Software Foundation.
14 14
15 This library is distributed in the hope that it will be useful, 15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details. 18 Library General Public License for more details.
19 19
20 You should have received a copy of the GNU Library General Public License 20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to 21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. 23 Boston, MA 02111-1307, USA.
24*/ 24*/
25 25
26#include "kaction.h" 26#include "kaction.h"
27 27
28#include <assert.h> 28#include <assert.h>
29 29
30#include <qtooltip.h> 30#include <qtooltip.h>
31//Added by qt3to4:
32#include <Q3CString>
33#include <Q3ValueList>
31//US#include <qwhatsthis.h> 34//US#include <qwhatsthis.h>
32//US#include <kaccel.h> 35//US#include <kaccel.h>
33//US#include <kaccelbase.h> 36//US#include <kaccelbase.h>
34#include <kapplication.h> 37#include <kapplication.h>
35#include <kdebug.h> 38#include <kdebug.h>
36#include <kguiitem.h> 39#include <kguiitem.h>
37//US#include <kmainwindow.h> 40//US#include <kmainwindow.h>
38//US#include <kmenubar.h> 41//US#include <kmenubar.h>
39//US#include <kpopupmenu.h> 42//US#include <kpopupmenu.h>
40#include <ktoolbar.h> 43#include <ktoolbar.h>
41#include <ktoolbarbutton.h> 44#include <ktoolbarbutton.h>
42 45
43//US added this includefiles 46//US added this includefiles
44#include <qmenubar.h> 47#include <qmenubar.h>
45#include <qtoolbar.h> 48#include <q3toolbar.h>
46#include <qpopupmenu.h> 49#include <q3popupmenu.h>
47#include <qiconset.h> 50#include <qicon.h>
48 51
49/** 52/**
50* How it works. 53* How it works.
51* KActionCollection is an organizing container for KActions. 54* KActionCollection is an organizing container for KActions.
52* KActionCollection keeps track of the information necessary to handle 55* KActionCollection keeps track of the information necessary to handle
53* configuration and shortcuts. 56* configuration and shortcuts.
54* 57*
55* Focus Widget pointer: 58* Focus Widget pointer:
56* This is the widget which is the focus for action shortcuts. 59* This is the widget which is the focus for action shortcuts.
57* It is set either by passing a QWidget* to the KActionCollection constructor 60* It is set either by passing a QWidget* to the KActionCollection constructor
58* or by calling setWidget() if the widget wasn't known when the object was 61* or by calling setWidget() if the widget wasn't known when the object was
59* initially constructed (as in KXMLGUIClient and KParts::PartBase) 62* initially constructed (as in KXMLGUIClient and KParts::PartBase)
60* 63*
61* Shortcuts: 64* Shortcuts:
62* An action's shortcut will not not be connected unless a focus widget has 65* An action's shortcut will not not be connected unless a focus widget has
63* been specified in KActionCollection. 66* been specified in KActionCollection.
64* 67*
65* XML Filename: 68* XML Filename:
66* This is used to save user-modified settings back to the *ui.rc file. 69* This is used to save user-modified settings back to the *ui.rc file.
67* It is set by KXMLGUIFactory. 70* It is set by KXMLGUIFactory.
68*/ 71*/
69 72
70int KAction::getToolButtonID() 73int KAction::getToolButtonID()
71{ 74{
72 static int toolbutton_no = -2; 75 static int toolbutton_no = -2;
73 return toolbutton_no--; 76 return toolbutton_no--;
74} 77}
75 78
76//--------------------------------------------------------------------- 79//---------------------------------------------------------------------
77// KAction::KActionPrivate 80// KAction::KActionPrivate
78//--------------------------------------------------------------------- 81//---------------------------------------------------------------------
79 82
80class KAction::KActionPrivate : public KGuiItem 83class KAction::KActionPrivate : public KGuiItem
81{ 84{
82public: 85public:
83 KActionPrivate() : KGuiItem() 86 KActionPrivate() : KGuiItem()
84 { 87 {
85 m_kaccel = 0; 88 m_kaccel = 0;
86 m_configurable = true; 89 m_configurable = true;
87 } 90 }
88 91
89 KAccel *m_kaccel; 92 KAccel *m_kaccel;
90 QValueList<KAccel*> m_kaccelList; 93 Q3ValueList<KAccel*> m_kaccelList;
91 94
92 QString m_groupText; 95 QString m_groupText;
93 QString m_group; 96 QString m_group;
94 97
95 KShortcut m_cut; 98 KShortcut m_cut;
96 KShortcut m_cutDefault; 99 KShortcut m_cutDefault;
97 100
98 bool m_configurable; 101 bool m_configurable;
99 102
100 struct Container 103 struct Container
101 { 104 {
102 Container() { m_container = 0; m_representative = 0; m_id = 0; } 105 Container() { m_container = 0; m_representative = 0; m_id = 0; }
103 Container( const Container& s ) { m_container = s.m_container; 106 Container( const Container& s ) { m_container = s.m_container;
104 m_id = s.m_id; m_representative = s.m_representative; } 107 m_id = s.m_id; m_representative = s.m_representative; }
105 QWidget* m_container; 108 QWidget* m_container;
106 int m_id; 109 int m_id;
107 QWidget* m_representative; 110 QWidget* m_representative;
108 }; 111 };
109 112
110 QValueList<Container> m_containers; 113 Q3ValueList<Container> m_containers;
111}; 114};
112 115
113//--------------------------------------------------------------------- 116//---------------------------------------------------------------------
114// KAction 117// KAction
115//--------------------------------------------------------------------- 118//---------------------------------------------------------------------
116KAction::KAction( const QString& text, const KShortcut& cut, 119KAction::KAction( const QString& text, const KShortcut& cut,
117 const QObject* receiver, const char* slot, 120 const QObject* receiver, const char* slot,
118 KActionCollection* parent, const char* name ) 121 KActionCollection* parent, const char* name )
119: QObject( parent, name ) 122: QObject( parent, name )
120{ 123{
121 initPrivate( text, cut, receiver, slot ); 124 initPrivate( text, cut, receiver, slot );
122} 125}
123 126
124KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut, 127KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut,
125 const QObject* receiver, const char* slot, 128 const QObject* receiver, const char* slot,
126 KActionCollection* parent, const char* name ) 129 KActionCollection* parent, const char* name )
127: QObject( parent, name ) 130: QObject( parent, name )
128{ 131{
129 initPrivate( text, cut, receiver, slot ); 132 initPrivate( text, cut, receiver, slot );
130 d->setIconName( sIconName ); 133 d->setIconName( sIconName );
131} 134}
132 135
133KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 136KAction::KAction( const QString& text, const QIcon& pix, const KShortcut& cut,
134 const QObject* receiver, const char* slot, 137 const QObject* receiver, const char* slot,
135 KActionCollection* parent, const char* name ) 138 KActionCollection* parent, const char* name )
136: QObject( parent, name ) 139: QObject( parent, name )
137{ 140{
138 initPrivate( text, cut, receiver, slot ); 141 initPrivate( text, cut, receiver, slot );
139 d->setIconSet( pix ); 142 d->setIconSet( pix );
140} 143}
141KAction::KAction( const KGuiItem& item, const KShortcut& cut, 144KAction::KAction( const KGuiItem& item, const KShortcut& cut,
142 const QObject* receiver, const char* slot, 145 const QObject* receiver, const char* slot,
143 KActionCollection* parent, const char* name ) 146 KActionCollection* parent, const char* name )
144: QObject( parent, name ) 147: QObject( parent, name )
145{ 148{
146 initPrivate( item.text(), cut, receiver, slot ); 149 initPrivate( item.text(), cut, receiver, slot );
147 if( item.hasIconSet() ) 150 if( item.hasIconSet() )
148 setIcon( item.iconName() ); 151 setIcon( item.iconName() );
149 setToolTip( item.toolTip() ); 152 setToolTip( item.toolTip() );
150 setWhatsThis( item.whatsThis() ); 153 setWhatsThis( item.whatsThis() );
151} 154}
152 155
153// KDE 4: remove 156// KDE 4: remove
154KAction::KAction( const QString& text, const KShortcut& cut, 157KAction::KAction( const QString& text, const KShortcut& cut,
155 QObject* parent, const char* name ) 158 QObject* parent, const char* name )
156 : QObject( parent, name ) 159 : QObject( parent, name )
157{ 160{
158 initPrivate( text, cut, 0, 0 ); 161 initPrivate( text, cut, 0, 0 );
159} 162}
160KAction::KAction( const QString& text, const KShortcut& cut, 163KAction::KAction( const QString& text, const KShortcut& cut,
161 const QObject* receiver, 164 const QObject* receiver,
162 const char* slot, QObject* parent, const char* name ) 165 const char* slot, QObject* parent, const char* name )
163 : QObject( parent, name ) 166 : QObject( parent, name )
164{ 167{
165 initPrivate( text, cut, receiver, slot ); 168 initPrivate( text, cut, receiver, slot );
166} 169}
167KAction::KAction( const QString& text, const QIconSet& pix, 170KAction::KAction( const QString& text, const QIcon& pix,
168 const KShortcut& cut, 171 const KShortcut& cut,
169 QObject* parent, const char* name ) 172 QObject* parent, const char* name )
170 : QObject( parent, name ) 173 : QObject( parent, name )
171{ 174{
172 initPrivate( text, cut, 0, 0 ); 175 initPrivate( text, cut, 0, 0 );
173 setIconSet( pix ); 176 setIconSet( pix );
174} 177}
175 178
176KAction::KAction( const QString& text, const QString& pix, 179KAction::KAction( const QString& text, const QString& pix,
177 const KShortcut& cut, 180 const KShortcut& cut,
178 QObject* parent, const char* name ) 181 QObject* parent, const char* name )
179: QObject( parent, name ) 182: QObject( parent, name )
180{ 183{
181 initPrivate( text, cut, 0, 0 ); 184 initPrivate( text, cut, 0, 0 );
182 d->setIconName( pix ); 185 d->setIconName( pix );
183} 186}
184 187
185KAction::KAction( const QString& text, const QIconSet& pix, 188KAction::KAction( const QString& text, const QIcon& pix,
186 const KShortcut& cut, 189 const KShortcut& cut,
187 const QObject* receiver, const char* slot, QObject* parent, 190 const QObject* receiver, const char* slot, QObject* parent,
188 const char* name ) 191 const char* name )
189 : QObject( parent, name ) 192 : QObject( parent, name )
190{ 193{
191 initPrivate( text, cut, receiver, slot ); 194 initPrivate( text, cut, receiver, slot );
192 setIconSet( pix ); 195 setIconSet( pix );
193} 196}
194 197
195KAction::KAction( const QString& text, const QString& pix, 198KAction::KAction( const QString& text, const QString& pix,
196 const KShortcut& cut, 199 const KShortcut& cut,
197 const QObject* receiver, const char* slot, QObject* parent, 200 const QObject* receiver, const char* slot, QObject* parent,
198 const char* name ) 201 const char* name )
199 : QObject( parent, name ) 202 : QObject( parent, name )
200{ 203{
201 initPrivate( text, cut, receiver, slot ); 204 initPrivate( text, cut, receiver, slot );
202 d->setIconName(pix); 205 d->setIconName(pix);
203} 206}
204 207
205KAction::KAction( QObject* parent, const char* name ) 208KAction::KAction( QObject* parent, const char* name )
206 : QObject( parent, name ) 209 : QObject( parent, name )
207{ 210{
208 211
209 initPrivate( QString::null, KShortcut(), 0, 0 ); 212 initPrivate( QString::null, KShortcut(), 0, 0 );
210} 213}
211// KDE 4: remove end 214// KDE 4: remove end
212 215
213KAction::~KAction() 216KAction::~KAction()
214{ 217{
215#ifndef KDE_NO_COMPAT 218#ifndef KDE_NO_COMPAT
216 if (d->m_kaccel) 219 if (d->m_kaccel)
217 unplugAccel(); 220 unplugAccel();
218#endif 221#endif
219 222
220 // If actionCollection hasn't already been destructed, 223 // If actionCollection hasn't already been destructed,
221 if ( m_parentCollection ) { 224 if ( m_parentCollection ) {
222 m_parentCollection->take( this ); 225 m_parentCollection->take( this );
223 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) 226 for( uint i = 0; i < d->m_kaccelList.count(); i++ )
224//US d->m_kaccelList[i]->remove( name() ); 227//US d->m_kaccelList[i]->remove( name() );
225 qDebug("KAction::KAction~ ...1 has top be fixed"); 228 qDebug("KAction::KAction~ ...1 has top be fixed");
226 } 229 }
227 230
228 // Do not call unplugAll from here, as tempting as it sounds. 231 // Do not call unplugAll from here, as tempting as it sounds.
229 // KAction is designed around the idea that you need to plug 232 // KAction is designed around the idea that you need to plug
230 // _and_ to unplug it "manually". Unplugging leads to an important 233 // _and_ to unplug it "manually". Unplugging leads to an important
231 // slowdown when e.g. closing the window, in which case we simply 234 // slowdown when e.g. closing the window, in which case we simply
232 // want to destroy everything asap, not to remove actions one by one 235 // want to destroy everything asap, not to remove actions one by one
233 // from the GUI. 236 // from the GUI.
234 237
235 delete d; d = 0; 238 delete d; d = 0;
236} 239}
237 240
238void KAction::initPrivate( const QString& text, const KShortcut& cut, 241void KAction::initPrivate( const QString& text, const KShortcut& cut,
239 const QObject* receiver, const char* slot ) 242 const QObject* receiver, const char* slot )
240{ 243{
241 d = new KActionPrivate; 244 d = new KActionPrivate;
242 245
243 d->m_cutDefault = cut; 246 d->m_cutDefault = cut;
244 247
245//US m_parentCollection = dynamic_cast<KActionCollection *>( parent() ); 248//US m_parentCollection = dynamic_cast<KActionCollection *>( parent() );
246 m_parentCollection = (KActionCollection *)( parent() ); 249 m_parentCollection = (KActionCollection *)( parent() );
247 kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl; 250 kdDebug(129) << "KAction::initPrivate(): this = " << this << " name = \"" << name() << "\" cut = " << cut.toStringInternal() << " m_parentCollection = " << m_parentCollection << endl;
248 if ( m_parentCollection ) 251 if ( m_parentCollection )
249 m_parentCollection->insert( this ); 252 m_parentCollection->insert( this );
250 253
251 if ( receiver && slot ) 254 if ( receiver && slot )
252 connect( this, SIGNAL( activated() ), receiver, slot ); 255 connect( this, SIGNAL( activated() ), receiver, slot );
253 256
254 if( !cut.isNull() && qstrcmp( name(), "unnamed" ) == 0 ) 257 if( !cut.isNull() && qstrcmp( name(), "unnamed" ) == 0 )
255 kdWarning(129) << "KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl; 258 kdWarning(129) << "KAction::initPrivate(): trying to assign a shortcut (" << cut.toStringInternal() << ") to an unnamed action." << endl;
256 d->setText( text ); 259 d->setText( text );
257 initShortcut( cut ); 260 initShortcut( cut );
258 261
259} 262}
260 263
261bool KAction::isPlugged() const 264bool KAction::isPlugged() const
262{ 265{
263 return (containerCount() > 0) || d->m_kaccel; 266 return (containerCount() > 0) || d->m_kaccel;
264} 267}
265 268
266bool KAction::isPlugged( const QWidget *container ) const 269bool KAction::isPlugged( const QWidget *container ) const
267{ 270{
268 return findContainer( container ) > -1; 271 return findContainer( container ) > -1;
269} 272}
270 273
271bool KAction::isPlugged( const QWidget *container, int id ) const 274bool KAction::isPlugged( const QWidget *container, int id ) const
272{ 275{
273 int i = findContainer( container ); 276 int i = findContainer( container );
274 return ( i > -1 && itemId( i ) == id ); 277 return ( i > -1 && itemId( i ) == id );
275} 278}
276 279
277bool KAction::isPlugged( const QWidget *container, const QWidget *_representative ) const 280bool KAction::isPlugged( const QWidget *container, const QWidget *_representative ) const
278{ 281{
279 int i = findContainer( container ); 282 int i = findContainer( container );
280 return ( i > -1 && representative( i ) == _representative ); 283 return ( i > -1 && representative( i ) == _representative );
281} 284}
282 285
283 286
284/* 287/*
285Three actionCollection conditions: 288Three actionCollection conditions:
286 1) Scope is known on creation and KAccel object is created (e.g. KMainWindow) 289 1) Scope is known on creation and KAccel object is created (e.g. KMainWindow)
287 2) Scope is unknown and no KAccel object is available (e.g. KXMLGUIClient) 290 2) Scope is unknown and no KAccel object is available (e.g. KXMLGUIClient)
288 a) addClient() will be called on object 291 a) addClient() will be called on object
289 b) we just want to add the actions to another KXMLGUIClient object 292 b) we just want to add the actions to another KXMLGUIClient object
290 293
291The question is how to do we incorporate #2b into the XMLGUI framework? 294The question is how to do we incorporate #2b into the XMLGUI framework?
292 295
293 296
294We have a KCommandHistory object with undo and redo actions in a passed actionCollection 297We have a KCommandHistory object with undo and redo actions in a passed actionCollection
295We have a KoDoc object which holds a KCommandHistory object and the actionCollection 298We have a KoDoc object which holds a KCommandHistory object and the actionCollection
296We have two KoView objects which both point to the same KoDoc object 299We have two KoView objects which both point to the same KoDoc object
297Undo and Redo should be available in both KoView objects, and 300Undo and Redo should be available in both KoView objects, and
298 calling the undo->setEnabled() should affect both KoViews 301 calling the undo->setEnabled() should affect both KoViews
299 302
300When addClient is called, it needs to be able to find the undo and redo actions 303When addClient is called, it needs to be able to find the undo and redo actions
301When it calls plug() on them, they need to be inserted into the KAccel object of the appropriate KoView 304When it calls plug() on them, they need to be inserted into the KAccel object of the appropriate KoView
302 305
303In this case, the actionCollection belongs to KoDoc and we need to let it know that its shortcuts 306In this case, the actionCollection belongs to KoDoc and we need to let it know that its shortcuts
304have the same scope as the KoView actionCollection 307have the same scope as the KoView actionCollection
305 308
306KXMLGUIClient::addSubActionCollection 309KXMLGUIClient::addSubActionCollection
307 310
308Document: 311Document:
309 create document actions 312 create document actions
310 313
311View 314View
312 create view actions 315 create view actions
313 add document actionCollection as sub-collection 316 add document actionCollection as sub-collection
314 317
315A parentCollection is created 318A parentCollection is created
316Scenario 1: parentCollection has a focus widget set (e.g. via KMainWindow) 319Scenario 1: parentCollection has a focus widget set (e.g. via KMainWindow)
317 A KAccel object is created in the parentCollection 320 A KAccel object is created in the parentCollection
318 A KAction is created with parent=parentCollection 321 A KAction is created with parent=parentCollection
319 The shortcut is inserted into this actionCollection 322 The shortcut is inserted into this actionCollection
320 Scenario 1a: xml isn't used 323 Scenario 1a: xml isn't used
321 done 324 done
322 Scenario 1b: KXMLGUIBuilder::addClient() called 325 Scenario 1b: KXMLGUIBuilder::addClient() called
323 setWidget is called -- ignore 326 setWidget is called -- ignore
324 shortcuts are set 327 shortcuts are set
325Scenario 2: parentCollection has no focus widget (e.g., KParts) 328Scenario 2: parentCollection has no focus widget (e.g., KParts)
326 A KAction is created with parent=parentCollection 329 A KAction is created with parent=parentCollection
327 Scenario 2a: xml isn't used 330 Scenario 2a: xml isn't used
328 no shortcuts 331 no shortcuts
329 Scenario 2b: KXMLGUIBuilder::addClient() called 332 Scenario 2b: KXMLGUIBuilder::addClient() called
330 setWidget is called 333 setWidget is called
331 shortcuts are inserted into current KAccel 334 shortcuts are inserted into current KAccel
332 shortcuts are set in all other KAccels, if the action is present in the other KAccels 335 shortcuts are set in all other KAccels, if the action is present in the other KAccels
333*/ 336*/
334 337
335/* 338/*
336shortcut may be set: 339shortcut may be set:
337 - on construction 340 - on construction
338 - on plug 341 - on plug
339 - on reading XML 342 - on reading XML
340 - on plugAccel (deprecated) 343 - on plugAccel (deprecated)
341 344
342On Construction: [via initShortcut()] 345On Construction: [via initShortcut()]
343 insert into KAccel of m_parentCollection, 346 insert into KAccel of m_parentCollection,
344 if kaccel() && isAutoConnectShortcuts() exists 347 if kaccel() && isAutoConnectShortcuts() exists
345 348
346On Plug: [via plug() -> plugShortcut()] 349On Plug: [via plug() -> plugShortcut()]
347 insert into KAccel of m_parentCollection, if exists and not already inserted into 350 insert into KAccel of m_parentCollection, if exists and not already inserted into
348 351
349On Read XML: [via setShortcut()] 352On Read XML: [via setShortcut()]
350 set in all current KAccels 353 set in all current KAccels
351 insert into KAccel of m_parentCollection, if exists and not already inserted into 354 insert into KAccel of m_parentCollection, if exists and not already inserted into
352*/ 355*/
353 356
354KAccel* KAction::kaccelCurrent() 357KAccel* KAction::kaccelCurrent()
355{ 358{
356 if( m_parentCollection && m_parentCollection->builderKAccel() ) 359 if( m_parentCollection && m_parentCollection->builderKAccel() )
357 return m_parentCollection->builderKAccel(); 360 return m_parentCollection->builderKAccel();
358 else if( m_parentCollection && m_parentCollection->kaccel() ) 361 else if( m_parentCollection && m_parentCollection->kaccel() )
359 return m_parentCollection->kaccel(); 362 return m_parentCollection->kaccel();
360 else 363 else
361 return 0L; 364 return 0L;
362} 365}
363 366
364// Only to be called from initPrivate() 367// Only to be called from initPrivate()
365bool KAction::initShortcut( const KShortcut& cut ) 368bool KAction::initShortcut( const KShortcut& cut )
366{ 369{
367 d->m_cut = cut; 370 d->m_cut = cut;
368 371
369 // Only insert action into KAccel if it has a valid name, 372 // Only insert action into KAccel if it has a valid name,
370 if( qstrcmp( name(), "unnamed" ) != 0 && 373 if( qstrcmp( name(), "unnamed" ) != 0 &&
371 m_parentCollection && 374 m_parentCollection &&
372 m_parentCollection->isAutoConnectShortcuts() && 375 m_parentCollection->isAutoConnectShortcuts() &&
373 m_parentCollection->kaccel() ) 376 m_parentCollection->kaccel() )
374 { 377 {
375 insertKAccel( m_parentCollection->kaccel() ); 378 insertKAccel( m_parentCollection->kaccel() );
376 return true; 379 return true;
377 } 380 }
378 return false; 381 return false;
379 } 382 }
380 383
381// Only to be called from plug() 384// Only to be called from plug()
382void KAction::plugShortcut() 385void KAction::plugShortcut()
383{ 386{
384 KAccel* kaccel = kaccelCurrent(); 387 KAccel* kaccel = kaccelCurrent();
385 388
386 //kdDebug(129) << "KAction::plugShortcut(): this = " << this << " kaccel() = " << (m_parentCollection ? m_parentCollection->kaccel() : 0) << endl; 389 //kdDebug(129) << "KAction::plugShortcut(): this = " << this << " kaccel() = " << (m_parentCollection ? m_parentCollection->kaccel() : 0) << endl;
387 if( kaccel && qstrcmp( name(), "unnamed" ) != 0 ) { 390 if( kaccel && qstrcmp( name(), "unnamed" ) != 0 ) {
388 // Check if already plugged into current KAccel object 391 // Check if already plugged into current KAccel object
389 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { 392 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) {
390 if( d->m_kaccelList[i] == kaccel ) 393 if( d->m_kaccelList[i] == kaccel )
391 return; 394 return;
392 } 395 }
393 396
394 insertKAccel( kaccel ); 397 insertKAccel( kaccel );
395 } 398 }
396} 399}
397 400
398bool KAction::setShortcut( const KShortcut& cut ) 401bool KAction::setShortcut( const KShortcut& cut )
399{ 402{
400 qDebug("KAction::setShortcut~ ...1 has top be fixed"); 403 qDebug("KAction::setShortcut~ ...1 has top be fixed");
401/*US 404/*US
402 bool bChanged = (d->m_cut != cut); 405 bool bChanged = (d->m_cut != cut);
403 d->m_cut = cut; 406 d->m_cut = cut;
404 407
405 KAccel* kaccel = kaccelCurrent(); 408 KAccel* kaccel = kaccelCurrent();
406 bool bInsertRequired = true; 409 bool bInsertRequired = true;
407 // Apply new shortcut to all existing KAccel objects 410 // Apply new shortcut to all existing KAccel objects
408 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { 411 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) {
409 // Check whether shortcut has already been plugged into 412 // Check whether shortcut has already been plugged into
410 // the current kaccel object. 413 // the current kaccel object.
411 if( d->m_kaccelList[i] == kaccel ) 414 if( d->m_kaccelList[i] == kaccel )
412 bInsertRequired = false; 415 bInsertRequired = false;
413 if( bChanged ) 416 if( bChanged )
414 updateKAccelShortcut( d->m_kaccelList[i] ); 417 updateKAccelShortcut( d->m_kaccelList[i] );
415 } 418 }
416 419
417 // Only insert action into KAccel if it has a valid name, 420 // Only insert action into KAccel if it has a valid name,
418 if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) ) 421 if( kaccel && bInsertRequired && qstrcmp( name(), "unnamed" ) )
419 insertKAccel( kaccel ); 422 insertKAccel( kaccel );
420 423
421 if( bChanged ) { 424 if( bChanged ) {
422 // KDE 4: remove 425 // KDE 4: remove
423 if ( d->m_kaccel ) 426 if ( d->m_kaccel )
424 d->m_kaccel->setShortcut( name(), cut ); 427 d->m_kaccel->setShortcut( name(), cut );
425 // KDE 4: remove end 428 // KDE 4: remove end
426 int len = containerCount(); 429 int len = containerCount();
427 for( int i = 0; i < len; ++i ) 430 for( int i = 0; i < len; ++i )
428 updateShortcut( i ); 431 updateShortcut( i );
429 } 432 }
430*/ 433*/
431 434
432 return true; 435 return true;
433} 436}
434 437
435bool KAction::updateKAccelShortcut( KAccel* kaccel ) 438bool KAction::updateKAccelShortcut( KAccel* kaccel )
436{ 439{
437 //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); 440 //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed");
438 441
439 // Check if action is permitted 442 // Check if action is permitted
440/*US 443/*US
441 if (kapp && !kapp->authorizeKAction(name())) 444 if (kapp && !kapp->authorizeKAction(name()))
442 return false; 445 return false;
443 446
444 bool b = true; 447 bool b = true;
445 448
446 if ( !kaccel->actions().actionPtr( name() ) ) { 449 if ( !kaccel->actions().actionPtr( name() ) ) {
447 if(!d->m_cut.isNull() ) { 450 if(!d->m_cut.isNull() ) {
448 kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl; 451 kdDebug(129) << "Inserting " << name() << ", " << d->text() << ", " << d->plainText() << endl;
449 b = kaccel->insert( name(), d->plainText(), QString::null, 452 b = kaccel->insert( name(), d->plainText(), QString::null,
450 d->m_cut, 453 d->m_cut,
451 this, SLOT(slotActivated()), 454 this, SLOT(slotActivated()),
452 isShortcutConfigurable(), isEnabled() ); 455 isShortcutConfigurable(), isEnabled() );
453 } 456 }
454 } 457 }
455 else 458 else
456 b = kaccel->setShortcut( name(), d->m_cut ); 459 b = kaccel->setShortcut( name(), d->m_cut );
457 460
458 return b; 461 return b;
459*/ 462*/
460 return true; 463 return true;
461} 464}
462 465
463void KAction::insertKAccel( KAccel* kaccel ) 466void KAction::insertKAccel( KAccel* kaccel )
464{ 467{
465 //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed"); 468 //qDebug("KAction::updateKAccelShortcut~ ...1 has top be fixed");
466 469
467/*US 470/*US
468 //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl; 471 //kdDebug(129) << "KAction::insertKAccel( " << kaccel << " ): this = " << this << endl;
469 if ( !kaccel->actions().actionPtr( name() ) ) { 472 if ( !kaccel->actions().actionPtr( name() ) ) {
470 if( updateKAccelShortcut( kaccel ) ) { 473 if( updateKAccelShortcut( kaccel ) ) {
471 d->m_kaccelList.append( kaccel ); 474 d->m_kaccelList.append( kaccel );
472 connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); 475 connect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
473 } 476 }
474 } 477 }
475 else 478 else
476 kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis 479 kdWarning(129) << "KAction::insertKAccel( kaccel = " << kaccel << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis
477*/ 480*/
478} 481}
479 482
480void KAction::removeKAccel( KAccel* kaccel ) 483void KAction::removeKAccel( KAccel* kaccel )
481{ 484{
482 // qDebug("KAction::removeKAccel~ ...1 has top be fixed"); 485 // qDebug("KAction::removeKAccel~ ...1 has top be fixed");
483 486
484/*US 487/*US
485 //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl; 488 //kdDebug(129) << "KAction::removeKAccel( " << i << " ): this = " << this << endl;
486 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { 489 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) {
487 if( d->m_kaccelList[i] == kaccel ) { 490 if( d->m_kaccelList[i] == kaccel ) {
488 kaccel->remove( name() ); 491 kaccel->remove( name() );
489 d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); 492 d->m_kaccelList.remove( d->m_kaccelList.at( i ) );
490 disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); 493 disconnect( kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
491 break; 494 break;
492 } 495 }
493 } 496 }
494*/ 497*/
495} 498}
496 499
497// KDE 4: remove 500// KDE 4: remove
498void KAction::setAccel( int keyQt ) 501void KAction::setAccel( int keyQt )
499{ 502{
500 setShortcut( KShortcut(keyQt) ); 503 setShortcut( KShortcut(keyQt) );
501} 504}
502// KDE 4: remove end 505// KDE 4: remove end
503 506
504void KAction::updateShortcut( int i ) 507void KAction::updateShortcut( int i )
505{ 508{
506 int id = itemId( i ); 509 int id = itemId( i );
507 510
508 QWidget* w = container( i ); 511 QWidget* w = container( i );
509 if ( w->inherits( "QPopupMenu" ) ) { 512 if ( w->inherits( "Q3PopupMenu" ) ) {
510 QPopupMenu* menu = static_cast<QPopupMenu*>(w); 513 Q3PopupMenu* menu = static_cast<Q3PopupMenu*>(w);
511 updateShortcut( menu, id ); 514 updateShortcut( menu, id );
512 } 515 }
513 else if ( w->inherits( "QMenuBar" ) ) 516 else if ( w->inherits( "QMenuBar" ) )
514//US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id ); 517//US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id );
515//US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id ); 518//US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id );
516 519
517 ; //qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed"); 520 ; //qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed");
518 521
519} 522}
520 523
521void KAction::updateShortcut( QPopupMenu* menu, int id ) 524void KAction::updateShortcut( Q3PopupMenu* menu, int id )
522{ 525{
523/*US 526/*US
524 //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; 527 //kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl;
525 // If the action has a KAccel object, 528 // If the action has a KAccel object,
526 // show the string representation of its shortcut. 529 // show the string representation of its shortcut.
527 if ( d->m_kaccel || d->m_kaccelList.count() ) { 530 if ( d->m_kaccel || d->m_kaccelList.count() ) {
528 QString s = menu->text( id ); 531 QString s = menu->text( id );
529 int i = s.find( '\t' ); 532 int i = s.find( '\t' );
530 if ( i >= 0 ) 533 if ( i >= 0 )
531 s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() ); 534 s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() );
532 else 535 else
533 s += "\t" + d->m_cut.seq(0).toString(); 536 s += "\t" + d->m_cut.seq(0).toString();
534 537
535 menu->changeItem( id, s ); 538 menu->changeItem( id, s );
536 } 539 }
537 // Otherwise insert the shortcut itself into the popup menu. 540 // Otherwise insert the shortcut itself into the popup menu.
538 else { 541 else {
539 // This is a fall-hack in case the KAction is missing a proper parent collection. 542 // This is a fall-hack in case the KAction is missing a proper parent collection.
540 // It should be removed eventually. --ellis 543 // It should be removed eventually. --ellis
541 menu->setAccel( d->m_cut.keyCodeQt(), id ); 544 menu->setAccel( d->m_cut.keyCodeQt(), id );
542 kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl; 545 kdWarning(129) << "KAction::updateShortcut(): name = \"" << name() << "\", cut = " << d->m_cut.toStringInternal() << "; No KAccel, probably missing a parent collection." << endl;
543 } 546 }
544*/ 547*/
545 548
546 549
547//qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed"); 550//qDebug("KAction::updateShortcut( QPopupMenu* menu, int id ) ...1 has top be fixed");
548 551
549} 552}
550 553
551const KShortcut& KAction::shortcut() const 554const KShortcut& KAction::shortcut() const
552{ 555{
553 return d->m_cut; 556 return d->m_cut;
554} 557}
555 558
556const KShortcut& KAction::shortcutDefault() const 559const KShortcut& KAction::shortcutDefault() const
557{ 560{
558 return d->m_cutDefault; 561 return d->m_cutDefault;
559} 562}
560 563
561QString KAction::shortcutText() const 564QString KAction::shortcutText() const
562{ 565{
563 return d->m_cut.toStringInternal(); 566 return d->m_cut.toStringInternal();
564} 567}
565 568
566void KAction::setShortcutText( const QString& s ) 569void KAction::setShortcutText( const QString& s )
567{ 570{
568 setShortcut( KShortcut(s) ); 571 setShortcut( KShortcut(s) );
569} 572}
570 573
571int KAction::accel() const 574int KAction::accel() const
572{ 575{
573 // qDebug("KAction::accel() ...1 has top be fixed"); 576 // qDebug("KAction::accel() ...1 has top be fixed");
574//US return d->m_cut.keyCodeQt(); 577//US return d->m_cut.keyCodeQt();
575 return 0; 578 return 0;
576} 579}
577 580
578void KAction::setGroup( const QString& grp ) 581void KAction::setGroup( const QString& grp )
579{ 582{
580 d->m_group = grp; 583 d->m_group = grp;
581 584
582 int len = containerCount(); 585 int len = containerCount();
583 for( int i = 0; i < len; ++i ) 586 for( int i = 0; i < len; ++i )
584 updateGroup( i ); 587 updateGroup( i );
585} 588}
586 589
587void KAction::updateGroup( int ) 590void KAction::updateGroup( int )
588{ 591{
589 // DO SOMETHING 592 // DO SOMETHING
590} 593}
591 594
592QString KAction::group() const 595QString KAction::group() const
593{ 596{
594 return d->m_group; 597 return d->m_group;
595} 598}
596 599
597bool KAction::isEnabled() const 600bool KAction::isEnabled() const
598{ 601{
599 return d->isEnabled(); 602 return d->isEnabled();
600} 603}
601 604
602bool KAction::isShortcutConfigurable() const 605bool KAction::isShortcutConfigurable() const
603{ 606{
604 return d->m_configurable; 607 return d->m_configurable;
605} 608}
606 609
607void KAction::setToolTip( const QString& tt ) 610void KAction::setToolTip( const QString& tt )
608{ 611{
609 //qDebug("KAction::setToolTip ...1 has top be fixed"); 612 //qDebug("KAction::setToolTip ...1 has top be fixed");
610 d->setToolTip( tt ); 613 d->setToolTip( tt );
611 614
612 int len = containerCount(); 615 int len = containerCount();
613 for( int i = 0; i < len; ++i ) 616 for( int i = 0; i < len; ++i )
614 updateToolTip( i ); 617 updateToolTip( i );
615} 618}
616 619
617void KAction::updateToolTip( int i ) 620void KAction::updateToolTip( int i )
618{ 621{
619 //qDebug("KAction::updateToolTip ...1 has top be fixed"); 622 //qDebug("KAction::updateToolTip ...1 has top be fixed");
620 QWidget *w = container( i ); 623 QWidget *w = container( i );
621 624
622 if ( w->inherits( "KToolBar" ) ) 625 if ( w->inherits( "KToolBar" ) )
623 QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); 626 QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() );
624 else if ( w->inherits( "QToolBar" ) ) 627 else if ( w->inherits( "Q3ToolBar" ) )
625 QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() ); 628 QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() );
626} 629}
627 630
628QString KAction::toolTip() const 631QString KAction::toolTip() const
629{ 632{
630 return d->toolTip(); 633 return d->toolTip();
631} 634}
632 635
633int KAction::plug( QWidget *w, int index ) 636int KAction::plug( QWidget *w, int index )
634{ 637{
635 //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl; 638 //kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl;
636 if (w == 0) { 639 if (w == 0) {
637 kdWarning(129) << "KAction::plug called with 0 argument\n"; 640 kdWarning(129) << "KAction::plug called with 0 argument\n";
638 return -1; 641 return -1;
639 } 642 }
640 643
641 644
642 645
643 // Check if action is permitted 646 // Check if action is permitted
644//US if (kapp && !kapp->authorizeKAction(name())) 647//US if (kapp && !kapp->authorizeKAction(name()))
645//US return -1; 648//US return -1;
646 649
647 plugShortcut(); 650 plugShortcut();
648 651
649 if ( w->inherits("QPopupMenu") ) 652 if ( w->inherits("Q3PopupMenu") )
650 { 653 {
651 QPopupMenu* menu = static_cast<QPopupMenu*>( w ); 654 Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( w );
652 int id; 655 int id;
653 // Don't insert shortcut into menu if it's already in a KAccel object. 656 // Don't insert shortcut into menu if it's already in a KAccel object.
654 //qDebug("KAction::plug warning: real shortcuts not available yet. "); 657 //qDebug("KAction::plug warning: real shortcuts not available yet. ");
655//US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt(); 658//US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt();
656 int keyQt = 0; 659 int keyQt = 0;
657 660
658 if ( d->hasIcon() ) 661 if ( d->hasIcon() )
659 { 662 {
660/*US 663/*US
661 KInstance *instance; 664 KInstance *instance;
662 if ( m_parentCollection ) 665 if ( m_parentCollection )
663 instance = m_parentCollection->instance(); 666 instance = m_parentCollection->instance();
664 else 667 else
665 instance = KGlobal::instance(); 668 instance = KGlobal::instance();
666*/ 669*/
667 id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet 670 id = menu->insertItem( d->iconSet( KIcon::Small, 0/*US , instance */), d->text(), this,//dsweet
668 SLOT( slotActivated() ), keyQt, 671 SLOT( slotActivated() ), keyQt,
669 -1, index ); 672 -1, index );
670 } 673 }
671 else 674 else
672 id = menu->insertItem( d->text(), this, 675 id = menu->insertItem( d->text(), this,
673 SLOT( slotActivated() ), //dsweet 676 SLOT( slotActivated() ), //dsweet
674 keyQt, -1, index ); 677 keyQt, -1, index );
675 678
676 // If the shortcut is already in a KAccel object, then 679 // If the shortcut is already in a KAccel object, then
677 // we need to set the menu item's shortcut text. 680 // we need to set the menu item's shortcut text.
678/*US if ( d->m_kaccelList.count() || d->m_kaccel ) 681/*US if ( d->m_kaccelList.count() || d->m_kaccel )
679 updateShortcut( menu, id ); 682 updateShortcut( menu, id );
680*/ 683*/
681 // call setItemEnabled only if the item really should be disabled, 684 // call setItemEnabled only if the item really should be disabled,
682 // because that method is slow and the item is per default enabled 685 // because that method is slow and the item is per default enabled
683 if ( !d->isEnabled() ) 686 if ( !d->isEnabled() )
684 menu->setItemEnabled( id, false ); 687 menu->setItemEnabled( id, false );
685 688
686 if ( !d->whatsThis().isEmpty() ) 689 if ( !d->whatsThis().isEmpty() )
687 menu->setWhatsThis( id, whatsThisWithIcon() ); 690 menu->setWhatsThis( id, whatsThisWithIcon() );
688 691
689 addContainer( menu, id ); 692 addContainer( menu, id );
690 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 693 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
691 694
692 if ( m_parentCollection ) 695 if ( m_parentCollection )
693 m_parentCollection->connectHighlight( menu, this ); 696 m_parentCollection->connectHighlight( menu, this );
694 697
695 return d->m_containers.count() - 1; 698 return d->m_containers.count() - 1;
696 } 699 }
697 else if ( w->inherits( "KToolBar" ) ) 700 else if ( w->inherits( "KToolBar" ) )
698 { 701 {
699 KToolBar *bar = static_cast<KToolBar *>( w ); 702 KToolBar *bar = static_cast<KToolBar *>( w );
700 703
701 int id_ = getToolButtonID(); 704 int id_ = getToolButtonID();
702/*US 705/*US
703 KInstance *instance; 706 KInstance *instance;
704 if ( m_parentCollection ) 707 if ( m_parentCollection )
705 instance = m_parentCollection->instance(); 708 instance = m_parentCollection->instance();
706 else 709 else
707 instance = KGlobal::instance(); 710 instance = KGlobal::instance();
708*/ 711*/
709 if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly 712 if ( icon().isEmpty() && !iconSet().pixmap().isNull() ) // old code using QIconSet directly
710 { 713 {
711 bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, 714 bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this,
712 SLOT( slotActivated() ), 715 SLOT( slotActivated() ),
713 d->isEnabled(), d->plainText(), index ); 716 d->isEnabled(), d->plainText(), index );
714 } 717 }
715 else 718 else
716 { 719 {
717 QString icon = d->iconName(); 720 QString icon = d->iconName();
718 if ( icon.isEmpty() ) 721 if ( icon.isEmpty() )
719 icon = "unknown"; 722 icon = "unknown";
720 bar->insertButton( icon, id_, SIGNAL( clicked() ), this, 723 bar->insertButton( icon, id_, SIGNAL( clicked() ), this,
721 SLOT( slotActivated() ), 724 SLOT( slotActivated() ),
722 d->isEnabled(), d->plainText(), index/*US, instance*/ ); 725 d->isEnabled(), d->plainText(), index/*US, instance*/ );
723 } 726 }
724 bar->getButton( id_ )->setName( QCString("toolbutton_")+name() ); 727 bar->getButton( id_ )->setName( Q3CString("toolbutton_")+name() );
725 728
726//US if ( !d->whatsThis().isEmpty() ) 729//US if ( !d->whatsThis().isEmpty() )
727//US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() ); 730//US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() );
728 if ( !d->toolTip().isEmpty() ) 731 if ( !d->toolTip().isEmpty() )
729 QToolTip::add( bar->getButton(id_), d->toolTip() ); 732 QToolTip::add( bar->getButton(id_), d->toolTip() );
730 733
731 addContainer( bar, id_ ); 734 addContainer( bar, id_ );
732 735
733 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 736 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
734 737
735 if ( m_parentCollection ) 738 if ( m_parentCollection )
736 m_parentCollection->connectHighlight( bar, this ); 739 m_parentCollection->connectHighlight( bar, this );
737 740
738 return containerCount() - 1; 741 return containerCount() - 1;
739 742
740 } 743 }
741 744
742 return -1; 745 return -1;
743} 746}
744 747
745void KAction::unplug( QWidget *w ) 748void KAction::unplug( QWidget *w )
746{ 749{
747 int i = findContainer( w ); 750 int i = findContainer( w );
748 if ( i == -1 ) 751 if ( i == -1 )
749 return; 752 return;
750 int id = itemId( i ); 753 int id = itemId( i );
751 754
752 if ( w->inherits( "QPopupMenu" ) ) 755 if ( w->inherits( "Q3PopupMenu" ) )
753 { 756 {
754 QPopupMenu *menu = static_cast<QPopupMenu *>( w ); 757 Q3PopupMenu *menu = static_cast<Q3PopupMenu *>( w );
755 menu->removeItem( id ); 758 menu->removeItem( id );
756 } 759 }
757 else if ( w->inherits( "KToolBar" ) ) 760 else if ( w->inherits( "KToolBar" ) )
758 { 761 {
759 KToolBar *bar = static_cast<KToolBar *>( w ); 762 KToolBar *bar = static_cast<KToolBar *>( w );
760 bar->removeItemDelayed( id ); 763 bar->removeItemDelayed( id );
761 } 764 }
762 else if ( w->inherits( "QMenuBar" ) ) 765 else if ( w->inherits( "QMenuBar" ) )
763 { 766 {
764 QMenuBar *bar = static_cast<QMenuBar *>( w ); 767 QMenuBar *bar = static_cast<QMenuBar *>( w );
765 bar->removeItem( id ); 768 bar->removeItem( id );
766 } 769 }
767 770
768 removeContainer( i ); 771 removeContainer( i );
769 772
770 if ( m_parentCollection ) 773 if ( m_parentCollection )
771 m_parentCollection->disconnectHighlight( w, this ); 774 m_parentCollection->disconnectHighlight( w, this );
772} 775}
773 776
774void KAction::plugAccel(KAccel *kacc, bool configurable) 777void KAction::plugAccel(KAccel *kacc, bool configurable)
775{ 778{
776 // qDebug("KAction::plugAccel ...1 has top be fixed"); 779 // qDebug("KAction::plugAccel ...1 has top be fixed");
777 780
778/*US 781/*US
779 kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl; 782 kdWarning(129) << "KAction::plugAccel(): call to deprecated action." << endl;
780 kdDebug(129) << kdBacktrace() << endl; 783 kdDebug(129) << kdBacktrace() << endl;
781 //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl; 784 //kdDebug(129) << "KAction::plugAccel( kacc = " << kacc << " ): name \"" << name() << "\"" << endl;
782 if ( d->m_kaccel ) 785 if ( d->m_kaccel )
783 unplugAccel(); 786 unplugAccel();
784 787
785 // If the parent collection's accel ptr isn't set yet 788 // If the parent collection's accel ptr isn't set yet
786 //if ( m_parentCollection && !m_parentCollection->accel() ) 789 //if ( m_parentCollection && !m_parentCollection->accel() )
787 // m_parentCollection->setAccel( kacc ); 790 // m_parentCollection->setAccel( kacc );
788 791
789 // We can only plug this action into the given KAccel object 792 // We can only plug this action into the given KAccel object
790 // if it does not already contain an action with the same name. 793 // if it does not already contain an action with the same name.
791 if ( !kacc->actions().actionPtr(name()) ) 794 if ( !kacc->actions().actionPtr(name()) )
792 { 795 {
793 d->m_kaccel = kacc; 796 d->m_kaccel = kacc;
794 d->m_kaccel->insert(name(), d->plainText(), QString::null, 797 d->m_kaccel->insert(name(), d->plainText(), QString::null,
795 KShortcut(d->m_cut), 798 KShortcut(d->m_cut),
796 this, SLOT(slotActivated()), 799 this, SLOT(slotActivated()),
797 configurable, isEnabled()); 800 configurable, isEnabled());
798 connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed())); 801 connect(d->m_kaccel, SIGNAL(destroyed()), this, SLOT(slotDestroyed()));
799 //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged())); 802 //connect(d->m_kaccel, SIGNAL(keycodeChanged()), this, SLOT(slotKeycodeChanged()));
800 } 803 }
801 else 804 else
802 kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis 805 kdWarning(129) << "KAction::plugAccel( kacc = " << kacc << " ): KAccel object already contains an action name \"" << name() << "\"" << endl; // -- ellis
803*/ 806*/
804} 807}
805 808
806void KAction::unplugAccel() 809void KAction::unplugAccel()
807{ 810{
808 // qDebug("KAction::unplugAccel ...1 has top be fixed"); 811 // qDebug("KAction::unplugAccel ...1 has top be fixed");
809/*US 812/*US
810 //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl; 813 //kdDebug(129) << "KAction::unplugAccel() " << this << " " << name() << endl;
811 if ( d->m_kaccel ) 814 if ( d->m_kaccel )
812 { 815 {
813 d->m_kaccel->remove(name()); 816 d->m_kaccel->remove(name());
814 d->m_kaccel = 0; 817 d->m_kaccel = 0;
815 } 818 }
816*/ 819*/
817} 820}
818 821
819void KAction::plugMainWindowAccel( QWidget *w ) 822void KAction::plugMainWindowAccel( QWidget *w )
820{ 823{
821 // qDebug("KAction::plugMainWindowAccel ...1 has top be fixed"); 824 // qDebug("KAction::plugMainWindowAccel ...1 has top be fixed");
822 825
823/*US 826/*US
824 // Note: topLevelWidget() stops too early, we can't use it. 827 // Note: topLevelWidget() stops too early, we can't use it.
825 QWidget * tl = w; 828 QWidget * tl = w;
826 QWidget * n; 829 QWidget * n;
827 while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store 830 while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store
828 tl = n; 831 tl = n;
829 832
830 KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow 833 KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow
831 if (mw) 834 if (mw)
832 plugAccel( mw->accel() ); 835 plugAccel( mw->accel() );
833 else 836 else
834 kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; 837 kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl;
835*/ 838*/
836} 839}
837 840
838void KAction::setEnabled(bool enable) 841void KAction::setEnabled(bool enable)
839{ 842{
840 //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl; 843 //kdDebug(129) << "KAction::setEnabled( " << enable << " ): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl;
841 if ( enable == d->isEnabled() ) 844 if ( enable == d->isEnabled() )
842 return; 845 return;
843 846
844 // KDE 4: remove 847 // KDE 4: remove
845//US if (d->m_kaccel) 848//US if (d->m_kaccel)
846//US d->m_kaccel->setEnabled(name(), enable); 849//US d->m_kaccel->setEnabled(name(), enable);
847 // KDE 4: remove end 850 // KDE 4: remove end
848 851
849//US for ( uint i = 0; i < d->m_kaccelList.count(); i++ ) 852//US for ( uint i = 0; i < d->m_kaccelList.count(); i++ )
850//US d->m_kaccelList[i]->setEnabled( name(), enable ); 853//US d->m_kaccelList[i]->setEnabled( name(), enable );
851 854
852 d->setEnabled( enable ); 855 d->setEnabled( enable );
853 856
854 int len = containerCount(); 857 int len = containerCount();
855 for( int i = 0; i < len; ++i ) 858 for( int i = 0; i < len; ++i )
856 updateEnabled( i ); 859 updateEnabled( i );
857 860
858 emit enabled( d->isEnabled() ); 861 emit enabled( d->isEnabled() );
859} 862}
860 863
861void KAction::updateEnabled( int i ) 864void KAction::updateEnabled( int i )
862{ 865{
863 QWidget *w = container( i ); 866 QWidget *w = container( i );
864 867
865 if ( w->inherits("QPopupMenu") ) 868 if ( w->inherits("Q3PopupMenu") )
866 static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); 869 static_cast<Q3PopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
867 else if ( w->inherits("QMenuBar") ) 870 else if ( w->inherits("QMenuBar") )
868 static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); 871 static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
869 else if ( w->inherits( "KToolBar" ) ) 872 else if ( w->inherits( "KToolBar" ) )
870 { 873 {
871 static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() ); 874 static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
872 } 875 }
873} 876}
874 877
875void KAction::setShortcutConfigurable( bool b ) 878void KAction::setShortcutConfigurable( bool b )
876{ 879{
877 d->m_configurable = b; 880 d->m_configurable = b;
878} 881}
879 882
880void KAction::setText( const QString& text ) 883void KAction::setText( const QString& text )
881{ 884{
882/*US 885/*US
883 // KDE 4: remove 886 // KDE 4: remove
884 if (d->m_kaccel) { 887 if (d->m_kaccel) {
885 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); 888 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name());
886 if (pAction) 889 if (pAction)
887 pAction->setLabel( text ); 890 pAction->setLabel( text );
888 } 891 }
889 // KDE 4: remove end 892 // KDE 4: remove end
890 893
891 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) { 894 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) {
892 KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name()); 895 KAccelAction* pAction = d->m_kaccelList[i]->actions().actionPtr(name());
893 if (pAction) 896 if (pAction)
894 pAction->setLabel( text ); 897 pAction->setLabel( text );
895 } 898 }
896*/ 899*/
897 d->setText( text ); 900 d->setText( text );
898 901
899 int len = containerCount(); 902 int len = containerCount();
900 for( int i = 0; i < len; ++i ) 903 for( int i = 0; i < len; ++i )
901 updateText( i ); 904 updateText( i );
902 905
903} 906}
904 907
905void KAction::updateText( int i ) 908void KAction::updateText( int i )
906{ 909{
907 QWidget *w = container( i ); 910 QWidget *w = container( i );
908 911
909 if ( w->inherits( "QPopupMenu" ) ) { 912 if ( w->inherits( "Q3PopupMenu" ) ) {
910 int id = itemId( i ); 913 int id = itemId( i );
911 static_cast<QPopupMenu*>(w)->changeItem( id, d->text() ); 914 static_cast<Q3PopupMenu*>(w)->changeItem( id, d->text() );
912 updateShortcut( static_cast<QPopupMenu*>(w), id ); 915 updateShortcut( static_cast<Q3PopupMenu*>(w), id );
913 } 916 }
914 else if ( w->inherits( "QMenuBar" ) ) 917 else if ( w->inherits( "QMenuBar" ) )
915 static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() ); 918 static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() );
916 else if ( w->inherits( "KToolBar" ) ) 919 else if ( w->inherits( "KToolBar" ) )
917 { 920 {
918 //qDebug("KAction::updateText ...3 has top be fixed"); 921 //qDebug("KAction::updateText ...3 has top be fixed");
919 QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) ); 922 QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) );
920 if ( button->inherits( "KToolBarButton" ) ) 923 if ( button->inherits( "KToolBarButton" ) )
921 static_cast<KToolBarButton *>(button)->setText( d->plainText() ); 924 static_cast<KToolBarButton *>(button)->setText( d->plainText() );
922 925
923 } 926 }
924} 927}
925 928
926QString KAction::text() const 929QString KAction::text() const
927{ 930{
928 return d->text(); 931 return d->text();
929} 932}
930 933
931QString KAction::plainText() const 934QString KAction::plainText() const
932{ 935{
933 return d->plainText( ); 936 return d->plainText( );
934} 937}
935 938
936void KAction::setIcon( const QString &icon ) 939void KAction::setIcon( const QString &icon )
937{ 940{
938 d->setIconName( icon ); 941 d->setIconName( icon );
939 942
940 // now handle any toolbars 943 // now handle any toolbars
941 int len = containerCount(); 944 int len = containerCount();
942 for ( int i = 0; i < len; ++i ) 945 for ( int i = 0; i < len; ++i )
943 updateIcon( i ); 946 updateIcon( i );
944} 947}
945 948
946void KAction::updateIcon( int id ) 949void KAction::updateIcon( int id )
947{ 950{
948 QWidget* w = container( id ); 951 QWidget* w = container( id );
949 952
950 if ( w->inherits( "QPopupMenu" ) ) { 953 if ( w->inherits( "Q3PopupMenu" ) ) {
951 int itemId_ = itemId( id ); 954 int itemId_ = itemId( id );
952 static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() ); 955 static_cast<Q3PopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() );
953 updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); 956 updateShortcut( static_cast<Q3PopupMenu*>(w), itemId_ );
954 } 957 }
955 else if ( w->inherits( "QMenuBar" ) ) 958 else if ( w->inherits( "QMenuBar" ) )
956 static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() ); 959 static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() );
957 else if ( w->inherits( "KToolBar" ) ) 960 else if ( w->inherits( "KToolBar" ) )
958 static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); 961 static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() );
959 else if ( w->inherits( "QToolBar" ) ) 962 else if ( w->inherits( "Q3ToolBar" ) )
960 { 963 {
961 qDebug("KAction::updateIcon has top be fixed"); 964 qDebug("KAction::updateIcon has top be fixed");
962//US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() ); 965//US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() );
963 } 966 }
964} 967}
965 968
966QString KAction::icon() const 969QString KAction::icon() const
967{ 970{
968 return d->iconName( ); 971 return d->iconName( );
969} 972}
970 973
971void KAction::setIconSet( const QIconSet &iconset ) 974void KAction::setIconSet( const QIcon &iconset )
972{ 975{
973 d->setIconSet( iconset ); 976 d->setIconSet( iconset );
974 977
975 int len = containerCount(); 978 int len = containerCount();
976 for( int i = 0; i < len; ++i ) 979 for( int i = 0; i < len; ++i )
977 updateIconSet( i ); 980 updateIconSet( i );
978} 981}
979 982
980 983
981void KAction::updateIconSet( int id ) 984void KAction::updateIconSet( int id )
982{ 985{
983 QWidget *w = container( id ); 986 QWidget *w = container( id );
984 987
985 if ( w->inherits( "QPopupMenu" ) ) 988 if ( w->inherits( "Q3PopupMenu" ) )
986 { 989 {
987 int itemId_ = itemId( id ); 990 int itemId_ = itemId( id );
988 static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() ); 991 static_cast<Q3PopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() );
989 updateShortcut( static_cast<QPopupMenu*>(w), itemId_ ); 992 updateShortcut( static_cast<Q3PopupMenu*>(w), itemId_ );
990 } 993 }
991 else if ( w->inherits( "QMenuBar" ) ) 994 else if ( w->inherits( "QMenuBar" ) )
992 static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() ); 995 static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() );
993 else if ( w->inherits( "KToolBar" ) ) 996 else if ( w->inherits( "KToolBar" ) )
994 { 997 {
995 if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better ) 998 if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better )
996 static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() ); 999 static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() );
997 else 1000 else
998 static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) ); 1001 static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) );
999 } 1002 }
1000} 1003}
1001 1004
1002QIconSet KAction::iconSet( KIcon::Group group, int size ) const 1005QIcon KAction::iconSet( KIcon::Group group, int size ) const
1003{ 1006{
1004 return d->iconSet( group, size ); 1007 return d->iconSet( group, size );
1005} 1008}
1006 1009
1007bool KAction::hasIcon() const 1010bool KAction::hasIcon() const
1008{ 1011{
1009 return d->hasIcon(); 1012 return d->hasIcon();
1010} 1013}
1011 1014
1012 1015
1013void KAction::setWhatsThis( const QString& text ) 1016void KAction::setWhatsThis( const QString& text )
1014{ 1017{
1015 d->setWhatsThis( text ); 1018 d->setWhatsThis( text );
1016 1019
1017 int len = containerCount(); 1020 int len = containerCount();
1018 for( int i = 0; i < len; ++i ) 1021 for( int i = 0; i < len; ++i )
1019 updateWhatsThis( i ); 1022 updateWhatsThis( i );
1020} 1023}
1021 1024
1022void KAction::updateWhatsThis( int i ) 1025void KAction::updateWhatsThis( int i )
1023{ 1026{
1024 qDebug("KAction::updateWhatsThis ...1 has top be fixed"); 1027 qDebug("KAction::updateWhatsThis ...1 has top be fixed");
1025 QPopupMenu* pm = popupMenu( i ); 1028 Q3PopupMenu* pm = popupMenu( i );
1026 if ( pm ) 1029 if ( pm )
1027 { 1030 {
1028 pm->setWhatsThis( itemId( i ), d->whatsThis() ); 1031 pm->setWhatsThis( itemId( i ), d->whatsThis() );
1029 return; 1032 return;
1030 } 1033 }
1031 1034
1032 KToolBar *tb = toolBar( i ); 1035 KToolBar *tb = toolBar( i );
1033 if ( tb ) 1036 if ( tb )
1034 { 1037 {
1035 QWidget *w = tb->getButton( itemId( i ) ); 1038 QWidget *w = tb->getButton( itemId( i ) );
1036//US QWhatsThis::remove( w ); 1039//US QWhatsThis::remove( w );
1037//US QWhatsThis::add( w, d->whatsThis() ); 1040//US QWhatsThis::add( w, d->whatsThis() );
1038 return; 1041 return;
1039 } 1042 }
1040} 1043}
1041 1044
1042QString KAction::whatsThis() const 1045QString KAction::whatsThis() const
1043{ 1046{
1044 return d->whatsThis(); 1047 return d->whatsThis();
1045} 1048}
1046 1049
1047QString KAction::whatsThisWithIcon() const 1050QString KAction::whatsThisWithIcon() const
1048{ 1051{
1049 QString text = whatsThis(); 1052 QString text = whatsThis();
1050 if (!d->iconName().isEmpty()) 1053 if (!d->iconName().isEmpty())
1051 return QString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text); 1054 return QString::fromLatin1("<img source=\"small|%1\"> %2").arg(d->iconName() ).arg(text);
1052 return text; 1055 return text;
1053} 1056}
1054 1057
1055QWidget* KAction::container( int index ) const 1058QWidget* KAction::container( int index ) const
1056{ 1059{
1057 assert( index < containerCount() ); 1060 assert( index < containerCount() );
1058 return d->m_containers[ index ].m_container; 1061 return d->m_containers[ index ].m_container;
1059} 1062}
1060 1063
1061KToolBar* KAction::toolBar( int index ) const 1064KToolBar* KAction::toolBar( int index ) const
1062{ 1065{
1063//US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container ); 1066//US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container );
1064 return (KToolBar *)( d->m_containers[ index ].m_container ); 1067 return (KToolBar *)( d->m_containers[ index ].m_container );
1065} 1068}
1066 1069
1067QPopupMenu* KAction::popupMenu( int index ) const 1070Q3PopupMenu* KAction::popupMenu( int index ) const
1068{ 1071{
1069//US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container ); 1072//US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container );
1070 return (QPopupMenu *)( d->m_containers[ index ].m_container ); 1073 return (Q3PopupMenu *)( d->m_containers[ index ].m_container );
1071} 1074}
1072 1075
1073QWidget* KAction::representative( int index ) const 1076QWidget* KAction::representative( int index ) const
1074{ 1077{
1075 return d->m_containers[ index ].m_representative; 1078 return d->m_containers[ index ].m_representative;
1076} 1079}
1077 1080
1078int KAction::itemId( int index ) const 1081int KAction::itemId( int index ) const
1079{ 1082{
1080 return d->m_containers[ index ].m_id; 1083 return d->m_containers[ index ].m_id;
1081} 1084}
1082 1085
1083int KAction::containerCount() const 1086int KAction::containerCount() const
1084{ 1087{
1085 return d->m_containers.count(); 1088 return d->m_containers.count();
1086} 1089}
1087 1090
1088uint KAction::kaccelCount() const 1091uint KAction::kaccelCount() const
1089{ 1092{
1090 return d->m_kaccelList.count(); 1093 return d->m_kaccelList.count();
1091} 1094}
1092 1095
1093void KAction::addContainer( QWidget* c, int id ) 1096void KAction::addContainer( QWidget* c, int id )
1094{ 1097{
1095 KActionPrivate::Container p; 1098 KActionPrivate::Container p;
1096 p.m_container = c; 1099 p.m_container = c;
1097 p.m_id = id; 1100 p.m_id = id;
1098 d->m_containers.append( p ); 1101 d->m_containers.append( p );
1099} 1102}
1100 1103
1101void KAction::addContainer( QWidget* c, QWidget* w ) 1104void KAction::addContainer( QWidget* c, QWidget* w )
1102{ 1105{
1103 KActionPrivate::Container p; 1106 KActionPrivate::Container p;
1104 p.m_container = c; 1107 p.m_container = c;
1105 p.m_representative = w; 1108 p.m_representative = w;
1106 d->m_containers.append( p ); 1109 d->m_containers.append( p );
1107} 1110}
1108 1111
1109void KAction::activate() 1112void KAction::activate()
1110{ 1113{
1111 slotActivated(); 1114 slotActivated();
1112} 1115}
1113 1116
1114void KAction::slotActivated() 1117void KAction::slotActivated()
1115{ 1118{
1116 emit activated(); 1119 emit activated();
1117} 1120}
1118 1121
1119void KAction::slotDestroyed() 1122void KAction::slotDestroyed()
1120{ 1123{
1121 1124
1122 const QObject* o = sender(); 1125 const QObject* o = sender();
1123 1126
1124/* 1127/*
1125 1128
1126 1129
1127 // KDE 4: remove 1130 // KDE 4: remove
1128 if ( o == d->m_kaccel ) 1131 if ( o == d->m_kaccel )
1129 { 1132 {
1130 d->m_kaccel = 0; 1133 d->m_kaccel = 0;
1131 return; 1134 return;
1132 } 1135 }
1133 // KDE 4: remove end 1136 // KDE 4: remove end
1134 1137
1135 for( uint i = 0; i < d->m_kaccelList.count(); i++ ) 1138 for( uint i = 0; i < d->m_kaccelList.count(); i++ )
1136 { 1139 {
1137 if ( o == d->m_kaccelList[i] ) 1140 if ( o == d->m_kaccelList[i] )
1138 { 1141 {
1139 disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) ); 1142 disconnect( d->m_kaccelList[i], SIGNAL(destroyed()), this, SLOT(slotDestroyed()) );
1140 d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); 1143 d->m_kaccelList.remove( d->m_kaccelList.at( i ) );
1141 return; 1144 return;
1142 } 1145 }
1143 } 1146 }
1144*/ 1147*/
1145 int i; 1148 int i;
1146 do 1149 do
1147 { 1150 {
1148 i = findContainer( static_cast<const QWidget*>( o ) ); 1151 i = findContainer( static_cast<const QWidget*>( o ) );
1149 if ( i != -1 ) 1152 if ( i != -1 )
1150 removeContainer( i ); 1153 removeContainer( i );
1151 } while ( i != -1 ); 1154 } while ( i != -1 );
1152 1155
1153} 1156}
1154 1157
1155int KAction::findContainer( const QWidget* widget ) const 1158int KAction::findContainer( const QWidget* widget ) const
1156{ 1159{
1157 int pos = 0; 1160 int pos = 0;
1158 QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin(); 1161 Q3ValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin();
1159 while( it != d->m_containers.end() ) 1162 while( it != d->m_containers.end() )
1160 { 1163 {
1161 if ( (*it).m_representative == widget || (*it).m_container == widget ) 1164 if ( (*it).m_representative == widget || (*it).m_container == widget )
1162 return pos; 1165 return pos;
1163 ++it; 1166 ++it;
1164 ++pos; 1167 ++pos;
1165 } 1168 }
1166 1169
1167 return -1; 1170 return -1;
1168} 1171}
1169 1172
1170void KAction::removeContainer( int index ) 1173void KAction::removeContainer( int index )
1171{ 1174{
1172 int i = 0; 1175 int i = 0;
1173 QValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin(); 1176 Q3ValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin();
1174 while( it != d->m_containers.end() ) 1177 while( it != d->m_containers.end() )
1175 { 1178 {
1176 if ( i == index ) 1179 if ( i == index )
1177 { 1180 {
1178 d->m_containers.remove( it ); 1181 d->m_containers.remove( it );
1179 return; 1182 return;
1180 } 1183 }
1181 ++it; 1184 ++it;
1182 ++i; 1185 ++i;
1183 } 1186 }
1184} 1187}
1185 1188
1186// FIXME: Remove this (ellis) 1189// FIXME: Remove this (ellis)
1187void KAction::slotKeycodeChanged() 1190void KAction::slotKeycodeChanged()
1188{ 1191{
1189 qDebug("KAction::slotKeycodeChanged() ...44 has top be fixed"); 1192 qDebug("KAction::slotKeycodeChanged() ...44 has top be fixed");
1190/*US 1193/*US
1191 kdDebug(129) << "KAction::slotKeycodeChanged()" << endl; // -- ellis 1194 kdDebug(129) << "KAction::slotKeycodeChanged()" << endl; // -- ellis
1192 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name()); 1195 KAccelAction* pAction = d->m_kaccel->actions().actionPtr(name());
1193 if( pAction ) 1196 if( pAction )
1194 setShortcut(pAction->shortcut()); 1197 setShortcut(pAction->shortcut());
1195*/ 1198*/
1196} 1199}
1197 1200
1198KActionCollection *KAction::parentCollection() const 1201KActionCollection *KAction::parentCollection() const
1199{ 1202{
1200 return m_parentCollection; 1203 return m_parentCollection;
1201} 1204}
1202 1205
1203void KAction::unplugAll() 1206void KAction::unplugAll()
1204{ 1207{
1205 while ( containerCount() != 0 ) 1208 while ( containerCount() != 0 )
1206 unplug( container( 0 ) ); 1209 unplug( container( 0 ) );
1207} 1210}
1208 1211
1209void KAction::virtual_hook( int, void* ) 1212void KAction::virtual_hook( int, void* )
1210{ /*BASE::virtual_hook( id, data );*/ } 1213{ /*BASE::virtual_hook( id, data );*/ }
1211 1214
1212/* vim: et sw=2 ts=2 1215/* vim: et sw=2 ts=2
1213 */ 1216 */
1214 1217
1215//US #include "kaction.moc" 1218//US #include "kaction.moc"
diff --git a/microkde/kdeui/kaction.h b/microkde/kdeui/kaction.h
index 13e2e1e..5c690ec 100644
--- a/microkde/kdeui/kaction.h
+++ b/microkde/kdeui/kaction.h
@@ -1,624 +1,626 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org> 3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org> 4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org> 5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org> 6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org> 7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org> 8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 9
10 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public 11 modify it under the terms of the GNU Library General Public
12 License version 2 as published by the Free Software Foundation. 12 License version 2 as published by the Free Software Foundation.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23*/ 23*/
24//$Id$ 24//$Id$
25 25
26#ifndef __kaction_h__ 26#ifndef __kaction_h__
27#define __kaction_h__ 27#define __kaction_h__
28 28
29 29
30//US #include <qkeysequence.h> 30//US #include <qkeysequence.h>
31#include <qobject.h> 31#include <qobject.h>
32#include <qvaluelist.h> 32#include <q3valuelist.h>
33#include <qguardedptr.h> 33#include <qpointer.h>
34//Added by qt3to4:
35#include <Q3PopupMenu>
34#include <kguiitem.h> 36#include <kguiitem.h>
35#include <kshortcut.h> 37#include <kshortcut.h>
36#include <kstdaction.h> 38#include <kstdaction.h>
37//US#include <kicontheme.h> 39//US#include <kicontheme.h>
38 40
39//US added the following files 41//US added the following files
40#include <kiconloader.h> 42#include <kiconloader.h>
41 43
42class QMenuBar; 44class QMenuBar;
43class QPopupMenu; 45class Q3PopupMenu;
44//USclass QComboBox; 46//USclass QComboBox;
45//USclass QPoint; 47//USclass QPoint;
46class QIconSet; 48class QIcon;
47class QString; 49class QString;
48class KToolBar; 50class KToolBar;
49 51
50class KAccel; 52class KAccel;
51//USclass KAccelActions; 53//USclass KAccelActions;
52//USclass KConfig; 54//USclass KConfig;
53//USclass KConfigBase; 55//USclass KConfigBase;
54//USclass KURL; 56//USclass KURL;
55//USclass KInstance; 57//USclass KInstance;
56//USclass KToolBar; 58//USclass KToolBar;
57class KActionCollection; 59class KActionCollection;
58//USclass KPopupMenu; 60//USclass KPopupMenu;
59class KMainWindow; 61class KMainWindow;
60 62
61/** 63/**
62 * The KAction class (and derived and super classes) provides a way to 64 * The KAction class (and derived and super classes) provides a way to
63 * easily encapsulate a "real" user-selected action or event in your 65 * easily encapsulate a "real" user-selected action or event in your
64 * program. 66 * program.
65 * 67 *
66 * For instance, a user may want to @p paste the contents of 68 * For instance, a user may want to @p paste the contents of
67 * the clipboard or @p scroll @p down a document or @p quit the 69 * the clipboard or @p scroll @p down a document or @p quit the
68 * application. These are all @p actions -- events that the 70 * application. These are all @p actions -- events that the
69 * user causes to happen. The KAction class allows the developer to 71 * user causes to happen. The KAction class allows the developer to
70 * deal with these actions in an easy and intuitive manner. 72 * deal with these actions in an easy and intuitive manner.
71 * 73 *
72 * Specifically, the KAction class encapsulated the various attributes 74 * Specifically, the KAction class encapsulated the various attributes
73 * to an event/action. For instance, an action might have an icon 75 * to an event/action. For instance, an action might have an icon
74 * that goes along with it (a clipboard for a "paste" action or 76 * that goes along with it (a clipboard for a "paste" action or
75 * scissors for a "cut" action). The action might have some text to 77 * scissors for a "cut" action). The action might have some text to
76 * describe the action. It will certainly have a method or function 78 * describe the action. It will certainly have a method or function
77 * that actually @p executes the action! All these attributes 79 * that actually @p executes the action! All these attributes
78 * are contained within the KAction object. 80 * are contained within the KAction object.
79 * 81 *
80 * The advantage of dealing with Actions is that you can manipulate 82 * The advantage of dealing with Actions is that you can manipulate
81 * the Action without regard to the GUI representation of it. For 83 * the Action without regard to the GUI representation of it. For
82 * instance, in the "normal" way of dealing with actions like "cut", 84 * instance, in the "normal" way of dealing with actions like "cut",
83 * you would manually insert a item for Cut into a menu and a button 85 * you would manually insert a item for Cut into a menu and a button
84 * into a toolbar. If you want to disable the cut action for a moment 86 * into a toolbar. If you want to disable the cut action for a moment
85 * (maybe nothing is selected), you woud have to hunt down the pointer 87 * (maybe nothing is selected), you woud have to hunt down the pointer
86 * to the menu item and the toolbar button and disable both 88 * to the menu item and the toolbar button and disable both
87 * individually. Setting the menu item and toolbar item up uses very 89 * individually. Setting the menu item and toolbar item up uses very
88 * similar code - but has to be done twice! 90 * similar code - but has to be done twice!
89 * 91 *
90 * With the Action concept, you simply "plug" the Action into whatever 92 * With the Action concept, you simply "plug" the Action into whatever
91 * GUI element you want. The KAction class will then take care of 93 * GUI element you want. The KAction class will then take care of
92 * correctly defining the menu item (with icons, accelerators, text, 94 * correctly defining the menu item (with icons, accelerators, text,
93 * etc) or toolbar button.. or whatever. From then on, if you 95 * etc) or toolbar button.. or whatever. From then on, if you
94 * manipulate the Action at all, the effect will propogate through all 96 * manipulate the Action at all, the effect will propogate through all
95 * GUI representations of it. Back to the "cut" example: if you want 97 * GUI representations of it. Back to the "cut" example: if you want
96 * to disable the Cut Action, you would simply do 98 * to disable the Cut Action, you would simply do
97 * 'cutAction->setEnabled(false)' and the menuitem and button would 99 * 'cutAction->setEnabled(false)' and the menuitem and button would
98 * instantly be disabled! 100 * instantly be disabled!
99 * 101 *
100 * This is the biggest advantage to the Action concept -- there is a 102 * This is the biggest advantage to the Action concept -- there is a
101 * one-to-one relationship between the "real" action and @p all 103 * one-to-one relationship between the "real" action and @p all
102 * GUI representations of it. 104 * GUI representations of it.
103 * 105 *
104 * KAction emits the activated() signal if the user activated the 106 * KAction emits the activated() signal if the user activated the
105 * corresponding GUI element ( menu item, toolbar button, etc. ) 107 * corresponding GUI element ( menu item, toolbar button, etc. )
106 * 108 *
107 * If you are in the situation of wanting to map the activated() 109 * If you are in the situation of wanting to map the activated()
108 * signal of multiple action objects to one slot, with a special 110 * signal of multiple action objects to one slot, with a special
109 * argument bound to each action, then you might consider using 111 * argument bound to each action, then you might consider using
110 * @ref QSignalMapper . A tiny example: 112 * @ref QSignalMapper . A tiny example:
111 * 113 *
112 * <PRE> 114 * <PRE>
113 * QSignalMapper *desktopNumberMapper = new QSignalMapper( this ); 115 * QSignalMapper *desktopNumberMapper = new QSignalMapper( this );
114 * connect( desktopNumberMapper, SIGNAL( mapped( int ) ), 116 * connect( desktopNumberMapper, SIGNAL( mapped( int ) ),
115 * this, SLOT( moveWindowToDesktop( int ) ) ); 117 * this, SLOT( moveWindowToDesktop( int ) ) );
116 * 118 *
117 * for ( uint i = 0; i < numberOfDesktops; ++i ) { 119 * for ( uint i = 0; i < numberOfDesktops; ++i ) {
118 * KAction *desktopAction = new KAction( i18n( "Move Window to Desktop %i" ).arg( i ), ... ); 120 * KAction *desktopAction = new KAction( i18n( "Move Window to Desktop %i" ).arg( i ), ... );
119 * connect( desktopAction, SIGNAL( activated() ), desktopNumberMapper, SLOT( map() ) ); 121 * connect( desktopAction, SIGNAL( activated() ), desktopNumberMapper, SLOT( map() ) );
120 * desktopNumberMapper->setMapping( desktopAction, i ); 122 * desktopNumberMapper->setMapping( desktopAction, i );
121 * } 123 * }
122 * </PRE> 124 * </PRE>
123 * 125 *
124 * @sect General Usage: 126 * @sect General Usage:
125 * 127 *
126 * The steps to using actions are roughly as follows 128 * The steps to using actions are roughly as follows
127 * 129 *
128 * @li Decide which attributes you want to associate with a given 130 * @li Decide which attributes you want to associate with a given
129 * action (icons, text, keyboard shortcut, etc) 131 * action (icons, text, keyboard shortcut, etc)
130 * @li Create the action using KAction (or derived or super class). 132 * @li Create the action using KAction (or derived or super class).
131 * @li "Plug" the Action into whatever GUI element you want. Typically, 133 * @li "Plug" the Action into whatever GUI element you want. Typically,
132 * this will be a menu or toolbar. 134 * this will be a menu or toolbar.
133 * 135 *
134 * @sect Detailed Example: 136 * @sect Detailed Example:
135 * 137 *
136 * Here is an example of enabling a "New [document]" action 138 * Here is an example of enabling a "New [document]" action
137 * <PRE> 139 * <PRE>
138 * KAction *newAct = new KAction(i18n("&New"), "filenew", 140 * KAction *newAct = new KAction(i18n("&New"), "filenew",
139 * KStdAccel::shortcut(KStdAccel::New), 141 * KStdAccel::shortcut(KStdAccel::New),
140 * this, SLOT(fileNew()), 142 * this, SLOT(fileNew()),
141 * actionCollection(), "new"); 143 * actionCollection(), "new");
142 * </PRE> 144 * </PRE>
143 * This line creates our action. It says that wherever this action is 145 * This line creates our action. It says that wherever this action is
144 * displayed, it will use "&New" as the text, the standard icon, and 146 * displayed, it will use "&New" as the text, the standard icon, and
145 * the standard shortcut. It further says that whenever this action 147 * the standard shortcut. It further says that whenever this action
146 * is invoked, it will use the fileNew() slot to execute it. 148 * is invoked, it will use the fileNew() slot to execute it.
147 * 149 *
148 * <PRE> 150 * <PRE>
149 * QPopupMenu *file = new QPopupMenu; 151 * QPopupMenu *file = new QPopupMenu;
150 * newAct->plug(file); 152 * newAct->plug(file);
151 * </PRE> 153 * </PRE>
152 * That just inserted the action into the File menu. The point is, it's not 154 * That just inserted the action into the File menu. The point is, it's not
153 * important in which menu it is: all manipulation of the item is 155 * important in which menu it is: all manipulation of the item is
154 * done through the newAct object. 156 * done through the newAct object.
155 * 157 *
156 * <PRE> 158 * <PRE>
157 * newAct->plug(toolBar()); 159 * newAct->plug(toolBar());
158 * </PRE> 160 * </PRE>
159 * And this inserted the Action into the main toolbar as a button. 161 * And this inserted the Action into the main toolbar as a button.
160 * 162 *
161 * That's it! 163 * That's it!
162 * 164 *
163 * If you want to disable that action sometime later, you can do so 165 * If you want to disable that action sometime later, you can do so
164 * with 166 * with
165 * <PRE> 167 * <PRE>
166 * newAct->setEnabled(false) 168 * newAct->setEnabled(false)
167 * </PRE> 169 * </PRE>
168 * and both the menuitem in File and the toolbar button will instantly 170 * and both the menuitem in File and the toolbar button will instantly
169 * be disabled. 171 * be disabled.
170 * 172 *
171 * Do not delete a KAction object without unplugging it from all its 173 * Do not delete a KAction object without unplugging it from all its
172 * containers. The simplest way to do that is to use the unplugAll() 174 * containers. The simplest way to do that is to use the unplugAll()
173 * as in the following example: 175 * as in the following example:
174 * <PRE> 176 * <PRE>
175 * newAct->unplugAll(); 177 * newAct->unplugAll();
176 * delete newAct; 178 * delete newAct;
177 * </PRE> 179 * </PRE>
178 * Normally you will not need to do this as KActionCollection manages 180 * Normally you will not need to do this as KActionCollection manages
179 * everything for you. 181 * everything for you.
180 * 182 *
181 * Note: if you are using a "standard" action like "new", "paste", 183 * Note: if you are using a "standard" action like "new", "paste",
182 * "quit", or any other action described in the KDE UI Standards, 184 * "quit", or any other action described in the KDE UI Standards,
183 * please use the methods in the @ref KStdAction class rather than 185 * please use the methods in the @ref KStdAction class rather than
184 * defining your own. 186 * defining your own.
185 * 187 *
186 * @sect Usage Within the XML Framework: 188 * @sect Usage Within the XML Framework:
187 * 189 *
188 * If you are using KAction within the context of the XML menu and 190 * If you are using KAction within the context of the XML menu and
189 * toolbar building framework, then there are a few tiny changes. The 191 * toolbar building framework, then there are a few tiny changes. The
190 * first is that you must insert your new action into an action 192 * first is that you must insert your new action into an action
191 * collection. The action collection (a @ref KActionCollection) is, 193 * collection. The action collection (a @ref KActionCollection) is,
192 * logically enough, a central collection of all of the actions 194 * logically enough, a central collection of all of the actions
193 * defined in your application. The XML UI framework code in KXMLGUI 195 * defined in your application. The XML UI framework code in KXMLGUI
194 * classes needs access to this collection in order to build up the 196 * classes needs access to this collection in order to build up the
195 * GUI (it's how the builder code knows which actions are valid and 197 * GUI (it's how the builder code knows which actions are valid and
196 * which aren't). 198 * which aren't).
197 * 199 *
198 * Also, if you use the XML builder framework, then you do not ever 200 * Also, if you use the XML builder framework, then you do not ever
199 * have to plug your actions into containers manually. The framework 201 * have to plug your actions into containers manually. The framework
200 * does that for you. 202 * does that for you.
201 * 203 *
202 * @see KStdAction 204 * @see KStdAction
203 * @short Class to encapsulate user-driven action or event 205 * @short Class to encapsulate user-driven action or event
204 */ 206 */
205class KAction : public QObject 207class KAction : public QObject
206{ 208{
207 friend class KActionCollection; 209 friend class KActionCollection;
208 Q_OBJECT 210 Q_OBJECT
209 Q_PROPERTY( int containerCount READ containerCount ) 211 Q_PROPERTY( int containerCount READ containerCount )
210 Q_PROPERTY( QString plainText READ plainText ) 212 Q_PROPERTY( QString plainText READ plainText )
211 Q_PROPERTY( QString text READ text WRITE setText ) 213 Q_PROPERTY( QString text READ text WRITE setText )
212 Q_PROPERTY( QString shortcut READ shortcutText WRITE setShortcutText ) 214 Q_PROPERTY( QString shortcut READ shortcutText WRITE setShortcutText )
213 Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled ) 215 Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
214 Q_PROPERTY( QString group READ group WRITE setGroup ) 216 Q_PROPERTY( QString group READ group WRITE setGroup )
215 Q_PROPERTY( QString whatsThis READ whatsThis WRITE setWhatsThis ) 217 Q_PROPERTY( QString whatsThis READ whatsThis WRITE setWhatsThis )
216 Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip ) 218 Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip )
217 Q_PROPERTY( QString icon READ icon WRITE setIcon ) 219 Q_PROPERTY( QString icon READ icon WRITE setIcon )
218public: 220public:
219 /** 221 /**
220 * Constructs an action with text, potential keyboard 222 * Constructs an action with text, potential keyboard
221 * shortcut, and a SLOT to call when this action is invoked by 223 * shortcut, and a SLOT to call when this action is invoked by
222 * the user. 224 * the user.
223 * 225 *
224 * If you do not want or have a keyboard shortcut, 226 * If you do not want or have a keyboard shortcut,
225 * set the @p cut param to 0. 227 * set the @p cut param to 0.
226 * 228 *
227 * This is the most common KAction used when you do not have a 229 * This is the most common KAction used when you do not have a
228 * corresponding icon (note that it won't appear in the current version 230 * corresponding icon (note that it won't appear in the current version
229 * of the "Edit ToolBar" dialog, because an action needs an icon to be 231 * of the "Edit ToolBar" dialog, because an action needs an icon to be
230 * plugged in a toolbar...). 232 * plugged in a toolbar...).
231 * 233 *
232 * @param text The text that will be displayed. 234 * @param text The text that will be displayed.
233 * @param cut The corresponding keyboard shortcut. 235 * @param cut The corresponding keyboard shortcut.
234 * @param receiver The SLOT's parent. 236 * @param receiver The SLOT's parent.
235 * @param slot The SLOT to invoke to execute this action. 237 * @param slot The SLOT to invoke to execute this action.
236 * @param parent This action's parent. 238 * @param parent This action's parent.
237 * @param name An internal name for this action. 239 * @param name An internal name for this action.
238 */ 240 */
239 KAction( const QString& text, const KShortcut& cut, 241 KAction( const QString& text, const KShortcut& cut,
240 const QObject* receiver, const char* slot, 242 const QObject* receiver, const char* slot,
241 KActionCollection* parent, const char* name ); 243 KActionCollection* parent, const char* name );
242 /** 244 /**
243 * Constructs an action with text, icon, potential keyboard 245 * Constructs an action with text, icon, potential keyboard
244 * shortcut, and a SLOT to call when this action is invoked by 246 * shortcut, and a SLOT to call when this action is invoked by
245 * the user. 247 * the user.
246 * 248 *
247 * If you do not want or have a keyboard shortcut, set the 249 * If you do not want or have a keyboard shortcut, set the
248 * @p cut param to 0. 250 * @p cut param to 0.
249 * 251 *
250 * This is the other common KAction used. Use it when you 252 * This is the other common KAction used. Use it when you
251 * @p do have a corresponding icon. 253 * @p do have a corresponding icon.
252 * 254 *
253 * @param text The text that will be displayed. 255 * @param text The text that will be displayed.
254 * @param pix The icon to display. 256 * @param pix The icon to display.
255 * @param cut The corresponding keyboard shortcut. 257 * @param cut The corresponding keyboard shortcut.
256 * @param receiver The SLOT's parent. 258 * @param receiver The SLOT's parent.
257 * @param slot The SLOT to invoke to execute this action. 259 * @param slot The SLOT to invoke to execute this action.
258 * @param parent This action's parent. 260 * @param parent This action's parent.
259 * @param name An internal name for this action. 261 * @param name An internal name for this action.
260 */ 262 */
261 263
262 KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 264 KAction( const QString& text, const QIcon& pix, const KShortcut& cut,
263 const QObject* receiver, const char* slot, 265 const QObject* receiver, const char* slot,
264 KActionCollection* parent, const char* name ); 266 KActionCollection* parent, const char* name );
265 267
266 /** 268 /**
267 * Constructs an action with text, icon, potential keyboard 269 * Constructs an action with text, icon, potential keyboard
268 * shortcut, and a SLOT to call when this action is invoked by 270 * shortcut, and a SLOT to call when this action is invoked by
269 * the user. The icon is loaded on demand later based on where it 271 * the user. The icon is loaded on demand later based on where it
270 * is plugged in. 272 * is plugged in.
271 * 273 *
272 * If you do not want or have a keyboard shortcut, set the 274 * If you do not want or have a keyboard shortcut, set the
273 * @p cut param to 0. 275 * @p cut param to 0.
274 * 276 *
275 * This is the other common KAction used. Use it when you 277 * This is the other common KAction used. Use it when you
276 * @p do have a corresponding icon. 278 * @p do have a corresponding icon.
277 * 279 *
278 * @param text The text that will be displayed. 280 * @param text The text that will be displayed.
279 * @param pix The icon to display. 281 * @param pix The icon to display.
280 * @param cut The corresponding keyboard shortcut (shortcut). 282 * @param cut The corresponding keyboard shortcut (shortcut).
281 * @param receiver The SLOT's parent. 283 * @param receiver The SLOT's parent.
282 * @param slot The SLOT to invoke to execute this action. 284 * @param slot The SLOT to invoke to execute this action.
283 * @param parent This action's parent. 285 * @param parent This action's parent.
284 * @param name An internal name for this action. 286 * @param name An internal name for this action.
285 */ 287 */
286 KAction( const QString& text, const QString& pix, const KShortcut& cut, 288 KAction( const QString& text, const QString& pix, const KShortcut& cut,
287 const QObject* receiver, const char* slot, 289 const QObject* receiver, const char* slot,
288 KActionCollection* parent, const char* name ); 290 KActionCollection* parent, const char* name );
289 291
290 /** 292 /**
291 * The same as the above constructor, but with a KGuiItem providing 293 * The same as the above constructor, but with a KGuiItem providing
292 * the text and icon. 294 * the text and icon.
293 * 295 *
294 * @param item The KGuiItem with the label and (optional) icon. 296 * @param item The KGuiItem with the label and (optional) icon.
295 */ 297 */
296 KAction( const KGuiItem& item, const KShortcut& cut, 298 KAction( const KGuiItem& item, const KShortcut& cut,
297 const QObject* receiver, const char* slot, 299 const QObject* receiver, const char* slot,
298 KActionCollection* parent, const char* name ); 300 KActionCollection* parent, const char* name );
299 /** 301 /**
300 * @obsolete 302 * @obsolete
301 */ 303 */
302 KAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 ); 304 KAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
303 /** 305 /**
304 * @obsolete 306 * @obsolete
305 */ 307 */
306 KAction( const QString& text, const KShortcut& cut, 308 KAction( const QString& text, const KShortcut& cut,
307 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 309 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
308 /** 310 /**
309 * @obsolete 311 * @obsolete
310 */ 312 */
311 KAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), 313 KAction( const QString& text, const QIcon& pix, const KShortcut& cut = KShortcut(),
312 QObject* parent = 0, const char* name = 0 ); 314 QObject* parent = 0, const char* name = 0 );
313 /** 315 /**
314 * @obsolete 316 * @obsolete
315 */ 317 */
316 KAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), 318 KAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
317 QObject* parent = 0, const char* name = 0 ); 319 QObject* parent = 0, const char* name = 0 );
318 /** 320 /**
319 * @obsolete 321 * @obsolete
320 */ 322 */
321 KAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 323 KAction( const QString& text, const QIcon& pix, const KShortcut& cut,
322 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 324 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
323 /** 325 /**
324 * @obsolete 326 * @obsolete
325 */ 327 */
326 KAction( const QString& text, const QString& pix, const KShortcut& cut, 328 KAction( const QString& text, const QString& pix, const KShortcut& cut,
327 const QObject* receiver, const char* slot, QObject* parent, 329 const QObject* receiver, const char* slot, QObject* parent,
328 const char* name = 0 ); 330 const char* name = 0 );
329 /** 331 /**
330 * @obsolete 332 * @obsolete
331 */ 333 */
332 KAction( QObject* parent = 0, const char* name = 0 ); 334 KAction( QObject* parent = 0, const char* name = 0 );
333 335
334 /** 336 /**
335 * Standard destructor 337 * Standard destructor
336 */ 338 */
337 virtual ~KAction(); 339 virtual ~KAction();
338 340
339 /** 341 /**
340 * "Plug" or insert this action into a given widget. 342 * "Plug" or insert this action into a given widget.
341 * 343 *
342 * This will 344 * This will
343 * typically be a menu or a toolbar. From this point on, you will 345 * typically be a menu or a toolbar. From this point on, you will
344 * never need to directly manipulate the item in the menu or 346 * never need to directly manipulate the item in the menu or
345 * toolbar. You do all enabling/disabling/manipulation directly 347 * toolbar. You do all enabling/disabling/manipulation directly
346 * with your KAction object. 348 * with your KAction object.
347 * 349 *
348 * @param w The GUI element to display this action 350 * @param w The GUI element to display this action
349 */ 351 */
350 virtual int plug( QWidget *w, int index = -1 ); 352 virtual int plug( QWidget *w, int index = -1 );
351 353
352 /** 354 /**
353 * @deprecated. Shouldn't be used. No substitute available. 355 * @deprecated. Shouldn't be used. No substitute available.
354 * 356 *
355 * "Plug" or insert this action into a given KAccel. 357 * "Plug" or insert this action into a given KAccel.
356 * 358 *
357 * @param accel The KAccel collection which holds this accel 359 * @param accel The KAccel collection which holds this accel
358 * @param configurable If the shortcut is configurable via 360 * @param configurable If the shortcut is configurable via
359 * the KAccel configuration dialog (this is somehow deprecated since 361 * the KAccel configuration dialog (this is somehow deprecated since
360 * there is now a KAction key configuration dialog). 362 * there is now a KAction key configuration dialog).
361 */ 363 */
362 virtual void plugAccel(KAccel *accel, bool configurable = true); 364 virtual void plugAccel(KAccel *accel, bool configurable = true);
363 365
364 /** 366 /**
365 * "Unplug" or remove this action from a given widget. 367 * "Unplug" or remove this action from a given widget.
366 * 368 *
367 * This will typically be a menu or a toolbar. This is rarely 369 * This will typically be a menu or a toolbar. This is rarely
368 * used in "normal" application. Typically, it would be used if 370 * used in "normal" application. Typically, it would be used if
369 * your application has several views or modes, each with a 371 * your application has several views or modes, each with a
370 * completely different menu structure. If you simply want to 372 * completely different menu structure. If you simply want to
371 * disable an action for a given period, use @ref setEnabled() 373 * disable an action for a given period, use @ref setEnabled()
372 * instead. 374 * instead.
373 * 375 *
374 * @param w Remove the action from this GUI element. 376 * @param w Remove the action from this GUI element.
375 */ 377 */
376 virtual void unplug( QWidget *w ); 378 virtual void unplug( QWidget *w );
377 379
378 /** 380 /**
379 * @deprecated. Complement method to plugAccel(). 381 * @deprecated. Complement method to plugAccel().
380 * Disconnect this action from the KAccel. 382 * Disconnect this action from the KAccel.
381 */ 383 */
382 virtual void unplugAccel(); 384 virtual void unplugAccel();
383 385
384 /** 386 /**
385 * returns whether the action is plugged into any container widget or not. 387 * returns whether the action is plugged into any container widget or not.
386 * @since 3.1 388 * @since 3.1
387 */ 389 */
388 virtual bool isPlugged() const; 390 virtual bool isPlugged() const;
389 391
390 /** 392 /**
391 * returns whether the action is plugged into the given container 393 * returns whether the action is plugged into the given container
392 */ 394 */
393 bool isPlugged( const QWidget *container ) const; 395 bool isPlugged( const QWidget *container ) const;
394 396
395 /** 397 /**
396 * returns whether the action is plugged into the given container with the given, container specific, id (often 398 * returns whether the action is plugged into the given container with the given, container specific, id (often
397 * menu or toolbar id ) . 399 * menu or toolbar id ) .
398 */ 400 */
399 virtual bool isPlugged( const QWidget *container, int id ) const; 401 virtual bool isPlugged( const QWidget *container, int id ) const;
400 402
401 /** 403 /**
402 * returns whether the action is plugged into the given container with the given, container specific, representative 404 * returns whether the action is plugged into the given container with the given, container specific, representative
403 * container widget item. 405 * container widget item.
404 */ 406 */
405 virtual bool isPlugged( const QWidget *container, const QWidget *_representative ) const; 407 virtual bool isPlugged( const QWidget *container, const QWidget *_representative ) const;
406 408
407 QWidget* container( int index ) const; 409 QWidget* container( int index ) const;
408 int itemId( int index ) const; 410 int itemId( int index ) const;
409 QWidget* representative( int index ) const; 411 QWidget* representative( int index ) const;
410 int containerCount() const; 412 int containerCount() const;
411 /// @since 3.1 413 /// @since 3.1
412 uint kaccelCount() const; 414 uint kaccelCount() const;
413 415
414 virtual bool hasIcon() const; 416 virtual bool hasIcon() const;
415#ifndef KDE_NO_COMPAT 417#ifndef KDE_NO_COMPAT
416 bool hasIconSet() const { return hasIcon(); } 418 bool hasIconSet() const { return hasIcon(); }
417#endif 419#endif
418 virtual QString plainText() const; 420 virtual QString plainText() const;
419 421
420 /** 422 /**
421 * Get the text associated with this action. 423 * Get the text associated with this action.
422 */ 424 */
423 virtual QString text() const; 425 virtual QString text() const;
424 426
425 /** 427 /**
426 * Get the keyboard shortcut associated with this action. 428 * Get the keyboard shortcut associated with this action.
427 */ 429 */
428 virtual const KShortcut& shortcut() const; 430 virtual const KShortcut& shortcut() const;
429 /** 431 /**
430 * Get the default shortcut for this action. 432 * Get the default shortcut for this action.
431 */ 433 */
432 virtual const KShortcut& shortcutDefault() const; 434 virtual const KShortcut& shortcutDefault() const;
433 435
434 // These two methods are for Q_PROPERTY 436 // These two methods are for Q_PROPERTY
435 QString shortcutText() const; 437 QString shortcutText() const;
436 void setShortcutText( const QString& ); 438 void setShortcutText( const QString& );
437 439
438 /** 440 /**
439 * Returns true if this action is enabled. 441 * Returns true if this action is enabled.
440 */ 442 */
441 virtual bool isEnabled() const; 443 virtual bool isEnabled() const;
442 444
443 /** 445 /**
444 * Returns true if this action's shortcut is configurable. 446 * Returns true if this action's shortcut is configurable.
445 */ 447 */
446 virtual bool isShortcutConfigurable() const; 448 virtual bool isShortcutConfigurable() const;
447 449
448 virtual QString group() const; 450 virtual QString group() const;
449 451
450 /** 452 /**
451 * Get the What's this text for the action. 453 * Get the What's this text for the action.
452 */ 454 */
453 virtual QString whatsThis() const; 455 virtual QString whatsThis() const;
454 456
455 /** 457 /**
456 * Get the tooltip text for the action. 458 * Get the tooltip text for the action.
457 */ 459 */
458 virtual QString toolTip() const; 460 virtual QString toolTip() const;
459 461
460 /** 462 /**
461 * Get the QIconSet from which the icons used to display this action will 463 * Get the QIconSet from which the icons used to display this action will
462 * be chosen. 464 * be chosen.
463 */ 465 */
464 virtual QIconSet iconSet( KIcon::Group group, int size=0 ) const; 466 virtual QIcon iconSet( KIcon::Group group, int size=0 ) const;
465 467
466#ifndef KDE_NO_COMPAT 468#ifndef KDE_NO_COMPAT
467 QIconSet iconSet() const 469 QIcon iconSet() const
468 { 470 {
469 return iconSet( KIcon::Small ); 471 return iconSet( KIcon::Small );
470 } 472 }
471#endif 473#endif
472 474
473 virtual QString icon() const; 475 virtual QString icon() const;
474 476
475 KActionCollection *parentCollection() const; 477 KActionCollection *parentCollection() const;
476 478
477 /** 479 /**
478 * @internal 480 * @internal
479 * Generate a toolbar button id. Made public for reimplementations. 481 * Generate a toolbar button id. Made public for reimplementations.
480 */ 482 */
481 static int getToolButtonID(); 483 static int getToolButtonID();
482 484
483 485
484 void unplugAll(); 486 void unplugAll();
485 487
486public slots: 488public slots:
487 /** 489 /**
488 * Sets the text associated with this action. The text is used for menu 490 * Sets the text associated with this action. The text is used for menu
489 * and toolbar labels etc. 491 * and toolbar labels etc.
490 */ 492 */
491 virtual void setText(const QString &text); 493 virtual void setText(const QString &text);
492 494
493 /** 495 /**
494 * Sets the keyboard shortcut associated with this action. 496 * Sets the keyboard shortcut associated with this action.
495 */ 497 */
496 virtual bool setShortcut( const KShortcut& ); 498 virtual bool setShortcut( const KShortcut& );
497 499
498 virtual void setGroup( const QString& ); 500 virtual void setGroup( const QString& );
499 501
500 /** 502 /**
501 * Sets the What's this text for the action. This text will be displayed when 503 * Sets the What's this text for the action. This text will be displayed when
502 * a widget that has been created by plugging this action into a container 504 * a widget that has been created by plugging this action into a container
503 * is clicked on in What's this mode. 505 * is clicked on in What's this mode.
504 * 506 *
505 * The What's this text can include QML markup as well as raw text. 507 * The What's this text can include QML markup as well as raw text.
506 */ 508 */
507 virtual void setWhatsThis( const QString& text ); 509 virtual void setWhatsThis( const QString& text );
508 510
509 /** 511 /**
510 * Sets the tooltip text for the action. 512 * Sets the tooltip text for the action.
511 * This will be used as a tooltip for a toolbar button, as a 513 * This will be used as a tooltip for a toolbar button, as a
512 * statusbar help-text for a menu item, and it also appears 514 * statusbar help-text for a menu item, and it also appears
513 * in the toolbar editor, to describe the action. 515 * in the toolbar editor, to describe the action.
514 */ 516 */
515 virtual void setToolTip( const QString& ); 517 virtual void setToolTip( const QString& );
516 518
517 /** 519 /**
518 * Sets the QIconSet from which the icons used to display this action will 520 * Sets the QIconSet from which the icons used to display this action will
519 * be chosen. 521 * be chosen.
520 */ 522 */
521 virtual void setIconSet( const QIconSet &iconSet ); 523 virtual void setIconSet( const QIcon &iconSet );
522 524
523 virtual void setIcon( const QString& icon ); 525 virtual void setIcon( const QString& icon );
524 526
525 /** 527 /**
526 * Enables or disables this action. All uses of this action (eg. in menus 528 * Enables or disables this action. All uses of this action (eg. in menus
527 * or toolbars) will be updated to reflect the state of the action. 529 * or toolbars) will be updated to reflect the state of the action.
528 */ 530 */
529 virtual void setEnabled(bool enable); 531 virtual void setEnabled(bool enable);
530 532
531 /** 533 /**
532 * Indicate whether the user may configure the action's shortcut. 534 * Indicate whether the user may configure the action's shortcut.
533 */ 535 */
534 virtual void setShortcutConfigurable( bool ); 536 virtual void setShortcutConfigurable( bool );
535 537
536 /** 538 /**
537 * Emulate user's interaction programmatically, by activating the action. 539 * Emulate user's interaction programmatically, by activating the action.
538 * The implementation simply emits activated(). 540 * The implementation simply emits activated().
539 */ 541 */
540 virtual void activate(); 542 virtual void activate();
541 543
542protected slots: 544protected slots:
543 virtual void slotDestroyed(); 545 virtual void slotDestroyed();
544 virtual void slotKeycodeChanged(); 546 virtual void slotKeycodeChanged();
545 virtual void slotActivated(); 547 virtual void slotActivated();
546 548
547protected: 549protected:
548 KToolBar* toolBar( int index ) const; 550 KToolBar* toolBar( int index ) const;
549 QPopupMenu* popupMenu( int index ) const; 551 Q3PopupMenu* popupMenu( int index ) const;
550 void removeContainer( int index ); 552 void removeContainer( int index );
551 int findContainer( const QWidget* widget ) const; 553 int findContainer( const QWidget* widget ) const;
552 void plugMainWindowAccel( QWidget *w ); 554 void plugMainWindowAccel( QWidget *w );
553 555
554 void addContainer( QWidget* parent, int id ); 556 void addContainer( QWidget* parent, int id );
555 void addContainer( QWidget* parent, QWidget* representative ); 557 void addContainer( QWidget* parent, QWidget* representative );
556 558
557 virtual void updateShortcut( int i ); 559 virtual void updateShortcut( int i );
558 virtual void updateShortcut( QPopupMenu* menu, int id ); 560 virtual void updateShortcut( Q3PopupMenu* menu, int id );
559 virtual void updateGroup( int id ); 561 virtual void updateGroup( int id );
560 virtual void updateText(int i ); 562 virtual void updateText(int i );
561 virtual void updateEnabled(int i); 563 virtual void updateEnabled(int i);
562 virtual void updateIconSet(int i); 564 virtual void updateIconSet(int i);
563 virtual void updateIcon( int i); 565 virtual void updateIcon( int i);
564 virtual void updateToolTip( int id ); 566 virtual void updateToolTip( int id );
565 virtual void updateWhatsThis( int i ); 567 virtual void updateWhatsThis( int i );
566 568
567 KActionCollection *m_parentCollection; 569 KActionCollection *m_parentCollection;
568 QString whatsThisWithIcon() const; 570 QString whatsThisWithIcon() const;
569 571
570signals: 572signals:
571 void activated(); 573 void activated();
572 void enabled( bool ); 574 void enabled( bool );
573 575
574private: 576private:
575 void initPrivate( const QString& text, const KShortcut& cut, 577 void initPrivate( const QString& text, const KShortcut& cut,
576 const QObject* receiver, const char* slot ); 578 const QObject* receiver, const char* slot );
577 KAccel* kaccelCurrent(); 579 KAccel* kaccelCurrent();
578 bool initShortcut( const KShortcut& ); 580 bool initShortcut( const KShortcut& );
579 void plugShortcut(); 581 void plugShortcut();
580 bool updateKAccelShortcut( KAccel* kaccel ); 582 bool updateKAccelShortcut( KAccel* kaccel );
581 void insertKAccel( KAccel* ); 583 void insertKAccel( KAccel* );
582 /** @internal To be used exclusively by KActionCollection::removeWidget(). */ 584 /** @internal To be used exclusively by KActionCollection::removeWidget(). */
583 void removeKAccel( KAccel* ); 585 void removeKAccel( KAccel* );
584 586
585#ifndef KDE_NO_COMPAT 587#ifndef KDE_NO_COMPAT
586public: 588public:
587 /** 589 /**
588 * @deprecated. Use shortcut(). 590 * @deprecated. Use shortcut().
589 * Get the keyboard accelerator associated with this action. 591 * Get the keyboard accelerator associated with this action.
590 */ 592 */
591 int accel() const; 593 int accel() const;
592 594
593 QString statusText() const 595 QString statusText() const
594 { return toolTip(); } 596 { return toolTip(); }
595 597
596 /** 598 /**
597 * @deprecated. Use setShortcut(). 599 * @deprecated. Use setShortcut().
598 * Sets the keyboard accelerator associated with this action. 600 * Sets the keyboard accelerator associated with this action.
599 */ 601 */
600 void setAccel( int key ); 602 void setAccel( int key );
601 603
602 /** 604 /**
603 * @deprecated. Use setToolTip instead (they do the same thing now). 605 * @deprecated. Use setToolTip instead (they do the same thing now).
604 */ 606 */
605 void setStatusText( const QString &text ) 607 void setStatusText( const QString &text )
606 { setToolTip( text ); } 608 { setToolTip( text ); }
607 609
608 /** 610 /**
609 * @deprecated. for backwards compatibility. 611 * @deprecated. for backwards compatibility.
610 */ 612 */
611 int menuId( int i ) { return itemId( i ); } 613 int menuId( int i ) { return itemId( i ); }
612#endif // !KDE_NO_COMPAT 614#endif // !KDE_NO_COMPAT
613 615
614protected: 616protected:
615 virtual void virtual_hook( int id, void* data ); 617 virtual void virtual_hook( int id, void* data );
616private: 618private:
617 class KActionPrivate; 619 class KActionPrivate;
618 KActionPrivate *d; 620 KActionPrivate *d;
619}; 621};
620 622
621#include <kactioncollection.h> 623#include <kactioncollection.h>
622#include <kactionclasses.h> 624#include <kactionclasses.h>
623 625
624#endif 626#endif
diff --git a/microkde/kdeui/kactionclasses.cpp b/microkde/kdeui/kactionclasses.cpp
index 82e6c8b..c611865 100644
--- a/microkde/kdeui/kactionclasses.cpp
+++ b/microkde/kdeui/kactionclasses.cpp
@@ -1,2058 +1,2059 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org> 3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org> 4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org> 5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org> 6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org> 7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org> 8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 (C) 2002 Joseph Wenninger <jowenn@kde.org> 9 (C) 2002 Joseph Wenninger <jowenn@kde.org>
10 10
11 This library is free software; you can redistribute it and/or 11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public 12 modify it under the terms of the GNU Library General Public
13 License version 2 as published by the Free Software Foundation. 13 License version 2 as published by the Free Software Foundation.
14 14
15 This library is distributed in the hope that it will be useful, 15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details. 18 Library General Public License for more details.
19 19
20 You should have received a copy of the GNU Library General Public License 20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to 21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. 23 Boston, MA 02111-1307, USA.
24*/ 24*/
25 25
26#include "kactionclasses.h" 26#include "kactionclasses.h"
27 27
28#include <assert.h> 28#include <assert.h>
29 29
30#include <qfontdatabase.h> 30#include <qfontdatabase.h>
31#include <qobjectlist.h> 31#include <qobject.h>
32//US#include <qwhatsthis.h> 32//US#include <qwhatsthis.h>
33#include <qtimer.h> 33#include <qtimer.h>
34//Added by qt3to4:
35#include <Q3ValueList>
34 36
35//US#include <kaccel.h> 37//US#include <kaccel.h>
36//US#include <kapplication.h> 38//US#include <kapplication.h>
37#include <kconfig.h> 39#include <kconfig.h>
38#include <kdebug.h> 40#include <kdebug.h>
39//US#include <kfontcombo.h> 41//US#include <kfontcombo.h>
40//US#include <kmainwindow.h> 42//US#include <kmainwindow.h>
41//US#include <kmenubar.h> 43//US#include <kmenubar.h>
42//US#include <kpopupmenu.h> 44//US#include <kpopupmenu.h>
43#include <kcombobox.h> 45#include <kcombobox.h>
44#include <ktoolbar.h> 46#include <ktoolbar.h>
45#include <ktoolbarbutton.h> 47#include <ktoolbarbutton.h>
46#include <kurl.h> 48#include <kurl.h>
47 49
48//US added the following includefiles 50//US added the following includefiles
49#include <kconfigbase.h> 51#include <kconfigbase.h>
50#include <qwidget.h> 52#include <qwidget.h>
51#include <qpopupmenu.h> 53#include <q3popupmenu.h>
52#include <qmenubar.h> 54#include <qmenubar.h>
53#include <qmainwindow.h> 55#include <q3mainwindow.h>
54#include <qtoolbar.h> 56#include <q3toolbar.h>
55#include <qcombobox.h> 57#include <qcombobox.h>
56#include <qmainwindow.h> 58#include <q3mainwindow.h>
57 59#include <qcoreapplication.h>
58 60
59static QFontDatabase *fontDataBase = 0; 61static QFontDatabase *fontDataBase = 0;
60 62
61static void cleanupFontDatabase() 63static void cleanupFontDatabase()
62{ 64{
63 delete fontDataBase; 65 delete fontDataBase;
64 fontDataBase = 0; 66 fontDataBase = 0;
65} 67}
66 68
67static void get_fonts( QStringList &lst ) 69static void get_fonts( QStringList &lst )
68{ 70{
69 if ( !fontDataBase ) { 71 if ( !fontDataBase ) {
70 fontDataBase = new QFontDatabase(); 72 fontDataBase = new QFontDatabase();
71 qAddPostRoutine( cleanupFontDatabase ); 73 qAddPostRoutine( cleanupFontDatabase );
72 } 74 }
73 lst.clear(); 75 lst.clear();
74 QStringList families = fontDataBase->families(); 76 QStringList families = fontDataBase->families();
75 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) 77 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
76 { 78 {
77 QString family = *it; 79 QString family = *it;
78 if ( family. contains('-') ) // remove foundry 80 if ( family. contains('-') ) // remove foundry
79 family = family.right( family.length() - family.find('-' ) - 1); 81 family = family.right( family.length() - family.find('-' ) - 1);
80 if ( !lst.contains( family ) ) 82 if ( !lst.contains( family ) )
81 lst.append( family ); 83 lst.append( family );
82 } 84 }
83 lst.sort(); 85 lst.sort();
84} 86}
85 87
86static QValueList<int> get_standard_font_sizes() 88static Q3ValueList<int> get_standard_font_sizes()
87{ 89{
88 if ( !fontDataBase ) { 90 if ( !fontDataBase ) {
89 fontDataBase = new QFontDatabase(); 91 fontDataBase = new QFontDatabase();
90 qAddPostRoutine( cleanupFontDatabase ); 92 qAddPostRoutine( cleanupFontDatabase );
91 } 93 }
92 return fontDataBase->standardSizes(); 94 return fontDataBase->standardSizes();
93} 95}
94 96
95class KToggleAction::KToggleActionPrivate 97class KToggleAction::KToggleActionPrivate
96{ 98{
97public: 99public:
98 KToggleActionPrivate() 100 KToggleActionPrivate()
99 { 101 {
100 m_checked = false; 102 m_checked = false;
101 } 103 }
102 104
103 bool m_checked; 105 bool m_checked;
104 QString m_exclusiveGroup; 106 QString m_exclusiveGroup;
105}; 107};
106 108
107KToggleAction::KToggleAction( const QString& text, const KShortcut& cut, 109KToggleAction::KToggleAction( const QString& text, const KShortcut& cut,
108 QObject* parent, 110 QObject* parent,
109 const char* name ) 111 const char* name )
110 : KAction( text, cut, parent, name ) 112 : KAction( text, cut, parent, name )
111{ 113{
112 d = new KToggleActionPrivate; 114 d = new KToggleActionPrivate;
113} 115}
114 116
115KToggleAction::KToggleAction( const QString& text, const KShortcut& cut, 117KToggleAction::KToggleAction( const QString& text, const KShortcut& cut,
116 const QObject* receiver, const char* slot, 118 const QObject* receiver, const char* slot,
117 QObject* parent, const char* name ) 119 QObject* parent, const char* name )
118 : KAction( text, cut, receiver, slot, parent, name ) 120 : KAction( text, cut, receiver, slot, parent, name )
119{ 121{
120 d = new KToggleActionPrivate; 122 d = new KToggleActionPrivate;
121} 123}
122 124
123KToggleAction::KToggleAction( const QString& text, const QIconSet& pix, 125KToggleAction::KToggleAction( const QString& text, const QIcon& pix,
124 const KShortcut& cut, 126 const KShortcut& cut,
125 QObject* parent, const char* name ) 127 QObject* parent, const char* name )
126 : KAction( text, pix, cut, parent, name ) 128 : KAction( text, pix, cut, parent, name )
127{ 129{
128 d = new KToggleActionPrivate; 130 d = new KToggleActionPrivate;
129} 131}
130 132
131KToggleAction::KToggleAction( const QString& text, const QString& pix, 133KToggleAction::KToggleAction( const QString& text, const QString& pix,
132 const KShortcut& cut, 134 const KShortcut& cut,
133 QObject* parent, const char* name ) 135 QObject* parent, const char* name )
134 : KAction( text, pix, cut, parent, name ) 136 : KAction( text, pix, cut, parent, name )
135{ 137{
136 d = new KToggleActionPrivate; 138 d = new KToggleActionPrivate;
137} 139}
138 140
139KToggleAction::KToggleAction( const QString& text, const QIconSet& pix, 141KToggleAction::KToggleAction( const QString& text, const QIcon& pix,
140 const KShortcut& cut, 142 const KShortcut& cut,
141 const QObject* receiver, 143 const QObject* receiver,
142 const char* slot, QObject* parent, 144 const char* slot, QObject* parent,
143 const char* name ) 145 const char* name )
144 : KAction( text, pix, cut, receiver, slot, parent, name ) 146 : KAction( text, pix, cut, receiver, slot, parent, name )
145{ 147{
146 d = new KToggleActionPrivate; 148 d = new KToggleActionPrivate;
147} 149}
148 150
149KToggleAction::KToggleAction( const QString& text, const QString& pix, 151KToggleAction::KToggleAction( const QString& text, const QString& pix,
150 const KShortcut& cut, 152 const KShortcut& cut,
151 const QObject* receiver, 153 const QObject* receiver,
152 const char* slot, QObject* parent, 154 const char* slot, QObject* parent,
153 const char* name ) 155 const char* name )
154 : KAction( text, pix, cut, receiver, slot, parent, name ) 156 : KAction( text, pix, cut, receiver, slot, parent, name )
155{ 157{
156 d = new KToggleActionPrivate; 158 d = new KToggleActionPrivate;
157} 159}
158 160
159KToggleAction::KToggleAction( QObject* parent, const char* name ) 161KToggleAction::KToggleAction( QObject* parent, const char* name )
160 : KAction( parent, name ) 162 : KAction( parent, name )
161{ 163{
162 d = new KToggleActionPrivate; 164 d = new KToggleActionPrivate;
163} 165}
164 166
165KToggleAction::~KToggleAction() 167KToggleAction::~KToggleAction()
166{ 168{
167 delete d; 169 delete d;
168} 170}
169 171
170int KToggleAction::plug( QWidget* widget, int index ) 172int KToggleAction::plug( QWidget* widget, int index )
171{ 173{
172 if ( !widget->inherits("QPopupMenu") && !widget->inherits("KToolBar") ) 174 if ( !widget->inherits("Q3PopupMenu") && !widget->inherits("KToolBar") )
173 { 175 {
174 kdWarning() << "Can not plug KToggleAction in " << widget->className() << endl; 176 kdWarning() << "Can not plug KToggleAction in " << widget->className() << endl;
175 return -1; 177 return -1;
176 } 178 }
177 179
178/*US 180/*US
179 if (kapp && !kapp->authorizeKAction(name())) 181 if (kapp && !kapp->authorizeKAction(name()))
180 return -1; 182 return -1;
181*/ 183*/
182 184
183 int _index = KAction::plug( widget, index ); 185 int _index = KAction::plug( widget, index );
184 if ( _index == -1 ) 186 if ( _index == -1 )
185 return _index; 187 return _index;
186 188
187 if ( widget->inherits("QPopupMenu") ) 189 if ( widget->inherits("Q3PopupMenu") )
188 { 190 {
189 int id = itemId( _index ); 191 int id = itemId( _index );
190 192
191 static_cast<QPopupMenu*>(widget)->setItemChecked( id, d->m_checked ); 193 static_cast<Q3PopupMenu*>(widget)->setItemChecked( id, d->m_checked );
192 } else if ( widget->inherits( "KToolBar" ) ) { 194 } else if ( widget->inherits( "KToolBar" ) ) {
193 195
194 KToolBar *bar = static_cast<KToolBar *>( widget ); 196 KToolBar *bar = static_cast<KToolBar *>( widget );
195 197
196 bar->setToggle( itemId( _index ), true ); 198 bar->setToggle( itemId( _index ), true );
197 bar->setButton( itemId( _index ), isChecked() ); 199 bar->setButton( itemId( _index ), isChecked() );
198 } 200 }
199 201
200 return _index; 202 return _index;
201} 203}
202 204
203void KToggleAction::setChecked( bool c ) 205void KToggleAction::setChecked( bool c )
204{ 206{
205 if ( c == d->m_checked ) 207 if ( c == d->m_checked )
206 return; 208 return;
207 //kdDebug(129) << "KToggleAction::setChecked(" << c << ") " << this << " " << name() << endl; 209 //kdDebug(129) << "KToggleAction::setChecked(" << c << ") " << this << " " << name() << endl;
208 210
209 d->m_checked = c; 211 d->m_checked = c;
210 212
211 int len = containerCount(); 213 int len = containerCount();
212 214
213 for( int i = 0; i < len; ++i ) 215 for( int i = 0; i < len; ++i )
214 updateChecked( i ); 216 updateChecked( i );
215 217
216 if ( c && parent() && !exclusiveGroup().isEmpty() ) { 218 if ( c && parent() && !exclusiveGroup().isEmpty() ) {
217 const QObjectList *list = parent()->children(); 219 const QObjectList list = parent()->children();
218 if ( list ) { 220 if ( !list.empty() ) {
219 QObjectListIt it( *list ); 221 for(QObjectList::const_iterator it=list.begin();it!=list.end();++it) {
220 for( ; it.current(); ++it ) { 222 if ( (*it)->inherits( "KToggleAction" ) && (*it) != this &&
221 if ( it.current()->inherits( "KToggleAction" ) && it.current() != this && 223 static_cast<KToggleAction*>((*it))->exclusiveGroup() == exclusiveGroup() ) {
222 static_cast<KToggleAction*>(it.current())->exclusiveGroup() == exclusiveGroup() ) { 224 KToggleAction *a = static_cast<KToggleAction*>(*it);
223 KToggleAction *a = static_cast<KToggleAction*>(it.current());
224 if( a->isChecked() ) { 225 if( a->isChecked() ) {
225 a->setChecked( false ); 226 a->setChecked( false );
226 emit a->toggled( false ); 227 emit a->toggled( false );
227 } 228 }
228 } 229 }
229 } 230 }
230 } 231 }
231 } 232 }
232} 233}
233 234
234void KToggleAction::updateChecked( int id ) 235void KToggleAction::updateChecked( int id )
235{ 236{
236 QWidget *w = container( id ); 237 QWidget *w = container( id );
237 238
238 if ( w->inherits( "QPopupMenu" ) ) 239 if ( w->inherits( "Q3PopupMenu" ) )
239 static_cast<QPopupMenu*>(w)->setItemChecked( itemId( id ), d->m_checked ); 240 static_cast<Q3PopupMenu*>(w)->setItemChecked( itemId( id ), d->m_checked );
240 else if ( w->inherits( "QMenuBar" ) ) 241 else if ( w->inherits( "QMenuBar" ) )
241 static_cast<QMenuBar*>(w)->setItemChecked( itemId( id ), d->m_checked ); 242 static_cast<QMenuBar*>(w)->setItemChecked( itemId( id ), d->m_checked );
242 else if ( w->inherits( "KToolBar" ) ) 243 else if ( w->inherits( "KToolBar" ) )
243 { 244 {
244 QWidget* r = static_cast<KToolBar*>( w )->getButton( itemId( id ) ); 245 QWidget* r = static_cast<KToolBar*>( w )->getButton( itemId( id ) );
245 if ( r && r->inherits( "KToolBarButton" ) ) 246 if ( r && r->inherits( "KToolBarButton" ) )
246 static_cast<KToolBar*>( w )->setButton( itemId( id ), d->m_checked ); 247 static_cast<KToolBar*>( w )->setButton( itemId( id ), d->m_checked );
247 } 248 }
248} 249}
249 250
250void KToggleAction::slotActivated() 251void KToggleAction::slotActivated()
251{ 252{
252 setChecked( !isChecked() ); 253 setChecked( !isChecked() );
253 emit activated(); 254 emit activated();
254 emit toggled( isChecked() ); 255 emit toggled( isChecked() );
255} 256}
256 257
257bool KToggleAction::isChecked() const 258bool KToggleAction::isChecked() const
258{ 259{
259 return d->m_checked; 260 return d->m_checked;
260} 261}
261 262
262void KToggleAction::setExclusiveGroup( const QString& name ) 263void KToggleAction::setExclusiveGroup( const QString& name )
263{ 264{
264 d->m_exclusiveGroup = name; 265 d->m_exclusiveGroup = name;
265} 266}
266 267
267QString KToggleAction::exclusiveGroup() const 268QString KToggleAction::exclusiveGroup() const
268{ 269{
269 return d->m_exclusiveGroup; 270 return d->m_exclusiveGroup;
270} 271}
271 272
272 273
273KRadioAction::KRadioAction( const QString& text, const KShortcut& cut, 274KRadioAction::KRadioAction( const QString& text, const KShortcut& cut,
274 QObject* parent, const char* name ) 275 QObject* parent, const char* name )
275: KToggleAction( text, cut, parent, name ) 276: KToggleAction( text, cut, parent, name )
276{ 277{
277} 278}
278 279
279KRadioAction::KRadioAction( const QString& text, const KShortcut& cut, 280KRadioAction::KRadioAction( const QString& text, const KShortcut& cut,
280 const QObject* receiver, const char* slot, 281 const QObject* receiver, const char* slot,
281 QObject* parent, const char* name ) 282 QObject* parent, const char* name )
282: KToggleAction( text, cut, receiver, slot, parent, name ) 283: KToggleAction( text, cut, receiver, slot, parent, name )
283{ 284{
284} 285}
285 286
286KRadioAction::KRadioAction( const QString& text, const QIconSet& pix, 287KRadioAction::KRadioAction( const QString& text, const QIcon& pix,
287 const KShortcut& cut, 288 const KShortcut& cut,
288 QObject* parent, const char* name ) 289 QObject* parent, const char* name )
289: KToggleAction( text, pix, cut, parent, name ) 290: KToggleAction( text, pix, cut, parent, name )
290{ 291{
291} 292}
292 293
293KRadioAction::KRadioAction( const QString& text, const QString& pix, 294KRadioAction::KRadioAction( const QString& text, const QString& pix,
294 const KShortcut& cut, 295 const KShortcut& cut,
295 QObject* parent, const char* name ) 296 QObject* parent, const char* name )
296: KToggleAction( text, pix, cut, parent, name ) 297: KToggleAction( text, pix, cut, parent, name )
297{ 298{
298} 299}
299 300
300KRadioAction::KRadioAction( const QString& text, const QIconSet& pix, 301KRadioAction::KRadioAction( const QString& text, const QIcon& pix,
301 const KShortcut& cut, 302 const KShortcut& cut,
302 const QObject* receiver, const char* slot, 303 const QObject* receiver, const char* slot,
303 QObject* parent, const char* name ) 304 QObject* parent, const char* name )
304: KToggleAction( text, pix, cut, receiver, slot, parent, name ) 305: KToggleAction( text, pix, cut, receiver, slot, parent, name )
305{ 306{
306} 307}
307 308
308KRadioAction::KRadioAction( const QString& text, const QString& pix, 309KRadioAction::KRadioAction( const QString& text, const QString& pix,
309 const KShortcut& cut, 310 const KShortcut& cut,
310 const QObject* receiver, const char* slot, 311 const QObject* receiver, const char* slot,
311 QObject* parent, const char* name ) 312 QObject* parent, const char* name )
312: KToggleAction( text, pix, cut, receiver, slot, parent, name ) 313: KToggleAction( text, pix, cut, receiver, slot, parent, name )
313{ 314{
314} 315}
315 316
316KRadioAction::KRadioAction( QObject* parent, const char* name ) 317KRadioAction::KRadioAction( QObject* parent, const char* name )
317: KToggleAction( parent, name ) 318: KToggleAction( parent, name )
318{ 319{
319} 320}
320 321
321void KRadioAction::slotActivated() 322void KRadioAction::slotActivated()
322{ 323{
323 if ( isChecked() ) 324 if ( isChecked() )
324 { 325 {
325 const QObject *senderObj = sender(); 326 const QObject *senderObj = sender();
326 327
327 if ( !senderObj || !senderObj->inherits( "KToolBarButton" ) ) 328 if ( !senderObj || !senderObj->inherits( "KToolBarButton" ) )
328 return; 329 return;
329 330
330 qDebug("KRadioAction::slotActivated has to be fixed"); 331 qDebug("KRadioAction::slotActivated has to be fixed");
331 const_cast<KToolBarButton *>( static_cast<const KToolBarButton *>( senderObj ) )->on( true ); 332 const_cast<KToolBarButton *>( static_cast<const KToolBarButton *>( senderObj ) )->on( true );
332 333
333 return; 334 return;
334 } 335 }
335 336
336 KToggleAction::slotActivated(); 337 KToggleAction::slotActivated();
337} 338}
338 339
339class KSelectAction::KSelectActionPrivate 340class KSelectAction::KSelectActionPrivate
340{ 341{
341public: 342public:
342 KSelectActionPrivate() 343 KSelectActionPrivate()
343 { 344 {
344 m_edit = false; 345 m_edit = false;
345 m_menuAccelsEnabled = true; 346 m_menuAccelsEnabled = true;
346 m_menu = 0; 347 m_menu = 0;
347 m_current = -1; 348 m_current = -1;
348 m_comboWidth = -1; 349 m_comboWidth = -1;
349 } 350 }
350 bool m_edit; 351 bool m_edit;
351 bool m_menuAccelsEnabled; 352 bool m_menuAccelsEnabled;
352 QPopupMenu *m_menu; 353 Q3PopupMenu *m_menu;
353 int m_current; 354 int m_current;
354 int m_comboWidth; 355 int m_comboWidth;
355 QStringList m_list; 356 QStringList m_list;
356 357
357 QString makeMenuText( const QString &_text ) 358 QString makeMenuText( const QString &_text )
358 { 359 {
359 if ( m_menuAccelsEnabled ) 360 if ( m_menuAccelsEnabled )
360 return _text; 361 return _text;
361 QString text = _text; 362 QString text = _text;
362 uint i = 0; 363 uint i = 0;
363 while ( i < text.length() ) { 364 while ( i < text.length() ) {
364 if ( text.at( i ) == '&' ) { 365 if ( text.at( i ) == '&' ) {
365 text.insert( i, '&' ); 366 text.insert( i, '&' );
366 i += 2; 367 i += 2;
367 } 368 }
368 else 369 else
369 ++i; 370 ++i;
370 } 371 }
371 return text; 372 return text;
372 } 373 }
373}; 374};
374 375
375KSelectAction::KSelectAction( const QString& text, const KShortcut& cut, 376KSelectAction::KSelectAction( const QString& text, const KShortcut& cut,
376 QObject* parent, const char* name ) 377 QObject* parent, const char* name )
377 : KAction( text, cut, parent, name ) 378 : KAction( text, cut, parent, name )
378{ 379{
379 d = new KSelectActionPrivate; 380 d = new KSelectActionPrivate;
380} 381}
381 382
382KSelectAction::KSelectAction( const QString& text, const KShortcut& cut, 383KSelectAction::KSelectAction( const QString& text, const KShortcut& cut,
383 const QObject* receiver, const char* slot, 384 const QObject* receiver, const char* slot,
384 QObject* parent, const char* name ) 385 QObject* parent, const char* name )
385 : KAction( text, cut, receiver, slot, parent, name ) 386 : KAction( text, cut, receiver, slot, parent, name )
386{ 387{
387 d = new KSelectActionPrivate; 388 d = new KSelectActionPrivate;
388} 389}
389 390
390KSelectAction::KSelectAction( const QString& text, const QIconSet& pix, 391KSelectAction::KSelectAction( const QString& text, const QIcon& pix,
391 const KShortcut& cut, 392 const KShortcut& cut,
392 QObject* parent, const char* name ) 393 QObject* parent, const char* name )
393 : KAction( text, pix, cut, parent, name ) 394 : KAction( text, pix, cut, parent, name )
394{ 395{
395 d = new KSelectActionPrivate; 396 d = new KSelectActionPrivate;
396} 397}
397 398
398KSelectAction::KSelectAction( const QString& text, const QString& pix, 399KSelectAction::KSelectAction( const QString& text, const QString& pix,
399 const KShortcut& cut, 400 const KShortcut& cut,
400 QObject* parent, const char* name ) 401 QObject* parent, const char* name )
401 : KAction( text, pix, cut, parent, name ) 402 : KAction( text, pix, cut, parent, name )
402{ 403{
403 d = new KSelectActionPrivate; 404 d = new KSelectActionPrivate;
404} 405}
405 406
406KSelectAction::KSelectAction( const QString& text, const QIconSet& pix, 407KSelectAction::KSelectAction( const QString& text, const QIcon& pix,
407 const KShortcut& cut, 408 const KShortcut& cut,
408 const QObject* receiver, 409 const QObject* receiver,
409 const char* slot, QObject* parent, 410 const char* slot, QObject* parent,
410 const char* name ) 411 const char* name )
411 : KAction( text, pix, cut, receiver, slot, parent, name ) 412 : KAction( text, pix, cut, receiver, slot, parent, name )
412{ 413{
413 d = new KSelectActionPrivate; 414 d = new KSelectActionPrivate;
414} 415}
415 416
416KSelectAction::KSelectAction( const QString& text, const QString& pix, 417KSelectAction::KSelectAction( const QString& text, const QString& pix,
417 const KShortcut& cut, 418 const KShortcut& cut,
418 const QObject* receiver, 419 const QObject* receiver,
419 const char* slot, QObject* parent, 420 const char* slot, QObject* parent,
420 const char* name ) 421 const char* name )
421 : KAction( text, pix, cut, receiver, slot, parent, name ) 422 : KAction( text, pix, cut, receiver, slot, parent, name )
422{ 423{
423 d = new KSelectActionPrivate; 424 d = new KSelectActionPrivate;
424} 425}
425 426
426KSelectAction::KSelectAction( QObject* parent, const char* name ) 427KSelectAction::KSelectAction( QObject* parent, const char* name )
427 : KAction( parent, name ) 428 : KAction( parent, name )
428{ 429{
429 d = new KSelectActionPrivate; 430 d = new KSelectActionPrivate;
430} 431}
431 432
432KSelectAction::~KSelectAction() 433KSelectAction::~KSelectAction()
433{ 434{
434 assert(d); 435 assert(d);
435 delete d->m_menu; 436 delete d->m_menu;
436 delete d; d = 0; 437 delete d; d = 0;
437} 438}
438 439
439void KSelectAction::setCurrentItem( int id ) 440void KSelectAction::setCurrentItem( int id )
440{ 441{
441 if ( id >= (int)d->m_list.count() ) { 442 if ( id >= (int)d->m_list.count() ) {
442 ASSERT(id < (int)d->m_list.count()); 443 Q_ASSERT(id < (int)d->m_list.count());
443 return; 444 return;
444 } 445 }
445 446
446 if ( d->m_menu ) 447 if ( d->m_menu )
447 { 448 {
448 if ( d->m_current >= 0 ) 449 if ( d->m_current >= 0 )
449 d->m_menu->setItemChecked( d->m_current, false ); 450 d->m_menu->setItemChecked( d->m_current, false );
450 if ( id >= 0 ) 451 if ( id >= 0 )
451 { 452 {
452 //US qDebug("KSelectAction::setCurrentItem %i", id); 453 //US qDebug("KSelectAction::setCurrentItem %i", id);
453 d->m_menu->setItemChecked( id, true ); 454 d->m_menu->setItemChecked( id, true );
454 } 455 }
455 } 456 }
456 457
457 d->m_current = id; 458 d->m_current = id;
458 459
459 int len = containerCount(); 460 int len = containerCount();
460 461
461 for( int i = 0; i < len; ++i ) 462 for( int i = 0; i < len; ++i )
462 updateCurrentItem( i ); 463 updateCurrentItem( i );
463 464
464 // emit KAction::activated(); 465 // emit KAction::activated();
465 // emit activated( currentItem() ); 466 // emit activated( currentItem() );
466 // emit activated( currentText() ); 467 // emit activated( currentText() );
467} 468}
468 469
469void KSelectAction::setComboWidth( int width ) 470void KSelectAction::setComboWidth( int width )
470{ 471{
471 if ( width < 0 ) 472 if ( width < 0 )
472 return; 473 return;
473 474
474 d->m_comboWidth=width; 475 d->m_comboWidth=width;
475 476
476 int len = containerCount(); 477 int len = containerCount();
477 478
478 for( int i = 0; i < len; ++i ) 479 for( int i = 0; i < len; ++i )
479 updateComboWidth( i ); 480 updateComboWidth( i );
480 481
481} 482}
482QPopupMenu* KSelectAction::popupMenu() const 483Q3PopupMenu* KSelectAction::popupMenu() const
483{ 484{
484 kdDebug(129) << "KSelectAction::popupMenu()" << endl; // remove -- ellis 485 kdDebug(129) << "KSelectAction::popupMenu()" << endl; // remove -- ellis
485 if ( !d->m_menu ) 486 if ( !d->m_menu )
486 { 487 {
487//US d->m_menu = new KPopupMenu(0L, "KSelectAction::popupMenu()"); 488//US d->m_menu = new KPopupMenu(0L, "KSelectAction::popupMenu()");
488 d->m_menu = new QPopupMenu(0L, "QSelectAction::popupMenu()"); 489 d->m_menu = new Q3PopupMenu(0L, "QSelectAction::popupMenu()");
489 setupMenu(); 490 setupMenu();
490 if ( d->m_current >= 0 ) 491 if ( d->m_current >= 0 )
491 d->m_menu->setItemChecked( d->m_current, true ); 492 d->m_menu->setItemChecked( d->m_current, true );
492 } 493 }
493 494
494 return d->m_menu; 495 return d->m_menu;
495} 496}
496 497
497void KSelectAction::setupMenu() const 498void KSelectAction::setupMenu() const
498{ 499{
499 if ( !d->m_menu ) 500 if ( !d->m_menu )
500 return; 501 return;
501 d->m_menu->clear(); 502 d->m_menu->clear();
502 503
503 QStringList::ConstIterator it = d->m_list.begin(); 504 QStringList::ConstIterator it = d->m_list.begin();
504 for( uint id = 0; it != d->m_list.end(); ++it, ++id ) { 505 for( uint id = 0; it != d->m_list.end(); ++it, ++id ) {
505 QString text = *it; 506 QString text = *it;
506 if ( !text.isEmpty() ) 507 if ( !text.isEmpty() )
507 d->m_menu->insertItem( d->makeMenuText( text ), this, SLOT( slotActivated( int ) ), 0, id ); 508 d->m_menu->insertItem( d->makeMenuText( text ), this, SLOT( slotActivated( int ) ), 0, id );
508 else 509 else
509 d->m_menu->insertSeparator(); 510 d->m_menu->insertSeparator();
510 } 511 }
511} 512}
512 513
513void KSelectAction::changeItem( int index, const QString& text ) 514void KSelectAction::changeItem( int index, const QString& text )
514{ 515{
515 if ( index < 0 || index >= (int)d->m_list.count() ) 516 if ( index < 0 || index >= (int)d->m_list.count() )
516 { 517 {
517 kdWarning() << "KSelectAction::changeItem Index out of scope" << endl; 518 kdWarning() << "KSelectAction::changeItem Index out of scope" << endl;
518 return; 519 return;
519 } 520 }
520 521
521 d->m_list[ index ] = text; 522 d->m_list[ index ] = text;
522 523
523 if ( d->m_menu ) 524 if ( d->m_menu )
524 d->m_menu->changeItem( index, d->makeMenuText( text ) ); 525 d->m_menu->changeItem( index, d->makeMenuText( text ) );
525 526
526 int len = containerCount(); 527 int len = containerCount();
527 for( int i = 0; i < len; ++i ) 528 for( int i = 0; i < len; ++i )
528 changeItem( i, index, text ); 529 changeItem( i, index, text );
529} 530}
530 531
531void KSelectAction::changeItem( int id, int index, const QString& text) 532void KSelectAction::changeItem( int id, int index, const QString& text)
532{ 533{
533 if ( index < 0 ) 534 if ( index < 0 )
534 return; 535 return;
535 536
536 QWidget* w = container( id ); 537 QWidget* w = container( id );
537 if ( w->inherits( "KToolBar" ) ) 538 if ( w->inherits( "KToolBar" ) )
538 { 539 {
539 QWidget* r = (static_cast<KToolBar*>( w ))->getWidget( itemId( id ) ); 540 QWidget* r = (static_cast<KToolBar*>( w ))->getWidget( itemId( id ) );
540 if ( r->inherits( "QComboBox" ) ) 541 if ( r->inherits( "QComboBox" ) )
541 { 542 {
542 QComboBox *b = static_cast<QComboBox*>( r ); 543 QComboBox *b = static_cast<QComboBox*>( r );
543 b->changeItem(text, index ); 544 b->changeItem(text, index );
544 } 545 }
545 } 546 }
546 547
547} 548}
548 549
549void KSelectAction::setItems( const QStringList &lst ) 550void KSelectAction::setItems( const QStringList &lst )
550{ 551{
551 kdDebug(129) << "KAction::setItems()" << endl; // remove -- ellis 552 kdDebug(129) << "KAction::setItems()" << endl; // remove -- ellis
552 d->m_list = lst; 553 d->m_list = lst;
553 d->m_current = -1; 554 d->m_current = -1;
554 555
555 setupMenu(); 556 setupMenu();
556 557
557 int len = containerCount(); 558 int len = containerCount();
558 for( int i = 0; i < len; ++i ) 559 for( int i = 0; i < len; ++i )
559 updateItems( i ); 560 updateItems( i );
560 561
561 // Disable if empty and not editable 562 // Disable if empty and not editable
562 setEnabled ( lst.count() > 0 || d->m_edit ); 563 setEnabled ( lst.count() > 0 || d->m_edit );
563} 564}
564 565
565QStringList KSelectAction::items() const 566QStringList KSelectAction::items() const
566{ 567{
567 return d->m_list; 568 return d->m_list;
568} 569}
569 570
570QString KSelectAction::currentText() const 571QString KSelectAction::currentText() const
571{ 572{
572 if ( currentItem() < 0 ) 573 if ( currentItem() < 0 )
573 return QString::null; 574 return QString::null;
574 575
575 return d->m_list[ currentItem() ]; 576 return d->m_list[ currentItem() ];
576} 577}
577 578
578int KSelectAction::currentItem() const 579int KSelectAction::currentItem() const
579{ 580{
580 return d->m_current; 581 return d->m_current;
581} 582}
582 583
583void KSelectAction::updateCurrentItem( int id ) 584void KSelectAction::updateCurrentItem( int id )
584{ 585{
585 if ( d->m_current < 0 ) 586 if ( d->m_current < 0 )
586 return; 587 return;
587 588
588 QWidget* w = container( id ); 589 QWidget* w = container( id );
589 if ( w->inherits( "KToolBar" ) ) { 590 if ( w->inherits( "KToolBar" ) ) {
590 QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) ); 591 QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) );
591 if ( r->inherits( "QComboBox" ) ) { 592 if ( r->inherits( "QComboBox" ) ) {
592 QComboBox *b = static_cast<QComboBox*>( r ); 593 QComboBox *b = static_cast<QComboBox*>( r );
593 b->setCurrentItem( d->m_current ); 594 b->setCurrentItem( d->m_current );
594 } 595 }
595 } 596 }
596} 597}
597 598
598int KSelectAction::comboWidth() const 599int KSelectAction::comboWidth() const
599{ 600{
600 return d->m_comboWidth; 601 return d->m_comboWidth;
601} 602}
602 603
603void KSelectAction::updateComboWidth( int id ) 604void KSelectAction::updateComboWidth( int id )
604{ 605{
605 QWidget* w = container( id ); 606 QWidget* w = container( id );
606 if ( w->inherits( "KToolBar" ) ) { 607 if ( w->inherits( "KToolBar" ) ) {
607 QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) ); 608 QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) );
608 if ( r->inherits( "QComboBox" ) ) { 609 if ( r->inherits( "QComboBox" ) ) {
609 QComboBox *cb = static_cast<QComboBox*>( r ); 610 QComboBox *cb = static_cast<QComboBox*>( r );
610 cb->setMinimumWidth( d->m_comboWidth ); 611 cb->setMinimumWidth( d->m_comboWidth );
611 cb->setMaximumWidth( d->m_comboWidth ); 612 cb->setMaximumWidth( d->m_comboWidth );
612 } 613 }
613 } 614 }
614} 615}
615 616
616void KSelectAction::updateItems( int id ) 617void KSelectAction::updateItems( int id )
617{ 618{
618 kdDebug(129) << "KAction::updateItems( " << id << ", lst )" << endl; // remove -- ellis 619 kdDebug(129) << "KAction::updateItems( " << id << ", lst )" << endl; // remove -- ellis
619 620
620 QWidget* w = container( id ); 621 QWidget* w = container( id );
621 if ( w->inherits( "KToolBar" ) ) { 622 if ( w->inherits( "KToolBar" ) ) {
622 623
623 QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) ); 624 QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) );
624 if ( r->inherits( "QComboBox" ) ) { 625 if ( r->inherits( "QComboBox" ) ) {
625 QComboBox *cb = static_cast<QComboBox*>( r ); 626 QComboBox *cb = static_cast<QComboBox*>( r );
626 cb->clear(); 627 cb->clear();
627 QStringList lst = comboItems(); 628 QStringList lst = comboItems();
628 QStringList::ConstIterator it = lst.begin(); 629 QStringList::ConstIterator it = lst.begin();
629 for( ; it != lst.end(); ++it ) 630 for( ; it != lst.end(); ++it )
630 cb->insertItem( *it ); 631 cb->insertItem( *it );
631 // Ok, this currently doesn't work due to a bug in QComboBox 632 // Ok, this currently doesn't work due to a bug in QComboBox
632 // (the sizehint is cached for ever and never recalculated) 633 // (the sizehint is cached for ever and never recalculated)
633 // Bug reported (against Qt 2.3.1). 634 // Bug reported (against Qt 2.3.1).
634 cb->setMinimumWidth( cb->sizeHint().width() ); 635 cb->setMinimumWidth( cb->sizeHint().width() );
635 } 636 }
636 } 637 }
637 638
638} 639}
639 640
640int KSelectAction::plug( QWidget *widget, int index ) 641int KSelectAction::plug( QWidget *widget, int index )
641{ 642{
642//US if (kapp && !kapp->authorizeKAction(name())) 643//US if (kapp && !kapp->authorizeKAction(name()))
643//US return -1; 644//US return -1;
644 645
645 kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis 646 kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis
646 if ( widget->inherits("QPopupMenu") ) 647 if ( widget->inherits("Q3PopupMenu") )
647 { 648 {
648 // Create the PopupMenu and store it in m_menu 649 // Create the PopupMenu and store it in m_menu
649 (void)popupMenu(); 650 (void)popupMenu();
650 651
651 QPopupMenu* menu = static_cast<QPopupMenu*>( widget ); 652 Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( widget );
652 int id; 653 int id;
653 654
654 if ( hasIconSet() ) 655 if ( hasIconSet() )
655 id = menu->insertItem( iconSet(), text(), d->m_menu, -1, index ); 656 id = menu->insertItem( iconSet(), text(), d->m_menu, -1, index );
656 else 657 else
657 id = menu->insertItem( text(), d->m_menu, -1, index ); 658 id = menu->insertItem( text(), d->m_menu, -1, index );
658 659
659 if ( !isEnabled() ) 660 if ( !isEnabled() )
660 menu->setItemEnabled( id, false ); 661 menu->setItemEnabled( id, false );
661 662
662 QString wth = whatsThis(); 663 QString wth = whatsThis();
663 if ( !wth.isEmpty() ) 664 if ( !wth.isEmpty() )
664 menu->setWhatsThis( id, wth ); 665 menu->setWhatsThis( id, wth );
665 666
666 addContainer( menu, id ); 667 addContainer( menu, id );
667 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 668 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
668 669
669 return containerCount() - 1; 670 return containerCount() - 1;
670 } 671 }
671 else if ( widget->inherits("KToolBar") ) 672 else if ( widget->inherits("KToolBar") )
672 { 673 {
673 674
674 KToolBar* bar = static_cast<KToolBar*>( widget ); 675 KToolBar* bar = static_cast<KToolBar*>( widget );
675 int id_ = KAction::getToolButtonID(); 676 int id_ = KAction::getToolButtonID();
676 bar->insertCombo( comboItems(), id_, isEditable(), 677 bar->insertCombo( comboItems(), id_, isEditable(),
677 SIGNAL( activated( const QString & ) ), this, 678 SIGNAL( activated( const QString & ) ), this,
678 SLOT( slotActivated( const QString & ) ), isEnabled(), 679 SLOT( slotActivated( const QString & ) ), isEnabled(),
679 toolTip(), -1, index ); 680 toolTip(), -1, index );
680 681
681 KComboBox *cb = bar->getCombo( id_ ); 682 KComboBox *cb = bar->getCombo( id_ );
682 if ( cb ) 683 if ( cb )
683 { 684 {
684 cb->setMaximumHeight( 34 ); 685 cb->setMaximumHeight( 34 );
685 if (!isEditable()) cb->setFocusPolicy(QWidget::NoFocus); 686 if (!isEditable()) cb->setFocusPolicy(Qt::NoFocus);
686 cb->setMinimumWidth( cb->sizeHint().width() ); 687 cb->setMinimumWidth( cb->sizeHint().width() );
687 if ( d->m_comboWidth > 0 ) 688 if ( d->m_comboWidth > 0 )
688 { 689 {
689 cb->setMinimumWidth( d->m_comboWidth ); 690 cb->setMinimumWidth( d->m_comboWidth );
690 cb->setMaximumWidth( d->m_comboWidth ); 691 cb->setMaximumWidth( d->m_comboWidth );
691 } 692 }
692 cb->setInsertionPolicy( QComboBox::NoInsertion ); 693 cb->setInsertionPolicy( QComboBox::NoInsertion );
693//US QWhatsThis::add( cb, whatsThis() ); 694//US QWhatsThis::add( cb, whatsThis() );
694 } 695 }
695 696
696 addContainer( bar, id_ ); 697 addContainer( bar, id_ );
697 698
698 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 699 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
699 700
700 updateCurrentItem( containerCount() - 1 ); 701 updateCurrentItem( containerCount() - 1 );
701 702
702 return containerCount() - 1; 703 return containerCount() - 1;
703 704
704 } 705 }
705 kdWarning() << "Can not plug KAction in " << widget->className() << endl; 706 kdWarning() << "Can not plug KAction in " << widget->className() << endl;
706 return -1; 707 return -1;
707} 708}
708 709
709QStringList KSelectAction::comboItems() const 710QStringList KSelectAction::comboItems() const
710{ 711{
711 //qDebug("KSelectAction::comboItems has to be fixed"); 712 //qDebug("KSelectAction::comboItems has to be fixed");
712 if( d->m_menuAccelsEnabled ) 713 if( d->m_menuAccelsEnabled )
713 { 714 {
714 QStringList lst; 715 QStringList lst;
715 QStringList::ConstIterator it = d->m_list.begin(); 716 QStringList::ConstIterator it = d->m_list.begin();
716 for( ; it != d->m_list.end(); ++it ) 717 for( ; it != d->m_list.end(); ++it )
717 { 718 {
718 QString item = *it; 719 QString item = *it;
719 int i = item.find( '&' ); 720 int i = item.find( '&' );
720 if ( i > -1 ) 721 if ( i > -1 )
721 item = item.remove( i, 1 ); 722 item = item.remove( i, 1 );
722 lst.append( item ); 723 lst.append( item );
723 } 724 }
724 return lst; 725 return lst;
725 } 726 }
726 else 727 else
727 { 728 {
728 return d->m_list; 729 return d->m_list;
729 } 730 }
730} 731}
731 732
732void KSelectAction::clear() 733void KSelectAction::clear()
733{ 734{
734 if ( d->m_menu ) 735 if ( d->m_menu )
735 d->m_menu->clear(); 736 d->m_menu->clear();
736 737
737 int len = containerCount(); 738 int len = containerCount();
738 for( int i = 0; i < len; ++i ) 739 for( int i = 0; i < len; ++i )
739 updateClear( i ); 740 updateClear( i );
740} 741}
741 742
742void KSelectAction::updateClear( int id ) 743void KSelectAction::updateClear( int id )
743{ 744{
744 745
745 QWidget* w = container( id ); 746 QWidget* w = container( id );
746 if ( w->inherits( "KToolBar" ) ) { 747 if ( w->inherits( "KToolBar" ) ) {
747 QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) ); 748 QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) );
748 if ( r->inherits( "QComboBox" ) ) { 749 if ( r->inherits( "QComboBox" ) ) {
749 QComboBox *b = static_cast<QComboBox*>( r ); 750 QComboBox *b = static_cast<QComboBox*>( r );
750 b->clear(); 751 b->clear();
751 } 752 }
752 } 753 }
753} 754}
754 755
755void KSelectAction::slotActivated( int id ) 756void KSelectAction::slotActivated( int id )
756{ 757{
757 if ( d->m_current == id ) 758 if ( d->m_current == id )
758 return; 759 return;
759 760
760 setCurrentItem( id ); 761 setCurrentItem( id );
761 // Delay this. Especially useful when the slot connected to activated() will re-create 762 // Delay this. Especially useful when the slot connected to activated() will re-create
762 // the menu, e.g. in the recent files action. This prevents a crash. 763 // the menu, e.g. in the recent files action. This prevents a crash.
763 764
764 QTimer::singleShot( 0, this, SLOT( slotActivated() ) ); 765 QTimer::singleShot( 0, this, SLOT( slotActivated() ) );
765} 766}
766 767
767void KSelectAction::slotActivated( const QString &text ) 768void KSelectAction::slotActivated( const QString &text )
768{ 769{
769 if ( isEditable() ) 770 if ( isEditable() )
770 { 771 {
771 QStringList lst = items(); 772 QStringList lst = items();
772 if(lst.contains(text)==0) 773 if(lst.contains(text)==0)
773 { 774 {
774 lst.append( text ); 775 lst.append( text );
775 setItems( lst ); 776 setItems( lst );
776 } 777 }
777 } 778 }
778 779
779 int i = items().findIndex( text ); 780 int i = items().findIndex( text );
780 if ( i > -1 ) 781 if ( i > -1 )
781 setCurrentItem( i ); 782 setCurrentItem( i );
782 else 783 else
783 setCurrentItem( comboItems().findIndex( text ) ); 784 setCurrentItem( comboItems().findIndex( text ) );
784 // Delay this. Especially useful when the slot connected to activated() will re-create 785 // Delay this. Especially useful when the slot connected to activated() will re-create
785 // the menu, e.g. in the recent files action. This prevents a crash. 786 // the menu, e.g. in the recent files action. This prevents a crash.
786 787
787 QTimer::singleShot( 0, this, SLOT( slotActivated() ) ); 788 QTimer::singleShot( 0, this, SLOT( slotActivated() ) );
788} 789}
789 790
790void KSelectAction::slotActivated() 791void KSelectAction::slotActivated()
791{ 792{
792 KAction::slotActivated(); 793 KAction::slotActivated();
793 kdDebug(129) << "KSelectAction::slotActivated currentItem=" << currentItem() << " currentText=" << currentText() << endl; 794 kdDebug(129) << "KSelectAction::slotActivated currentItem=" << currentItem() << " currentText=" << currentText() << endl;
794 emit activated( currentItem() ); 795 emit activated( currentItem() );
795 emit activated( currentText() ); 796 emit activated( currentText() );
796} 797}
797 798
798void KSelectAction::setEditable( bool edit ) 799void KSelectAction::setEditable( bool edit )
799{ 800{
800 d->m_edit = edit; 801 d->m_edit = edit;
801} 802}
802 803
803bool KSelectAction::isEditable() const 804bool KSelectAction::isEditable() const
804{ 805{
805 return d->m_edit; 806 return d->m_edit;
806} 807}
807 808
808void KSelectAction::setRemoveAmpersandsInCombo( bool b ) 809void KSelectAction::setRemoveAmpersandsInCombo( bool b )
809{ 810{
810 setMenuAccelsEnabled( b ); 811 setMenuAccelsEnabled( b );
811} 812}
812 813
813bool KSelectAction::removeAmpersandsInCombo() const 814bool KSelectAction::removeAmpersandsInCombo() const
814{ 815{
815 return menuAccelsEnabled( ); 816 return menuAccelsEnabled( );
816} 817}
817 818
818void KSelectAction::setMenuAccelsEnabled( bool b ) 819void KSelectAction::setMenuAccelsEnabled( bool b )
819{ 820{
820 d->m_menuAccelsEnabled = b; 821 d->m_menuAccelsEnabled = b;
821} 822}
822 823
823bool KSelectAction::menuAccelsEnabled() const 824bool KSelectAction::menuAccelsEnabled() const
824{ 825{
825 return d->m_menuAccelsEnabled; 826 return d->m_menuAccelsEnabled;
826} 827}
827 828
828class KListAction::KListActionPrivate 829class KListAction::KListActionPrivate
829{ 830{
830public: 831public:
831 KListActionPrivate() 832 KListActionPrivate()
832 { 833 {
833 m_current = 0; 834 m_current = 0;
834 } 835 }
835 int m_current; 836 int m_current;
836}; 837};
837 838
838KListAction::KListAction( const QString& text, const KShortcut& cut, 839KListAction::KListAction( const QString& text, const KShortcut& cut,
839 QObject* parent, const char* name ) 840 QObject* parent, const char* name )
840 : KSelectAction( text, cut, parent, name ) 841 : KSelectAction( text, cut, parent, name )
841{ 842{
842 d = new KListActionPrivate; 843 d = new KListActionPrivate;
843} 844}
844 845
845KListAction::KListAction( const QString& text, const KShortcut& cut, 846KListAction::KListAction( const QString& text, const KShortcut& cut,
846 const QObject* receiver, const char* slot, 847 const QObject* receiver, const char* slot,
847 QObject* parent, const char* name ) 848 QObject* parent, const char* name )
848 : KSelectAction( text, cut, parent, name ) 849 : KSelectAction( text, cut, parent, name )
849{ 850{
850 d = new KListActionPrivate; 851 d = new KListActionPrivate;
851 if ( receiver ) 852 if ( receiver )
852 connect( this, SIGNAL( activated( int ) ), receiver, slot ); 853 connect( this, SIGNAL( activated( int ) ), receiver, slot );
853} 854}
854 855
855KListAction::KListAction( const QString& text, const QIconSet& pix, 856KListAction::KListAction( const QString& text, const QIcon& pix,
856 const KShortcut& cut, 857 const KShortcut& cut,
857 QObject* parent, const char* name ) 858 QObject* parent, const char* name )
858 : KSelectAction( text, pix, cut, parent, name ) 859 : KSelectAction( text, pix, cut, parent, name )
859{ 860{
860 d = new KListActionPrivate; 861 d = new KListActionPrivate;
861} 862}
862 863
863KListAction::KListAction( const QString& text, const QString& pix, 864KListAction::KListAction( const QString& text, const QString& pix,
864 const KShortcut& cut, 865 const KShortcut& cut,
865 QObject* parent, const char* name ) 866 QObject* parent, const char* name )
866 : KSelectAction( text, pix, cut, parent, name ) 867 : KSelectAction( text, pix, cut, parent, name )
867{ 868{
868 d = new KListActionPrivate; 869 d = new KListActionPrivate;
869} 870}
870 871
871KListAction::KListAction( const QString& text, const QIconSet& pix, 872KListAction::KListAction( const QString& text, const QIcon& pix,
872 const KShortcut& cut, const QObject* receiver, 873 const KShortcut& cut, const QObject* receiver,
873 const char* slot, QObject* parent, 874 const char* slot, QObject* parent,
874 const char* name ) 875 const char* name )
875 : KSelectAction( text, pix, cut, parent, name ) 876 : KSelectAction( text, pix, cut, parent, name )
876{ 877{
877 d = new KListActionPrivate; 878 d = new KListActionPrivate;
878 if ( receiver ) 879 if ( receiver )
879 connect( this, SIGNAL( activated( int ) ), receiver, slot ); 880 connect( this, SIGNAL( activated( int ) ), receiver, slot );
880} 881}
881 882
882KListAction::KListAction( const QString& text, const QString& pix, 883KListAction::KListAction( const QString& text, const QString& pix,
883 const KShortcut& cut, const QObject* receiver, 884 const KShortcut& cut, const QObject* receiver,
884 const char* slot, QObject* parent, 885 const char* slot, QObject* parent,
885 const char* name ) 886 const char* name )
886 : KSelectAction( text, pix, cut, parent, name ) 887 : KSelectAction( text, pix, cut, parent, name )
887{ 888{
888 d = new KListActionPrivate; 889 d = new KListActionPrivate;
889 if ( receiver ) 890 if ( receiver )
890 connect( this, SIGNAL( activated( int ) ), receiver, slot ); 891 connect( this, SIGNAL( activated( int ) ), receiver, slot );
891} 892}
892 893
893KListAction::KListAction( QObject* parent, const char* name ) 894KListAction::KListAction( QObject* parent, const char* name )
894 : KSelectAction( parent, name ) 895 : KSelectAction( parent, name )
895{ 896{
896 d = new KListActionPrivate; 897 d = new KListActionPrivate;
897} 898}
898 899
899KListAction::~KListAction() 900KListAction::~KListAction()
900{ 901{
901 delete d; d = 0; 902 delete d; d = 0;
902} 903}
903 904
904void KListAction::setCurrentItem( int index ) 905void KListAction::setCurrentItem( int index )
905{ 906{
906 KSelectAction::setCurrentItem( index ); 907 KSelectAction::setCurrentItem( index );
907 d->m_current = index; 908 d->m_current = index;
908 909
909 // emit KAction::activated(); 910 // emit KAction::activated();
910 // emit activated( currentItem() ); 911 // emit activated( currentItem() );
911 // emit activated( currentText() ); 912 // emit activated( currentText() );
912} 913}
913 914
914QString KListAction::currentText() const 915QString KListAction::currentText() const
915{ 916{
916 if ( currentItem() < 0 ) 917 if ( currentItem() < 0 )
917 return QString::null; 918 return QString::null;
918 919
919 return items()[ currentItem() ]; 920 return items()[ currentItem() ];
920} 921}
921 922
922int KListAction::currentItem() const 923int KListAction::currentItem() const
923{ 924{
924 return d->m_current; 925 return d->m_current;
925} 926}
926 927
927class KRecentFilesAction::KRecentFilesActionPrivate 928class KRecentFilesAction::KRecentFilesActionPrivate
928{ 929{
929public: 930public:
930 KRecentFilesActionPrivate() 931 KRecentFilesActionPrivate()
931 { 932 {
932 m_maxItems = 0; 933 m_maxItems = 0;
933 } 934 }
934 uint m_maxItems; 935 uint m_maxItems;
935}; 936};
936 937
937KRecentFilesAction::KRecentFilesAction( const QString& text, 938KRecentFilesAction::KRecentFilesAction( const QString& text,
938 const KShortcut& cut, 939 const KShortcut& cut,
939 QObject* parent, const char* name, 940 QObject* parent, const char* name,
940 uint maxItems ) 941 uint maxItems )
941 : KListAction( text, cut, parent, name) 942 : KListAction( text, cut, parent, name)
942{ 943{
943 d = new KRecentFilesActionPrivate; 944 d = new KRecentFilesActionPrivate;
944 d->m_maxItems = maxItems; 945 d->m_maxItems = maxItems;
945 946
946 init(); 947 init();
947} 948}
948 949
949KRecentFilesAction::KRecentFilesAction( const QString& text, 950KRecentFilesAction::KRecentFilesAction( const QString& text,
950 const KShortcut& cut, 951 const KShortcut& cut,
951 const QObject* receiver, 952 const QObject* receiver,
952 const char* slot, 953 const char* slot,
953 QObject* parent, const char* name, 954 QObject* parent, const char* name,
954 uint maxItems ) 955 uint maxItems )
955 : KListAction( text, cut, parent, name) 956 : KListAction( text, cut, parent, name)
956{ 957{
957 d = new KRecentFilesActionPrivate; 958 d = new KRecentFilesActionPrivate;
958 d->m_maxItems = maxItems; 959 d->m_maxItems = maxItems;
959 960
960 init(); 961 init();
961 962
962 if ( receiver ) 963 if ( receiver )
963 connect( this, SIGNAL(urlSelected(const KURL&)), 964 connect( this, SIGNAL(urlSelected(const KURL&)),
964 receiver, slot ); 965 receiver, slot );
965} 966}
966 967
967KRecentFilesAction::KRecentFilesAction( const QString& text, 968KRecentFilesAction::KRecentFilesAction( const QString& text,
968 const QIconSet& pix, 969 const QIcon& pix,
969 const KShortcut& cut, 970 const KShortcut& cut,
970 QObject* parent, const char* name, 971 QObject* parent, const char* name,
971 uint maxItems ) 972 uint maxItems )
972 : KListAction( text, pix, cut, parent, name) 973 : KListAction( text, pix, cut, parent, name)
973{ 974{
974 d = new KRecentFilesActionPrivate; 975 d = new KRecentFilesActionPrivate;
975 d->m_maxItems = maxItems; 976 d->m_maxItems = maxItems;
976 977
977 init(); 978 init();
978} 979}
979 980
980KRecentFilesAction::KRecentFilesAction( const QString& text, 981KRecentFilesAction::KRecentFilesAction( const QString& text,
981 const QString& pix, 982 const QString& pix,
982 const KShortcut& cut, 983 const KShortcut& cut,
983 QObject* parent, const char* name, 984 QObject* parent, const char* name,
984 uint maxItems ) 985 uint maxItems )
985 : KListAction( text, pix, cut, parent, name) 986 : KListAction( text, pix, cut, parent, name)
986{ 987{
987 d = new KRecentFilesActionPrivate; 988 d = new KRecentFilesActionPrivate;
988 d->m_maxItems = maxItems; 989 d->m_maxItems = maxItems;
989 990
990 init(); 991 init();
991} 992}
992 993
993KRecentFilesAction::KRecentFilesAction( const QString& text, 994KRecentFilesAction::KRecentFilesAction( const QString& text,
994 const QIconSet& pix, 995 const QIcon& pix,
995 const KShortcut& cut, 996 const KShortcut& cut,
996 const QObject* receiver, 997 const QObject* receiver,
997 const char* slot, 998 const char* slot,
998 QObject* parent, const char* name, 999 QObject* parent, const char* name,
999 uint maxItems ) 1000 uint maxItems )
1000 : KListAction( text, pix, cut, parent, name) 1001 : KListAction( text, pix, cut, parent, name)
1001{ 1002{
1002 d = new KRecentFilesActionPrivate; 1003 d = new KRecentFilesActionPrivate;
1003 d->m_maxItems = maxItems; 1004 d->m_maxItems = maxItems;
1004 1005
1005 init(); 1006 init();
1006 1007
1007 if ( receiver ) 1008 if ( receiver )
1008 connect( this, SIGNAL(urlSelected(const KURL&)), 1009 connect( this, SIGNAL(urlSelected(const KURL&)),
1009 receiver, slot ); 1010 receiver, slot );
1010} 1011}
1011 1012
1012KRecentFilesAction::KRecentFilesAction( const QString& text, 1013KRecentFilesAction::KRecentFilesAction( const QString& text,
1013 const QString& pix, 1014 const QString& pix,
1014 const KShortcut& cut, 1015 const KShortcut& cut,
1015 const QObject* receiver, 1016 const QObject* receiver,
1016 const char* slot, 1017 const char* slot,
1017 QObject* parent, const char* name, 1018 QObject* parent, const char* name,
1018 uint maxItems ) 1019 uint maxItems )
1019 : KListAction( text, pix, cut, parent, name) 1020 : KListAction( text, pix, cut, parent, name)
1020{ 1021{
1021 d = new KRecentFilesActionPrivate; 1022 d = new KRecentFilesActionPrivate;
1022 d->m_maxItems = maxItems; 1023 d->m_maxItems = maxItems;
1023 1024
1024 init(); 1025 init();
1025 1026
1026 if ( receiver ) 1027 if ( receiver )
1027 connect( this, SIGNAL(urlSelected(const KURL&)), 1028 connect( this, SIGNAL(urlSelected(const KURL&)),
1028 receiver, slot ); 1029 receiver, slot );
1029} 1030}
1030 1031
1031KRecentFilesAction::KRecentFilesAction( QObject* parent, const char* name, 1032KRecentFilesAction::KRecentFilesAction( QObject* parent, const char* name,
1032 uint maxItems ) 1033 uint maxItems )
1033 : KListAction( parent, name ) 1034 : KListAction( parent, name )
1034{ 1035{
1035 d = new KRecentFilesActionPrivate; 1036 d = new KRecentFilesActionPrivate;
1036 d->m_maxItems = maxItems; 1037 d->m_maxItems = maxItems;
1037 1038
1038 init(); 1039 init();
1039} 1040}
1040 1041
1041void KRecentFilesAction::init() 1042void KRecentFilesAction::init()
1042{ 1043{
1043 connect( this, SIGNAL( activated( const QString& ) ), 1044 connect( this, SIGNAL( activated( const QString& ) ),
1044 this, SLOT( itemSelected( const QString& ) ) ); 1045 this, SLOT( itemSelected( const QString& ) ) );
1045 1046
1046 setMenuAccelsEnabled( false ); 1047 setMenuAccelsEnabled( false );
1047} 1048}
1048 1049
1049KRecentFilesAction::~KRecentFilesAction() 1050KRecentFilesAction::~KRecentFilesAction()
1050{ 1051{
1051 delete d; d = 0; 1052 delete d; d = 0;
1052} 1053}
1053 1054
1054uint KRecentFilesAction::maxItems() const 1055uint KRecentFilesAction::maxItems() const
1055{ 1056{
1056 return d->m_maxItems; 1057 return d->m_maxItems;
1057} 1058}
1058 1059
1059void KRecentFilesAction::setMaxItems( uint maxItems ) 1060void KRecentFilesAction::setMaxItems( uint maxItems )
1060{ 1061{
1061 QStringList lst = items(); 1062 QStringList lst = items();
1062 uint oldCount = lst.count(); 1063 uint oldCount = lst.count();
1063 1064
1064 // set new maxItems 1065 // set new maxItems
1065 d->m_maxItems = maxItems; 1066 d->m_maxItems = maxItems;
1066 1067
1067 // remove all items that are too much 1068 // remove all items that are too much
1068 while( lst.count() > maxItems ) 1069 while( lst.count() > maxItems )
1069 { 1070 {
1070 // remove last item 1071 // remove last item
1071 lst.remove( lst.last() ); 1072 lst.remove( lst.last() );
1072 } 1073 }
1073 1074
1074 // set new list if changed 1075 // set new list if changed
1075 if( lst.count() != oldCount ) 1076 if( lst.count() != oldCount )
1076 setItems( lst ); 1077 setItems( lst );
1077} 1078}
1078 1079
1079void KRecentFilesAction::addURL( const KURL& url ) 1080void KRecentFilesAction::addURL( const KURL& url )
1080{ 1081{
1081 QString file = url.prettyURL(); 1082 QString file = url.prettyURL();
1082 QStringList lst = items(); 1083 QStringList lst = items();
1083 1084
1084 // remove file if already in list 1085 // remove file if already in list
1085 lst.remove( file ); 1086 lst.remove( file );
1086 1087
1087 // remove las item if already maxitems in list 1088 // remove las item if already maxitems in list
1088 if( lst.count() == d->m_maxItems ) 1089 if( lst.count() == d->m_maxItems )
1089 { 1090 {
1090 // remove last item 1091 // remove last item
1091 lst.remove( lst.last() ); 1092 lst.remove( lst.last() );
1092 } 1093 }
1093 1094
1094 // add file to list 1095 // add file to list
1095 lst.prepend( file ); 1096 lst.prepend( file );
1096 setItems( lst ); 1097 setItems( lst );
1097} 1098}
1098 1099
1099void KRecentFilesAction::removeURL( const KURL& url ) 1100void KRecentFilesAction::removeURL( const KURL& url )
1100{ 1101{
1101 QStringList lst = items(); 1102 QStringList lst = items();
1102 QString file = url.prettyURL(); 1103 QString file = url.prettyURL();
1103 1104
1104 // remove url 1105 // remove url
1105 if( lst.count() > 0 ) 1106 if( lst.count() > 0 )
1106 { 1107 {
1107 lst.remove( file ); 1108 lst.remove( file );
1108 setItems( lst ); 1109 setItems( lst );
1109 } 1110 }
1110} 1111}
1111 1112
1112void KRecentFilesAction::clearURLList() 1113void KRecentFilesAction::clearURLList()
1113{ 1114{
1114 clear(); 1115 clear();
1115} 1116}
1116 1117
1117void KRecentFilesAction::loadEntries( KConfig* config, QString groupname) 1118void KRecentFilesAction::loadEntries( KConfig* config, QString groupname)
1118{ 1119{
1119 QString key; 1120 QString key;
1120 QString value; 1121 QString value;
1121 QString oldGroup; 1122 QString oldGroup;
1122 QStringList lst; 1123 QStringList lst;
1123 1124
1124 oldGroup = config->group(); 1125 oldGroup = config->group();
1125 1126
1126 if (groupname.isEmpty()) 1127 if (groupname.isEmpty())
1127 groupname = "RecentFiles"; 1128 groupname = "RecentFiles";
1128 config->setGroup( groupname ); 1129 config->setGroup( groupname );
1129 1130
1130 // read file list 1131 // read file list
1131 for( unsigned int i = 1 ; i <= d->m_maxItems ; i++ ) 1132 for( unsigned int i = 1 ; i <= d->m_maxItems ; i++ )
1132 { 1133 {
1133 key = QString( "File%1" ).arg( i ); 1134 key = QString( "File%1" ).arg( i );
1134 value = config->readEntry( key, QString::null ); 1135 value = config->readEntry( key, QString::null );
1135 1136
1136 if (!value.isNull()) 1137 if (!value.isNull())
1137 lst.append( value ); 1138 lst.append( value );
1138 } 1139 }
1139 1140
1140 // set file 1141 // set file
1141 setItems( lst ); 1142 setItems( lst );
1142 1143
1143 config->setGroup( oldGroup ); 1144 config->setGroup( oldGroup );
1144} 1145}
1145 1146
1146void KRecentFilesAction::saveEntries( KConfig* config, QString groupname ) 1147void KRecentFilesAction::saveEntries( KConfig* config, QString groupname )
1147{ 1148{
1148 QString key; 1149 QString key;
1149 QString value; 1150 QString value;
1150 QStringList lst = items(); 1151 QStringList lst = items();
1151 1152
1152 if (groupname.isEmpty()) 1153 if (groupname.isEmpty())
1153 groupname = "RecentFiles"; 1154 groupname = "RecentFiles";
1154 1155
1155 config->deleteGroup( groupname); 1156 config->deleteGroup( groupname);
1156 1157
1157 KConfigGroupSaver( config, groupname ); 1158 KConfigGroupSaver( config, groupname );
1158 1159
1159 // write file list 1160 // write file list
1160 for( unsigned int i = 1 ; i <= lst.count() ; i++ ) 1161 for( unsigned int i = 1 ; i <= lst.count() ; i++ )
1161 { 1162 {
1162 key = QString( "File%1" ).arg( i ); 1163 key = QString( "File%1" ).arg( i );
1163 value = lst[ i - 1 ]; 1164 value = lst[ i - 1 ];
1164 config->writeEntry( key, value ); 1165 config->writeEntry( key, value );
1165 } 1166 }
1166} 1167}
1167 1168
1168void KRecentFilesAction::itemSelected( const QString& text ) 1169void KRecentFilesAction::itemSelected( const QString& text )
1169{ 1170{
1170 emit urlSelected( KURL( text ) ); 1171 emit urlSelected( KURL( text ) );
1171} 1172}
1172 1173
1173class KFontAction::KFontActionPrivate 1174class KFontAction::KFontActionPrivate
1174{ 1175{
1175public: 1176public:
1176 KFontActionPrivate() 1177 KFontActionPrivate()
1177 { 1178 {
1178 } 1179 }
1179 QStringList m_fonts; 1180 QStringList m_fonts;
1180}; 1181};
1181 1182
1182KFontAction::KFontAction( const QString& text, 1183KFontAction::KFontAction( const QString& text,
1183 const KShortcut& cut, QObject* parent, 1184 const KShortcut& cut, QObject* parent,
1184 const char* name ) 1185 const char* name )
1185 : KSelectAction( text, cut, parent, name ) 1186 : KSelectAction( text, cut, parent, name )
1186{ 1187{
1187 d = new KFontActionPrivate; 1188 d = new KFontActionPrivate;
1188 get_fonts( d->m_fonts ); 1189 get_fonts( d->m_fonts );
1189 KSelectAction::setItems( d->m_fonts ); 1190 KSelectAction::setItems( d->m_fonts );
1190 setEditable( true ); 1191 setEditable( true );
1191} 1192}
1192 1193
1193KFontAction::KFontAction( const QString& text, const KShortcut& cut, 1194KFontAction::KFontAction( const QString& text, const KShortcut& cut,
1194 const QObject* receiver, const char* slot, 1195 const QObject* receiver, const char* slot,
1195 QObject* parent, const char* name ) 1196 QObject* parent, const char* name )
1196 : KSelectAction( text, cut, receiver, slot, parent, name ) 1197 : KSelectAction( text, cut, receiver, slot, parent, name )
1197{ 1198{
1198 d = new KFontActionPrivate; 1199 d = new KFontActionPrivate;
1199 get_fonts( d->m_fonts ); 1200 get_fonts( d->m_fonts );
1200 KSelectAction::setItems( d->m_fonts ); 1201 KSelectAction::setItems( d->m_fonts );
1201 setEditable( true ); 1202 setEditable( true );
1202} 1203}
1203 1204
1204KFontAction::KFontAction( const QString& text, const QIconSet& pix, 1205KFontAction::KFontAction( const QString& text, const QIcon& pix,
1205 const KShortcut& cut, 1206 const KShortcut& cut,
1206 QObject* parent, const char* name ) 1207 QObject* parent, const char* name )
1207 : KSelectAction( text, pix, cut, parent, name ) 1208 : KSelectAction( text, pix, cut, parent, name )
1208{ 1209{
1209 d = new KFontActionPrivate; 1210 d = new KFontActionPrivate;
1210 get_fonts( d->m_fonts ); 1211 get_fonts( d->m_fonts );
1211 KSelectAction::setItems( d->m_fonts ); 1212 KSelectAction::setItems( d->m_fonts );
1212 setEditable( true ); 1213 setEditable( true );
1213} 1214}
1214 1215
1215KFontAction::KFontAction( const QString& text, const QString& pix, 1216KFontAction::KFontAction( const QString& text, const QString& pix,
1216 const KShortcut& cut, 1217 const KShortcut& cut,
1217 QObject* parent, const char* name ) 1218 QObject* parent, const char* name )
1218 : KSelectAction( text, pix, cut, parent, name ) 1219 : KSelectAction( text, pix, cut, parent, name )
1219{ 1220{
1220 d = new KFontActionPrivate; 1221 d = new KFontActionPrivate;
1221 get_fonts( d->m_fonts ); 1222 get_fonts( d->m_fonts );
1222 KSelectAction::setItems( d->m_fonts ); 1223 KSelectAction::setItems( d->m_fonts );
1223 setEditable( true ); 1224 setEditable( true );
1224} 1225}
1225 1226
1226KFontAction::KFontAction( const QString& text, const QIconSet& pix, 1227KFontAction::KFontAction( const QString& text, const QIcon& pix,
1227 const KShortcut& cut, 1228 const KShortcut& cut,
1228 const QObject* receiver, const char* slot, 1229 const QObject* receiver, const char* slot,
1229 QObject* parent, const char* name ) 1230 QObject* parent, const char* name )
1230 : KSelectAction( text, pix, cut, receiver, slot, parent, name ) 1231 : KSelectAction( text, pix, cut, receiver, slot, parent, name )
1231{ 1232{
1232 d = new KFontActionPrivate; 1233 d = new KFontActionPrivate;
1233 get_fonts( d->m_fonts ); 1234 get_fonts( d->m_fonts );
1234 KSelectAction::setItems( d->m_fonts ); 1235 KSelectAction::setItems( d->m_fonts );
1235 setEditable( true ); 1236 setEditable( true );
1236} 1237}
1237 1238
1238KFontAction::KFontAction( const QString& text, const QString& pix, 1239KFontAction::KFontAction( const QString& text, const QString& pix,
1239 const KShortcut& cut, 1240 const KShortcut& cut,
1240 const QObject* receiver, const char* slot, 1241 const QObject* receiver, const char* slot,
1241 QObject* parent, const char* name ) 1242 QObject* parent, const char* name )
1242 : KSelectAction( text, pix, cut, receiver, slot, parent, name ) 1243 : KSelectAction( text, pix, cut, receiver, slot, parent, name )
1243{ 1244{
1244 d = new KFontActionPrivate; 1245 d = new KFontActionPrivate;
1245 get_fonts( d->m_fonts ); 1246 get_fonts( d->m_fonts );
1246 KSelectAction::setItems( d->m_fonts ); 1247 KSelectAction::setItems( d->m_fonts );
1247 setEditable( true ); 1248 setEditable( true );
1248} 1249}
1249 1250
1250 1251
1251KFontAction::KFontAction( QObject* parent, const char* name ) 1252KFontAction::KFontAction( QObject* parent, const char* name )
1252 : KSelectAction( parent, name ) 1253 : KSelectAction( parent, name )
1253{ 1254{
1254 d = new KFontActionPrivate; 1255 d = new KFontActionPrivate;
1255 get_fonts( d->m_fonts ); 1256 get_fonts( d->m_fonts );
1256 KSelectAction::setItems( d->m_fonts ); 1257 KSelectAction::setItems( d->m_fonts );
1257 setEditable( true ); 1258 setEditable( true );
1258} 1259}
1259 1260
1260KFontAction::~KFontAction() 1261KFontAction::~KFontAction()
1261{ 1262{
1262 delete d; 1263 delete d;
1263 d = 0; 1264 d = 0;
1264} 1265}
1265 1266
1266/* 1267/*
1267 * Maintenance note: Keep in sync with KFontCombo::setCurrentFont() 1268 * Maintenance note: Keep in sync with KFontCombo::setCurrentFont()
1268 */ 1269 */
1269void KFontAction::setFont( const QString &family ) 1270void KFontAction::setFont( const QString &family )
1270{ 1271{
1271 QString lowerName = family.lower(); 1272 QString lowerName = family.lower();
1272 int i = 0; 1273 int i = 0;
1273 for ( QStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i ) 1274 for ( QStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i )
1274 { 1275 {
1275 if ((*it).lower() == lowerName) 1276 if ((*it).lower() == lowerName)
1276 { 1277 {
1277 setCurrentItem(i); 1278 setCurrentItem(i);
1278 return; 1279 return;
1279 } 1280 }
1280 } 1281 }
1281 i = lowerName.find(" ["); 1282 i = lowerName.find(" [");
1282 if (i>-1) 1283 if (i>-1)
1283 { 1284 {
1284 lowerName = lowerName.left(i); 1285 lowerName = lowerName.left(i);
1285 i = 0; 1286 i = 0;
1286 for ( QStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i ) 1287 for ( QStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i )
1287 { 1288 {
1288 if ((*it).lower() == lowerName) 1289 if ((*it).lower() == lowerName)
1289 { 1290 {
1290 setCurrentItem(i); 1291 setCurrentItem(i);
1291 return; 1292 return;
1292 } 1293 }
1293 } 1294 }
1294 } 1295 }
1295 1296
1296 lowerName += " ["; 1297 lowerName += " [";
1297 i = 0; 1298 i = 0;
1298 for ( QStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i ) 1299 for ( QStringList::Iterator it = d->m_fonts.begin(); it != d->m_fonts.end(); ++it, ++i )
1299 { 1300 {
1300 if ((*it).lower().startsWith(lowerName)) 1301 if ((*it).lower().startsWith(lowerName))
1301 { 1302 {
1302 setCurrentItem(i); 1303 setCurrentItem(i);
1303 return; 1304 return;
1304 } 1305 }
1305 } 1306 }
1306 kdDebug(129) << "Font not found " << family.lower() << endl; 1307 kdDebug(129) << "Font not found " << family.lower() << endl;
1307} 1308}
1308 1309
1309int KFontAction::plug( QWidget *w, int index ) 1310int KFontAction::plug( QWidget *w, int index )
1310{ 1311{
1311 qDebug("KFontAction::plug ha to be fixed"); 1312 qDebug("KFontAction::plug ha to be fixed");
1312/*US 1313/*US
1313 if (kapp && !kapp->authorizeKAction(name())) 1314 if (kapp && !kapp->authorizeKAction(name()))
1314 return -1; 1315 return -1;
1315 if ( w->inherits("KToolBar") ) 1316 if ( w->inherits("KToolBar") )
1316 { 1317 {
1317 KToolBar* bar = static_cast<KToolBar*>( w ); 1318 KToolBar* bar = static_cast<KToolBar*>( w );
1318 int id_ = KAction::getToolButtonID(); 1319 int id_ = KAction::getToolButtonID();
1319 KFontCombo *cb = new KFontCombo( items(), bar ); 1320 KFontCombo *cb = new KFontCombo( items(), bar );
1320 connect( cb, SIGNAL( activated( const QString & ) ), 1321 connect( cb, SIGNAL( activated( const QString & ) ),
1321 SLOT( slotActivated( const QString & ) ) ); 1322 SLOT( slotActivated( const QString & ) ) );
1322 cb->setEnabled( isEnabled() ); 1323 cb->setEnabled( isEnabled() );
1323 bar->insertWidget( id_, comboWidth(), cb, index ); 1324 bar->insertWidget( id_, comboWidth(), cb, index );
1324 cb->setMinimumWidth( cb->sizeHint().width() ); 1325 cb->setMinimumWidth( cb->sizeHint().width() );
1325 1326
1326 addContainer( bar, id_ ); 1327 addContainer( bar, id_ );
1327 1328
1328 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 1329 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
1329 1330
1330 updateCurrentItem( containerCount() - 1 ); 1331 updateCurrentItem( containerCount() - 1 );
1331 1332
1332 return containerCount() - 1; 1333 return containerCount() - 1;
1333 } 1334 }
1334 else return KSelectAction::plug( w, index ); 1335 else return KSelectAction::plug( w, index );
1335*/ 1336*/
1336 return 3; 1337 return 3;
1337} 1338}
1338 1339
1339class KFontSizeAction::KFontSizeActionPrivate 1340class KFontSizeAction::KFontSizeActionPrivate
1340{ 1341{
1341public: 1342public:
1342 KFontSizeActionPrivate() 1343 KFontSizeActionPrivate()
1343 { 1344 {
1344 } 1345 }
1345}; 1346};
1346 1347
1347KFontSizeAction::KFontSizeAction( const QString& text, 1348KFontSizeAction::KFontSizeAction( const QString& text,
1348 const KShortcut& cut, 1349 const KShortcut& cut,
1349 QObject* parent, const char* name ) 1350 QObject* parent, const char* name )
1350 : KSelectAction( text, cut, parent, name ) 1351 : KSelectAction( text, cut, parent, name )
1351{ 1352{
1352 init(); 1353 init();
1353} 1354}
1354 1355
1355KFontSizeAction::KFontSizeAction( const QString& text, 1356KFontSizeAction::KFontSizeAction( const QString& text,
1356 const KShortcut& cut, 1357 const KShortcut& cut,
1357 const QObject* receiver, const char* slot, 1358 const QObject* receiver, const char* slot,
1358 QObject* parent, const char* name ) 1359 QObject* parent, const char* name )
1359 : KSelectAction( text, cut, receiver, slot, parent, name ) 1360 : KSelectAction( text, cut, receiver, slot, parent, name )
1360{ 1361{
1361 init(); 1362 init();
1362} 1363}
1363 1364
1364KFontSizeAction::KFontSizeAction( const QString& text, const QIconSet& pix, 1365KFontSizeAction::KFontSizeAction( const QString& text, const QIcon& pix,
1365 const KShortcut& cut, 1366 const KShortcut& cut,
1366 QObject* parent, const char* name ) 1367 QObject* parent, const char* name )
1367 : KSelectAction( text, pix, cut, parent, name ) 1368 : KSelectAction( text, pix, cut, parent, name )
1368{ 1369{
1369 init(); 1370 init();
1370} 1371}
1371 1372
1372KFontSizeAction::KFontSizeAction( const QString& text, const QString& pix, 1373KFontSizeAction::KFontSizeAction( const QString& text, const QString& pix,
1373 const KShortcut& cut, 1374 const KShortcut& cut,
1374 QObject* parent, const char* name ) 1375 QObject* parent, const char* name )
1375 : KSelectAction( text, pix, cut, parent, name ) 1376 : KSelectAction( text, pix, cut, parent, name )
1376{ 1377{
1377 init(); 1378 init();
1378} 1379}
1379 1380
1380KFontSizeAction::KFontSizeAction( const QString& text, const QIconSet& pix, 1381KFontSizeAction::KFontSizeAction( const QString& text, const QIcon& pix,
1381 const KShortcut& cut, 1382 const KShortcut& cut,
1382 const QObject* receiver, 1383 const QObject* receiver,
1383 const char* slot, QObject* parent, 1384 const char* slot, QObject* parent,
1384 const char* name ) 1385 const char* name )
1385 : KSelectAction( text, pix, cut, receiver, slot, parent, name ) 1386 : KSelectAction( text, pix, cut, receiver, slot, parent, name )
1386{ 1387{
1387 init(); 1388 init();
1388} 1389}
1389 1390
1390KFontSizeAction::KFontSizeAction( const QString& text, const QString& pix, 1391KFontSizeAction::KFontSizeAction( const QString& text, const QString& pix,
1391 const KShortcut& cut, 1392 const KShortcut& cut,
1392 const QObject* receiver, 1393 const QObject* receiver,
1393 const char* slot, QObject* parent, 1394 const char* slot, QObject* parent,
1394 const char* name ) 1395 const char* name )
1395 : KSelectAction( text, pix, cut, receiver, slot, parent, name ) 1396 : KSelectAction( text, pix, cut, receiver, slot, parent, name )
1396{ 1397{
1397 init(); 1398 init();
1398} 1399}
1399 1400
1400KFontSizeAction::KFontSizeAction( QObject* parent, const char* name ) 1401KFontSizeAction::KFontSizeAction( QObject* parent, const char* name )
1401 : KSelectAction( parent, name ) 1402 : KSelectAction( parent, name )
1402{ 1403{
1403 init(); 1404 init();
1404} 1405}
1405 1406
1406KFontSizeAction::~KFontSizeAction() 1407KFontSizeAction::~KFontSizeAction()
1407{ 1408{
1408 delete d; 1409 delete d;
1409 d = 0; 1410 d = 0;
1410} 1411}
1411 1412
1412void KFontSizeAction::init() 1413void KFontSizeAction::init()
1413{ 1414{
1414 d = new KFontSizeActionPrivate; 1415 d = new KFontSizeActionPrivate;
1415 1416
1416 setEditable( true ); 1417 setEditable( true );
1417 QValueList<int> sizes = get_standard_font_sizes(); 1418 Q3ValueList<int> sizes = get_standard_font_sizes();
1418 QStringList lst; 1419 QStringList lst;
1419 for ( QValueList<int>::Iterator it = sizes.begin(); it != sizes.end(); ++it ) 1420 for ( Q3ValueList<int>::Iterator it = sizes.begin(); it != sizes.end(); ++it )
1420 lst.append( QString::number( *it ) ); 1421 lst.append( QString::number( *it ) );
1421 1422
1422 setItems( lst ); 1423 setItems( lst );
1423} 1424}
1424 1425
1425void KFontSizeAction::setFontSize( int size ) 1426void KFontSizeAction::setFontSize( int size )
1426{ 1427{
1427 if ( size == fontSize() ) { 1428 if ( size == fontSize() ) {
1428 setCurrentItem( items().findIndex( QString::number( size ) ) ); 1429 setCurrentItem( items().findIndex( QString::number( size ) ) );
1429 return; 1430 return;
1430 } 1431 }
1431 1432
1432 if ( size < 1 ) { 1433 if ( size < 1 ) {
1433 kdWarning() << "KFontSizeAction: Size " << size << " is out of range" << endl; 1434 kdWarning() << "KFontSizeAction: Size " << size << " is out of range" << endl;
1434 return; 1435 return;
1435 } 1436 }
1436 1437
1437 int index = items().findIndex( QString::number( size ) ); 1438 int index = items().findIndex( QString::number( size ) );
1438 if ( index == -1 ) { 1439 if ( index == -1 ) {
1439 // Insert at the correct position in the list (to keep sorting) 1440 // Insert at the correct position in the list (to keep sorting)
1440 QValueList<int> lst; 1441 Q3ValueList<int> lst;
1441 // Convert to list of ints 1442 // Convert to list of ints
1442 QStringList itemsList = items(); 1443 QStringList itemsList = items();
1443 for (QStringList::Iterator it = itemsList.begin() ; it != itemsList.end() ; ++it) 1444 for (QStringList::Iterator it = itemsList.begin() ; it != itemsList.end() ; ++it)
1444 lst.append( (*it).toInt() ); 1445 lst.append( (*it).toInt() );
1445 // New size 1446 // New size
1446 lst.append( size ); 1447 lst.append( size );
1447 // Sort the list 1448 // Sort the list
1448qDebug("KFontSizeAction::setFontSize heapsort not found."); 1449qDebug("KFontSizeAction::setFontSize heapsort not found.");
1449//US has to be fixed 1450//US has to be fixed
1450//US qHeapSort( lst ); 1451//US qHeapSort( lst );
1451 // Convert back to string list 1452 // Convert back to string list
1452 QStringList strLst; 1453 QStringList strLst;
1453 for (QValueList<int>::Iterator it = lst.begin() ; it != lst.end() ; ++it) 1454 for (Q3ValueList<int>::Iterator it = lst.begin() ; it != lst.end() ; ++it)
1454 strLst.append( QString::number(*it) ); 1455 strLst.append( QString::number(*it) );
1455 KSelectAction::setItems( strLst ); 1456 KSelectAction::setItems( strLst );
1456 // Find new current item 1457 // Find new current item
1457 index = lst.findIndex( size ); 1458 index = lst.findIndex( size );
1458 setCurrentItem( index ); 1459 setCurrentItem( index );
1459 } 1460 }
1460 else 1461 else
1461 setCurrentItem( index ); 1462 setCurrentItem( index );
1462 1463
1463 1464
1464 //emit KAction::activated(); 1465 //emit KAction::activated();
1465 //emit activated( index ); 1466 //emit activated( index );
1466 //emit activated( QString::number( size ) ); 1467 //emit activated( QString::number( size ) );
1467 //emit fontSizeChanged( size ); 1468 //emit fontSizeChanged( size );
1468} 1469}
1469 1470
1470int KFontSizeAction::fontSize() const 1471int KFontSizeAction::fontSize() const
1471{ 1472{
1472 return currentText().toInt(); 1473 return currentText().toInt();
1473} 1474}
1474 1475
1475void KFontSizeAction::slotActivated( int index ) 1476void KFontSizeAction::slotActivated( int index )
1476{ 1477{
1477 KSelectAction::slotActivated( index ); 1478 KSelectAction::slotActivated( index );
1478 1479
1479 emit fontSizeChanged( items()[ index ].toInt() ); 1480 emit fontSizeChanged( items()[ index ].toInt() );
1480} 1481}
1481 1482
1482void KFontSizeAction::slotActivated( const QString& size ) 1483void KFontSizeAction::slotActivated( const QString& size )
1483{ 1484{
1484 setFontSize( size.toInt() ); // insert sorted first 1485 setFontSize( size.toInt() ); // insert sorted first
1485 KSelectAction::slotActivated( size ); 1486 KSelectAction::slotActivated( size );
1486 emit fontSizeChanged( size.toInt() ); 1487 emit fontSizeChanged( size.toInt() );
1487} 1488}
1488 1489
1489class KActionMenu::KActionMenuPrivate 1490class KActionMenu::KActionMenuPrivate
1490{ 1491{
1491public: 1492public:
1492 KActionMenuPrivate() 1493 KActionMenuPrivate()
1493 { 1494 {
1494//US m_popup = new KPopupMenu(0L,"KActionMenu::KActionMenuPrivate"); 1495//US m_popup = new KPopupMenu(0L,"KActionMenu::KActionMenuPrivate");
1495 m_popup = new QPopupMenu(0L,"KActionMenu::KActionMenuPrivate"); 1496 m_popup = new Q3PopupMenu(0L,"KActionMenu::KActionMenuPrivate");
1496 m_delayed = true; 1497 m_delayed = true;
1497 m_stickyMenu = true; 1498 m_stickyMenu = true;
1498 } 1499 }
1499 ~KActionMenuPrivate() 1500 ~KActionMenuPrivate()
1500 { 1501 {
1501 delete m_popup; m_popup = 0; 1502 delete m_popup; m_popup = 0;
1502 } 1503 }
1503 1504
1504//US KPopupMenu *m_popup; 1505//US KPopupMenu *m_popup;
1505 QPopupMenu *m_popup; 1506 Q3PopupMenu *m_popup;
1506 bool m_delayed; 1507 bool m_delayed;
1507 bool m_stickyMenu; 1508 bool m_stickyMenu;
1508}; 1509};
1509 1510
1510KActionMenu::KActionMenu( QObject* parent, const char* name ) 1511KActionMenu::KActionMenu( QObject* parent, const char* name )
1511 : KAction( parent, name ) 1512 : KAction( parent, name )
1512{ 1513{
1513 d = new KActionMenuPrivate; 1514 d = new KActionMenuPrivate;
1514 setShortcutConfigurable( false ); 1515 setShortcutConfigurable( false );
1515} 1516}
1516 1517
1517KActionMenu::KActionMenu( const QString& text, QObject* parent, 1518KActionMenu::KActionMenu( const QString& text, QObject* parent,
1518 const char* name ) 1519 const char* name )
1519 : KAction( text, 0, parent, name ) 1520 : KAction( text, 0, parent, name )
1520{ 1521{
1521 d = new KActionMenuPrivate; 1522 d = new KActionMenuPrivate;
1522 setShortcutConfigurable( false ); 1523 setShortcutConfigurable( false );
1523} 1524}
1524 1525
1525KActionMenu::KActionMenu( const QString& text, const QIconSet& icon, 1526KActionMenu::KActionMenu( const QString& text, const QIcon& icon,
1526 QObject* parent, const char* name ) 1527 QObject* parent, const char* name )
1527 : KAction( text, icon, 0, parent, name ) 1528 : KAction( text, icon, 0, parent, name )
1528{ 1529{
1529 d = new KActionMenuPrivate; 1530 d = new KActionMenuPrivate;
1530 setShortcutConfigurable( false ); 1531 setShortcutConfigurable( false );
1531} 1532}
1532 1533
1533KActionMenu::KActionMenu( const QString& text, const QString& icon, 1534KActionMenu::KActionMenu( const QString& text, const QString& icon,
1534 QObject* parent, const char* name ) 1535 QObject* parent, const char* name )
1535 : KAction( text, icon, 0, parent, name ) 1536 : KAction( text, icon, 0, parent, name )
1536{ 1537{
1537 d = new KActionMenuPrivate; 1538 d = new KActionMenuPrivate;
1538 setShortcutConfigurable( false ); 1539 setShortcutConfigurable( false );
1539} 1540}
1540 1541
1541KActionMenu::~KActionMenu() 1542KActionMenu::~KActionMenu()
1542{ 1543{
1543 unplugAll(); 1544 unplugAll();
1544 kdDebug(129) << "KActionMenu::~KActionMenu()" << endl; // ellis 1545 kdDebug(129) << "KActionMenu::~KActionMenu()" << endl; // ellis
1545 delete d; d = 0; 1546 delete d; d = 0;
1546} 1547}
1547 1548
1548void KActionMenu::popup( const QPoint& global ) 1549void KActionMenu::popup( const QPoint& global )
1549{ 1550{
1550 popupMenu()->popup( global ); 1551 popupMenu()->popup( global );
1551} 1552}
1552 1553
1553 1554
1554//US KPopupMenu* KActionMenu::popupMenu() const 1555//US KPopupMenu* KActionMenu::popupMenu() const
1555QPopupMenu* KActionMenu::popupMenu() const 1556Q3PopupMenu* KActionMenu::popupMenu() const
1556{ 1557{
1557 return d->m_popup; 1558 return d->m_popup;
1558} 1559}
1559 1560
1560void KActionMenu::insert( KAction* cmd, int index ) 1561void KActionMenu::insert( KAction* cmd, int index )
1561{ 1562{
1562 if ( cmd ) 1563 if ( cmd )
1563 cmd->plug( d->m_popup, index ); 1564 cmd->plug( d->m_popup, index );
1564} 1565}
1565 1566
1566void KActionMenu::remove( KAction* cmd ) 1567void KActionMenu::remove( KAction* cmd )
1567{ 1568{
1568 if ( cmd ) 1569 if ( cmd )
1569 cmd->unplug( d->m_popup ); 1570 cmd->unplug( d->m_popup );
1570} 1571}
1571 1572
1572bool KActionMenu::delayed() const { 1573bool KActionMenu::delayed() const {
1573 return d->m_delayed; 1574 return d->m_delayed;
1574} 1575}
1575 1576
1576void KActionMenu::setDelayed(bool _delayed) { 1577void KActionMenu::setDelayed(bool _delayed) {
1577 d->m_delayed = _delayed; 1578 d->m_delayed = _delayed;
1578} 1579}
1579 1580
1580bool KActionMenu::stickyMenu() const { 1581bool KActionMenu::stickyMenu() const {
1581 return d->m_stickyMenu; 1582 return d->m_stickyMenu;
1582} 1583}
1583 1584
1584void KActionMenu::setStickyMenu(bool sticky) { 1585void KActionMenu::setStickyMenu(bool sticky) {
1585 d->m_stickyMenu = sticky; 1586 d->m_stickyMenu = sticky;
1586} 1587}
1587 1588
1588int KActionMenu::plug( QWidget* widget, int index ) 1589int KActionMenu::plug( QWidget* widget, int index )
1589{ 1590{
1590/*US 1591/*US
1591 if (kapp && !kapp->authorizeKAction(name())) 1592 if (kapp && !kapp->authorizeKAction(name()))
1592 return -1; 1593 return -1;
1593*/ 1594*/
1594 kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis 1595 kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis
1595 if ( widget->inherits("QPopupMenu") ) 1596 if ( widget->inherits("Q3PopupMenu") )
1596 { 1597 {
1597 QPopupMenu* menu = static_cast<QPopupMenu*>( widget ); 1598 Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( widget );
1598 int id; 1599 int id;
1599 if ( hasIconSet() ) 1600 if ( hasIconSet() )
1600 id = menu->insertItem( iconSet(), text(), d->m_popup, -1, index ); 1601 id = menu->insertItem( iconSet(), text(), d->m_popup, -1, index );
1601 else 1602 else
1602 id = menu->insertItem( text(), d->m_popup, -1, index ); 1603 id = menu->insertItem( text(), d->m_popup, -1, index );
1603 1604
1604 if ( !isEnabled() ) 1605 if ( !isEnabled() )
1605 menu->setItemEnabled( id, false ); 1606 menu->setItemEnabled( id, false );
1606 1607
1607 addContainer( menu, id ); 1608 addContainer( menu, id );
1608 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 1609 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
1609 1610
1610 if ( m_parentCollection ) 1611 if ( m_parentCollection )
1611 m_parentCollection->connectHighlight( menu, this ); 1612 m_parentCollection->connectHighlight( menu, this );
1612 1613
1613 return containerCount() - 1; 1614 return containerCount() - 1;
1614 } 1615 }
1615 else if ( widget->inherits( "KToolBar" ) ) 1616 else if ( widget->inherits( "KToolBar" ) )
1616 { 1617 {
1617 KToolBar *bar = static_cast<KToolBar *>( widget ); 1618 KToolBar *bar = static_cast<KToolBar *>( widget );
1618 1619
1619 int id_ = KAction::getToolButtonID(); 1620 int id_ = KAction::getToolButtonID();
1620 1621
1621 if ( icon().isEmpty() && !iconSet().isNull() ) 1622 if ( icon().isEmpty() && !iconSet().isNull() )
1622 bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, 1623 bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this,
1623 SLOT( slotActivated() ), isEnabled(), plainText(), 1624 SLOT( slotActivated() ), isEnabled(), plainText(),
1624 index ); 1625 index );
1625 else 1626 else
1626 { 1627 {
1627 /*US 1628 /*US
1628 KInstance *instance; 1629 KInstance *instance;
1629 1630
1630 if ( m_parentCollection ) 1631 if ( m_parentCollection )
1631 instance = m_parentCollection->instance(); 1632 instance = m_parentCollection->instance();
1632 else 1633 else
1633 instance = KGlobal::instance(); 1634 instance = KGlobal::instance();
1634*/ 1635*/
1635 bar->insertButton( icon(), id_, SIGNAL( clicked() ), this, 1636 bar->insertButton( icon(), id_, SIGNAL( clicked() ), this,
1636 SLOT( slotActivated() ), isEnabled(), plainText(), 1637 SLOT( slotActivated() ), isEnabled(), plainText(),
1637 index/*US, instance */); 1638 index/*US, instance */);
1638 } 1639 }
1639 1640
1640 addContainer( bar, id_ ); 1641 addContainer( bar, id_ );
1641/*US 1642/*US
1642 if (!whatsThis().isEmpty()) 1643 if (!whatsThis().isEmpty())
1643 QWhatsThis::add( bar->getButton(id_), whatsThis() ); 1644 QWhatsThis::add( bar->getButton(id_), whatsThis() );
1644*/ 1645*/
1645 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 1646 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
1646 1647
1647 if (delayed()) { 1648 if (delayed()) {
1648 bar->setDelayedPopup( id_, popupMenu(), stickyMenu() ); 1649 bar->setDelayedPopup( id_, popupMenu(), stickyMenu() );
1649 } else { 1650 } else {
1650 bar->getButton(id_)->setPopup(popupMenu(), stickyMenu() ); 1651 bar->getButton(id_)->setPopup(popupMenu(), stickyMenu() );
1651 } 1652 }
1652 1653
1653 if ( m_parentCollection ) 1654 if ( m_parentCollection )
1654 m_parentCollection->connectHighlight( bar, this ); 1655 m_parentCollection->connectHighlight( bar, this );
1655 1656
1656 return containerCount() - 1; 1657 return containerCount() - 1;
1657 } 1658 }
1658 else if ( widget->inherits( "QMenuBar" ) ) 1659 else if ( widget->inherits( "QMenuBar" ) )
1659 { 1660 {
1660 QMenuBar *bar = static_cast<QMenuBar *>( widget ); 1661 QMenuBar *bar = static_cast<QMenuBar *>( widget );
1661 1662
1662 int id; 1663 int id;
1663 1664
1664 id = bar->insertItem( text(), popupMenu(), -1, index ); 1665 id = bar->insertItem( text(), popupMenu(), -1, index );
1665 1666
1666 if ( !isEnabled() ) 1667 if ( !isEnabled() )
1667 bar->setItemEnabled( id, false ); 1668 bar->setItemEnabled( id, false );
1668 1669
1669 addContainer( bar, id ); 1670 addContainer( bar, id );
1670 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 1671 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
1671 1672
1672 return containerCount() - 1; 1673 return containerCount() - 1;
1673 } 1674 }
1674 1675
1675 return -1; 1676 return -1;
1676} 1677}
1677 1678
1678//////// 1679////////
1679 1680
1680KToolBarPopupAction::KToolBarPopupAction( const QString& text, 1681KToolBarPopupAction::KToolBarPopupAction( const QString& text,
1681 const QString& icon, 1682 const QString& icon,
1682 const KShortcut& cut, 1683 const KShortcut& cut,
1683 QObject* parent, const char* name ) 1684 QObject* parent, const char* name )
1684 : KAction( text, icon, cut, parent, name ) 1685 : KAction( text, icon, cut, parent, name )
1685{ 1686{
1686 m_popup = 0; 1687 m_popup = 0;
1687 m_delayed = true; 1688 m_delayed = true;
1688 m_stickyMenu = true; 1689 m_stickyMenu = true;
1689} 1690}
1690 1691
1691KToolBarPopupAction::KToolBarPopupAction( const QString& text, 1692KToolBarPopupAction::KToolBarPopupAction( const QString& text,
1692 const QString& icon, 1693 const QString& icon,
1693 const KShortcut& cut, 1694 const KShortcut& cut,
1694 const QObject* receiver, 1695 const QObject* receiver,
1695 const char* slot, QObject* parent, 1696 const char* slot, QObject* parent,
1696 const char* name ) 1697 const char* name )
1697 : KAction( text, icon, cut, receiver, slot, parent, name ) 1698 : KAction( text, icon, cut, receiver, slot, parent, name )
1698{ 1699{
1699 m_popup = 0; 1700 m_popup = 0;
1700 m_delayed = true; 1701 m_delayed = true;
1701 m_stickyMenu = true; 1702 m_stickyMenu = true;
1702} 1703}
1703 1704
1704KToolBarPopupAction::KToolBarPopupAction( const KGuiItem& item, 1705KToolBarPopupAction::KToolBarPopupAction( const KGuiItem& item,
1705 const KShortcut& cut, 1706 const KShortcut& cut,
1706 const QObject* receiver, 1707 const QObject* receiver,
1707 const char* slot, KActionCollection* parent, 1708 const char* slot, KActionCollection* parent,
1708 const char* name ) 1709 const char* name )
1709 : KAction( item, cut, receiver, slot, parent, name ) 1710 : KAction( item, cut, receiver, slot, parent, name )
1710{ 1711{
1711 m_popup = 0; 1712 m_popup = 0;
1712 m_delayed = true; 1713 m_delayed = true;
1713 m_stickyMenu = true; 1714 m_stickyMenu = true;
1714} 1715}
1715 1716
1716 1717
1717KToolBarPopupAction::~KToolBarPopupAction() 1718KToolBarPopupAction::~KToolBarPopupAction()
1718{ 1719{
1719 if ( m_popup ) 1720 if ( m_popup )
1720 delete m_popup; 1721 delete m_popup;
1721} 1722}
1722 1723
1723bool KToolBarPopupAction::delayed() const { 1724bool KToolBarPopupAction::delayed() const {
1724 return m_delayed; 1725 return m_delayed;
1725} 1726}
1726 1727
1727void KToolBarPopupAction::setDelayed(bool delayed) { 1728void KToolBarPopupAction::setDelayed(bool delayed) {
1728 m_delayed = delayed; 1729 m_delayed = delayed;
1729} 1730}
1730 1731
1731bool KToolBarPopupAction::stickyMenu() const { 1732bool KToolBarPopupAction::stickyMenu() const {
1732 return m_stickyMenu; 1733 return m_stickyMenu;
1733} 1734}
1734 1735
1735void KToolBarPopupAction::setStickyMenu(bool sticky) { 1736void KToolBarPopupAction::setStickyMenu(bool sticky) {
1736 m_stickyMenu = sticky; 1737 m_stickyMenu = sticky;
1737} 1738}
1738 1739
1739int KToolBarPopupAction::plug( QWidget *widget, int index ) 1740int KToolBarPopupAction::plug( QWidget *widget, int index )
1740{ 1741{
1741/*US 1742/*US
1742 if (kapp && !kapp->authorizeKAction(name())) 1743 if (kapp && !kapp->authorizeKAction(name()))
1743 return -1; 1744 return -1;
1744*/ 1745*/
1745 // This is very related to KActionMenu::plug. 1746 // This is very related to KActionMenu::plug.
1746 // In fact this class could be an interesting base class for KActionMenu 1747 // In fact this class could be an interesting base class for KActionMenu
1747 if ( widget->inherits( "KToolBar" ) ) 1748 if ( widget->inherits( "KToolBar" ) )
1748 { 1749 {
1749 KToolBar *bar = (KToolBar *)widget; 1750 KToolBar *bar = (KToolBar *)widget;
1750 1751
1751 int id_ = KAction::getToolButtonID(); 1752 int id_ = KAction::getToolButtonID();
1752/*US 1753/*US
1753 KInstance * instance; 1754 KInstance * instance;
1754 if ( m_parentCollection ) 1755 if ( m_parentCollection )
1755 instance = m_parentCollection->instance(); 1756 instance = m_parentCollection->instance();
1756 else 1757 else
1757 instance = KGlobal::instance(); 1758 instance = KGlobal::instance();
1758*/ 1759*/
1759 bar->insertButton( icon(), id_, SIGNAL( clicked() ), this, 1760 bar->insertButton( icon(), id_, SIGNAL( clicked() ), this,
1760 SLOT( slotActivated() ), isEnabled(), plainText(), 1761 SLOT( slotActivated() ), isEnabled(), plainText(),
1761 index/*US, instance*/ ); 1762 index/*US, instance*/ );
1762 1763
1763 addContainer( bar, id_ ); 1764 addContainer( bar, id_ );
1764 1765
1765 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 1766 connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
1766 1767
1767 if (delayed()) { 1768 if (delayed()) {
1768 bar->setDelayedPopup( id_, popupMenu(), stickyMenu() ); 1769 bar->setDelayedPopup( id_, popupMenu(), stickyMenu() );
1769 } else { 1770 } else {
1770 bar->getButton(id_)->setPopup(popupMenu(), stickyMenu()); 1771 bar->getButton(id_)->setPopup(popupMenu(), stickyMenu());
1771 } 1772 }
1772/*US 1773/*US
1773 if ( !whatsThis().isEmpty() ) 1774 if ( !whatsThis().isEmpty() )
1774 QWhatsThis::add( bar->getButton( id_ ), whatsThisWithIcon() ); 1775 QWhatsThis::add( bar->getButton( id_ ), whatsThisWithIcon() );
1775*/ 1776*/
1776 return containerCount() - 1; 1777 return containerCount() - 1;
1777 } 1778 }
1778 1779
1779 1780
1780 return KAction::plug( widget, index ); 1781 return KAction::plug( widget, index );
1781} 1782}
1782 1783
1783//US KPopupMenu *KToolBarPopupAction::popupMenu() const 1784//US KPopupMenu *KToolBarPopupAction::popupMenu() const
1784QPopupMenu *KToolBarPopupAction::popupMenu() const 1785Q3PopupMenu *KToolBarPopupAction::popupMenu() const
1785{ 1786{
1786 if ( !m_popup ) { 1787 if ( !m_popup ) {
1787 KToolBarPopupAction *that = const_cast<KToolBarPopupAction*>(this); 1788 KToolBarPopupAction *that = const_cast<KToolBarPopupAction*>(this);
1788//US that->m_popup = new KPopupMenu; 1789//US that->m_popup = new KPopupMenu;
1789 that->m_popup = new QPopupMenu; 1790 that->m_popup = new Q3PopupMenu;
1790 } 1791 }
1791 return m_popup; 1792 return m_popup;
1792} 1793}
1793 1794
1794//////// 1795////////
1795 1796
1796KToggleToolBarAction::KToggleToolBarAction( const char* toolBarName, 1797KToggleToolBarAction::KToggleToolBarAction( const char* toolBarName,
1797 const QString& text, KActionCollection* parent, const char* name ) 1798 const QString& text, KActionCollection* parent, const char* name )
1798 : KToggleAction( text, KShortcut(), parent, name ) 1799 : KToggleAction( text, KShortcut(), parent, name )
1799 , m_toolBarName( toolBarName ) 1800 , m_toolBarName( toolBarName )
1800 , m_toolBar( 0L ) 1801 , m_toolBar( 0L )
1801{ 1802{
1802} 1803}
1803 1804
1804KToggleToolBarAction::KToggleToolBarAction( KToolBar *toolBar, const QString &text, 1805KToggleToolBarAction::KToggleToolBarAction( KToolBar *toolBar, const QString &text,
1805 KActionCollection *parent, const char *name ) 1806 KActionCollection *parent, const char *name )
1806 : KToggleAction( text, KShortcut(), parent, name ) 1807 : KToggleAction( text, KShortcut(), parent, name )
1807 , m_toolBarName( 0 ) 1808 , m_toolBarName( 0 )
1808 , m_toolBar( toolBar ) 1809 , m_toolBar( toolBar )
1809{ 1810{
1810} 1811}
1811 1812
1812KToggleToolBarAction::~KToggleToolBarAction() 1813KToggleToolBarAction::~KToggleToolBarAction()
1813{ 1814{
1814} 1815}
1815 1816
1816int KToggleToolBarAction::plug( QWidget* w, int index ) 1817int KToggleToolBarAction::plug( QWidget* w, int index )
1817{ 1818{
1818 qDebug("KToggleToolBarAction::plug has to be fixed"); 1819 qDebug("KToggleToolBarAction::plug has to be fixed");
1819/*US 1820/*US
1820 if (kapp && !kapp->authorizeKAction(name())) 1821 if (kapp && !kapp->authorizeKAction(name()))
1821 return -1; 1822 return -1;
1822 1823
1823 if ( !m_toolBar ) { 1824 if ( !m_toolBar ) {
1824 // Note: topLevelWidget() stops too early, we can't use it. 1825 // Note: topLevelWidget() stops too early, we can't use it.
1825 QWidget * tl = w; 1826 QWidget * tl = w;
1826 QWidget * n; 1827 QWidget * n;
1827 while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store 1828 while ( !tl->isDialog() && ( n = tl->parentWidget() ) ) // lookup parent and store
1828 tl = n; 1829 tl = n;
1829 1830
1830//US KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow 1831//US KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow
1831 QMainWindow * mw = 0; 1832 QMainWindow * mw = 0;
1832 if ( tl->inherits("QMainWindow") ) 1833 if ( tl->inherits("QMainWindow") )
1833 mw = (QMainWindow *)(tl); // try to see if it's a kmainwindow 1834 mw = (QMainWindow *)(tl); // try to see if it's a kmainwindow
1834 1835
1835 if ( mw ) 1836 if ( mw )
1836 m_toolBar = mw->toolBar( m_toolBarName ); 1837 m_toolBar = mw->toolBar( m_toolBarName );
1837 } 1838 }
1838 1839
1839 if( m_toolBar ) { 1840 if( m_toolBar ) {
1840 setChecked( m_toolBar->isVisible() ); 1841 setChecked( m_toolBar->isVisible() );
1841 connect( m_toolBar, SIGNAL(visibilityChanged(bool)), this, SLOT(setChecked(bool)) ); 1842 connect( m_toolBar, SIGNAL(visibilityChanged(bool)), this, SLOT(setChecked(bool)) );
1842 // Also emit toggled when the toolbar's visibility changes (see comment in header) 1843 // Also emit toggled when the toolbar's visibility changes (see comment in header)
1843 connect( m_toolBar, SIGNAL(visibilityChanged(bool)), this, SIGNAL(toggled(bool)) ); 1844 connect( m_toolBar, SIGNAL(visibilityChanged(bool)), this, SIGNAL(toggled(bool)) );
1844 } else { 1845 } else {
1845 setEnabled( false ); 1846 setEnabled( false );
1846 } 1847 }
1847*/ 1848*/
1848 return KToggleAction::plug( w, index ); 1849 return KToggleAction::plug( w, index );
1849} 1850}
1850 1851
1851void KToggleToolBarAction::setChecked( bool c ) 1852void KToggleToolBarAction::setChecked( bool c )
1852{ 1853{
1853 if( m_toolBar && c != m_toolBar->isVisible() ) { 1854 if( m_toolBar && c != m_toolBar->isVisible() ) {
1854 if( c ) { 1855 if( c ) {
1855 m_toolBar->show(); 1856 m_toolBar->show();
1856 } else { 1857 } else {
1857 m_toolBar->hide(); 1858 m_toolBar->hide();
1858 } 1859 }
1859 qDebug("KToggleToolBarAction::setChecked has to be fixed"); 1860 qDebug("KToggleToolBarAction::setChecked has to be fixed");
1860/*US 1861/*US
1861 QMainWindow* mw = m_toolBar->mainWindow(); 1862 QMainWindow* mw = m_toolBar->mainWindow();
1862 if ( mw && mw->inherits( "KMainWindow" ) ) 1863 if ( mw && mw->inherits( "KMainWindow" ) )
1863 static_cast<KMainWindow *>( mw )->setSettingsDirty(); 1864 static_cast<KMainWindow *>( mw )->setSettingsDirty();
1864*/ 1865*/
1865 } 1866 }
1866 KToggleAction::setChecked( c ); 1867 KToggleAction::setChecked( c );
1867 1868
1868} 1869}
1869 1870
1870//////// 1871////////
1871 1872
1872KWidgetAction::KWidgetAction( QWidget* widget, 1873KWidgetAction::KWidgetAction( QWidget* widget,
1873 const QString& text, const KShortcut& cut, 1874 const QString& text, const KShortcut& cut,
1874 const QObject* receiver, const char* slot, 1875 const QObject* receiver, const char* slot,
1875 KActionCollection* parent, const char* name ) 1876 KActionCollection* parent, const char* name )
1876 : KAction( text, cut, receiver, slot, parent, name ) 1877 : KAction( text, cut, receiver, slot, parent, name )
1877 , m_widget( widget ) 1878 , m_widget( widget )
1878 , m_autoSized( false ) 1879 , m_autoSized( false )
1879{ 1880{
1880} 1881}
1881 1882
1882KWidgetAction::~KWidgetAction() 1883KWidgetAction::~KWidgetAction()
1883{ 1884{
1884} 1885}
1885 1886
1886void KWidgetAction::setAutoSized( bool autoSized ) 1887void KWidgetAction::setAutoSized( bool autoSized )
1887{ 1888{
1888 if( m_autoSized == autoSized ) 1889 if( m_autoSized == autoSized )
1889 return; 1890 return;
1890 1891
1891 m_autoSized = autoSized; 1892 m_autoSized = autoSized;
1892 1893
1893 if( !m_widget || !isPlugged() ) 1894 if( !m_widget || !isPlugged() )
1894 return; 1895 return;
1895 1896
1896 KToolBar* toolBar = (KToolBar*)m_widget->parent(); 1897 KToolBar* toolBar = (KToolBar*)m_widget->parent();
1897 int i = findContainer( toolBar ); 1898 int i = findContainer( toolBar );
1898 if ( i == -1 ) 1899 if ( i == -1 )
1899 return; 1900 return;
1900 int id = itemId( i ); 1901 int id = itemId( i );
1901 1902
1902 toolBar->setItemAutoSized( id, m_autoSized ); 1903 toolBar->setItemAutoSized( id, m_autoSized );
1903 1904
1904} 1905}
1905 1906
1906int KWidgetAction::plug( QWidget* w, int index ) 1907int KWidgetAction::plug( QWidget* w, int index )
1907{ 1908{
1908/*US 1909/*US
1909 if (kapp && !kapp->authorizeKAction(name())) 1910 if (kapp && !kapp->authorizeKAction(name()))
1910 return -1; 1911 return -1;
1911*/ 1912*/
1912 if ( !w->inherits( "KToolBar" ) ) { 1913 if ( !w->inherits( "KToolBar" ) ) {
1913 kdError() << "KWidgetAction::plug: KWidgetAction must be plugged into KToolBar." << endl; 1914 kdError() << "KWidgetAction::plug: KWidgetAction must be plugged into KToolBar." << endl;
1914 return -1; 1915 return -1;
1915 } 1916 }
1916 if ( !m_widget ) { 1917 if ( !m_widget ) {
1917 kdError() << "KWidgetAction::plug: Widget was deleted or null!" << endl; 1918 kdError() << "KWidgetAction::plug: Widget was deleted or null!" << endl;
1918 return -1; 1919 return -1;
1919 } 1920 }
1920 1921
1921 KToolBar* toolBar = static_cast<KToolBar*>( w ); 1922 KToolBar* toolBar = static_cast<KToolBar*>( w );
1922 1923
1923 int id = KAction::getToolButtonID(); 1924 int id = KAction::getToolButtonID();
1924 1925
1925 m_widget->reparent( toolBar, QPoint() ); 1926 m_widget->reparent( toolBar, QPoint() );
1926 toolBar->insertWidget( id, 0, m_widget, index ); 1927 toolBar->insertWidget( id, 0, m_widget, index );
1927 toolBar->setItemAutoSized( id, m_autoSized ); 1928 toolBar->setItemAutoSized( id, m_autoSized );
1928 1929
1929//US QWhatsThis::add( m_widget, whatsThis() ); 1930//US QWhatsThis::add( m_widget, whatsThis() );
1930 addContainer( toolBar, id ); 1931 addContainer( toolBar, id );
1931 1932
1932 connect( toolBar, SIGNAL( toolbarDestroyed() ), this, SLOT( slotToolbarDestroyed() ) ); 1933 connect( toolBar, SIGNAL( toolbarDestroyed() ), this, SLOT( slotToolbarDestroyed() ) );
1933 connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 1934 connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
1934 1935
1935 return containerCount() - 1; 1936 return containerCount() - 1;
1936} 1937}
1937 1938
1938void KWidgetAction::unplug( QWidget *w ) 1939void KWidgetAction::unplug( QWidget *w )
1939{ 1940{
1940 if( !m_widget || !isPlugged() ) 1941 if( !m_widget || !isPlugged() )
1941 return; 1942 return;
1942 1943
1943 KToolBar* toolBar = (KToolBar*)m_widget->parent(); 1944 KToolBar* toolBar = (KToolBar*)m_widget->parent();
1944 if ( toolBar == w ) 1945 if ( toolBar == w )
1945 { 1946 {
1946 disconnect( toolBar, SIGNAL( toolbarDestroyed() ), this, SLOT( slotToolbarDestroyed() ) ); 1947 disconnect( toolBar, SIGNAL( toolbarDestroyed() ), this, SLOT( slotToolbarDestroyed() ) );
1947 m_widget->reparent( 0L, QPoint(), false ); // false = showit 1948 m_widget->reparent( 0L, QPoint(), false ); // false = showit
1948 } 1949 }
1949 KAction::unplug( w ); 1950 KAction::unplug( w );
1950} 1951}
1951 1952
1952void KWidgetAction::slotToolbarDestroyed() 1953void KWidgetAction::slotToolbarDestroyed()
1953{ 1954{
1954 //Q_ASSERT( m_widget ); // When exiting the app the widget could be destroyed before the toolbar. 1955 //Q_ASSERT( m_widget ); // When exiting the app the widget could be destroyed before the toolbar.
1955 1956
1956 ASSERT( isPlugged() ); 1957 Q_ASSERT( isPlugged() );
1957 if( !m_widget || !isPlugged() ) 1958 if( !m_widget || !isPlugged() )
1958 return; 1959 return;
1959 1960
1960 // Don't let a toolbar being destroyed, delete my widget. 1961 // Don't let a toolbar being destroyed, delete my widget.
1961 m_widget->reparent( 0L, QPoint(), false /*showIt*/ ); 1962 m_widget->reparent( 0L, QPoint(), false /*showIt*/ );
1962} 1963}
1963 1964
1964//////// 1965////////
1965 1966
1966KActionSeparator::KActionSeparator( QObject *parent, const char *name ) 1967KActionSeparator::KActionSeparator( QObject *parent, const char *name )
1967 : KAction( parent, name ) 1968 : KAction( parent, name )
1968{ 1969{
1969} 1970}
1970 1971
1971KActionSeparator::~KActionSeparator() 1972KActionSeparator::~KActionSeparator()
1972{ 1973{
1973} 1974}
1974 1975
1975int KActionSeparator::plug( QWidget *widget, int index ) 1976int KActionSeparator::plug( QWidget *widget, int index )
1976{ 1977{
1977 if ( widget->inherits("QPopupMenu") ) 1978 if ( widget->inherits("Q3PopupMenu") )
1978 { 1979 {
1979 QPopupMenu* menu = static_cast<QPopupMenu*>( widget ); 1980 Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( widget );
1980 1981
1981 int id = menu->insertSeparator( index ); 1982 int id = menu->insertSeparator( index );
1982 1983
1983 addContainer( menu, id ); 1984 addContainer( menu, id );
1984 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 1985 connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
1985 1986
1986 return containerCount() - 1; 1987 return containerCount() - 1;
1987 } 1988 }
1988 else if ( widget->inherits( "QMenuBar" ) ) 1989 else if ( widget->inherits( "QMenuBar" ) )
1989 { 1990 {
1990 QMenuBar *menuBar = static_cast<QMenuBar *>( widget ); 1991 QMenuBar *menuBar = static_cast<QMenuBar *>( widget );
1991 1992
1992 int id = menuBar->insertSeparator( index ); 1993 int id = menuBar->insertSeparator( index );
1993 1994
1994 addContainer( menuBar, id ); 1995 addContainer( menuBar, id );
1995 1996
1996 connect( menuBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 1997 connect( menuBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
1997 1998
1998 return containerCount() - 1; 1999 return containerCount() - 1;
1999 } 2000 }
2000 else if ( widget->inherits( "KToolBar" ) ) 2001 else if ( widget->inherits( "KToolBar" ) )
2001 { 2002 {
2002 KToolBar *toolBar = static_cast<KToolBar *>( widget ); 2003 KToolBar *toolBar = static_cast<KToolBar *>( widget );
2003 2004
2004 int id = toolBar->insertSeparator( index ); 2005 int id = toolBar->insertSeparator( index );
2005// toolBar->addSeparator(); 2006// toolBar->addSeparator();
2006 2007
2007 addContainer( toolBar, id ); 2008 addContainer( toolBar, id );
2008 2009
2009 connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); 2010 connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
2010 2011
2011 return containerCount() - 1; 2012 return containerCount() - 1;
2012 } 2013 }
2013 2014
2014 return -1; 2015 return -1;
2015} 2016}
2016 2017
2017void KToggleAction::virtual_hook( int id, void* data ) 2018void KToggleAction::virtual_hook( int id, void* data )
2018{ KAction::virtual_hook( id, data ); } 2019{ KAction::virtual_hook( id, data ); }
2019 2020
2020void KRadioAction::virtual_hook( int id, void* data ) 2021void KRadioAction::virtual_hook( int id, void* data )
2021{ KToggleAction::virtual_hook( id, data ); } 2022{ KToggleAction::virtual_hook( id, data ); }
2022 2023
2023void KSelectAction::virtual_hook( int id, void* data ) 2024void KSelectAction::virtual_hook( int id, void* data )
2024{ KAction::virtual_hook( id, data ); } 2025{ KAction::virtual_hook( id, data ); }
2025 2026
2026void KListAction::virtual_hook( int id, void* data ) 2027void KListAction::virtual_hook( int id, void* data )
2027{ KSelectAction::virtual_hook( id, data ); } 2028{ KSelectAction::virtual_hook( id, data ); }
2028 2029
2029void KRecentFilesAction::virtual_hook( int id, void* data ) 2030void KRecentFilesAction::virtual_hook( int id, void* data )
2030{ KListAction::virtual_hook( id, data ); } 2031{ KListAction::virtual_hook( id, data ); }
2031 2032
2032void KFontAction::virtual_hook( int id, void* data ) 2033void KFontAction::virtual_hook( int id, void* data )
2033{ KSelectAction::virtual_hook( id, data ); } 2034{ KSelectAction::virtual_hook( id, data ); }
2034 2035
2035void KFontSizeAction::virtual_hook( int id, void* data ) 2036void KFontSizeAction::virtual_hook( int id, void* data )
2036{ KSelectAction::virtual_hook( id, data ); } 2037{ KSelectAction::virtual_hook( id, data ); }
2037 2038
2038void KActionMenu::virtual_hook( int id, void* data ) 2039void KActionMenu::virtual_hook( int id, void* data )
2039{ KAction::virtual_hook( id, data ); } 2040{ KAction::virtual_hook( id, data ); }
2040 2041
2041void KToolBarPopupAction::virtual_hook( int id, void* data ) 2042void KToolBarPopupAction::virtual_hook( int id, void* data )
2042{ KAction::virtual_hook( id, data ); } 2043{ KAction::virtual_hook( id, data ); }
2043 2044
2044void KToggleToolBarAction::virtual_hook( int id, void* data ) 2045void KToggleToolBarAction::virtual_hook( int id, void* data )
2045{ KToggleAction::virtual_hook( id, data ); } 2046{ KToggleAction::virtual_hook( id, data ); }
2046 2047
2047void KWidgetAction::virtual_hook( int id, void* data ) 2048void KWidgetAction::virtual_hook( int id, void* data )
2048{ KAction::virtual_hook( id, data ); } 2049{ KAction::virtual_hook( id, data ); }
2049 2050
2050void KActionSeparator::virtual_hook( int id, void* data ) 2051void KActionSeparator::virtual_hook( int id, void* data )
2051{ KAction::virtual_hook( id, data ); } 2052{ KAction::virtual_hook( id, data ); }
2052 2053
2053/* vim: et sw=2 ts=2 2054/* vim: et sw=2 ts=2
2054 */ 2055 */
2055 2056
2056/*US 2057/*US
2057#include "kactionclasses.moc" 2058#include "kactionclasses.moc"
2058*/ 2059*/
diff --git a/microkde/kdeui/kactionclasses.h b/microkde/kdeui/kactionclasses.h
index f6e7a0f..a9b9104 100644
--- a/microkde/kdeui/kactionclasses.h
+++ b/microkde/kdeui/kactionclasses.h
@@ -1,1223 +1,1226 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org> 3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org> 4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org> 5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org> 6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org> 7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org> 8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 9
10 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public 11 modify it under the terms of the GNU Library General Public
12 License version 2 as published by the Free Software Foundation. 12 License version 2 as published by the Free Software Foundation.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23*/ 23*/
24//$Id$ 24//$Id$
25 25
26#ifndef __kactionclasses_h__ 26#ifndef __kactionclasses_h__
27#define __kactionclasses_h__ 27#define __kactionclasses_h__
28 28
29#include <kaction.h> 29#include <kaction.h>
30 30
31//US#include <qkeysequence.h> 31//US#include <qkeysequence.h>
32//US#include <qobject.h> 32//US#include <qobject.h>
33//US#include <qvaluelist.h> 33//US#include <qvaluelist.h>
34//US#include <qguardedptr.h> 34//US#include <qguardedptr.h>
35//US#include <kguiitem.h> 35//US#include <kguiitem.h>
36#include <kshortcut.h> 36#include <kshortcut.h>
37//Added by qt3to4:
38#include <Q3CString>
39#include <Q3PopupMenu>
37//US#include <kstdaction.h> 40//US#include <kstdaction.h>
38//US#include <kicontheme.h> 41//US#include <kicontheme.h>
39 42
40class QMenuBar; 43class QMenuBar;
41class QPopupMenu; 44class Q3PopupMenu;
42//USclass QComboBox; 45//USclass QComboBox;
43//USclass QPoint; 46//USclass QPoint;
44//USclass QIconSet; 47//USclass QIconSet;
45//USclass QString; 48//USclass QString;
46//USclass KToolBar; 49//USclass KToolBar;
47 50
48//USclass KAccel; 51//USclass KAccel;
49//USclass KAccelActions; 52//USclass KAccelActions;
50class KConfig; 53class KConfig;
51//USclass KConfigBase; 54//USclass KConfigBase;
52class KURL; 55class KURL;
53//USclass KInstance; 56//USclass KInstance;
54 57
55 58
56//US class KToolBar needs to be replaced 59//US class KToolBar needs to be replaced
57class KToolBar; 60#include "ktoolbar.h"
58class KActionCollection; 61class KActionCollection;
59 62
60//US class KPopupMenu needs to be replaced 63//US class KPopupMenu needs to be replaced
61//US class KPopupMenu; 64//US class KPopupMenu;
62//USclass KMainWindow; 65//USclass KMainWindow;
63 66
64/** 67/**
65 * Checkbox like action. 68 * Checkbox like action.
66 * 69 *
67 * This action provides two states: checked or not. 70 * This action provides two states: checked or not.
68 * 71 *
69 * @short Checkbox like action. 72 * @short Checkbox like action.
70 */ 73 */
71class KToggleAction : public KAction 74class KToggleAction : public KAction
72{ 75{
73 Q_OBJECT 76 Q_OBJECT
74 Q_PROPERTY( bool checked READ isChecked WRITE setChecked ) 77 Q_PROPERTY( bool checked READ isChecked WRITE setChecked )
75 Q_PROPERTY( QString exclusiveGroup READ exclusiveGroup WRITE setExclusiveGroup ) 78 Q_PROPERTY( QString exclusiveGroup READ exclusiveGroup WRITE setExclusiveGroup )
76public: 79public:
77 80
78 /** 81 /**
79 * Constructs a toggle action with text and potential keyboard 82 * Constructs a toggle action with text and potential keyboard
80 * accelerator but nothing else. Use this only if you really 83 * accelerator but nothing else. Use this only if you really
81 * know what you are doing. 84 * know what you are doing.
82 * 85 *
83 * @param text The text that will be displayed. 86 * @param text The text that will be displayed.
84 * @param cut The corresponding keyboard accelerator (shortcut). 87 * @param cut The corresponding keyboard accelerator (shortcut).
85 * @param parent This action's parent. 88 * @param parent This action's parent.
86 * @param name An internal name for this action. 89 * @param name An internal name for this action.
87 */ 90 */
88 KToggleAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 ); 91 KToggleAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
89 92
90 /** 93 /**
91 * @param text The text that will be displayed. 94 * @param text The text that will be displayed.
92 * @param cut The corresponding keyboard accelerator (shortcut). 95 * @param cut The corresponding keyboard accelerator (shortcut).
93 * @param receiver The SLOT's parent. 96 * @param receiver The SLOT's parent.
94 * @param slot The SLOT to invoke to execute this action. 97 * @param slot The SLOT to invoke to execute this action.
95 * @param parent This action's parent. 98 * @param parent This action's parent.
96 * @param name An internal name for this action. 99 * @param name An internal name for this action.
97 */ 100 */
98 KToggleAction( const QString& text, const KShortcut& cut, 101 KToggleAction( const QString& text, const KShortcut& cut,
99 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 102 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
100 103
101 /** 104 /**
102 * @param text The text that will be displayed. 105 * @param text The text that will be displayed.
103 * @param pix The icons that go with this action. 106 * @param pix The icons that go with this action.
104 * @param cut The corresponding keyboard accelerator (shortcut). 107 * @param cut The corresponding keyboard accelerator (shortcut).
105 * @param parent This action's parent. 108 * @param parent This action's parent.
106 * @param name An internal name for this action. 109 * @param name An internal name for this action.
107 */ 110 */
108 KToggleAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), 111 KToggleAction( const QString& text, const QIcon& pix, const KShortcut& cut = KShortcut(),
109 QObject* parent = 0, const char* name = 0 ); 112 QObject* parent = 0, const char* name = 0 );
110 113
111 /** 114 /**
112 * @param text The text that will be displayed. 115 * @param text The text that will be displayed.
113 * @param pix The dynamically loaded icon that goes with this action. 116 * @param pix The dynamically loaded icon that goes with this action.
114 * @param cut The corresponding keyboard accelerator (shortcut). 117 * @param cut The corresponding keyboard accelerator (shortcut).
115 * @param parent This action's parent. 118 * @param parent This action's parent.
116 * @param name An internal name for this action. 119 * @param name An internal name for this action.
117 */ 120 */
118 KToggleAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), 121 KToggleAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
119 QObject* parent = 0, const char* name = 0 ); 122 QObject* parent = 0, const char* name = 0 );
120 123
121 /** 124 /**
122 * @param text The text that will be displayed. 125 * @param text The text that will be displayed.
123 * @param pix The icons that go with this action. 126 * @param pix The icons that go with this action.
124 * @param cut The corresponding keyboard accelerator (shortcut). 127 * @param cut The corresponding keyboard accelerator (shortcut).
125 * @param receiver The SLOT's parent. 128 * @param receiver The SLOT's parent.
126 * @param slot The SLOT to invoke to execute this action. 129 * @param slot The SLOT to invoke to execute this action.
127 * @param parent This action's parent. 130 * @param parent This action's parent.
128 * @param name An internal name for this action. 131 * @param name An internal name for this action.
129 */ 132 */
130 KToggleAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 133 KToggleAction( const QString& text, const QIcon& pix, const KShortcut& cut,
131 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 134 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
132 135
133 /** 136 /**
134 * @param text The text that will be displayed. 137 * @param text The text that will be displayed.
135 * @param pix The dynamically loaded icon that goes with this action. 138 * @param pix The dynamically loaded icon that goes with this action.
136 * @param cut The corresponding keyboard accelerator (shortcut). 139 * @param cut The corresponding keyboard accelerator (shortcut).
137 * @param receiver The SLOT's parent. 140 * @param receiver The SLOT's parent.
138 * @param slot The SLOT to invoke to execute this action. 141 * @param slot The SLOT to invoke to execute this action.
139 * @param parent This action's parent. 142 * @param parent This action's parent.
140 * @param name An internal name for this action. 143 * @param name An internal name for this action.
141 */ 144 */
142 KToggleAction( const QString& text, const QString& pix, const KShortcut& cut, 145 KToggleAction( const QString& text, const QString& pix, const KShortcut& cut,
143 const QObject* receiver, const char* slot, 146 const QObject* receiver, const char* slot,
144 QObject* parent, const char* name = 0 ); 147 QObject* parent, const char* name = 0 );
145 148
146 /** 149 /**
147 * @param parent This action's parent. 150 * @param parent This action's parent.
148 * @param name An internal name for this action. 151 * @param name An internal name for this action.
149 */ 152 */
150 KToggleAction( QObject* parent = 0, const char* name = 0 ); 153 KToggleAction( QObject* parent = 0, const char* name = 0 );
151 154
152 /** 155 /**
153 * Destructor 156 * Destructor
154 */ 157 */
155 virtual ~KToggleAction(); 158 virtual ~KToggleAction();
156 159
157 /** 160 /**
158 * "Plug" or insert this action into a given widget. 161 * "Plug" or insert this action into a given widget.
159 * 162 *
160 * This will typically be a menu or a toolbar. From this point 163 * This will typically be a menu or a toolbar. From this point
161 * on, you will never need to directly manipulate the item in the 164 * on, you will never need to directly manipulate the item in the
162 * menu or toolbar. You do all enabling/disabling/manipulation 165 * menu or toolbar. You do all enabling/disabling/manipulation
163 * directly with your KToggleAction object. 166 * directly with your KToggleAction object.
164 * 167 *
165 * @param widget The GUI element to display this action. 168 * @param widget The GUI element to display this action.
166 * @param index The index of the item. 169 * @param index The index of the item.
167 */ 170 */
168 virtual int plug( QWidget* widget, int index = -1 ); 171 virtual int plug( QWidget* widget, int index = -1 );
169 172
170 /** 173 /**
171 * Returns the actual state of the action. 174 * Returns the actual state of the action.
172 */ 175 */
173 bool isChecked() const; 176 bool isChecked() const;
174 177
175 /** 178 /**
176 * @return which "exclusive group" this action is part of. 179 * @return which "exclusive group" this action is part of.
177 * @see setExclusiveGroup 180 * @see setExclusiveGroup
178 */ 181 */
179 QString exclusiveGroup() const; 182 QString exclusiveGroup() const;
180 183
181 /** 184 /**
182 * Defines which "exclusive group" this action is part of. 185 * Defines which "exclusive group" this action is part of.
183 * In a given exclusive group, only one toggle action can be checked 186 * In a given exclusive group, only one toggle action can be checked
184 * at a any moment. Checking an action unchecks the other actions 187 * at a any moment. Checking an action unchecks the other actions
185 * of the group. 188 * of the group.
186 */ 189 */
187 virtual void setExclusiveGroup( const QString& name ); 190 virtual void setExclusiveGroup( const QString& name );
188 191
189public slots: 192public slots:
190 /** 193 /**
191 * Sets the state of the action. 194 * Sets the state of the action.
192 */ 195 */
193 virtual void setChecked( bool ); 196 virtual void setChecked( bool );
194 197
195protected slots: 198protected slots:
196 virtual void slotActivated(); 199 virtual void slotActivated();
197 200
198protected: 201protected:
199 virtual void updateChecked( int id ); 202 virtual void updateChecked( int id );
200 203
201signals: 204signals:
202 void toggled( bool ); 205 void toggled( bool );
203 206
204protected: 207protected:
205 virtual void virtual_hook( int id, void* data ); 208 virtual void virtual_hook( int id, void* data );
206private: 209private:
207 class KToggleActionPrivate; 210 class KToggleActionPrivate;
208 KToggleActionPrivate *d; 211 KToggleActionPrivate *d;
209}; 212};
210 213
211/** 214/**
212 * An action that operates like a radio button. At any given time 215 * An action that operates like a radio button. At any given time
213 * only a single action from the group will be active. 216 * only a single action from the group will be active.
214 */ 217 */
215class KRadioAction : public KToggleAction 218class KRadioAction : public KToggleAction
216{ 219{
217 Q_OBJECT 220 Q_OBJECT
218public: 221public:
219 /** 222 /**
220 * Constructs a radio action with text and potential keyboard 223 * Constructs a radio action with text and potential keyboard
221 * accelerator but nothing else. Use this only if you really 224 * accelerator but nothing else. Use this only if you really
222 * know what you are doing. 225 * know what you are doing.
223 * 226 *
224 * @param text The text that will be displayed. 227 * @param text The text that will be displayed.
225 * @param cut The corresponding keyboard accelerator (shortcut). 228 * @param cut The corresponding keyboard accelerator (shortcut).
226 * @param parent This action's parent. 229 * @param parent This action's parent.
227 * @param name An internal name for this action. 230 * @param name An internal name for this action.
228 */ 231 */
229 KRadioAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 ); 232 KRadioAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
230 233
231 /** 234 /**
232 * @param text The text that will be displayed. 235 * @param text The text that will be displayed.
233 * @param cut The corresponding keyboard accelerator (shortcut). 236 * @param cut The corresponding keyboard accelerator (shortcut).
234 * @param receiver The SLOT's parent. 237 * @param receiver The SLOT's parent.
235 * @param slot The SLOT to invoke to execute this action. 238 * @param slot The SLOT to invoke to execute this action.
236 * @param parent This action's parent. 239 * @param parent This action's parent.
237 * @param name An internal name for this action. 240 * @param name An internal name for this action.
238 */ 241 */
239 KRadioAction( const QString& text, const KShortcut& cut, 242 KRadioAction( const QString& text, const KShortcut& cut,
240 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 243 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
241 244
242 /** 245 /**
243 * @param text The text that will be displayed. 246 * @param text The text that will be displayed.
244 * @param pix The icons that go with this action. 247 * @param pix The icons that go with this action.
245 * @param cut The corresponding keyboard accelerator (shortcut). 248 * @param cut The corresponding keyboard accelerator (shortcut).
246 * @param parent This action's parent. 249 * @param parent This action's parent.
247 * @param name An internal name for this action. 250 * @param name An internal name for this action.
248 */ 251 */
249 KRadioAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), 252 KRadioAction( const QString& text, const QIcon& pix, const KShortcut& cut = KShortcut(),
250 QObject* parent = 0, const char* name = 0 ); 253 QObject* parent = 0, const char* name = 0 );
251 254
252 /** 255 /**
253 * @param text The text that will be displayed. 256 * @param text The text that will be displayed.
254 * @param pix The dynamically loaded icon that goes with this action. 257 * @param pix The dynamically loaded icon that goes with this action.
255 * @param cut The corresponding keyboard accelerator (shortcut). 258 * @param cut The corresponding keyboard accelerator (shortcut).
256 * @param parent This action's parent. 259 * @param parent This action's parent.
257 * @param name An internal name for this action. 260 * @param name An internal name for this action.
258 */ 261 */
259 KRadioAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), 262 KRadioAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
260 QObject* parent = 0, const char* name = 0 ); 263 QObject* parent = 0, const char* name = 0 );
261 264
262 /** 265 /**
263 * @param text The text that will be displayed. 266 * @param text The text that will be displayed.
264 * @param pix The icons that go with this action. 267 * @param pix The icons that go with this action.
265 * @param cut The corresponding keyboard accelerator (shortcut). 268 * @param cut The corresponding keyboard accelerator (shortcut).
266 * @param receiver The SLOT's parent. 269 * @param receiver The SLOT's parent.
267 * @param slot The SLOT to invoke to execute this action. 270 * @param slot The SLOT to invoke to execute this action.
268 * @param parent This action's parent. 271 * @param parent This action's parent.
269 * @param name An internal name for this action. 272 * @param name An internal name for this action.
270 */ 273 */
271 KRadioAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 274 KRadioAction( const QString& text, const QIcon& pix, const KShortcut& cut,
272 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 275 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
273 276
274 /** 277 /**
275 * @param text The text that will be displayed. 278 * @param text The text that will be displayed.
276 * @param pix The dynamically loaded icon that goes with this action. 279 * @param pix The dynamically loaded icon that goes with this action.
277 * @param cut The corresponding keyboard accelerator (shortcut). 280 * @param cut The corresponding keyboard accelerator (shortcut).
278 * @param receiver The SLOT's parent. 281 * @param receiver The SLOT's parent.
279 * @param slot The SLOT to invoke to execute this action. 282 * @param slot The SLOT to invoke to execute this action.
280 * @param parent This action's parent. 283 * @param parent This action's parent.
281 * @param name An internal name for this action. 284 * @param name An internal name for this action.
282 */ 285 */
283 KRadioAction( const QString& text, const QString& pix, const KShortcut& cut, 286 KRadioAction( const QString& text, const QString& pix, const KShortcut& cut,
284 const QObject* receiver, const char* slot, 287 const QObject* receiver, const char* slot,
285 QObject* parent, const char* name = 0 ); 288 QObject* parent, const char* name = 0 );
286 289
287 /** 290 /**
288 * @param parent This action's parent. 291 * @param parent This action's parent.
289 * @param name An internal name for this action. 292 * @param name An internal name for this action.
290 */ 293 */
291 KRadioAction( QObject* parent = 0, const char* name = 0 ); 294 KRadioAction( QObject* parent = 0, const char* name = 0 );
292 295
293protected: 296protected:
294 virtual void slotActivated(); 297 virtual void slotActivated();
295 298
296protected: 299protected:
297 virtual void virtual_hook( int id, void* data ); 300 virtual void virtual_hook( int id, void* data );
298private: 301private:
299 class KRadioActionPrivate; 302 class KRadioActionPrivate;
300 KRadioActionPrivate *d; 303 KRadioActionPrivate *d;
301}; 304};
302 305
303/** 306/**
304 * Action for selecting one of several items. 307 * Action for selecting one of several items.
305 * 308 *
306 * This action shows up a submenu with a list of items. 309 * This action shows up a submenu with a list of items.
307 * One of them can be checked. If the user clicks on an item 310 * One of them can be checked. If the user clicks on an item
308 * this item will automatically be checked, 311 * this item will automatically be checked,
309 * the formerly checked item becomes unchecked. 312 * the formerly checked item becomes unchecked.
310 * There can be only one item checked at a time. 313 * There can be only one item checked at a time.
311 * 314 *
312 * @short Action for selecting one of several items 315 * @short Action for selecting one of several items
313 */ 316 */
314class KSelectAction : public KAction 317class KSelectAction : public KAction
315{ 318{
316 Q_OBJECT 319 Q_OBJECT
317 Q_PROPERTY( int currentItem READ currentItem WRITE setCurrentItem ) 320 Q_PROPERTY( int currentItem READ currentItem WRITE setCurrentItem )
318 Q_PROPERTY( QStringList items READ items WRITE setItems ) 321 Q_PROPERTY( QStringList items READ items WRITE setItems )
319 Q_PROPERTY( bool editable READ isEditable WRITE setEditable ) 322 Q_PROPERTY( bool editable READ isEditable WRITE setEditable )
320 Q_PROPERTY( int comboWidth READ comboWidth WRITE setComboWidth ) 323 Q_PROPERTY( int comboWidth READ comboWidth WRITE setComboWidth )
321 Q_PROPERTY( QString currentText READ currentText ) 324 Q_PROPERTY( QString currentText READ currentText )
322 Q_PROPERTY( bool menuAccelsEnabled READ menuAccelsEnabled WRITE setMenuAccelsEnabled ) 325 Q_PROPERTY( bool menuAccelsEnabled READ menuAccelsEnabled WRITE setMenuAccelsEnabled )
323public: 326public:
324 327
325 /** 328 /**
326 * Constructs a select action with text and potential keyboard 329 * Constructs a select action with text and potential keyboard
327 * accelerator but nothing else. Use this only if you really 330 * accelerator but nothing else. Use this only if you really
328 * know what you are doing. 331 * know what you are doing.
329 * 332 *
330 * @param text The text that will be displayed. 333 * @param text The text that will be displayed.
331 * @param cut The corresponding keyboard accelerator (shortcut). 334 * @param cut The corresponding keyboard accelerator (shortcut).
332 * @param parent This action's parent. 335 * @param parent This action's parent.
333 * @param name An internal name for this action. 336 * @param name An internal name for this action.
334 */ 337 */
335 KSelectAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 ); 338 KSelectAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
336 339
337 /** 340 /**
338 * @param text The text that will be displayed. 341 * @param text The text that will be displayed.
339 * @param cut The corresponding keyboard accelerator (shortcut). 342 * @param cut The corresponding keyboard accelerator (shortcut).
340 * @param receiver The SLOT's parent. 343 * @param receiver The SLOT's parent.
341 * @param slot The SLOT to invoke to execute this action. 344 * @param slot The SLOT to invoke to execute this action.
342 * @param parent This action's parent. 345 * @param parent This action's parent.
343 * @param name An internal name for this action. 346 * @param name An internal name for this action.
344 */ 347 */
345 KSelectAction( const QString& text, const KShortcut& cut, 348 KSelectAction( const QString& text, const KShortcut& cut,
346 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 349 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
347 350
348 /** 351 /**
349 * @param text The text that will be displayed. 352 * @param text The text that will be displayed.
350 * @param pix The icons that go with this action. 353 * @param pix The icons that go with this action.
351 * @param cut The corresponding keyboard accelerator (shortcut). 354 * @param cut The corresponding keyboard accelerator (shortcut).
352 * @param parent This action's parent. 355 * @param parent This action's parent.
353 * @param name An internal name for this action. 356 * @param name An internal name for this action.
354 */ 357 */
355 KSelectAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), 358 KSelectAction( const QString& text, const QIcon& pix, const KShortcut& cut = KShortcut(),
356 QObject* parent = 0, const char* name = 0 ); 359 QObject* parent = 0, const char* name = 0 );
357 360
358 /** 361 /**
359 * @param text The text that will be displayed. 362 * @param text The text that will be displayed.
360 * @param pix The dynamically loaded icon that goes with this action. 363 * @param pix The dynamically loaded icon that goes with this action.
361 * @param cut The corresponding keyboard accelerator (shortcut). 364 * @param cut The corresponding keyboard accelerator (shortcut).
362 * @param parent This action's parent. 365 * @param parent This action's parent.
363 * @param name An internal name for this action. 366 * @param name An internal name for this action.
364 */ 367 */
365 KSelectAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), 368 KSelectAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
366 QObject* parent = 0, const char* name = 0 ); 369 QObject* parent = 0, const char* name = 0 );
367 370
368 /** 371 /**
369 * @param text The text that will be displayed. 372 * @param text The text that will be displayed.
370 * @param pix The icons that go with this action. 373 * @param pix The icons that go with this action.
371 * @param cut The corresponding keyboard accelerator (shortcut). 374 * @param cut The corresponding keyboard accelerator (shortcut).
372 * @param receiver The SLOT's parent. 375 * @param receiver The SLOT's parent.
373 * @param slot The SLOT to invoke to execute this action. 376 * @param slot The SLOT to invoke to execute this action.
374 * @param parent This action's parent. 377 * @param parent This action's parent.
375 * @param name An internal name for this action. 378 * @param name An internal name for this action.
376 */ 379 */
377 KSelectAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 380 KSelectAction( const QString& text, const QIcon& pix, const KShortcut& cut,
378 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 ); 381 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
379 382
380 /** 383 /**
381 * @param text The text that will be displayed. 384 * @param text The text that will be displayed.
382 * @param pix The dynamically loaded icon that goes with this action. 385 * @param pix The dynamically loaded icon that goes with this action.
383 * @param cut The corresponding keyboard accelerator (shortcut). 386 * @param cut The corresponding keyboard accelerator (shortcut).
384 * @param receiver The SLOT's parent. 387 * @param receiver The SLOT's parent.
385 * @param slot The SLOT to invoke to execute this action. 388 * @param slot The SLOT to invoke to execute this action.
386 * @param parent This action's parent. 389 * @param parent This action's parent.
387 * @param name An internal name for this action. 390 * @param name An internal name for this action.
388 */ 391 */
389 KSelectAction( const QString& text, const QString& pix, const KShortcut& cut, 392 KSelectAction( const QString& text, const QString& pix, const KShortcut& cut,
390 const QObject* receiver, const char* slot, 393 const QObject* receiver, const char* slot,
391 QObject* parent, const char* name = 0 ); 394 QObject* parent, const char* name = 0 );
392 395
393 /** 396 /**
394 * @param parent This action's parent. 397 * @param parent This action's parent.
395 * @param name An internal name for this action. 398 * @param name An internal name for this action.
396 */ 399 */
397 KSelectAction( QObject* parent = 0, const char* name = 0 ); 400 KSelectAction( QObject* parent = 0, const char* name = 0 );
398 401
399 /** 402 /**
400 * Destructor 403 * Destructor
401 */ 404 */
402 virtual ~KSelectAction(); 405 virtual ~KSelectAction();
403 406
404 /** 407 /**
405 * "Plug" or insert this action into a given widget. 408 * "Plug" or insert this action into a given widget.
406 * 409 *
407 * This will typically be a menu or a toolbar. 410 * This will typically be a menu or a toolbar.
408 * From this point on, you will never need to directly 411 * From this point on, you will never need to directly
409 * manipulate the item in the menu or toolbar. 412 * manipulate the item in the menu or toolbar.
410 * You do all enabling/disabling/manipulation directly with your KSelectAction object. 413 * You do all enabling/disabling/manipulation directly with your KSelectAction object.
411 * 414 *
412 * @param widget The GUI element to display this action. 415 * @param widget The GUI element to display this action.
413 * @param index The index of the item. 416 * @param index The index of the item.
414 */ 417 */
415 virtual int plug( QWidget* widget, int index = -1 ); 418 virtual int plug( QWidget* widget, int index = -1 );
416 419
417 /** 420 /**
418 * When this action is plugged into a toolbar, it creates a combobox. 421 * When this action is plugged into a toolbar, it creates a combobox.
419 * @return true if the combo editable. 422 * @return true if the combo editable.
420 */ 423 */
421 virtual bool isEditable() const; 424 virtual bool isEditable() const;
422 425
423 /** 426 /**
424 * @return the items that can be selected with this action. 427 * @return the items that can be selected with this action.
425 * Use setItems to set them. 428 * Use setItems to set them.
426 */ 429 */
427 virtual QStringList items() const; 430 virtual QStringList items() const;
428 431
429 virtual void changeItem( int index, const QString& text ); 432 virtual void changeItem( int index, const QString& text );
430 433
431 virtual QString currentText() const; 434 virtual QString currentText() const;
432 435
433 virtual int currentItem() const; 436 virtual int currentItem() const;
434 437
435 /** 438 /**
436 * When this action is plugged into a toolbar, it creates a combobox. 439 * When this action is plugged into a toolbar, it creates a combobox.
437 * This returns the maximum width set by setComboWidth 440 * This returns the maximum width set by setComboWidth
438 */ 441 */
439 virtual int comboWidth() const; 442 virtual int comboWidth() const;
440 443
441 QPopupMenu* popupMenu() const; 444 Q3PopupMenu* popupMenu() const;
442 445
443 /** 446 /**
444 * Deprecated. See @ref setMenuAccelsEnabled . 447 * Deprecated. See @ref setMenuAccelsEnabled .
445 * @since 3.1 448 * @since 3.1
446 */ 449 */
447 void setRemoveAmpersandsInCombo( bool b ); 450 void setRemoveAmpersandsInCombo( bool b );
448 /// @since 3.1 451 /// @since 3.1
449 bool removeAmpersandsInCombo() const; 452 bool removeAmpersandsInCombo() const;
450 453
451 /** 454 /**
452 * Sets whether any occurence of the ampersand character ( &amp; ) in items 455 * Sets whether any occurence of the ampersand character ( &amp; ) in items
453 * should be interpreted as keyboard accelerator for items displayed in a 456 * should be interpreted as keyboard accelerator for items displayed in a
454 * menu or not. 457 * menu or not.
455 * @since 3.1 458 * @since 3.1
456 */ 459 */
457 void setMenuAccelsEnabled( bool b ); 460 void setMenuAccelsEnabled( bool b );
458 /// @since 3.1 461 /// @since 3.1
459 bool menuAccelsEnabled() const; 462 bool menuAccelsEnabled() const;
460 463
461public slots: 464public slots:
462 /** 465 /**
463 * Sets the currently checked item. 466 * Sets the currently checked item.
464 * 467 *
465 * @param index Index of the item (remember the first item is zero). 468 * @param index Index of the item (remember the first item is zero).
466 */ 469 */
467 virtual void setCurrentItem( int index ); 470 virtual void setCurrentItem( int index );
468 471
469 /** 472 /**
470 * Sets the items to be displayed in this action 473 * Sets the items to be displayed in this action
471 * You need to call this. 474 * You need to call this.
472 */ 475 */
473 virtual void setItems( const QStringList &lst ); 476 virtual void setItems( const QStringList &lst );
474 477
475 /** 478 /**
476 * Clears up all the items in this action 479 * Clears up all the items in this action
477 */ 480 */
478 virtual void clear(); 481 virtual void clear();
479 482
480 /** 483 /**
481 * When this action is plugged into a toolbar, it creates a combobox. 484 * When this action is plugged into a toolbar, it creates a combobox.
482 * This makes the combo editable or read-only. 485 * This makes the combo editable or read-only.
483 */ 486 */
484 virtual void setEditable( bool ); 487 virtual void setEditable( bool );
485 488
486 /** 489 /**
487 * When this action is plugged into a toolbar, it creates a combobox. 490 * When this action is plugged into a toolbar, it creates a combobox.
488 * This gives a _maximum_ size to the combobox. 491 * This gives a _maximum_ size to the combobox.
489 * The minimum size is automatically given by the contents (the items). 492 * The minimum size is automatically given by the contents (the items).
490 */ 493 */
491 virtual void setComboWidth( int width ); 494 virtual void setComboWidth( int width );
492 495
493protected: 496protected:
494 virtual void changeItem( int id, int index, const QString& text ); 497 virtual void changeItem( int id, int index, const QString& text );
495 498
496 /** 499 /**
497 * Depending on the menuAccelsEnabled property this method will return the 500 * Depending on the menuAccelsEnabled property this method will return the
498 * actions items in a way for inclusion in a combobox with the ampersand 501 * actions items in a way for inclusion in a combobox with the ampersand
499 * character removed from all items or not. 502 * character removed from all items or not.
500 * @since 3.1 503 * @since 3.1
501 */ 504 */
502 QStringList comboItems() const; 505 QStringList comboItems() const;
503 506
504protected slots: 507protected slots:
505 virtual void slotActivated( int id ); 508 virtual void slotActivated( int id );
506 virtual void slotActivated( const QString &text ); 509 virtual void slotActivated( const QString &text );
507 virtual void slotActivated(); 510 virtual void slotActivated();
508 511
509signals: 512signals:
510 void activated( int index ); 513 void activated( int index );
511 void activated( const QString& text ); 514 void activated( const QString& text );
512 515
513protected: 516protected:
514 virtual void updateCurrentItem( int id ); 517 virtual void updateCurrentItem( int id );
515 518
516 virtual void updateComboWidth( int id ); 519 virtual void updateComboWidth( int id );
517 520
518 virtual void updateItems( int id ); 521 virtual void updateItems( int id );
519 522
520 virtual void updateClear( int id ); 523 virtual void updateClear( int id );
521 524
522protected: 525protected:
523 virtual void virtual_hook( int id, void* data ); 526 virtual void virtual_hook( int id, void* data );
524private: 527private:
525 void setupMenu() const; 528 void setupMenu() const;
526 class KSelectActionPrivate; 529 class KSelectActionPrivate;
527 KSelectActionPrivate *d; 530 KSelectActionPrivate *d;
528 531
529}; 532};
530 533
531/// Remove this class in KDE-4.0. It doesn't add _anything_ to KSelectAction 534/// Remove this class in KDE-4.0. It doesn't add _anything_ to KSelectAction
532/** 535/**
533 * @deprecated Use KSelectAction instead. 536 * @deprecated Use KSelectAction instead.
534 */ 537 */
535class KListAction : public KSelectAction 538class KListAction : public KSelectAction
536{ 539{
537 Q_OBJECT 540 Q_OBJECT
538public: 541public:
539 /** 542 /**
540 * Constructs a list action with text and potential keyboard 543 * Constructs a list action with text and potential keyboard
541 * accelerator but nothing else. Use this only if you really 544 * accelerator but nothing else. Use this only if you really
542 * know what you are doing. 545 * know what you are doing.
543 * 546 *
544 * @param text The text that will be displayed. 547 * @param text The text that will be displayed.
545 * @param cut The corresponding keyboard accelerator (shortcut). 548 * @param cut The corresponding keyboard accelerator (shortcut).
546 * @param parent This action's parent. 549 * @param parent This action's parent.
547 * @param name An internal name for this action. 550 * @param name An internal name for this action.
548 */ 551 */
549 KListAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, 552 KListAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0,
550 const char* name = 0 ); 553 const char* name = 0 );
551 554
552 /** 555 /**
553 * @param text The text that will be displayed. 556 * @param text The text that will be displayed.
554 * @param cut The corresponding keyboard accelerator (shortcut). 557 * @param cut The corresponding keyboard accelerator (shortcut).
555 * @param receiver The SLOT's parent. 558 * @param receiver The SLOT's parent.
556 * @param slot The SLOT to invoke to execute this action. 559 * @param slot The SLOT to invoke to execute this action.
557 * @param parent This action's parent. 560 * @param parent This action's parent.
558 * @param name An internal name for this action. 561 * @param name An internal name for this action.
559 */ 562 */
560 KListAction( const QString& text, const KShortcut& cut, const QObject* receiver, 563 KListAction( const QString& text, const KShortcut& cut, const QObject* receiver,
561 const char* slot, QObject* parent, const char* name = 0 ); 564 const char* slot, QObject* parent, const char* name = 0 );
562 565
563 /** 566 /**
564 * @param text The text that will be displayed. 567 * @param text The text that will be displayed.
565 * @param pix The icons that go with this action. 568 * @param pix The icons that go with this action.
566 * @param cut The corresponding keyboard accelerator (shortcut). 569 * @param cut The corresponding keyboard accelerator (shortcut).
567 * @param parent This action's parent. 570 * @param parent This action's parent.
568 * @param name An internal name for this action. 571 * @param name An internal name for this action.
569 */ 572 */
570 KListAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), 573 KListAction( const QString& text, const QIcon& pix, const KShortcut& cut = KShortcut(),
571 QObject* parent = 0, const char* name = 0 ); 574 QObject* parent = 0, const char* name = 0 );
572 575
573 /** 576 /**
574 * @param text The text that will be displayed. 577 * @param text The text that will be displayed.
575 * @param pix The dynamically loaded icon that goes with this action. 578 * @param pix The dynamically loaded icon that goes with this action.
576 * @param cut The corresponding keyboard accelerator (shortcut). 579 * @param cut The corresponding keyboard accelerator (shortcut).
577 * @param parent This action's parent. 580 * @param parent This action's parent.
578 * @param name An internal name for this action. 581 * @param name An internal name for this action.
579 */ 582 */
580 KListAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), 583 KListAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
581 QObject* parent = 0, const char* name = 0 ); 584 QObject* parent = 0, const char* name = 0 );
582 585
583 /** 586 /**
584 * @param text The text that will be displayed. 587 * @param text The text that will be displayed.
585 * @param pix The icons that go with this action. 588 * @param pix The icons that go with this action.
586 * @param cut The corresponding keyboard accelerator (shortcut). 589 * @param cut The corresponding keyboard accelerator (shortcut).
587 * @param receiver The SLOT's parent. 590 * @param receiver The SLOT's parent.
588 * @param slot The SLOT to invoke to execute this action. 591 * @param slot The SLOT to invoke to execute this action.
589 * @param parent This action's parent. 592 * @param parent This action's parent.
590 * @param name An internal name for this action. 593 * @param name An internal name for this action.
591 */ 594 */
592 KListAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 595 KListAction( const QString& text, const QIcon& pix, const KShortcut& cut,
593 const QObject* receiver, const char* slot, QObject* parent, 596 const QObject* receiver, const char* slot, QObject* parent,
594 const char* name = 0 ); 597 const char* name = 0 );
595 598
596 /** 599 /**
597 * @param text The text that will be displayed. 600 * @param text The text that will be displayed.
598 * @param pix The dynamically loaded icon that goes with this action. 601 * @param pix The dynamically loaded icon that goes with this action.
599 * @param cut The corresponding keyboard accelerator (shortcut). 602 * @param cut The corresponding keyboard accelerator (shortcut).
600 * @param receiver The SLOT's parent. 603 * @param receiver The SLOT's parent.
601 * @param slot The SLOT to invoke to execute this action. 604 * @param slot The SLOT to invoke to execute this action.
602 * @param parent This action's parent. 605 * @param parent This action's parent.
603 * @param name An internal name for this action. 606 * @param name An internal name for this action.
604 */ 607 */
605 KListAction( const QString& text, const QString& pix, const KShortcut& cut, 608 KListAction( const QString& text, const QString& pix, const KShortcut& cut,
606 const QObject* receiver, const char* slot, QObject* parent, 609 const QObject* receiver, const char* slot, QObject* parent,
607 const char* name = 0 ); 610 const char* name = 0 );
608 611
609 /** 612 /**
610 * @param parent This action's parent. 613 * @param parent This action's parent.
611 * @param name An internal name for this action. 614 * @param name An internal name for this action.
612 */ 615 */
613 KListAction( QObject* parent = 0, const char* name = 0 ); 616 KListAction( QObject* parent = 0, const char* name = 0 );
614 617
615 /** 618 /**
616 * Destructor 619 * Destructor
617 */ 620 */
618 virtual ~KListAction(); 621 virtual ~KListAction();
619 622
620 623
621 virtual QString currentText() const; 624 virtual QString currentText() const;
622 virtual int currentItem() const; 625 virtual int currentItem() const;
623 626
624 627
625public slots: 628public slots:
626 /** 629 /**
627 * Sets the currently checked item. 630 * Sets the currently checked item.
628 * 631 *
629 * @param index Index of the item (remember the first item is zero). 632 * @param index Index of the item (remember the first item is zero).
630 */ 633 */
631 virtual void setCurrentItem( int index ); 634 virtual void setCurrentItem( int index );
632 635
633protected: 636protected:
634 virtual void virtual_hook( int id, void* data ); 637 virtual void virtual_hook( int id, void* data );
635private: 638private:
636 class KListActionPrivate; 639 class KListActionPrivate;
637 KListActionPrivate *d; 640 KListActionPrivate *d;
638}; 641};
639 642
640/** 643/**
641 * This class is an action to handle a recent files submenu. 644 * This class is an action to handle a recent files submenu.
642 * The best way to create the action is to use KStdAction::openRecent. 645 * The best way to create the action is to use KStdAction::openRecent.
643 * Then you simply need to call @ref loadEntries on startup, @ref saveEntries 646 * Then you simply need to call @ref loadEntries on startup, @ref saveEntries
644 * on shutdown, @ref addURL when your application loads/saves a file. 647 * on shutdown, @ref addURL when your application loads/saves a file.
645 * 648 *
646 * @author Michael Koch 649 * @author Michael Koch
647 * @short Recent files action 650 * @short Recent files action
648 */ 651 */
649class KRecentFilesAction : public KListAction // TODO public KSelectAction 652class KRecentFilesAction : public KListAction // TODO public KSelectAction
650{ 653{
651 Q_OBJECT 654 Q_OBJECT
652 Q_PROPERTY( uint maxItems READ maxItems WRITE setMaxItems ) 655 Q_PROPERTY( uint maxItems READ maxItems WRITE setMaxItems )
653public: 656public:
654 /** 657 /**
655 * @param text The text that will be displayed. 658 * @param text The text that will be displayed.
656 * @param cut The corresponding keyboard accelerator (shortcut). 659 * @param cut The corresponding keyboard accelerator (shortcut).
657 * @param parent This action's parent. 660 * @param parent This action's parent.
658 * @param name An internal name for this action. 661 * @param name An internal name for this action.
659 * @param maxItems The maximum number of files to display 662 * @param maxItems The maximum number of files to display
660 */ 663 */
661 KRecentFilesAction( const QString& text, const KShortcut& cut, 664 KRecentFilesAction( const QString& text, const KShortcut& cut,
662 QObject* parent, const char* name = 0, 665 QObject* parent, const char* name = 0,
663 uint maxItems = 10 ); 666 uint maxItems = 10 );
664 667
665 /** 668 /**
666 * @param text The text that will be displayed. 669 * @param text The text that will be displayed.
667 * @param cut The corresponding keyboard accelerator (shortcut). 670 * @param cut The corresponding keyboard accelerator (shortcut).
668 * @param receiver The SLOT's parent. 671 * @param receiver The SLOT's parent.
669 * @param slot The SLOT to invoke when a URL is selected. 672 * @param slot The SLOT to invoke when a URL is selected.
670 * Its signature is of the form slotURLSelected( const KURL & ). 673 * Its signature is of the form slotURLSelected( const KURL & ).
671 * @param parent This action's parent. 674 * @param parent This action's parent.
672 * @param name An internal name for this action. 675 * @param name An internal name for this action.
673 * @param maxItems The maximum number of files to display 676 * @param maxItems The maximum number of files to display
674 */ 677 */
675 KRecentFilesAction( const QString& text, const KShortcut& cut, 678 KRecentFilesAction( const QString& text, const KShortcut& cut,
676 const QObject* receiver, const char* slot, 679 const QObject* receiver, const char* slot,
677 QObject* parent, const char* name = 0, 680 QObject* parent, const char* name = 0,
678 uint maxItems = 10 ); 681 uint maxItems = 10 );
679 682
680 /** 683 /**
681 * @param text The text that will be displayed. 684 * @param text The text that will be displayed.
682 * @param pix The icons that go with this action. 685 * @param pix The icons that go with this action.
683 * @param cut The corresponding keyboard accelerator (shortcut). 686 * @param cut The corresponding keyboard accelerator (shortcut).
684 * @param parent This action's parent. 687 * @param parent This action's parent.
685 * @param name An internal name for this action. 688 * @param name An internal name for this action.
686 * @param maxItems The maximum number of files to display 689 * @param maxItems The maximum number of files to display
687 */ 690 */
688 KRecentFilesAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 691 KRecentFilesAction( const QString& text, const QIcon& pix, const KShortcut& cut,
689 QObject* parent, const char* name = 0, 692 QObject* parent, const char* name = 0,
690 uint maxItems = 10 ); 693 uint maxItems = 10 );
691 694
692 /** 695 /**
693 * @param text The text that will be displayed. 696 * @param text The text that will be displayed.
694 * @param pix The dynamically loaded icon that goes with this action. 697 * @param pix The dynamically loaded icon that goes with this action.
695 * @param cut The corresponding keyboard accelerator (shortcut). 698 * @param cut The corresponding keyboard accelerator (shortcut).
696 * @param parent This action's parent. 699 * @param parent This action's parent.
697 * @param name An internal name for this action. 700 * @param name An internal name for this action.
698 * @param maxItems The maximum number of files to display 701 * @param maxItems The maximum number of files to display
699 */ 702 */
700 KRecentFilesAction( const QString& text, const QString& pix, const KShortcut& cut, 703 KRecentFilesAction( const QString& text, const QString& pix, const KShortcut& cut,
701 QObject* parent, const char* name = 0, 704 QObject* parent, const char* name = 0,
702 uint maxItems = 10 ); 705 uint maxItems = 10 );
703 706
704 /** 707 /**
705 * @param text The text that will be displayed. 708 * @param text The text that will be displayed.
706 * @param pix The icons that go with this action. 709 * @param pix The icons that go with this action.
707 * @param cut The corresponding keyboard accelerator (shortcut). 710 * @param cut The corresponding keyboard accelerator (shortcut).
708 * @param receiver The SLOT's parent. 711 * @param receiver The SLOT's parent.
709 * @param slot The SLOT to invoke when a URL is selected. 712 * @param slot The SLOT to invoke when a URL is selected.
710 * Its signature is of the form slotURLSelected( const KURL & ). 713 * Its signature is of the form slotURLSelected( const KURL & ).
711 * @param parent This action's parent. 714 * @param parent This action's parent.
712 * @param name An internal name for this action. 715 * @param name An internal name for this action.
713 * @param maxItems The maximum number of files to display 716 * @param maxItems The maximum number of files to display
714 */ 717 */
715 KRecentFilesAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 718 KRecentFilesAction( const QString& text, const QIcon& pix, const KShortcut& cut,
716 const QObject* receiver, const char* slot, 719 const QObject* receiver, const char* slot,
717 QObject* parent, const char* name = 0, 720 QObject* parent, const char* name = 0,
718 uint maxItems = 10 ); 721 uint maxItems = 10 );
719 722
720 /** 723 /**
721 * @param text The text that will be displayed. 724 * @param text The text that will be displayed.
722 * @param pix The dynamically loaded icon that goes with this action. 725 * @param pix The dynamically loaded icon that goes with this action.
723 * @param cut The corresponding keyboard accelerator (shortcut). 726 * @param cut The corresponding keyboard accelerator (shortcut).
724 * @param receiver The SLOT's parent. 727 * @param receiver The SLOT's parent.
725 * @param slot The SLOT to invoke when a URL is selected. 728 * @param slot The SLOT to invoke when a URL is selected.
726 * Its signature is of the form slotURLSelected( const KURL & ). 729 * Its signature is of the form slotURLSelected( const KURL & ).
727 * @param parent This action's parent. 730 * @param parent This action's parent.
728 * @param name An internal name for this action. 731 * @param name An internal name for this action.
729 * @param maxItems The maximum number of files to display 732 * @param maxItems The maximum number of files to display
730 */ 733 */
731 KRecentFilesAction( const QString& text, const QString& pix, const KShortcut& cut, 734 KRecentFilesAction( const QString& text, const QString& pix, const KShortcut& cut,
732 const QObject* receiver, const char* slot, 735 const QObject* receiver, const char* slot,
733 QObject* parent, const char* name = 0, 736 QObject* parent, const char* name = 0,
734 uint maxItems = 10 ); 737 uint maxItems = 10 );
735 738
736 /** 739 /**
737 * @param parent This action's parent. 740 * @param parent This action's parent.
738 * @param name An internal name for this action. 741 * @param name An internal name for this action.
739 * @param maxItems The maximum number of files to display 742 * @param maxItems The maximum number of files to display
740 */ 743 */
741 KRecentFilesAction( QObject* parent = 0, const char* name = 0, 744 KRecentFilesAction( QObject* parent = 0, const char* name = 0,
742 uint maxItems = 10 ); 745 uint maxItems = 10 );
743 746
744 /** 747 /**
745 * Destructor. 748 * Destructor.
746 */ 749 */
747 virtual ~KRecentFilesAction(); 750 virtual ~KRecentFilesAction();
748 751
749 /** 752 /**
750 * Returns the maximum of items in the recent files list. 753 * Returns the maximum of items in the recent files list.
751 */ 754 */
752 uint maxItems() const; 755 uint maxItems() const;
753 756
754public slots: 757public slots:
755 /** 758 /**
756 * Sets the maximum of items in the recent files list. 759 * Sets the maximum of items in the recent files list.
757 * The default for this value is 10 set in the constructor. 760 * The default for this value is 10 set in the constructor.
758 * 761 *
759 * If this value is lesser than the number of items currently 762 * If this value is lesser than the number of items currently
760 * in the recent files list the last items are deleted until 763 * in the recent files list the last items are deleted until
761 * the number of items are equal to the new maximum. 764 * the number of items are equal to the new maximum.
762 */ 765 */
763 void setMaxItems( uint maxItems ); 766 void setMaxItems( uint maxItems );
764 767
765 /** 768 /**
766 * Loads the recent files entries from a given KConfig object. 769 * Loads the recent files entries from a given KConfig object.
767 * You can provide the name of the group used to load the entries. 770 * You can provide the name of the group used to load the entries.
768 * If the groupname is empty, entries are load from a group called 'RecentFiles' 771 * If the groupname is empty, entries are load from a group called 'RecentFiles'
769 * 772 *
770 * This method does not effect the active group of KConfig. 773 * This method does not effect the active group of KConfig.
771 */ 774 */
772 void loadEntries( KConfig* config, QString groupname=QString::null ); 775 void loadEntries( KConfig* config, QString groupname=QString::null );
773 776
774 /** 777 /**
775 * Saves the current recent files entries to a given KConfig object. 778 * Saves the current recent files entries to a given KConfig object.
776 * You can provide the name of the group used to load the entries. 779 * You can provide the name of the group used to load the entries.
777 * If the groupname is empty, entries are saved to a group called 'RecentFiles' 780 * If the groupname is empty, entries are saved to a group called 'RecentFiles'
778 * 781 *
779 * This method does not effect the active group of KConfig. 782 * This method does not effect the active group of KConfig.
780 */ 783 */
781 void saveEntries( KConfig* config, QString groupname=QString::null ); 784 void saveEntries( KConfig* config, QString groupname=QString::null );
782 785
783public slots: 786public slots:
784 /** 787 /**
785 * Add URL to recent files list. 788 * Add URL to recent files list.
786 * 789 *
787 * @param url The URL of the file 790 * @param url The URL of the file
788 */ 791 */
789 void addURL( const KURL& url ); 792 void addURL( const KURL& url );
790 793
791 /** 794 /**
792 * Remove an URL from the recent files list. 795 * Remove an URL from the recent files list.
793 * 796 *
794 * @param url The URL of the file 797 * @param url The URL of the file
795 */ 798 */
796 void removeURL( const KURL& url ); 799 void removeURL( const KURL& url );
797 800
798 /** 801 /**
799 * Removes all entries from the recent files list. 802 * Removes all entries from the recent files list.
800 */ 803 */
801 void clearURLList(); 804 void clearURLList();
802 805
803signals: 806signals:
804 807
805 /** 808 /**
806 * This signal gets emited when the user selects an URL. 809 * This signal gets emited when the user selects an URL.
807 * 810 *
808 * @param url The URL thats the user selected. 811 * @param url The URL thats the user selected.
809 */ 812 */
810 void urlSelected( const KURL& url ); 813 void urlSelected( const KURL& url );
811 814
812protected slots: 815protected slots:
813 /** 816 /**
814 * 817 *
815 */ 818 */
816 void itemSelected( const QString& string ); 819 void itemSelected( const QString& string );
817 820
818protected: 821protected:
819 virtual void virtual_hook( int id, void* data ); 822 virtual void virtual_hook( int id, void* data );
820private: 823private:
821 void init(); 824 void init();
822 825
823 class KRecentFilesActionPrivate; 826 class KRecentFilesActionPrivate;
824 KRecentFilesActionPrivate *d; 827 KRecentFilesActionPrivate *d;
825}; 828};
826 829
827class KFontAction : public KSelectAction 830class KFontAction : public KSelectAction
828{ 831{
829 Q_OBJECT 832 Q_OBJECT
830 Q_PROPERTY( QString font READ font WRITE setFont ) 833 Q_PROPERTY( QString font READ font WRITE setFont )
831public: 834public:
832 KFontAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, 835 KFontAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0,
833 const char* name = 0 ); 836 const char* name = 0 );
834 KFontAction( const QString& text, const KShortcut& cut, 837 KFontAction( const QString& text, const KShortcut& cut,
835 const QObject* receiver, const char* slot, QObject* parent, 838 const QObject* receiver, const char* slot, QObject* parent,
836 const char* name = 0 ); 839 const char* name = 0 );
837 KFontAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), 840 KFontAction( const QString& text, const QIcon& pix, const KShortcut& cut = KShortcut(),
838 QObject* parent = 0, const char* name = 0 ); 841 QObject* parent = 0, const char* name = 0 );
839 KFontAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), 842 KFontAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
840 QObject* parent = 0, const char* name = 0 ); 843 QObject* parent = 0, const char* name = 0 );
841 KFontAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 844 KFontAction( const QString& text, const QIcon& pix, const KShortcut& cut,
842 const QObject* receiver, const char* slot, QObject* parent, 845 const QObject* receiver, const char* slot, QObject* parent,
843 const char* name = 0 ); 846 const char* name = 0 );
844 KFontAction( const QString& text, const QString& pix, const KShortcut& cut, 847 KFontAction( const QString& text, const QString& pix, const KShortcut& cut,
845 const QObject* receiver, const char* slot, QObject* parent, 848 const QObject* receiver, const char* slot, QObject* parent,
846 const char* name = 0 ); 849 const char* name = 0 );
847 850
848 KFontAction( QObject* parent = 0, const char* name = 0 ); 851 KFontAction( QObject* parent = 0, const char* name = 0 );
849 ~KFontAction(); 852 ~KFontAction();
850 853
851 QString font() const { 854 QString font() const {
852 return currentText(); 855 return currentText();
853 } 856 }
854 857
855 int plug( QWidget*, int index = -1 ); 858 int plug( QWidget*, int index = -1 );
856 859
857public slots: 860public slots:
858 void setFont( const QString &family ); 861 void setFont( const QString &family );
859 862
860protected: 863protected:
861 virtual void virtual_hook( int id, void* data ); 864 virtual void virtual_hook( int id, void* data );
862private: 865private:
863 class KFontActionPrivate; 866 class KFontActionPrivate;
864 KFontActionPrivate *d; 867 KFontActionPrivate *d;
865}; 868};
866 869
867class KFontSizeAction : public KSelectAction 870class KFontSizeAction : public KSelectAction
868{ 871{
869 Q_OBJECT 872 Q_OBJECT
870 Q_PROPERTY( int fontSize READ fontSize WRITE setFontSize ) 873 Q_PROPERTY( int fontSize READ fontSize WRITE setFontSize )
871public: 874public:
872 KFontSizeAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, 875 KFontSizeAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0,
873 const char* name = 0 ); 876 const char* name = 0 );
874 KFontSizeAction( const QString& text, const KShortcut& cut, const QObject* receiver, 877 KFontSizeAction( const QString& text, const KShortcut& cut, const QObject* receiver,
875 const char* slot, QObject* parent, const char* name = 0 ); 878 const char* slot, QObject* parent, const char* name = 0 );
876 KFontSizeAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(), 879 KFontSizeAction( const QString& text, const QIcon& pix, const KShortcut& cut = KShortcut(),
877 QObject* parent = 0, const char* name = 0 ); 880 QObject* parent = 0, const char* name = 0 );
878 KFontSizeAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(), 881 KFontSizeAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
879 QObject* parent = 0, const char* name = 0 ); 882 QObject* parent = 0, const char* name = 0 );
880 KFontSizeAction( const QString& text, const QIconSet& pix, const KShortcut& cut, 883 KFontSizeAction( const QString& text, const QIcon& pix, const KShortcut& cut,
881 const QObject* receiver, const char* slot, 884 const QObject* receiver, const char* slot,
882 QObject* parent, const char* name = 0 ); 885 QObject* parent, const char* name = 0 );
883 KFontSizeAction( const QString& text, const QString& pix, const KShortcut& cut, 886 KFontSizeAction( const QString& text, const QString& pix, const KShortcut& cut,
884 const QObject* receiver, const char* slot, 887 const QObject* receiver, const char* slot,
885 QObject* parent, const char* name = 0 ); 888 QObject* parent, const char* name = 0 );
886 KFontSizeAction( QObject* parent = 0, const char* name = 0 ); 889 KFontSizeAction( QObject* parent = 0, const char* name = 0 );
887 890
888 virtual ~KFontSizeAction(); 891 virtual ~KFontSizeAction();
889 892
890 virtual int fontSize() const; 893 virtual int fontSize() const;
891 894
892public slots: 895public slots:
893 virtual void setFontSize( int size ); 896 virtual void setFontSize( int size );
894 897
895protected slots: 898protected slots:
896 virtual void slotActivated( int ); 899 virtual void slotActivated( int );
897 virtual void slotActivated( const QString& ); 900 virtual void slotActivated( const QString& );
898 virtual void slotActivated() { KAction::slotActivated(); } 901 virtual void slotActivated() { KAction::slotActivated(); }
899 902
900signals: 903signals:
901 void fontSizeChanged( int ); 904 void fontSizeChanged( int );
902 905
903private: 906private:
904 void init(); 907 void init();
905 908
906 909
907protected: 910protected:
908 virtual void virtual_hook( int id, void* data ); 911 virtual void virtual_hook( int id, void* data );
909private: 912private:
910 class KFontSizeActionPrivate; 913 class KFontSizeActionPrivate;
911 KFontSizeActionPrivate *d; 914 KFontSizeActionPrivate *d;
912}; 915};
913 916
914 917
915/** 918/**
916 * A KActionMenu is an action that holds a sub-menu of other actions. 919 * A KActionMenu is an action that holds a sub-menu of other actions.
917 * insert() and remove() allow to insert and remove actions into this action-menu. 920 * insert() and remove() allow to insert and remove actions into this action-menu.
918 * Plugged in a popupmenu, it will create a submenu. 921 * Plugged in a popupmenu, it will create a submenu.
919 * Plugged in a toolbar, it will create a button with a popup menu. 922 * Plugged in a toolbar, it will create a button with a popup menu.
920 * 923 *
921 * This is the action used by the XMLGUI since it holds other actions. 924 * This is the action used by the XMLGUI since it holds other actions.
922 * If you want a submenu for selecting one tool among many (without icons), see KSelectAction. 925 * If you want a submenu for selecting one tool among many (without icons), see KSelectAction.
923 * See also setDelayed about the main action. 926 * See also setDelayed about the main action.
924 */ 927 */
925class KActionMenu : public KAction 928class KActionMenu : public KAction
926{ 929{
927 Q_OBJECT 930 Q_OBJECT
928 Q_PROPERTY( bool delayed READ delayed WRITE setDelayed ) 931 Q_PROPERTY( bool delayed READ delayed WRITE setDelayed )
929 Q_PROPERTY( bool stickyMenu READ stickyMenu WRITE setStickyMenu ) 932 Q_PROPERTY( bool stickyMenu READ stickyMenu WRITE setStickyMenu )
930 933
931public: 934public:
932 KActionMenu( const QString& text, QObject* parent = 0, 935 KActionMenu( const QString& text, QObject* parent = 0,
933 const char* name = 0 ); 936 const char* name = 0 );
934 KActionMenu( const QString& text, const QIconSet& icon, 937 KActionMenu( const QString& text, const QIcon& icon,
935 QObject* parent = 0, const char* name = 0 ); 938 QObject* parent = 0, const char* name = 0 );
936 KActionMenu( const QString& text, const QString& icon, 939 KActionMenu( const QString& text, const QString& icon,
937 QObject* parent = 0, const char* name = 0 ); 940 QObject* parent = 0, const char* name = 0 );
938 KActionMenu( QObject* parent = 0, const char* name = 0 ); 941 KActionMenu( QObject* parent = 0, const char* name = 0 );
939 virtual ~KActionMenu(); 942 virtual ~KActionMenu();
940 943
941 virtual void insert( KAction*, int index = -1 ); 944 virtual void insert( KAction*, int index = -1 );
942 virtual void remove( KAction* ); 945 virtual void remove( KAction* );
943 946
944//US KPopupMenu* popupMenu() const; 947//US KPopupMenu* popupMenu() const;
945 QPopupMenu* popupMenu() const; 948 Q3PopupMenu* popupMenu() const;
946 void popup( const QPoint& global ); 949 void popup( const QPoint& global );
947 950
948 /** 951 /**
949 * Returns true if this action creates a delayed popup menu 952 * Returns true if this action creates a delayed popup menu
950 * when plugged in a KToolbar. 953 * when plugged in a KToolbar.
951 */ 954 */
952 bool delayed() const; 955 bool delayed() const;
953 /** 956 /**
954 * If set to true, this action will create a delayed popup menu 957 * If set to true, this action will create a delayed popup menu
955 * when plugged in a KToolbar. Otherwise it creates a normal popup. 958 * when plugged in a KToolbar. Otherwise it creates a normal popup.
956 * Default: delayed 959 * Default: delayed
957 * 960 *
958 * Remember that if the "main" action (the toolbar button itself) 961 * Remember that if the "main" action (the toolbar button itself)
959 * cannot be clicked, then you should call setDelayed(false). 962 * cannot be clicked, then you should call setDelayed(false).
960 * 963 *
961 * On the opposite, if the main action can be clicked, it can only happen 964 * On the opposite, if the main action can be clicked, it can only happen
962 * in a toolbar: in a menu, the parent of a submenu can't be activated. 965 * in a toolbar: in a menu, the parent of a submenu can't be activated.
963 * To get a "normal" menu item when plugged a menu (and no submenu) 966 * To get a "normal" menu item when plugged a menu (and no submenu)
964 * use KToolBarPopupAction. 967 * use KToolBarPopupAction.
965 */ 968 */
966 void setDelayed(bool _delayed); 969 void setDelayed(bool _delayed);
967 970
968 /** 971 /**
969 * Returns true if this action creates a sticky popup menu. 972 * Returns true if this action creates a sticky popup menu.
970 * See @ref setStickyMenu. 973 * See @ref setStickyMenu.
971 */ 974 */
972 bool stickyMenu() const; 975 bool stickyMenu() const;
973 /** 976 /**
974 * If set to true, this action will create a sticky popup menu 977 * If set to true, this action will create a sticky popup menu
975 * when plugged in a KToolbar. 978 * when plugged in a KToolbar.
976 * "Sticky", means it's visible until a selection is made or the mouse is 979 * "Sticky", means it's visible until a selection is made or the mouse is
977 * clicked elsewhere. This feature allows you to make a selection without 980 * clicked elsewhere. This feature allows you to make a selection without
978 * having to press and hold down the mouse while making a selection. 981 * having to press and hold down the mouse while making a selection.
979 * Default: sticky. 982 * Default: sticky.
980 */ 983 */
981 void setStickyMenu(bool sticky); 984 void setStickyMenu(bool sticky);
982 985
983 virtual int plug( QWidget* widget, int index = -1 ); 986 virtual int plug( QWidget* widget, int index = -1 );
984 987
985protected: 988protected:
986 virtual void virtual_hook( int id, void* data ); 989 virtual void virtual_hook( int id, void* data );
987private: 990private:
988 class KActionMenuPrivate; 991 class KActionMenuPrivate;
989 KActionMenuPrivate *d; 992 KActionMenuPrivate *d;
990}; 993};
991 994
992/** 995/**
993 * This action is a normal action everywhere, except in a toolbar 996 * This action is a normal action everywhere, except in a toolbar
994 * where it also has a popupmenu (optionnally delayed). This action is designed 997 * where it also has a popupmenu (optionnally delayed). This action is designed
995 * for history actions (back/forward, undo/redo) and for any other action 998 * for history actions (back/forward, undo/redo) and for any other action
996 * that has more detail in a toolbar than in a menu (e.g. tool chooser 999 * that has more detail in a toolbar than in a menu (e.g. tool chooser
997 * with "Other" leading to a dialog...). 1000 * with "Other" leading to a dialog...).
998 */ 1001 */
999class KToolBarPopupAction : public KAction 1002class KToolBarPopupAction : public KAction
1000{ 1003{
1001 Q_OBJECT 1004 Q_OBJECT
1002 Q_PROPERTY( bool delayed READ delayed WRITE setDelayed ) 1005 Q_PROPERTY( bool delayed READ delayed WRITE setDelayed )
1003 Q_PROPERTY( bool stickyMenu READ stickyMenu WRITE setStickyMenu ) 1006 Q_PROPERTY( bool stickyMenu READ stickyMenu WRITE setStickyMenu )
1004 1007
1005public: 1008public:
1006 //Not all constructors - because we need an icon, since this action only makes 1009 //Not all constructors - because we need an icon, since this action only makes
1007 // sense when being plugged at least in a toolbar. 1010 // sense when being plugged at least in a toolbar.
1008 /** 1011 /**
1009 * Create a KToolBarPopupAction, with a text, an icon, an optionnal accelerator, 1012 * Create a KToolBarPopupAction, with a text, an icon, an optionnal accelerator,
1010 * parent and name. 1013 * parent and name.
1011 * 1014 *
1012 * @param text The text that will be displayed. 1015 * @param text The text that will be displayed.
1013 * @param icon The icon to display. 1016 * @param icon The icon to display.
1014 * @param cut The corresponding keyboard accelerator (shortcut). 1017 * @param cut The corresponding keyboard accelerator (shortcut).
1015 * @param parent This action's parent. 1018 * @param parent This action's parent.
1016 * @param name An internal name for this action. 1019 * @param name An internal name for this action.
1017 */ 1020 */
1018 KToolBarPopupAction( const QString& text, const QString& icon, const KShortcut& cut = KShortcut(), 1021 KToolBarPopupAction( const QString& text, const QString& icon, const KShortcut& cut = KShortcut(),
1019 QObject* parent = 0, const char* name = 0 ); 1022 QObject* parent = 0, const char* name = 0 );
1020 1023
1021 /** 1024 /**
1022 * Create a KToolBarPopupAction, with a text, an icon, an accelerator, 1025 * Create a KToolBarPopupAction, with a text, an icon, an accelerator,
1023 * a slot connected to the action, parent and name. 1026 * a slot connected to the action, parent and name.
1024 * 1027 *
1025 * If you do not want or have a keyboard accelerator, set the 1028 * If you do not want or have a keyboard accelerator, set the
1026 * @p cut param to 0. 1029 * @p cut param to 0.
1027 * 1030 *
1028 * @param text The text that will be displayed. 1031 * @param text The text that will be displayed.
1029 * @param icon The icon to display. 1032 * @param icon The icon to display.
1030 * @param cut The corresponding keyboard accelerator (shortcut). 1033 * @param cut The corresponding keyboard accelerator (shortcut).
1031 * @param receiver The SLOT's owner. 1034 * @param receiver The SLOT's owner.
1032 * @param slot The SLOT to invoke to execute this action. 1035 * @param slot The SLOT to invoke to execute this action.
1033 * @param parent This action's parent. 1036 * @param parent This action's parent.
1034 * @param name An internal name for this action. 1037 * @param name An internal name for this action.
1035 */ 1038 */
1036 KToolBarPopupAction( const QString& text, const QString& icon, const KShortcut& cut, 1039 KToolBarPopupAction( const QString& text, const QString& icon, const KShortcut& cut,
1037 const QObject* receiver, const char* slot, 1040 const QObject* receiver, const char* slot,
1038 QObject* parent = 0, const char* name = 0 ); 1041 QObject* parent = 0, const char* name = 0 );
1039 1042
1040 /** 1043 /**
1041 * Create a KToolBarPopupAction, with a KGuiItem, an accelerator, 1044 * Create a KToolBarPopupAction, with a KGuiItem, an accelerator,
1042 * a slot connected to the action, parent and name. The text and the 1045 * a slot connected to the action, parent and name. The text and the
1043 * icon are taken from the KGuiItem. 1046 * icon are taken from the KGuiItem.
1044 * 1047 *
1045 * If you do not want or have a keyboard accelerator, set the 1048 * If you do not want or have a keyboard accelerator, set the
1046 * @p cut param to 0. 1049 * @p cut param to 0.
1047 * 1050 *
1048 * @param item The text and icon that will be displayed. 1051 * @param item The text and icon that will be displayed.
1049 * @param cut The corresponding keyboard accelerator (shortcut). 1052 * @param cut The corresponding keyboard accelerator (shortcut).
1050 * @param receiver The SLOT's owner. 1053 * @param receiver The SLOT's owner.
1051 * @param slot The SLOT to invoke to execute this action. 1054 * @param slot The SLOT to invoke to execute this action.
1052 * @param parent This action's parent. 1055 * @param parent This action's parent.
1053 * @param name An internal name for this action. 1056 * @param name An internal name for this action.
1054 */ 1057 */
1055 1058
1056 KToolBarPopupAction( const KGuiItem& item, const KShortcut& cut, 1059 KToolBarPopupAction( const KGuiItem& item, const KShortcut& cut,
1057 const QObject* receiver, const char* slot, 1060 const QObject* receiver, const char* slot,
1058 KActionCollection* parent, const char* name ); 1061 KActionCollection* parent, const char* name );
1059 1062
1060 virtual ~KToolBarPopupAction(); 1063 virtual ~KToolBarPopupAction();
1061 1064
1062 virtual int plug( QWidget *widget, int index = -1 ); 1065 virtual int plug( QWidget *widget, int index = -1 );
1063 1066
1064 /** 1067 /**
1065 * The popup menu that is shown when clicking (some time) on the toolbar 1068 * The popup menu that is shown when clicking (some time) on the toolbar
1066 * button. You may want to plug items into it on creation, or connect to 1069 * button. You may want to plug items into it on creation, or connect to
1067 * aboutToShow for a more dynamic menu. 1070 * aboutToShow for a more dynamic menu.
1068 */ 1071 */
1069//US KPopupMenu *popupMenu() const; 1072//US KPopupMenu *popupMenu() const;
1070 QPopupMenu *popupMenu() const; 1073 Q3PopupMenu *popupMenu() const;
1071 1074
1072 /** 1075 /**
1073 * Returns true if this action creates a delayed popup menu 1076 * Returns true if this action creates a delayed popup menu
1074 * when plugged in a KToolbar. 1077 * when plugged in a KToolbar.
1075 */ 1078 */
1076 bool delayed() const; 1079 bool delayed() const;
1077 /** 1080 /**
1078 * If set to true, this action will create a delayed popup menu 1081 * If set to true, this action will create a delayed popup menu
1079 * when plugged in a KToolbar. Otherwise it creates a normal popup. 1082 * when plugged in a KToolbar. Otherwise it creates a normal popup.
1080 * Default: delayed. 1083 * Default: delayed.
1081 */ 1084 */
1082 void setDelayed(bool delayed); 1085 void setDelayed(bool delayed);
1083 /** 1086 /**
1084 * Returns true if this action creates a sticky popup menu. 1087 * Returns true if this action creates a sticky popup menu.
1085 * See @ref setStickyMenu. 1088 * See @ref setStickyMenu.
1086 */ 1089 */
1087 bool stickyMenu() const; 1090 bool stickyMenu() const;
1088 /** 1091 /**
1089 * If set to true, this action will create a sticky popup menu 1092 * If set to true, this action will create a sticky popup menu
1090 * when plugged in a KToolbar. 1093 * when plugged in a KToolbar.
1091 * "Sticky", means it's visible until a selection is made or the mouse is 1094 * "Sticky", means it's visible until a selection is made or the mouse is
1092 * clicked elsewhere. This feature allows you to make a selection without 1095 * clicked elsewhere. This feature allows you to make a selection without
1093 * having to press and hold down the mouse while making a selection. 1096 * having to press and hold down the mouse while making a selection.
1094 * Only available if delayed() is true. 1097 * Only available if delayed() is true.
1095 * Default: sticky. 1098 * Default: sticky.
1096 */ 1099 */
1097 void setStickyMenu(bool sticky); 1100 void setStickyMenu(bool sticky);
1098 1101
1099private: 1102private:
1100//US KPopupMenu *m_popup; 1103//US KPopupMenu *m_popup;
1101 QPopupMenu *m_popup; 1104 Q3PopupMenu *m_popup;
1102 bool m_delayed:1; 1105 bool m_delayed:1;
1103 bool m_stickyMenu:1; 1106 bool m_stickyMenu:1;
1104protected: 1107protected:
1105 virtual void virtual_hook( int id, void* data ); 1108 virtual void virtual_hook( int id, void* data );
1106private: 1109private:
1107 class KToolBarPopupActionPrivate; 1110 class KToolBarPopupActionPrivate;
1108 KToolBarPopupActionPrivate *d; 1111 KToolBarPopupActionPrivate *d;
1109}; 1112};
1110 1113
1111/** 1114/**
1112 * An action that takes care of everything associated with 1115 * An action that takes care of everything associated with
1113 * showing or hiding a toolbar by a menu action. It will 1116 * showing or hiding a toolbar by a menu action. It will
1114 * show or hide the toolbar with the given name when 1117 * show or hide the toolbar with the given name when
1115 * activated, and check or uncheck itself if the toolbar 1118 * activated, and check or uncheck itself if the toolbar
1116 * is manually shown or hidden. 1119 * is manually shown or hidden.
1117 * 1120 *
1118 * If you need to perfom some additional action when the 1121 * If you need to perfom some additional action when the
1119 * toolbar is shown or hidden, connect to the toggled(bool) 1122 * toolbar is shown or hidden, connect to the toggled(bool)
1120 * signal. It will be emitted after the toolbar's 1123 * signal. It will be emitted after the toolbar's
1121 * visibility has changed, whenever it changes. 1124 * visibility has changed, whenever it changes.
1122 * @since 3.1 1125 * @since 3.1
1123 */ 1126 */
1124class KToggleToolBarAction : public KToggleAction 1127class KToggleToolBarAction : public KToggleAction
1125{ 1128{
1126 Q_OBJECT 1129 Q_OBJECT
1127public: 1130public:
1128 /** 1131 /**
1129 * Create a KToggleToolbarAction that manages the toolbar 1132 * Create a KToggleToolbarAction that manages the toolbar
1130 * named toolBarName. This can be either the name of a 1133 * named toolBarName. This can be either the name of a
1131 * toolbar in an xml ui file, or a toolbar programmatically 1134 * toolbar in an xml ui file, or a toolbar programmatically
1132 * created with that name. 1135 * created with that name.
1133 */ 1136 */
1134 KToggleToolBarAction( const char* toolBarName, const QString& text, 1137 KToggleToolBarAction( const char* toolBarName, const QString& text,
1135 KActionCollection* parent, const char* name ); 1138 KActionCollection* parent, const char* name );
1136 KToggleToolBarAction( KToolBar *toolBar, const QString &text, 1139 KToggleToolBarAction( KToolBar *toolBar, const QString &text,
1137 KActionCollection *parent, const char *name ); 1140 KActionCollection *parent, const char *name );
1138 virtual ~KToggleToolBarAction(); 1141 virtual ~KToggleToolBarAction();
1139 1142
1140 virtual int plug( QWidget*, int index = -1 ); 1143 virtual int plug( QWidget*, int index = -1 );
1141 1144
1142 KToolBar *toolBar() { 1145 KToolBar *toolBar() {
1143 return m_toolBar; 1146 return m_toolBar;
1144 } 1147 }
1145 1148
1146public slots: 1149public slots:
1147 virtual void setChecked( bool ); 1150 virtual void setChecked( bool );
1148 1151
1149private: 1152private:
1150 QCString m_toolBarName; 1153 Q3CString m_toolBarName;
1151 QGuardedPtr<KToolBar> m_toolBar; 1154 QPointer<KToolBar> m_toolBar;
1152protected: 1155protected:
1153 virtual void virtual_hook( int id, void* data ); 1156 virtual void virtual_hook( int id, void* data );
1154private: 1157private:
1155 class KToggleToolBarActionPrivate; 1158 class KToggleToolBarActionPrivate;
1156 KToggleToolBarActionPrivate *d; 1159 KToggleToolBarActionPrivate *d;
1157}; 1160};
1158 1161
1159/** 1162/**
1160 * An action that automatically embeds a widget into a 1163 * An action that automatically embeds a widget into a
1161 * toolbar. 1164 * toolbar.
1162 */ 1165 */
1163class KWidgetAction : public KAction 1166class KWidgetAction : public KAction
1164{ 1167{
1165 Q_OBJECT 1168 Q_OBJECT
1166public: 1169public:
1167 /** 1170 /**
1168 * Create an action that will embed widget into a toolbar 1171 * Create an action that will embed widget into a toolbar
1169 * when plugged. This action may only be plugged into 1172 * when plugged. This action may only be plugged into
1170 * a toolbar. 1173 * a toolbar.
1171 */ 1174 */
1172 KWidgetAction( QWidget* widget, const QString& text, 1175 KWidgetAction( QWidget* widget, const QString& text,
1173 const KShortcut& cut, 1176 const KShortcut& cut,
1174 const QObject* receiver, const char* slot, 1177 const QObject* receiver, const char* slot,
1175 KActionCollection* parent, const char* name ); 1178 KActionCollection* parent, const char* name );
1176 virtual ~KWidgetAction(); 1179 virtual ~KWidgetAction();
1177 1180
1178 /** 1181 /**
1179 * Returns the widget associated with this action. 1182 * Returns the widget associated with this action.
1180 */ 1183 */
1181 QWidget* widget() { return m_widget; } 1184 QWidget* widget() { return m_widget; }
1182 1185
1183 void setAutoSized( bool ); 1186 void setAutoSized( bool );
1184 1187
1185 /** 1188 /**
1186 * Plug the action. The widget passed to the constructor 1189 * Plug the action. The widget passed to the constructor
1187 * will be reparented to w, which must inherit KToolBar. 1190 * will be reparented to w, which must inherit KToolBar.
1188 */ 1191 */
1189 virtual int plug( QWidget* w, int index = -1 ); 1192 virtual int plug( QWidget* w, int index = -1 );
1190 /** 1193 /**
1191 * Unplug the action. Ensures that the action is not 1194 * Unplug the action. Ensures that the action is not
1192 * destroyed. It will be hidden and reparented to 0L instead. 1195 * destroyed. It will be hidden and reparented to 0L instead.
1193 */ 1196 */
1194 virtual void unplug( QWidget *w ); 1197 virtual void unplug( QWidget *w );
1195protected slots: 1198protected slots:
1196 void slotToolbarDestroyed(); 1199 void slotToolbarDestroyed();
1197private: 1200private:
1198 QGuardedPtr<QWidget> m_widget; 1201 QPointer<QWidget> m_widget;
1199 bool m_autoSized; 1202 bool m_autoSized;
1200protected: 1203protected:
1201 virtual void virtual_hook( int id, void* data ); 1204 virtual void virtual_hook( int id, void* data );
1202private: 1205private:
1203 class KWidgetActionPrivate; 1206 class KWidgetActionPrivate;
1204 KWidgetActionPrivate *d; 1207 KWidgetActionPrivate *d;
1205}; 1208};
1206 1209
1207class KActionSeparator : public KAction 1210class KActionSeparator : public KAction
1208{ 1211{
1209 Q_OBJECT 1212 Q_OBJECT
1210public: 1213public:
1211 KActionSeparator( QObject* parent = 0, const char* name = 0 ); 1214 KActionSeparator( QObject* parent = 0, const char* name = 0 );
1212 virtual ~KActionSeparator(); 1215 virtual ~KActionSeparator();
1213 1216
1214 virtual int plug( QWidget*, int index = -1 ); 1217 virtual int plug( QWidget*, int index = -1 );
1215 1218
1216protected: 1219protected:
1217 virtual void virtual_hook( int id, void* data ); 1220 virtual void virtual_hook( int id, void* data );
1218private: 1221private:
1219 class KActionSeparatorPrivate; 1222 class KActionSeparatorPrivate;
1220 KActionSeparatorPrivate *d; 1223 KActionSeparatorPrivate *d;
1221}; 1224};
1222 1225
1223#endif 1226#endif
diff --git a/microkde/kdeui/kactioncollection.cpp b/microkde/kdeui/kactioncollection.cpp
index 69e5d02..4d66c7f 100644
--- a/microkde/kdeui/kactioncollection.cpp
+++ b/microkde/kdeui/kactioncollection.cpp
@@ -1,840 +1,842 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org> 3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org> 4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org> 5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org> 6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org> 7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org> 8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 (C) 2002 Joseph Wenninger <jowenn@kde.org> 9 (C) 2002 Joseph Wenninger <jowenn@kde.org>
10 10
11 This library is free software; you can redistribute it and/or 11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public 12 modify it under the terms of the GNU Library General Public
13 License version 2 as published by the Free Software Foundation. 13 License version 2 as published by the Free Software Foundation.
14 14
15 This library is distributed in the hope that it will be useful, 15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details. 18 Library General Public License for more details.
19 19
20 You should have received a copy of the GNU Library General Public License 20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to 21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. 23 Boston, MA 02111-1307, USA.
24*/ 24*/
25 25
26#include "kactioncollection.h" 26#include "kactioncollection.h"
27//US#include "kactionshortcutlist.h" 27//US#include "kactionshortcutlist.h"
28 28
29#include <qptrdict.h> 29#include <q3ptrdict.h>
30//Added by qt3to4:
31#include <Q3ValueList>
30//US#include <qvariant.h> 32//US#include <qvariant.h>
31 33
32//US#include <kaccel.h> 34//US#include <kaccel.h>
33//US#include <kaccelbase.h> 35//US#include <kaccelbase.h>
34//US#include <kapplication.h> 36//US#include <kapplication.h>
35#include <kdebug.h> 37#include <kdebug.h>
36//US#include <kxmlguifactory.h> 38//US#include <kxmlguifactory.h>
37 39
38//US I included the following files 40//US I included the following files
39#include <qasciidict.h> 41#include <q3asciidict.h>
40#include <qptrlist.h> 42#include <q3ptrlist.h>
41#include "kaction.h" 43#include "kaction.h"
42#include <kglobal.h> 44#include <kglobal.h>
43#include <qobject.h> 45#include <qobject.h>
44#include <qwidget.h> 46#include <qwidget.h>
45 47
46class KActionCollection::KActionCollectionPrivate 48class KActionCollection::KActionCollectionPrivate
47{ 49{
48public: 50public:
49 KActionCollectionPrivate() 51 KActionCollectionPrivate()
50 { 52 {
51//US m_instance = 0; 53//US m_instance = 0;
52 //m_bOneKAccelOnly = false; 54 //m_bOneKAccelOnly = false;
53 //m_iWidgetCurrent = 0; 55 //m_iWidgetCurrent = 0;
54 m_bAutoConnectShortcuts = true; 56 m_bAutoConnectShortcuts = true;
55 m_widget = 0; 57 m_widget = 0;
56 m_kaccel = m_builderKAccel = 0; 58 m_kaccel = m_builderKAccel = 0;
57 m_dctHighlightContainers.setAutoDelete( true ); 59 m_dctHighlightContainers.setAutoDelete( true );
58 m_highlight = false; 60 m_highlight = false;
59 m_currentHighlightAction = 0; 61 m_currentHighlightAction = 0;
60 m_statusCleared = true; 62 m_statusCleared = true;
61 } 63 }
62 64
63//US KInstance *m_instance; 65//US KInstance *m_instance;
64//US QString m_sXMLFile; 66//US QString m_sXMLFile;
65 bool m_bAutoConnectShortcuts; 67 bool m_bAutoConnectShortcuts;
66 //bool m_bOneKAccelOnly; 68 //bool m_bOneKAccelOnly;
67 //int m_iWidgetCurrent; 69 //int m_iWidgetCurrent;
68 //QValueList<QWidget*> m_widgetList; 70 //QValueList<QWidget*> m_widgetList;
69 //QValueList<KAccel*> m_kaccelList; 71 //QValueList<KAccel*> m_kaccelList;
70 QValueList<KActionCollection*> m_docList; 72 Q3ValueList<KActionCollection*> m_docList;
71 QWidget *m_widget; 73 QWidget *m_widget;
72 KAccel *m_kaccel; 74 KAccel *m_kaccel;
73 KAccel *m_builderKAccel; 75 KAccel *m_builderKAccel;
74 76
75 QAsciiDict<KAction> m_actionDict; 77 Q3AsciiDict<KAction> m_actionDict;
76 QPtrDict< QPtrList<KAction> > m_dctHighlightContainers; 78 Q3PtrDict< Q3PtrList<KAction> > m_dctHighlightContainers;
77 bool m_highlight; 79 bool m_highlight;
78 KAction *m_currentHighlightAction; 80 KAction *m_currentHighlightAction;
79 bool m_statusCleared; 81 bool m_statusCleared;
80}; 82};
81 83
82KActionCollection::KActionCollection( QWidget *parent, const char *name /*US, 84KActionCollection::KActionCollection( QWidget *parent, const char *name /*US,
83 KInstance *instance */) 85 KInstance *instance */)
84 : QObject( (QObject*)parent, name ) 86 : QObject( (QObject*)parent, name )
85{ 87{
86 kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis 88 kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis
87 d = new KActionCollectionPrivate; 89 d = new KActionCollectionPrivate;
88 if( parent ) 90 if( parent )
89 setWidget( parent ); 91 setWidget( parent );
90 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); 92 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
91//US setInstance( instance ); 93//US setInstance( instance );
92} 94}
93 95
94 96
95KActionCollection::KActionCollection( QWidget *watch, QObject* parent, const char *name /*US, 97KActionCollection::KActionCollection( QWidget *watch, QObject* parent, const char *name /*US,
96 KInstance *instance */) 98 KInstance *instance */)
97 : QObject( parent, name ) 99 : QObject( parent, name )
98{ 100{
99 kdDebug(129) << "KActionCollection::KActionCollection( " << watch << ", " << parent << ", " << name << " ): this = " << this << endl; //ellis 101 kdDebug(129) << "KActionCollection::KActionCollection( " << watch << ", " << parent << ", " << name << " ): this = " << this << endl; //ellis
100 d = new KActionCollectionPrivate; 102 d = new KActionCollectionPrivate;
101 if( watch ) 103 if( watch )
102 setWidget( watch ); 104 setWidget( watch );
103 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); 105 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
104//US setInstance( instance ); 106//US setInstance( instance );
105} 107}
106 108
107// KDE 4: remove 109// KDE 4: remove
108KActionCollection::KActionCollection( QObject *parent, const char *name /*US, 110KActionCollection::KActionCollection( QObject *parent, const char *name /*US,
109 KInstance *instance */) 111 KInstance *instance */)
110 : QObject( parent, name ) 112 : QObject( parent, name )
111{ 113{
112 kdWarning(129) << "KActionCollection::KActionCollection( QObject *parent, const char *name, KInstance *instance )" << endl; //ellis 114 kdWarning(129) << "KActionCollection::KActionCollection( QObject *parent, const char *name, KInstance *instance )" << endl; //ellis
113//US kdBacktrace not available 115//US kdBacktrace not available
114//US kdDebug(129) << kdBacktrace() << endl; 116//US kdDebug(129) << kdBacktrace() << endl;
115 d = new KActionCollectionPrivate; 117 d = new KActionCollectionPrivate;
116//US QWidget* w = dynamic_cast<QWidget*>( parent ); 118//US QWidget* w = dynamic_cast<QWidget*>( parent );
117 QWidget* w = (QWidget*)( parent ); 119 QWidget* w = (QWidget*)( parent );
118 if( w ) 120 if( w )
119 setWidget( w ); 121 setWidget( w );
120 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); 122 //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
121//US setInstance( instance ); 123//US setInstance( instance );
122} 124}
123 125
124KActionCollection::KActionCollection( const KActionCollection &copy ) 126KActionCollection::KActionCollection( const KActionCollection &copy )
125 : QObject() 127 : QObject()
126{ 128{
127 kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl; 129 kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl;
128 d = new KActionCollectionPrivate; 130 d = new KActionCollectionPrivate;
129 *this = copy; 131 *this = copy;
130} 132}
131// KDE 4: remove end 133// KDE 4: remove end
132 134
133KActionCollection::~KActionCollection() 135KActionCollection::~KActionCollection()
134{ 136{
135 kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl; 137 kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl;
136 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { 138 for ( Q3AsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
137 KAction* pAction = it.current(); 139 KAction* pAction = it.current();
138 if ( pAction->m_parentCollection == this ) 140 if ( pAction->m_parentCollection == this )
139 pAction->m_parentCollection = 0L; 141 pAction->m_parentCollection = 0L;
140 } 142 }
141 143
142//US delete d->m_kaccel; 144//US delete d->m_kaccel;
143//US delete d->m_builderKAccel; 145//US delete d->m_builderKAccel;
144 delete d; d = 0; 146 delete d; d = 0;
145} 147}
146 148
147void KActionCollection::setWidget( QWidget* w ) 149void KActionCollection::setWidget( QWidget* w )
148{ 150{
149 //if ( d->m_actionDict.count() > 0 ) { 151 //if ( d->m_actionDict.count() > 0 ) {
150 // kdError(129) << "KActionCollection::setWidget(): must be called before any actions are added to collection!" << endl; 152 // kdError(129) << "KActionCollection::setWidget(): must be called before any actions are added to collection!" << endl;
151 // kdDebug(129) << kdBacktrace() << endl; 153 // kdDebug(129) << kdBacktrace() << endl;
152 //} 154 //}
153 //else 155 //else
154 if ( !d->m_widget ) { 156 if ( !d->m_widget ) {
155 d->m_widget = w; 157 d->m_widget = w;
156 //qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde"); 158 //qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde");
157//US d->m_kaccel = new KAccel( w, this, "KActionCollection-KAccel" ); 159//US d->m_kaccel = new KAccel( w, this, "KActionCollection-KAccel" );
158 } 160 }
159 else if ( d->m_widget != w ) 161 else if ( d->m_widget != w )
160 ; 162 ;
161 163
162} 164}
163 165
164void KActionCollection::setAutoConnectShortcuts( bool b ) 166void KActionCollection::setAutoConnectShortcuts( bool b )
165{ 167{
166 d->m_bAutoConnectShortcuts = b; 168 d->m_bAutoConnectShortcuts = b;
167} 169}
168 170
169bool KActionCollection::isAutoConnectShortcuts() 171bool KActionCollection::isAutoConnectShortcuts()
170{ 172{
171 return d->m_bAutoConnectShortcuts; 173 return d->m_bAutoConnectShortcuts;
172} 174}
173 175
174bool KActionCollection::addDocCollection( KActionCollection* pDoc ) 176bool KActionCollection::addDocCollection( KActionCollection* pDoc )
175{ 177{
176 d->m_docList.append( pDoc ); 178 d->m_docList.append( pDoc );
177 return true; 179 return true;
178} 180}
179 181
180void KActionCollection::beginXMLPlug( QWidget *widget ) 182void KActionCollection::beginXMLPlug( QWidget *widget )
181{ 183{
182 qDebug("KActionCollection::beginXMLPlug has to be fixed"); 184 qDebug("KActionCollection::beginXMLPlug has to be fixed");
183/*US 185/*US
184 kdDebug(129) << "KActionCollection::beginXMLPlug( buildWidget = " << widget << " ): this = " << this << " d->m_builderKAccel = " << d->m_builderKAccel << endl; 186 kdDebug(129) << "KActionCollection::beginXMLPlug( buildWidget = " << widget << " ): this = " << this << " d->m_builderKAccel = " << d->m_builderKAccel << endl;
185 187
186 if( widget && !d->m_builderKAccel ) { 188 if( widget && !d->m_builderKAccel ) {
187 d->m_builderKAccel = new KAccel( widget, this, "KActionCollection-BuilderKAccel" ); 189 d->m_builderKAccel = new KAccel( widget, this, "KActionCollection-BuilderKAccel" );
188 } 190 }
189*/ 191*/
190} 192}
191 193
192void KActionCollection::endXMLPlug() 194void KActionCollection::endXMLPlug()
193{ 195{
194 kdDebug(129) << "KActionCollection::endXMLPlug(): this = " << this << endl; 196 kdDebug(129) << "KActionCollection::endXMLPlug(): this = " << this << endl;
195 //s_kaccelXML = 0; 197 //s_kaccelXML = 0;
196} 198}
197 199
198void KActionCollection::prepareXMLUnplug() 200void KActionCollection::prepareXMLUnplug()
199{ 201{
200 qDebug("KActionCollection::prepareXMLUnplug has to be fixed"); 202 qDebug("KActionCollection::prepareXMLUnplug has to be fixed");
201/*US 203/*US
202 kdDebug(129) << "KActionCollection::prepareXMLUnplug(): this = " << this << endl; 204 kdDebug(129) << "KActionCollection::prepareXMLUnplug(): this = " << this << endl;
203 unplugShortcuts( d->m_kaccel ); 205 unplugShortcuts( d->m_kaccel );
204 206
205 if( d->m_builderKAccel ) { 207 if( d->m_builderKAccel ) {
206 unplugShortcuts( d->m_builderKAccel ); 208 unplugShortcuts( d->m_builderKAccel );
207 delete d->m_builderKAccel; 209 delete d->m_builderKAccel;
208 d->m_builderKAccel = 0; 210 d->m_builderKAccel = 0;
209 } 211 }
210*/ 212*/
211} 213}
212 214
213void KActionCollection::unplugShortcuts( KAccel* kaccel ) 215void KActionCollection::unplugShortcuts( KAccel* kaccel )
214{ 216{
215 qDebug("KActionCollection::unplugShortcuts has to be fixed"); 217 qDebug("KActionCollection::unplugShortcuts has to be fixed");
216/*US 218/*US
217 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { 219 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
218 KAction* pAction = it.current(); 220 KAction* pAction = it.current();
219 pAction->removeKAccel( kaccel ); 221 pAction->removeKAccel( kaccel );
220 } 222 }
221 223
222 for( uint i = 0; i < d->m_docList.count(); i++ ) 224 for( uint i = 0; i < d->m_docList.count(); i++ )
223 d->m_docList[i]->unplugShortcuts( kaccel ); 225 d->m_docList[i]->unplugShortcuts( kaccel );
224*/ 226*/
225 227
226} 228}
227 229
228/*void KActionCollection::addWidget( QWidget* w ) 230/*void KActionCollection::addWidget( QWidget* w )
229{ 231{
230 if( !d->m_bOneKAccelOnly ) { 232 if( !d->m_bOneKAccelOnly ) {
231 kdDebug(129) << "KActionCollection::addWidget( " << w << " ): this = " << this << endl; 233 kdDebug(129) << "KActionCollection::addWidget( " << w << " ): this = " << this << endl;
232 for( uint i = 0; i < d->m_widgetList.count(); i++ ) { 234 for( uint i = 0; i < d->m_widgetList.count(); i++ ) {
233 if( d->m_widgetList[i] == w ) { 235 if( d->m_widgetList[i] == w ) {
234 d->m_iWidgetCurrent = i; 236 d->m_iWidgetCurrent = i;
235 return; 237 return;
236 } 238 }
237 } 239 }
238 d->m_iWidgetCurrent = d->m_widgetList.count(); 240 d->m_iWidgetCurrent = d->m_widgetList.count();
239 d->m_widgetList.append( w ); 241 d->m_widgetList.append( w );
240 d->m_kaccelList.append( new KAccel( w, this, "KActionCollection-KAccel" ) ); 242 d->m_kaccelList.append( new KAccel( w, this, "KActionCollection-KAccel" ) );
241 } 243 }
242} 244}
243 245
244void KActionCollection::removeWidget( QWidget* w ) 246void KActionCollection::removeWidget( QWidget* w )
245{ 247{
246 if( !d->m_bOneKAccelOnly ) { 248 if( !d->m_bOneKAccelOnly ) {
247 kdDebug(129) << "KActionCollection::removeWidget( " << w << " ): this = " << this << endl; 249 kdDebug(129) << "KActionCollection::removeWidget( " << w << " ): this = " << this << endl;
248 for( uint i = 0; i < d->m_widgetList.count(); i++ ) { 250 for( uint i = 0; i < d->m_widgetList.count(); i++ ) {
249 if( d->m_widgetList[i] == w ) { 251 if( d->m_widgetList[i] == w ) {
250 // Remove KAccel object from children. 252 // Remove KAccel object from children.
251 KAccel* pKAccel = d->m_kaccelList[i]; 253 KAccel* pKAccel = d->m_kaccelList[i];
252 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { 254 for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
253 KAction* pAction = it.current(); 255 KAction* pAction = it.current();
254 if ( pAction->m_parentCollection == this ) { 256 if ( pAction->m_parentCollection == this ) {
255 pAction->removeKAccel( pKAccel ); 257 pAction->removeKAccel( pKAccel );
256 } 258 }
257 } 259 }
258 delete pKAccel; 260 delete pKAccel;
259 261
260 d->m_widgetList.remove( d->m_widgetList.at( i ) ); 262 d->m_widgetList.remove( d->m_widgetList.at( i ) );
261 d->m_kaccelList.remove( d->m_kaccelList.at( i ) ); 263 d->m_kaccelList.remove( d->m_kaccelList.at( i ) );
262 264
263 if( d->m_iWidgetCurrent == (int)i ) 265 if( d->m_iWidgetCurrent == (int)i )
264 d->m_iWidgetCurrent = -1; 266 d->m_iWidgetCurrent = -1;
265 else if( d->m_iWidgetCurrent > (int)i ) 267 else if( d->m_iWidgetCurrent > (int)i )
266 d->m_iWidgetCurrent--; 268 d->m_iWidgetCurrent--;
267 return; 269 return;
268 } 270 }
269 } 271 }
270 kdWarning(129) << "KActionCollection::removeWidget( " << w << " ): widget not in list." << endl; 272 kdWarning(129) << "KActionCollection::removeWidget( " << w << " ): widget not in list." << endl;
271 } 273 }
272} 274}
273 275
274bool KActionCollection::ownsKAccel() const 276bool KActionCollection::ownsKAccel() const
275{ 277{
276 return d->m_bOneKAccelOnly; 278 return d->m_bOneKAccelOnly;
277} 279}
278 280
279uint KActionCollection::widgetCount() const 281uint KActionCollection::widgetCount() const
280{ 282{
281 return d->m_widgetList.count(); 283 return d->m_widgetList.count();
282} 284}
283 285
284const KAccel* KActionCollection::widgetKAccel( uint i ) const 286const KAccel* KActionCollection::widgetKAccel( uint i ) const
285{ 287{
286 return d->m_kaccelList[i]; 288 return d->m_kaccelList[i];
287}*/ 289}*/
288 290
289//US we are using no accelerators so far. So just setup an empty implementation. 291//US we are using no accelerators so far. So just setup an empty implementation.
290KAccel* KActionCollection::kaccel() 292KAccel* KActionCollection::kaccel()
291{ 293{
292 //if( d->m_kaccelList.count() > 0 ) 294 //if( d->m_kaccelList.count() > 0 )
293 // return d->m_kaccelList[d->m_iWidgetCurrent]; 295 // return d->m_kaccelList[d->m_iWidgetCurrent];
294 //else 296 //else
295 // return 0; 297 // return 0;
296//US return d->m_kaccel; 298//US return d->m_kaccel;
297 return 0; 299 return 0;
298} 300}
299 301
300//US we are using no accelerators so far. So just setup an empty implementation. 302//US we are using no accelerators so far. So just setup an empty implementation.
301const KAccel* KActionCollection::kaccel() const 303const KAccel* KActionCollection::kaccel() const
302{ 304{
303 //if( d->m_kaccelList.count() > 0 ) 305 //if( d->m_kaccelList.count() > 0 )
304 // return d->m_kaccelList[d->m_iWidgetCurrent]; 306 // return d->m_kaccelList[d->m_iWidgetCurrent];
305 //else 307 //else
306 // return 0; 308 // return 0;
307 //USreturn d->m_kaccel; 309 //USreturn d->m_kaccel;
308 return 0; 310 return 0;
309} 311}
310 312
311/*void KActionCollection::findMainWindow( QWidget *w ) 313/*void KActionCollection::findMainWindow( QWidget *w )
312{ 314{
313 // Note: topLevelWidget() stops too early, we can't use it. 315 // Note: topLevelWidget() stops too early, we can't use it.
314 QWidget * tl = w; 316 QWidget * tl = w;
315 while ( tl->parentWidget() ) // lookup parent and store 317 while ( tl->parentWidget() ) // lookup parent and store
316 tl = tl->parentWidget(); 318 tl = tl->parentWidget();
317 319
318 KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow 320 KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow
319 if (mw) 321 if (mw)
320 d->m_mainwindow = mw; 322 d->m_mainwindow = mw;
321 else 323 else
322 kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; 324 kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl;
323}*/ 325}*/
324 326
325void KActionCollection::_insert( KAction* action ) 327void KActionCollection::_insert( KAction* action )
326{ 328{
327 char unnamed_name[100]; 329 char unnamed_name[100];
328 const char *name = action->name(); 330 const char *name = action->name();
329 if( qstrcmp( name, "unnamed" ) == 0 ) 331 if( qstrcmp( name, "unnamed" ) == 0 )
330 { 332 {
331 sprintf(unnamed_name, "unnamed-%p", (void *)action); 333 sprintf(unnamed_name, "unnamed-%p", (void *)action);
332 name = unnamed_name; 334 name = unnamed_name;
333 } 335 }
334 KAction *a = d->m_actionDict[ name ]; 336 KAction *a = d->m_actionDict[ name ];
335 if ( a == action ) 337 if ( a == action )
336 return; 338 return;
337 339
338 d->m_actionDict.insert( name, action ); 340 d->m_actionDict.insert( name, action );
339 341
340 emit inserted( action ); 342 emit inserted( action );
341} 343}
342 344
343void KActionCollection::_remove( KAction* action ) 345void KActionCollection::_remove( KAction* action )
344{ 346{
345 delete _take( action ); 347 delete _take( action );
346} 348}
347 349
348KAction* KActionCollection::_take( KAction* action ) 350KAction* KActionCollection::_take( KAction* action )
349{ 351{
350 char unnamed_name[100]; 352 char unnamed_name[100];
351 const char *name = action->name(); 353 const char *name = action->name();
352 if( qstrcmp( name, "unnamed" ) == 0 ) 354 if( qstrcmp( name, "unnamed" ) == 0 )
353 { 355 {
354 sprintf(unnamed_name, "unnamed-%p", (void *) action); 356 sprintf(unnamed_name, "unnamed-%p", (void *) action);
355 name = unnamed_name; 357 name = unnamed_name;
356 } 358 }
357 359
358 KAction *a = d->m_actionDict.take( name ); 360 KAction *a = d->m_actionDict.take( name );
359 if ( !a || a != action ) 361 if ( !a || a != action )
360 return 0; 362 return 0;
361 363
362 emit removed( action ); 364 emit removed( action );
363 return a; 365 return a;
364} 366}
365 367
366void KActionCollection::_clear() 368void KActionCollection::_clear()
367{ 369{
368 QAsciiDictIterator<KAction> it( d->m_actionDict ); 370 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
369 while ( it.current() ) 371 while ( it.current() )
370 _remove( it.current() ); 372 _remove( it.current() );
371} 373}
372 374
373void KActionCollection::insert( KAction* action ) { _insert( action ); } 375void KActionCollection::insert( KAction* action ) { _insert( action ); }
374void KActionCollection::remove( KAction* action ) { _remove( action ); } 376void KActionCollection::remove( KAction* action ) { _remove( action ); }
375KAction* KActionCollection::take( KAction* action ) { return _take( action ); } 377KAction* KActionCollection::take( KAction* action ) { return _take( action ); }
376void KActionCollection::clear() { _clear(); } 378void KActionCollection::clear() { _clear(); }
377KAccel* KActionCollection::accel() { return kaccel(); } 379KAccel* KActionCollection::accel() { return kaccel(); }
378const KAccel* KActionCollection::accel() const { return kaccel(); } 380const KAccel* KActionCollection::accel() const { return kaccel(); }
379KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; } 381KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; }
380 382
381KAction* KActionCollection::action( const char* name, const char* classname ) const 383KAction* KActionCollection::action( const char* name, const char* classname ) const
382{ 384{
383 KAction* pAction = 0; 385 KAction* pAction = 0;
384 386
385 if ( !classname && name ) 387 if ( !classname && name )
386 pAction = d->m_actionDict[ name ]; 388 pAction = d->m_actionDict[ name ];
387 389
388 else { 390 else {
389 QAsciiDictIterator<KAction> it( d->m_actionDict ); 391 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
390 for( ; it.current(); ++it ) 392 for( ; it.current(); ++it )
391 { 393 {
392 if ( ( !name || strcmp( it.current()->name(), name ) == 0 ) && 394 if ( ( !name || strcmp( it.current()->name(), name ) == 0 ) &&
393 ( !classname || strcmp( it.current()->className(), classname ) == 0 ) ) { 395 ( !classname || strcmp( it.current()->className(), classname ) == 0 ) ) {
394 pAction = it.current(); 396 pAction = it.current();
395 break; 397 break;
396 } 398 }
397 } 399 }
398 } 400 }
399 401
400 if( !pAction ) { 402 if( !pAction ) {
401 for( uint i = 0; i < d->m_docList.count() && !pAction; i++ ) 403 for( uint i = 0; i < d->m_docList.count() && !pAction; i++ )
402 pAction = d->m_docList[i]->action( name, classname ); 404 pAction = d->m_docList[i]->action( name, classname );
403 } 405 }
404 406
405 return pAction; 407 return pAction;
406} 408}
407 409
408KAction* KActionCollection::action( int index ) const 410KAction* KActionCollection::action( int index ) const
409{ 411{
410 QAsciiDictIterator<KAction> it( d->m_actionDict ); 412 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
411 it += index; 413 it += index;
412 return it.current(); 414 return it.current();
413// return d->m_actions.at( index ); 415// return d->m_actions.at( index );
414} 416}
415/*US 417/*US
416bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) 418bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig )
417{ 419{
418 return KActionShortcutList(this).readSettings( sConfigGroup, pConfig ); 420 return KActionShortcutList(this).readSettings( sConfigGroup, pConfig );
419} 421}
420 422
421bool KActionCollection::writeShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) const 423bool KActionCollection::writeShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) const
422{ 424{
423 return KActionShortcutList((KActionCollection*)this).writeSettings( sConfigGroup, pConfig ); 425 return KActionShortcutList((KActionCollection*)this).writeSettings( sConfigGroup, pConfig );
424} 426}
425*/ 427*/
426uint KActionCollection::count() const 428uint KActionCollection::count() const
427{ 429{
428 return d->m_actionDict.count(); 430 return d->m_actionDict.count();
429} 431}
430 432
431QStringList KActionCollection::groups() const 433QStringList KActionCollection::groups() const
432{ 434{
433 QStringList lst; 435 QStringList lst;
434 436
435 QAsciiDictIterator<KAction> it( d->m_actionDict ); 437 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
436 for( ; it.current(); ++it ) 438 for( ; it.current(); ++it )
437 if ( !it.current()->group().isEmpty() && !lst.contains( it.current()->group() ) ) 439 if ( !it.current()->group().isEmpty() && !lst.contains( it.current()->group() ) )
438 lst.append( it.current()->group() ); 440 lst.append( it.current()->group() );
439 441
440 return lst; 442 return lst;
441} 443}
442 444
443KActionPtrList KActionCollection::actions( const QString& group ) const 445KActionPtrList KActionCollection::actions( const QString& group ) const
444{ 446{
445 KActionPtrList lst; 447 KActionPtrList lst;
446 448
447 QAsciiDictIterator<KAction> it( d->m_actionDict ); 449 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
448 for( ; it.current(); ++it ) 450 for( ; it.current(); ++it )
449 if ( it.current()->group() == group ) 451 if ( it.current()->group() == group )
450 lst.append( it.current() ); 452 lst.append( it.current() );
451 else if ( it.current()->group().isEmpty() && group.isEmpty() ) 453 else if ( it.current()->group().isEmpty() && group.isEmpty() )
452 lst.append( it.current() ); 454 lst.append( it.current() );
453 455
454 return lst; 456 return lst;
455} 457}
456 458
457KActionPtrList KActionCollection::actions() const 459KActionPtrList KActionCollection::actions() const
458{ 460{
459 KActionPtrList lst; 461 KActionPtrList lst;
460 462
461 QAsciiDictIterator<KAction> it( d->m_actionDict ); 463 Q3AsciiDictIterator<KAction> it( d->m_actionDict );
462 for( ; it.current(); ++it ) 464 for( ; it.current(); ++it )
463 lst.append( it.current() ); 465 lst.append( it.current() );
464 466
465 return lst; 467 return lst;
466} 468}
467 469
468/*US we have no instance object. Use KGlobal instead 470/*US we have no instance object. Use KGlobal instead
469void KActionCollection::setInstance( KInstance *instance ) 471void KActionCollection::setInstance( KInstance *instance )
470{ 472{
471 if ( instance ) 473 if ( instance )
472 d->m_instance = instance; 474 d->m_instance = instance;
473qDebug("KActionCollection::setInstance has to be fixed"); 475qDebug("KActionCollection::setInstance has to be fixed");
474 else 476 else
475 d->m_instance = KGlobal::instance(); 477 d->m_instance = KGlobal::instance();
476} 478}
477 479
478KInstance *KActionCollection::instance() const 480KInstance *KActionCollection::instance() const
479{ 481{
480 return d->m_instance; 482 return d->m_instance;
481} 483}
482*/ 484*/
483 485
484/*US we have no XML facility in microkde 486/*US we have no XML facility in microkde
485void KActionCollection::setXMLFile( const QString& sXMLFile ) 487void KActionCollection::setXMLFile( const QString& sXMLFile )
486{ 488{
487 d->m_sXMLFile = sXMLFile; 489 d->m_sXMLFile = sXMLFile;
488} 490}
489 491
490const QString& KActionCollection::xmlFile() const 492const QString& KActionCollection::xmlFile() const
491{ 493{
492 return d->m_sXMLFile; 494 return d->m_sXMLFile;
493} 495}
494*/ 496*/
495 497
496void KActionCollection::setHighlightingEnabled( bool enable ) 498void KActionCollection::setHighlightingEnabled( bool enable )
497{ 499{
498 d->m_highlight = enable; 500 d->m_highlight = enable;
499} 501}
500 502
501bool KActionCollection::highlightingEnabled() const 503bool KActionCollection::highlightingEnabled() const
502{ 504{
503 return d->m_highlight; 505 return d->m_highlight;
504} 506}
505 507
506void KActionCollection::connectHighlight( QWidget *container, KAction *action ) 508void KActionCollection::connectHighlight( QWidget *container, KAction *action )
507{ 509{
508 if ( !d->m_highlight ) 510 if ( !d->m_highlight )
509 return; 511 return;
510 512
511 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; 513 Q3PtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ];
512 514
513 if ( !actionList ) 515 if ( !actionList )
514 { 516 {
515 actionList = new QPtrList<KAction>; 517 actionList = new Q3PtrList<KAction>;
516 518
517 if ( container->inherits( "QPopupMenu" ) ) 519 if ( container->inherits( "Q3PopupMenu" ) )
518 { 520 {
519 connect( container, SIGNAL( highlighted( int ) ), 521 connect( container, SIGNAL( highlighted( int ) ),
520 this, SLOT( slotMenuItemHighlighted( int ) ) ); 522 this, SLOT( slotMenuItemHighlighted( int ) ) );
521 connect( container, SIGNAL( aboutToHide() ), 523 connect( container, SIGNAL( aboutToHide() ),
522 this, SLOT( slotMenuAboutToHide() ) ); 524 this, SLOT( slotMenuAboutToHide() ) );
523 } 525 }
524//US else if ( container->inherits( "KToolBar" ) ) 526//US else if ( container->inherits( "KToolBar" ) )
525 else if ( container->inherits( "QToolBar" ) ) 527 else if ( container->inherits( "Q3ToolBar" ) )
526 { 528 {
527 connect( container, SIGNAL( highlighted( int, bool ) ), 529 connect( container, SIGNAL( highlighted( int, bool ) ),
528 this, SLOT( slotToolBarButtonHighlighted( int, bool ) ) ); 530 this, SLOT( slotToolBarButtonHighlighted( int, bool ) ) );
529 } 531 }
530 532
531 connect( container, SIGNAL( destroyed() ), 533 connect( container, SIGNAL( destroyed() ),
532 this, SLOT( slotDestroyed() ) ); 534 this, SLOT( slotDestroyed() ) );
533 535
534 d->m_dctHighlightContainers.insert( container, actionList ); 536 d->m_dctHighlightContainers.insert( container, actionList );
535 } 537 }
536 538
537 actionList->append( action ); 539 actionList->append( action );
538} 540}
539 541
540void KActionCollection::disconnectHighlight( QWidget *container, KAction *action ) 542void KActionCollection::disconnectHighlight( QWidget *container, KAction *action )
541{ 543{
542 if ( !d->m_highlight ) 544 if ( !d->m_highlight )
543 return; 545 return;
544 546
545 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; 547 Q3PtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ];
546 548
547 if ( !actionList ) 549 if ( !actionList )
548 return; 550 return;
549 551
550 actionList->removeRef( action ); 552 actionList->removeRef( action );
551 553
552 if ( actionList->count() == 0 ) 554 if ( actionList->count() == 0 )
553 d->m_dctHighlightContainers.remove( container ); 555 d->m_dctHighlightContainers.remove( container );
554} 556}
555 557
556void KActionCollection::slotMenuItemHighlighted( int id ) 558void KActionCollection::slotMenuItemHighlighted( int id )
557{ 559{
558 if ( !d->m_highlight ) 560 if ( !d->m_highlight )
559 return; 561 return;
560 562
561 if ( d->m_currentHighlightAction ) 563 if ( d->m_currentHighlightAction )
562 emit actionHighlighted( d->m_currentHighlightAction, false ); 564 emit actionHighlighted( d->m_currentHighlightAction, false );
563 565
564 QWidget *container = static_cast<QWidget *>( const_cast<QObject *>( sender() ) ); 566 QWidget *container = static_cast<QWidget *>( const_cast<QObject *>( sender() ) );
565 567
566 d->m_currentHighlightAction = findAction( container, id ); 568 d->m_currentHighlightAction = findAction( container, id );
567 569
568 if ( !d->m_currentHighlightAction ) 570 if ( !d->m_currentHighlightAction )
569 { 571 {
570 if ( !d->m_statusCleared ) 572 if ( !d->m_statusCleared )
571 emit clearStatusText(); 573 emit clearStatusText();
572 d->m_statusCleared = true; 574 d->m_statusCleared = true;
573 return; 575 return;
574 } 576 }
575 577
576 d->m_statusCleared = false; 578 d->m_statusCleared = false;
577 emit actionHighlighted( d->m_currentHighlightAction ); 579 emit actionHighlighted( d->m_currentHighlightAction );
578 emit actionHighlighted( d->m_currentHighlightAction, true ); 580 emit actionHighlighted( d->m_currentHighlightAction, true );
579 emit actionStatusText( d->m_currentHighlightAction->toolTip() ); 581 emit actionStatusText( d->m_currentHighlightAction->toolTip() );
580} 582}
581 583
582void KActionCollection::slotMenuAboutToHide() 584void KActionCollection::slotMenuAboutToHide()
583{ 585{
584 if ( d->m_currentHighlightAction ) 586 if ( d->m_currentHighlightAction )
585 emit actionHighlighted( d->m_currentHighlightAction, false ); 587 emit actionHighlighted( d->m_currentHighlightAction, false );
586 d->m_currentHighlightAction = 0; 588 d->m_currentHighlightAction = 0;
587 589
588 if ( !d->m_statusCleared ) 590 if ( !d->m_statusCleared )
589 emit clearStatusText(); 591 emit clearStatusText();
590 d->m_statusCleared = true; 592 d->m_statusCleared = true;
591} 593}
592 594
593void KActionCollection::slotToolBarButtonHighlighted( int id, bool highlight ) 595void KActionCollection::slotToolBarButtonHighlighted( int id, bool highlight )
594{ 596{
595 if ( !d->m_highlight ) 597 if ( !d->m_highlight )
596 return; 598 return;
597 599
598 QWidget *container = static_cast<QWidget *>( const_cast<QObject *>( sender() ) ); 600 QWidget *container = static_cast<QWidget *>( const_cast<QObject *>( sender() ) );
599 601
600 KAction *action = findAction( container, id ); 602 KAction *action = findAction( container, id );
601 603
602 if ( !action ) 604 if ( !action )
603 { 605 {
604 d->m_currentHighlightAction = 0; 606 d->m_currentHighlightAction = 0;
605 // use tooltip groups for toolbar status text stuff instead (Simon) 607 // use tooltip groups for toolbar status text stuff instead (Simon)
606// emit clearStatusText(); 608// emit clearStatusText();
607 return; 609 return;
608 } 610 }
609 611
610 emit actionHighlighted( action, highlight ); 612 emit actionHighlighted( action, highlight );
611 613
612 if ( highlight ) 614 if ( highlight )
613 d->m_currentHighlightAction = action; 615 d->m_currentHighlightAction = action;
614 else 616 else
615 { 617 {
616 d->m_currentHighlightAction = 0; 618 d->m_currentHighlightAction = 0;
617// emit clearStatusText(); 619// emit clearStatusText();
618 } 620 }
619} 621}
620 622
621void KActionCollection::slotDestroyed() 623void KActionCollection::slotDestroyed()
622{ 624{
623 d->m_dctHighlightContainers.remove( reinterpret_cast<void *>( const_cast<QObject *>(sender()) ) ); 625 d->m_dctHighlightContainers.remove( reinterpret_cast<void *>( const_cast<QObject *>(sender()) ) );
624} 626}
625 627
626KAction *KActionCollection::findAction( QWidget *container, int id ) 628KAction *KActionCollection::findAction( QWidget *container, int id )
627{ 629{
628 QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ reinterpret_cast<void *>( container ) ]; 630 Q3PtrList<KAction> *actionList = d->m_dctHighlightContainers[ reinterpret_cast<void *>( container ) ];
629 631
630 if ( !actionList ) 632 if ( !actionList )
631 return 0; 633 return 0;
632 634
633 QPtrListIterator<KAction> it( *actionList ); 635 Q3PtrListIterator<KAction> it( *actionList );
634 for (; it.current(); ++it ) 636 for (; it.current(); ++it )
635 if ( it.current()->isPlugged( container, id ) ) 637 if ( it.current()->isPlugged( container, id ) )
636 return it.current(); 638 return it.current();
637 639
638 return 0; 640 return 0;
639} 641}
640 642
641// KDE 4: remove 643// KDE 4: remove
642KActionCollection KActionCollection::operator+(const KActionCollection &c ) const 644KActionCollection KActionCollection::operator+(const KActionCollection &c ) const
643{ 645{
644 kdWarning(129) << "KActionCollection::operator+(): function is severely deprecated." << endl; 646 kdWarning(129) << "KActionCollection::operator+(): function is severely deprecated." << endl;
645 KActionCollection ret( *this ); 647 KActionCollection ret( *this );
646 648
647 QValueList<KAction *> actions = c.actions(); 649 Q3ValueList<KAction *> actions = c.actions();
648 QValueList<KAction *>::ConstIterator it = actions.begin(); 650 Q3ValueList<KAction *>::ConstIterator it = actions.begin();
649 QValueList<KAction *>::ConstIterator end = actions.end(); 651 Q3ValueList<KAction *>::ConstIterator end = actions.end();
650 for (; it != end; ++it ) 652 for (; it != end; ++it )
651 ret.insert( *it ); 653 ret.insert( *it );
652 654
653 return ret; 655 return ret;
654} 656}
655 657
656KActionCollection &KActionCollection::operator=( const KActionCollection &copy ) 658KActionCollection &KActionCollection::operator=( const KActionCollection &copy )
657{ 659{
658 kdWarning(129) << "KActionCollection::operator=(): function is severely deprecated." << endl; 660 kdWarning(129) << "KActionCollection::operator=(): function is severely deprecated." << endl;
659 //d->m_bOneKAccelOnly = copy.d->m_bOneKAccelOnly; 661 //d->m_bOneKAccelOnly = copy.d->m_bOneKAccelOnly;
660 //d->m_iWidgetCurrent = copy.d->m_iWidgetCurrent; 662 //d->m_iWidgetCurrent = copy.d->m_iWidgetCurrent;
661 //d->m_widgetList = copy.d->m_widgetList; 663 //d->m_widgetList = copy.d->m_widgetList;
662 //d->m_kaccelList = copy.d->m_kaccelList; 664 //d->m_kaccelList = copy.d->m_kaccelList;
663 d->m_widget = copy.d->m_widget; 665 d->m_widget = copy.d->m_widget;
664 d->m_kaccel = copy.d->m_kaccel; 666 d->m_kaccel = copy.d->m_kaccel;
665 d->m_actionDict = copy.d->m_actionDict; 667 d->m_actionDict = copy.d->m_actionDict;
666//US setInstance( copy.instance() ); 668//US setInstance( copy.instance() );
667 return *this; 669 return *this;
668} 670}
669 671
670KActionCollection &KActionCollection::operator+=( const KActionCollection &c ) 672KActionCollection &KActionCollection::operator+=( const KActionCollection &c )
671{ 673{
672 kdWarning(129) << "KActionCollection::operator+=(): function is severely deprecated." << endl; 674 kdWarning(129) << "KActionCollection::operator+=(): function is severely deprecated." << endl;
673 QAsciiDictIterator<KAction> it(c.d->m_actionDict); 675 Q3AsciiDictIterator<KAction> it(c.d->m_actionDict);
674 for ( ; it.current(); ++it ) 676 for ( ; it.current(); ++it )
675 insert( it.current() ); 677 insert( it.current() );
676 678
677 return *this; 679 return *this;
678} 680}
679// KDE 4: remove end 681// KDE 4: remove end
680 682
681//--------------------------------------------------------------------- 683//---------------------------------------------------------------------
682// KActionShortcutList 684// KActionShortcutList
683//--------------------------------------------------------------------- 685//---------------------------------------------------------------------
684/*US 686/*US
685KActionShortcutList::KActionShortcutList( KActionCollection* pColl ) 687KActionShortcutList::KActionShortcutList( KActionCollection* pColl )
686: m_actions( *pColl ) 688: m_actions( *pColl )
687 { } 689 { }
688KActionShortcutList::~KActionShortcutList() 690KActionShortcutList::~KActionShortcutList()
689 { } 691 { }
690uint KActionShortcutList::count() const 692uint KActionShortcutList::count() const
691 { return m_actions.count(); } 693 { return m_actions.count(); }
692QString KActionShortcutList::name( uint i ) const 694QString KActionShortcutList::name( uint i ) const
693 { return m_actions.action(i)->name(); } 695 { return m_actions.action(i)->name(); }
694QString KActionShortcutList::label( uint i ) const 696QString KActionShortcutList::label( uint i ) const
695 { return m_actions.action(i)->text(); } 697 { return m_actions.action(i)->text(); }
696QString KActionShortcutList::whatsThis( uint i ) const 698QString KActionShortcutList::whatsThis( uint i ) const
697 { return m_actions.action(i)->whatsThis(); } 699 { return m_actions.action(i)->whatsThis(); }
698const KShortcut& KActionShortcutList::shortcut( uint i ) const 700const KShortcut& KActionShortcutList::shortcut( uint i ) const
699 { return m_actions.action(i)->shortcut(); } 701 { return m_actions.action(i)->shortcut(); }
700const KShortcut& KActionShortcutList::shortcutDefault( uint i ) const 702const KShortcut& KActionShortcutList::shortcutDefault( uint i ) const
701 { return m_actions.action(i)->shortcutDefault(); } 703 { return m_actions.action(i)->shortcutDefault(); }
702bool KActionShortcutList::isConfigurable( uint i ) const 704bool KActionShortcutList::isConfigurable( uint i ) const
703 { return m_actions.action(i)->isShortcutConfigurable(); } 705 { return m_actions.action(i)->isShortcutConfigurable(); }
704bool KActionShortcutList::setShortcut( uint i, const KShortcut& cut ) 706bool KActionShortcutList::setShortcut( uint i, const KShortcut& cut )
705 { return m_actions.action(i)->setShortcut( cut ); } 707 { return m_actions.action(i)->setShortcut( cut ); }
706const KInstance* KActionShortcutList::instance() const 708const KInstance* KActionShortcutList::instance() const
707 { return m_actions.instance(); } 709 { return m_actions.instance(); }
708QVariant KActionShortcutList::getOther( Other, uint ) const 710QVariant KActionShortcutList::getOther( Other, uint ) const
709 { return QVariant(); } 711 { return QVariant(); }
710bool KActionShortcutList::setOther( Other, uint, QVariant ) 712bool KActionShortcutList::setOther( Other, uint, QVariant )
711 { return false; } 713 { return false; }
712 714
713bool KActionShortcutList::save() const 715bool KActionShortcutList::save() const
714{ 716{
715 kdDebug(129) << "KActionShortcutList::save(): xmlFile = " << m_actions.xmlFile() << endl; 717 kdDebug(129) << "KActionShortcutList::save(): xmlFile = " << m_actions.xmlFile() << endl;
716 718
717 if( m_actions.xmlFile().isEmpty() ) 719 if( m_actions.xmlFile().isEmpty() )
718 return writeSettings(); 720 return writeSettings();
719 721
720 QString tagActionProp = QString::fromLatin1("ActionProperties"); 722 QString tagActionProp = QString::fromLatin1("ActionProperties");
721 QString tagAction = QString::fromLatin1("Action"); 723 QString tagAction = QString::fromLatin1("Action");
722 QString attrName = QString::fromLatin1("name"); 724 QString attrName = QString::fromLatin1("name");
723 QString attrShortcut = QString::fromLatin1("shortcut"); 725 QString attrShortcut = QString::fromLatin1("shortcut");
724 QString attrAccel = QString::fromLatin1("accel"); // Depricated attribute 726 QString attrAccel = QString::fromLatin1("accel"); // Depricated attribute
725 727
726 // Read XML file 728 // Read XML file
727 QString sXml( KXMLGUIFactory::readConfigFile( m_actions.xmlFile(), false, instance() ) ); 729 QString sXml( KXMLGUIFactory::readConfigFile( m_actions.xmlFile(), false, instance() ) );
728 QDomDocument doc; 730 QDomDocument doc;
729 doc.setContent( sXml ); 731 doc.setContent( sXml );
730 732
731 // Process XML data 733 // Process XML data
732 734
733 // first, lets see if we have existing properties 735 // first, lets see if we have existing properties
734 QDomElement elem; 736 QDomElement elem;
735 QDomElement it = doc.documentElement(); 737 QDomElement it = doc.documentElement();
736 // KXMLGUIFactory::removeDOMComments( it ); <-- What was this for? --ellis 738 // KXMLGUIFactory::removeDOMComments( it ); <-- What was this for? --ellis
737 it = it.firstChild().toElement(); 739 it = it.firstChild().toElement();
738 for( ; !it.isNull(); it = it.nextSibling().toElement() ) { 740 for( ; !it.isNull(); it = it.nextSibling().toElement() ) {
739 if( it.tagName() == tagActionProp ) { 741 if( it.tagName() == tagActionProp ) {
740 elem = it; 742 elem = it;
741 break; 743 break;
742 } 744 }
743 } 745 }
744 746
745 // if there was none, create one 747 // if there was none, create one
746 if( elem.isNull() ) { 748 if( elem.isNull() ) {
747 elem = doc.createElement( tagActionProp ); 749 elem = doc.createElement( tagActionProp );
748 doc.documentElement().appendChild( elem ); 750 doc.documentElement().appendChild( elem );
749 } 751 }
750 752
751 // now, iterate through our actions 753 // now, iterate through our actions
752 uint nSize = count(); 754 uint nSize = count();
753 for( uint i = 0; i < nSize; i++ ) { 755 for( uint i = 0; i < nSize; i++ ) {
754 const QString& sName = name(i); 756 const QString& sName = name(i);
755 757
756 bool bSameAsDefault = (shortcut(i) == shortcutDefault(i)); 758 bool bSameAsDefault = (shortcut(i) == shortcutDefault(i));
757 //kdDebug(129) << "name = " << sName << " shortcut = " << shortcut(i).toStringInternal() << " def = " << shortcutDefault(i).toStringInternal() << endl; 759 //kdDebug(129) << "name = " << sName << " shortcut = " << shortcut(i).toStringInternal() << " def = " << shortcutDefault(i).toStringInternal() << endl;
758 760
759 // now see if this element already exists 761 // now see if this element already exists
760 QDomElement act_elem; 762 QDomElement act_elem;
761 for( it = elem.firstChild().toElement(); !it.isNull(); it = it.nextSibling().toElement() ) { 763 for( it = elem.firstChild().toElement(); !it.isNull(); it = it.nextSibling().toElement() ) {
762 if( it.attribute( attrName ) == sName ) { 764 if( it.attribute( attrName ) == sName ) {
763 act_elem = it; 765 act_elem = it;
764 break; 766 break;
765 } 767 }
766 } 768 }
767 769
768 // nope, create a new one 770 // nope, create a new one
769 if( act_elem.isNull() ) { 771 if( act_elem.isNull() ) {
770 if( bSameAsDefault ) 772 if( bSameAsDefault )
771 continue; 773 continue;
772 //kdDebug(129) << "\tnode doesn't exist." << endl; 774 //kdDebug(129) << "\tnode doesn't exist." << endl;
773 act_elem = doc.createElement( tagAction ); 775 act_elem = doc.createElement( tagAction );
774 act_elem.setAttribute( attrName, sName ); 776 act_elem.setAttribute( attrName, sName );
775 } 777 }
776 778
777 act_elem.removeAttribute( attrAccel ); 779 act_elem.removeAttribute( attrAccel );
778 if( bSameAsDefault ) { 780 if( bSameAsDefault ) {
779 act_elem.removeAttribute( attrShortcut ); 781 act_elem.removeAttribute( attrShortcut );
780 //kdDebug(129) << "act_elem.attributes().count() = " << act_elem.attributes().count() << endl; 782 //kdDebug(129) << "act_elem.attributes().count() = " << act_elem.attributes().count() << endl;
781 if( act_elem.attributes().count() == 1 ) 783 if( act_elem.attributes().count() == 1 )
782 elem.removeChild( act_elem ); 784 elem.removeChild( act_elem );
783 } else { 785 } else {
784 act_elem.setAttribute( attrShortcut, shortcut(i).toStringInternal() ); 786 act_elem.setAttribute( attrShortcut, shortcut(i).toStringInternal() );
785 elem.appendChild( act_elem ); 787 elem.appendChild( act_elem );
786 } 788 }
787 } 789 }
788 790
789 // Write back to XML file 791 // Write back to XML file
790 return KXMLGUIFactory::saveConfigFile( doc, m_actions.xmlFile(), instance() ); 792 return KXMLGUIFactory::saveConfigFile( doc, m_actions.xmlFile(), instance() );
791} 793}
792 794
793//--------------------------------------------------------------------- 795//---------------------------------------------------------------------
794// KActionPtrShortcutList 796// KActionPtrShortcutList
795//--------------------------------------------------------------------- 797//---------------------------------------------------------------------
796 798
797KActionPtrShortcutList::KActionPtrShortcutList( KActionPtrList& list ) 799KActionPtrShortcutList::KActionPtrShortcutList( KActionPtrList& list )
798: m_actions( list ) 800: m_actions( list )
799 { } 801 { }
800KActionPtrShortcutList::~KActionPtrShortcutList() 802KActionPtrShortcutList::~KActionPtrShortcutList()
801 { } 803 { }
802uint KActionPtrShortcutList::count() const 804uint KActionPtrShortcutList::count() const
803 { return m_actions.count(); } 805 { return m_actions.count(); }
804QString KActionPtrShortcutList::name( uint i ) const 806QString KActionPtrShortcutList::name( uint i ) const
805 { return m_actions[i]->name(); } 807 { return m_actions[i]->name(); }
806QString KActionPtrShortcutList::label( uint i ) const 808QString KActionPtrShortcutList::label( uint i ) const
807 { return m_actions[i]->text(); } 809 { return m_actions[i]->text(); }
808QString KActionPtrShortcutList::whatsThis( uint i ) const 810QString KActionPtrShortcutList::whatsThis( uint i ) const
809 { return m_actions[i]->whatsThis(); } 811 { return m_actions[i]->whatsThis(); }
810const KShortcut& KActionPtrShortcutList::shortcut( uint i ) const 812const KShortcut& KActionPtrShortcutList::shortcut( uint i ) const
811 { return m_actions[i]->shortcut(); } 813 { return m_actions[i]->shortcut(); }
812const KShortcut& KActionPtrShortcutList::shortcutDefault( uint i ) const 814const KShortcut& KActionPtrShortcutList::shortcutDefault( uint i ) const
813 { return m_actions[i]->shortcutDefault(); } 815 { return m_actions[i]->shortcutDefault(); }
814bool KActionPtrShortcutList::isConfigurable( uint i ) const 816bool KActionPtrShortcutList::isConfigurable( uint i ) const
815 { return m_actions[i]->isShortcutConfigurable(); } 817 { return m_actions[i]->isShortcutConfigurable(); }
816bool KActionPtrShortcutList::setShortcut( uint i, const KShortcut& cut ) 818bool KActionPtrShortcutList::setShortcut( uint i, const KShortcut& cut )
817 { return m_actions[i]->setShortcut( cut ); } 819 { return m_actions[i]->setShortcut( cut ); }
818QVariant KActionPtrShortcutList::getOther( Other, uint ) const 820QVariant KActionPtrShortcutList::getOther( Other, uint ) const
819 { return QVariant(); } 821 { return QVariant(); }
820bool KActionPtrShortcutList::setOther( Other, uint, QVariant ) 822bool KActionPtrShortcutList::setOther( Other, uint, QVariant )
821 { return false; } 823 { return false; }
822bool KActionPtrShortcutList::save() const 824bool KActionPtrShortcutList::save() const
823 { return false; } 825 { return false; }
824 826
825void KActionShortcutList::virtual_hook( int id, void* data ) 827void KActionShortcutList::virtual_hook( int id, void* data )
826{ KShortcutList::virtual_hook( id, data ); } 828{ KShortcutList::virtual_hook( id, data ); }
827 829
828void KActionPtrShortcutList::virtual_hook( int id, void* data ) 830void KActionPtrShortcutList::virtual_hook( int id, void* data )
829{ KShortcutList::virtual_hook( id, data ); } 831{ KShortcutList::virtual_hook( id, data ); }
830*/ 832*/
831 833
832void KActionCollection::virtual_hook( int, void* ) 834void KActionCollection::virtual_hook( int, void* )
833{ /*BASE::virtual_hook( id, data );*/ } 835{ /*BASE::virtual_hook( id, data );*/ }
834 836
835/* vim: et sw=2 ts=2 837/* vim: et sw=2 ts=2
836 */ 838 */
837 839
838/*US 840/*US
839#include "kactioncollection.moc" 841#include "kactioncollection.moc"
840*/ 842*/
diff --git a/microkde/kdeui/kactioncollection.h b/microkde/kdeui/kactioncollection.h
index b9466d0..50cb02a 100644
--- a/microkde/kdeui/kactioncollection.h
+++ b/microkde/kdeui/kactioncollection.h
@@ -1,329 +1,331 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
3 (C) 1999 Simon Hausmann <hausmann@kde.org> 3 (C) 1999 Simon Hausmann <hausmann@kde.org>
4 (C) 2000 Nicolas Hadacek <haadcek@kde.org> 4 (C) 2000 Nicolas Hadacek <haadcek@kde.org>
5 (C) 2000 Kurt Granroth <granroth@kde.org> 5 (C) 2000 Kurt Granroth <granroth@kde.org>
6 (C) 2000 Michael Koch <koch@kde.org> 6 (C) 2000 Michael Koch <koch@kde.org>
7 (C) 2001 Holger Freyther <freyther@kde.org> 7 (C) 2001 Holger Freyther <freyther@kde.org>
8 (C) 2002 Ellis Whitehead <ellis@kde.org> 8 (C) 2002 Ellis Whitehead <ellis@kde.org>
9 9
10 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public 11 modify it under the terms of the GNU Library General Public
12 License version 2 as published by the Free Software Foundation. 12 License version 2 as published by the Free Software Foundation.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23*/ 23*/
24//$Id$ 24//$Id$
25 25
26#ifndef __kactioncollection_h__ 26#ifndef __kactioncollection_h__
27#define __kactioncollection_h__ 27#define __kactioncollection_h__
28 28
29#include <kaction.h> 29#include <kaction.h>
30 30
31//US #include <qkeysequence.h> 31//US #include <qkeysequence.h>
32#include <qobject.h> 32#include <qobject.h>
33//Added by qt3to4:
34#include <Q3ValueList>
33//US#include <qvaluelist.h> 35//US#include <qvaluelist.h>
34//US#include <qguardedptr.h> 36//US#include <qguardedptr.h>
35//US #include <kguiitem.h> 37//US #include <kguiitem.h>
36//US#include <kshortcut.h> 38//US#include <kshortcut.h>
37//US#include <kstdaction.h> 39//US#include <kstdaction.h>
38//US#include <kicontheme.h> 40//US#include <kicontheme.h>
39 41
40//USclass QMenuBar; 42//USclass QMenuBar;
41//USclass QPopupMenu; 43//USclass QPopupMenu;
42//USclass QComboBox; 44//USclass QComboBox;
43//USclass QPoint; 45//USclass QPoint;
44//USclass QIconSet; 46//USclass QIconSet;
45//USclass QString; 47//USclass QString;
46//USclass KToolBar; 48//USclass KToolBar;
47 49
48//USclass KAccel; 50//USclass KAccel;
49//USclass KAccelActions; 51//USclass KAccelActions;
50//USclass KConfig; 52//USclass KConfig;
51//USclass KConfigBase; 53//USclass KConfigBase;
52//USclass KURL; 54//USclass KURL;
53//USclass KInstance; 55//USclass KInstance;
54//USclass KToolBar; 56//USclass KToolBar;
55//USclass KActionCollection; 57//USclass KActionCollection;
56//USclass KPopupMenu; 58//USclass KPopupMenu;
57//USclass KMainWindow; 59//USclass KMainWindow;
58 60
59//US added inclidefiles 61//US added inclidefiles
60class QWidget; 62class QWidget;
61 63
62 64
63typedef QValueList<KAction *> KActionPtrList; 65typedef Q3ValueList<KAction *> KActionPtrList;
64 66
65/** 67/**
66 * A managed set of KAction objects. 68 * A managed set of KAction objects.
67 */ 69 */
68class KActionCollection : public QObject 70class KActionCollection : public QObject
69{ 71{
70 friend class KAction; 72 friend class KAction;
71 friend class KXMLGUIClient; 73 friend class KXMLGUIClient;
72 74
73 Q_OBJECT 75 Q_OBJECT
74public: 76public:
75 KActionCollection( QWidget *parent, const char *name = 0/*US , KInstance *instance = 0 */); 77 KActionCollection( QWidget *parent, const char *name = 0/*US , KInstance *instance = 0 */);
76 /** 78 /**
77 * Use this constructor if you want the collection's actions to restrict 79 * Use this constructor if you want the collection's actions to restrict
78 * their accelerator keys to @p watch rather than the @p parent. If 80 * their accelerator keys to @p watch rather than the @p parent. If
79 * you don't require shortcuts, you can pass a null to the @p watch parameter. 81 * you don't require shortcuts, you can pass a null to the @p watch parameter.
80 */ 82 */
81 KActionCollection( QWidget *watch, QObject* parent, const char *name = 0/*US, KInstance *instance = 0 */); 83 KActionCollection( QWidget *watch, QObject* parent, const char *name = 0/*US, KInstance *instance = 0 */);
82 KActionCollection( const KActionCollection &copy ); 84 KActionCollection( const KActionCollection &copy );
83 virtual ~KActionCollection(); 85 virtual ~KActionCollection();
84 86
85 /** 87 /**
86 * This sets the widget to which the keyboard shortcuts should be attached. 88 * This sets the widget to which the keyboard shortcuts should be attached.
87 * You only need to call this if a null pointer was passed in the constructor. 89 * You only need to call this if a null pointer was passed in the constructor.
88 */ 90 */
89 virtual void setWidget( QWidget *widget ); 91 virtual void setWidget( QWidget *widget );
90 92
91 /** 93 /**
92 * This indicates whether new actions which are created in this collection 94 * This indicates whether new actions which are created in this collection
93 * should have their keyboard shortcuts automatically connected on 95 * should have their keyboard shortcuts automatically connected on
94 * construction. Set to 'false' if you will be loading XML-based settings. 96 * construction. Set to 'false' if you will be loading XML-based settings.
95 * This is automatically done by KParts. The default is 'true'. 97 * This is automatically done by KParts. The default is 'true'.
96 * @see isAutoConnectShortcuts() 98 * @see isAutoConnectShortcuts()
97 */ 99 */
98 void setAutoConnectShortcuts( bool ); 100 void setAutoConnectShortcuts( bool );
99 101
100 /** 102 /**
101 * This indicates whether new actions which are created in this collection 103 * This indicates whether new actions which are created in this collection
102 * have their keyboard shortcuts automatically connected on 104 * have their keyboard shortcuts automatically connected on
103 * construction. 105 * construction.
104 * @see setAutoConnectShortcuts() 106 * @see setAutoConnectShortcuts()
105 */ 107 */
106 bool isAutoConnectShortcuts(); 108 bool isAutoConnectShortcuts();
107 109
108 /** 110 /**
109 * This sets the default shortcut scope for new actions created in this 111 * This sets the default shortcut scope for new actions created in this
110 * collection. The default is ScopeUnspecified. Ideally the default 112 * collection. The default is ScopeUnspecified. Ideally the default
111 * would have been ScopeWidget, but that would cause some backwards 113 * would have been ScopeWidget, but that would cause some backwards
112 * compatibility problems. 114 * compatibility problems.
113 */ 115 */
114 //void setDefaultScope( KAction::Scope ); 116 //void setDefaultScope( KAction::Scope );
115 117
116 /** 118 /**
117 * Doc/View model. This lets you add the action collection of a document 119 * Doc/View model. This lets you add the action collection of a document
118 * to a view's action collection. 120 * to a view's action collection.
119 */ 121 */
120 bool addDocCollection( KActionCollection* pDoc ); 122 bool addDocCollection( KActionCollection* pDoc );
121 123
122 /** Returns the number of widgets which this collection is associated with. */ 124 /** Returns the number of widgets which this collection is associated with. */
123 //uint widgetCount() const; 125 //uint widgetCount() const;
124 126
125 /** 127 /**
126 * Returns true if the collection has its own KAccel object. This will be 128 * Returns true if the collection has its own KAccel object. This will be
127 * the case if it was constructed with a valid widget ptr or if setWidget() 129 * the case if it was constructed with a valid widget ptr or if setWidget()
128 * was called. 130 * was called.
129 */ 131 */
130 //bool ownsKAccel() const; 132 //bool ownsKAccel() const;
131 133
132 /** @deprecated Deprecated because of ambiguous name. Use kaccel() */ 134 /** @deprecated Deprecated because of ambiguous name. Use kaccel() */
133 virtual KAccel* accel(); 135 virtual KAccel* accel();
134 /** @deprecated Deprecated because of ambiguous name. Use kaccel() */ 136 /** @deprecated Deprecated because of ambiguous name. Use kaccel() */
135 virtual const KAccel* accel() const; 137 virtual const KAccel* accel() const;
136 138
137 /** Returns the KAccel object of the most recently set widget. */ 139 /** Returns the KAccel object of the most recently set widget. */
138 KAccel* kaccel(); 140 KAccel* kaccel();
139 /** Returns the KAccel object of the most recently set widget. Const version for convenience. */ 141 /** Returns the KAccel object of the most recently set widget. Const version for convenience. */
140 const KAccel* kaccel() const; 142 const KAccel* kaccel() const;
141 143
142 /** @internal, for KAction::kaccelCurrent() */ 144 /** @internal, for KAction::kaccelCurrent() */
143 KAccel* builderKAccel() const; 145 KAccel* builderKAccel() const;
144 /** Returns the KAccel object associated with widget #. */ 146 /** Returns the KAccel object associated with widget #. */
145 //KAccel* widgetKAccel( uint i ); 147 //KAccel* widgetKAccel( uint i );
146 //const KAccel* widgetKAccel( uint i ) const; 148 //const KAccel* widgetKAccel( uint i ) const;
147 149
148 /** Returns the number of actions in the collection */ 150 /** Returns the number of actions in the collection */
149 virtual uint count() const; 151 virtual uint count() const;
150 bool isEmpty() const { return count() == 0; } 152 bool isEmpty() const { return count() == 0; }
151 /** 153 /**
152 * Return the KAction* at position "index" in the action collection. 154 * Return the KAction* at position "index" in the action collection.
153 * @see count() 155 * @see count()
154 */ 156 */
155 virtual KAction* action( int index ) const; 157 virtual KAction* action( int index ) const;
156 /** 158 /**
157 * Find an action (optionally, of a given subclass of KAction) in the action collection. 159 * Find an action (optionally, of a given subclass of KAction) in the action collection.
158 * @param name Name of the KAction. 160 * @param name Name of the KAction.
159 * @param classname Name of the KAction subclass. 161 * @param classname Name of the KAction subclass.
160 * @return A pointer to the first KAction in the collection which matches the parameters or 162 * @return A pointer to the first KAction in the collection which matches the parameters or
161 * null if nothing matches. 163 * null if nothing matches.
162 */ 164 */
163 virtual KAction* action( const char* name, const char* classname = 0 ) const; 165 virtual KAction* action( const char* name, const char* classname = 0 ) const;
164 166
165 /** Returns a list of all the groups of all the KActions in this action collection. 167 /** Returns a list of all the groups of all the KActions in this action collection.
166 * @see KAction::group() 168 * @see KAction::group()
167 * @see KAction::setGroup() 169 * @see KAction::setGroup()
168 */ 170 */
169 virtual QStringList groups() const; 171 virtual QStringList groups() const;
170 /** 172 /**
171 * Returns the list of actions in a particular managed by this action collection. 173 * Returns the list of actions in a particular managed by this action collection.
172 * @param group The name of the group. 174 * @param group The name of the group.
173 */ 175 */
174 virtual KActionPtrList actions( const QString& group ) const; 176 virtual KActionPtrList actions( const QString& group ) const;
175 /** Returns the list of actions managed by this action collection. */ 177 /** Returns the list of actions managed by this action collection. */
176 virtual KActionPtrList actions() const; 178 virtual KActionPtrList actions() const;
177 179
178 /** 180 /**
179 * Used for reading shortcut configuration from a non-XML rc file. 181 * Used for reading shortcut configuration from a non-XML rc file.
180 */ 182 */
181//US bool readShortcutSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 ); 183//US bool readShortcutSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 );
182 /** 184 /**
183 * Used for writing shortcut configuration to a non-XML rc file. 185 * Used for writing shortcut configuration to a non-XML rc file.
184 */ 186 */
185//US bool writeShortcutSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 ) const; 187//US bool writeShortcutSettings( const QString& sConfigGroup = QString::null, KConfigBase* pConfig = 0 ) const;
186 188
187//US void setInstance( KInstance *instance ); 189//US void setInstance( KInstance *instance );
188 /** The instance with which this class is associated. */ 190 /** The instance with which this class is associated. */
189//US KInstance *instance() const; 191//US KInstance *instance() const;
190 192
191 /** 193 /**
192 * Use this to tell the KActionCollection what rc file its configuration 194 * Use this to tell the KActionCollection what rc file its configuration
193 * is stored in. 195 * is stored in.
194 */ 196 */
195 void setXMLFile( const QString& ); 197 void setXMLFile( const QString& );
196 /** The rc file in which the current configuration is stored. */ 198 /** The rc file in which the current configuration is stored. */
197 const QString& xmlFile() const; 199 const QString& xmlFile() const;
198 200
199 /** 201 /**
200 * Enable highlighting notification for specific KActions. 202 * Enable highlighting notification for specific KActions.
201 * @see connectHighlight() 203 * @see connectHighlight()
202 * @see disconnectHighlight() 204 * @see disconnectHighlight()
203 * @see actionHighlighted() 205 * @see actionHighlighted()
204 * @see actionHighlighted() 206 * @see actionHighlighted()
205 * @see highlightingEnabled() 207 * @see highlightingEnabled()
206 */ 208 */
207 void setHighlightingEnabled( bool enable ); 209 void setHighlightingEnabled( bool enable );
208 /** 210 /**
209 * Return whether highlighting notifications are enabled. 211 * Return whether highlighting notifications are enabled.
210 * @see connectHighlight() 212 * @see connectHighlight()
211 * @see disconnectHighlight() 213 * @see disconnectHighlight()
212 * @see actionHighlighted() 214 * @see actionHighlighted()
213 * @see setHighlightingEnabled() 215 * @see setHighlightingEnabled()
214 * @see actionHighlighted() 216 * @see actionHighlighted()
215 */ 217 */
216 bool highlightingEnabled() const; 218 bool highlightingEnabled() const;
217 219
218 /** 220 /**
219 * Call this function if you want to receive a signal whenever a KAction is highlighted in a menu or a toolbar. 221 * Call this function if you want to receive a signal whenever a KAction is highlighted in a menu or a toolbar.
220 * @param container A container in which the KAction is plugged (must inherit QPopupMenu or KToolBar) 222 * @param container A container in which the KAction is plugged (must inherit QPopupMenu or KToolBar)
221 * @param action The action you are interested in 223 * @param action The action you are interested in
222 * @see disconnectHighlight() 224 * @see disconnectHighlight()
223 * @see actionHighlighted() 225 * @see actionHighlighted()
224 * @see setHighlightingEnabled() 226 * @see setHighlightingEnabled()
225 * @see highlightingEnabled() 227 * @see highlightingEnabled()
226 * @see actionHighlighted() 228 * @see actionHighlighted()
227 */ 229 */
228 void connectHighlight( QWidget *container, KAction *action ); 230 void connectHighlight( QWidget *container, KAction *action );
229 /** 231 /**
230 * Disconnect highlight notifications for a particular pair of contianer and action. 232 * Disconnect highlight notifications for a particular pair of contianer and action.
231 * @param container A container in which the KAction is plugged (must inherit QPopupMenu or KToolBar) 233 * @param container A container in which the KAction is plugged (must inherit QPopupMenu or KToolBar)
232 * @param action The action you are interested in 234 * @param action The action you are interested in
233 * @see connectHighlight() 235 * @see connectHighlight()
234 * @see actionHighlighted() 236 * @see actionHighlighted()
235 * @see setHighlightingEnabled() 237 * @see setHighlightingEnabled()
236 * @see highlightingEnabled() 238 * @see highlightingEnabled()
237 * @see actionHighlighted() 239 * @see actionHighlighted()
238 */ 240 */
239 void disconnectHighlight( QWidget *container, KAction *action ); 241 void disconnectHighlight( QWidget *container, KAction *action );
240 242
241signals: 243signals:
242 void inserted( KAction* ); 244 void inserted( KAction* );
243 void removed( KAction* ); 245 void removed( KAction* );
244 246
245 /** Emitted when "action" is highlighted. 247 /** Emitted when "action" is highlighted.
246 * @see connectHighlight() 248 * @see connectHighlight()
247 * @see disconnectHighlight() 249 * @see disconnectHighlight()
248 * @see actionHighlighted() 250 * @see actionHighlighted()
249 * @see setHighlightingEnabled() 251 * @see setHighlightingEnabled()
250 * @see highlightingEnabled() 252 * @see highlightingEnabled()
251 */ 253 */
252 void actionHighlighted( KAction *action ); 254 void actionHighlighted( KAction *action );
253 /** Emitted when "action" is highlighed or loses highlighting. 255 /** Emitted when "action" is highlighed or loses highlighting.
254 * @see connectHighlight() 256 * @see connectHighlight()
255 * @see disconnectHighlight() 257 * @see disconnectHighlight()
256 * @see actionHighlighted() 258 * @see actionHighlighted()
257 * @see setHighlightingEnabled() 259 * @see setHighlightingEnabled()
258 * @see highlightingEnabled() 260 * @see highlightingEnabled()
259 */ 261 */
260 void actionHighlighted( KAction *action, bool highlight ); 262 void actionHighlighted( KAction *action, bool highlight );
261 263
262 void actionStatusText( const QString &text ); 264 void actionStatusText( const QString &text );
263 void clearStatusText(); 265 void clearStatusText();
264 266
265private: 267private:
266 /** 268 /**
267 * @internal Only to be called by KXMLGUIFactory::addClient(). 269 * @internal Only to be called by KXMLGUIFactory::addClient().
268 * When actions are being connected, KAction needs to know what 270 * When actions are being connected, KAction needs to know what
269 * widget it should connect widget-scope actions to, and what 271 * widget it should connect widget-scope actions to, and what
270 * main window it should connect 272 * main window it should connect
271 */ 273 */
272 void beginXMLPlug( QWidget *widget ); 274 void beginXMLPlug( QWidget *widget );
273 void endXMLPlug(); 275 void endXMLPlug();
274 /** @internal. Only to be called by KXMLGUIFactory::removeClient() */ 276 /** @internal. Only to be called by KXMLGUIFactory::removeClient() */
275 void prepareXMLUnplug(); 277 void prepareXMLUnplug();
276 void unplugShortcuts( KAccel* kaccel ); 278 void unplugShortcuts( KAccel* kaccel );
277 279
278 void _clear(); 280 void _clear();
279 void _insert( KAction* ); 281 void _insert( KAction* );
280 void _remove( KAction* ); 282 void _remove( KAction* );
281 KAction* _take( KAction* ); 283 KAction* _take( KAction* );
282 284
283private slots: 285private slots:
284 void slotMenuItemHighlighted( int id ); 286 void slotMenuItemHighlighted( int id );
285 void slotToolBarButtonHighlighted( int id, bool highlight ); 287 void slotToolBarButtonHighlighted( int id, bool highlight );
286 void slotMenuAboutToHide(); 288 void slotMenuAboutToHide();
287 void slotDestroyed(); 289 void slotDestroyed();
288 290
289private: 291private:
290 KAction *findAction( QWidget *container, int id ); 292 KAction *findAction( QWidget *container, int id );
291 293
292#ifndef KDE_NO_COMPAT 294#ifndef KDE_NO_COMPAT
293public: 295public:
294 KActionCollection( QObject *parent, const char *name = 0 /*US, KInstance *instance = 0 */); 296 KActionCollection( QObject *parent, const char *name = 0 /*US, KInstance *instance = 0 */);
295 297
296 void insert( KAction* ); 298 void insert( KAction* );
297 299
298 /** 300 /**
299 * @deprecated Removes an action from the collection and deletes it. 301 * @deprecated Removes an action from the collection and deletes it.
300 * @param action The KAction to remove. 302 * @param action The KAction to remove.
301 */ 303 */
302 void remove( KAction* action ); 304 void remove( KAction* action );
303 305
304 /** 306 /**
305 * @deprecated Removes an action from the collection. 307 * @deprecated Removes an action from the collection.
306 * @return NULL if not found else returns action. 308 * @return NULL if not found else returns action.
307 * @param action the KAction to remove. 309 * @param action the KAction to remove.
308 */ 310 */
309 KAction* take( KAction* action ); 311 KAction* take( KAction* action );
310 312
311 KActionCollection operator+ ( const KActionCollection& ) const; 313 KActionCollection operator+ ( const KActionCollection& ) const;
312 KActionCollection& operator= ( const KActionCollection& ); 314 KActionCollection& operator= ( const KActionCollection& );
313 KActionCollection& operator+= ( const KActionCollection& ); 315 KActionCollection& operator+= ( const KActionCollection& );
314 316
315public slots: 317public slots:
316 /** 318 /**
317 * Clears the entire actionCollection, deleting all actions. 319 * Clears the entire actionCollection, deleting all actions.
318 * @see #remove 320 * @see #remove
319 */ 321 */
320 void clear(); 322 void clear();
321#endif // !KDE_NO_COMPAT 323#endif // !KDE_NO_COMPAT
322protected: 324protected:
323 virtual void virtual_hook( int id, void* data ); 325 virtual void virtual_hook( int id, void* data );
324private: 326private:
325 class KActionCollectionPrivate; 327 class KActionCollectionPrivate;
326 KActionCollectionPrivate *d; 328 KActionCollectionPrivate *d;
327}; 329};
328 330
329#endif 331#endif
diff --git a/microkde/kdeui/kbuttonbox.cpp b/microkde/kdeui/kbuttonbox.cpp
index 83d622a..3ea6703 100644
--- a/microkde/kdeui/kbuttonbox.cpp
+++ b/microkde/kdeui/kbuttonbox.cpp
@@ -1,300 +1,302 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com) 2 Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20/* 20/*
21 * KButtonBox class 21 * KButtonBox class
22 * 22 *
23 * A container widget for buttons. Uses Qt layout control to place the 23 * A container widget for buttons. Uses Qt layout control to place the
24 * buttons, can handle both vertical and horizontal button placement. 24 * buttons, can handle both vertical and horizontal button placement.
25* 25*
26 * HISTORY 26 * HISTORY
27 * 27 *
28 * 03/08/2000 Mario Weilguni <mweilguni@kde.org> 28 * 03/08/2000 Mario Weilguni <mweilguni@kde.org>
29 * Removed all those long outdated Motif stuff 29 * Removed all those long outdated Motif stuff
30 * Improved and clarified some if conditions (easier to understand) 30 * Improved and clarified some if conditions (easier to understand)
31 * 31 *
32 * 11/13/98 Reginald Stadlbauer <reggie@kde.org> 32 * 11/13/98 Reginald Stadlbauer <reggie@kde.org>
33 * Now in Qt 1.4x motif default buttons have no extra width/height anymore. 33 * Now in Qt 1.4x motif default buttons have no extra width/height anymore.
34 * So the KButtonBox doesn't add this width/height to default buttons anymore 34 * So the KButtonBox doesn't add this width/height to default buttons anymore
35 * which makes the buttons look better. 35 * which makes the buttons look better.
36 * 36 *
37 * 01/17/98 Mario Weilguni <mweilguni@sime.com> 37 * 01/17/98 Mario Weilguni <mweilguni@sime.com>
38 * Fixed a bug in sizeHint() 38 * Fixed a bug in sizeHint()
39 * Improved the handling of Motif default buttons 39 * Improved the handling of Motif default buttons
40 * 40 *
41 * 01/09/98 Mario Weilguni <mweilguni@sime.com> 41 * 01/09/98 Mario Weilguni <mweilguni@sime.com>
42 * The last button was to far right away from the right/bottom border. 42 * The last button was to far right away from the right/bottom border.
43 * Fixed this. Removed old code. Buttons get now a minimum width. 43 * Fixed this. Removed old code. Buttons get now a minimum width.
44 * Programmer may now override minimum width and height of a button. 44 * Programmer may now override minimum width and height of a button.
45 * 45 *
46 */ 46 */
47 47
48//US #include "kbuttonbox.moc" 48//US #include "kbuttonbox.moc"
49 49
50#include <kbuttonbox.h> 50#include <kbuttonbox.h>
51#include <qpushbutton.h> 51#include <qpushbutton.h>
52#include <qptrlist.h> 52#include <q3ptrlist.h>
53//Added by qt3to4:
54#include <QResizeEvent>
53#include <assert.h> 55#include <assert.h>
54 56
55#define minButtonWidth 50 57#define minButtonWidth 50
56 58
57class KButtonBox::Item { 59class KButtonBox::Item {
58public: 60public:
59 QPushButton *button; 61 QPushButton *button;
60 bool noexpand; 62 bool noexpand;
61 unsigned short stretch; 63 unsigned short stretch;
62 unsigned short actual_size; 64 unsigned short actual_size;
63}; 65};
64 66
65template class QPtrList<KButtonBox::Item>; 67template class Q3PtrList<KButtonBox::Item>;
66 68
67class KButtonBoxPrivate { 69class KButtonBoxPrivate {
68public: 70public:
69 unsigned short border; 71 unsigned short border;
70 unsigned short autoborder; 72 unsigned short autoborder;
71 unsigned short orientation; 73 unsigned short orientation;
72 bool activated; 74 bool activated;
73 QPtrList<KButtonBox::Item> buttons; 75 Q3PtrList<KButtonBox::Item> buttons;
74}; 76};
75 77
76KButtonBox::KButtonBox(QWidget *parent, Orientation _orientation, 78KButtonBox::KButtonBox(QWidget *parent, Qt::Orientation _orientation,
77 int border, int autoborder) 79 int border, int autoborder)
78 : QWidget(parent) 80 : QWidget(parent)
79{ 81{
80 data = new KButtonBoxPrivate; 82 data = new KButtonBoxPrivate;
81 assert(data != 0); 83 assert(data != 0);
82 84
83 data->orientation = _orientation; 85 data->orientation = _orientation;
84 data->border = border; 86 data->border = border;
85 data->autoborder = autoborder < 0 ? border : autoborder; 87 data->autoborder = autoborder < 0 ? border : autoborder;
86 data->buttons.setAutoDelete(TRUE); 88 data->buttons.setAutoDelete(TRUE);
87} 89}
88 90
89KButtonBox::~KButtonBox() { 91KButtonBox::~KButtonBox() {
90 delete data; 92 delete data;
91} 93}
92 94
93QPushButton *KButtonBox::addButton(const QString& text, bool noexpand) { 95QPushButton *KButtonBox::addButton(const QString& text, bool noexpand) {
94 Item *item = new Item; 96 Item *item = new Item;
95 97
96 item->button = new QPushButton(text, this); 98 item->button = new QPushButton(text, this);
97 item->noexpand = noexpand; 99 item->noexpand = noexpand;
98 data->buttons.append(item); 100 data->buttons.append(item);
99 item->button->adjustSize(); 101 item->button->adjustSize();
100 102
101 return item->button; 103 return item->button;
102} 104}
103 105
104 QPushButton * 106 QPushButton *
105KButtonBox::addButton( 107KButtonBox::addButton(
106 const QString & text, 108 const QString & text,
107 QObject * receiver, 109 QObject * receiver,
108 const char * slot, 110 const char * slot,
109 bool noexpand 111 bool noexpand
110) 112)
111{ 113{
112 QPushButton * pb = addButton(text, noexpand); 114 QPushButton * pb = addButton(text, noexpand);
113 115
114 if ((0 != receiver) && (0 != slot)) 116 if ((0 != receiver) && (0 != slot))
115 QObject::connect(pb, SIGNAL(clicked()), receiver, slot); 117 QObject::connect(pb, SIGNAL(clicked()), receiver, slot);
116 118
117 return pb; 119 return pb;
118} 120}
119 121
120 122
121void KButtonBox::addStretch(int scale) { 123void KButtonBox::addStretch(int scale) {
122 if(scale > 0) { 124 if(scale > 0) {
123 Item *item = new Item; 125 Item *item = new Item;
124 item->button = 0; 126 item->button = 0;
125 item->noexpand = FALSE; 127 item->noexpand = FALSE;
126 item->stretch = scale; 128 item->stretch = scale;
127 data->buttons.append(item); 129 data->buttons.append(item);
128 } 130 }
129} 131}
130 132
131void KButtonBox::layout() { 133void KButtonBox::layout() {
132 // resize all buttons 134 // resize all buttons
133 QSize bs = bestButtonSize(); 135 QSize bs = bestButtonSize();
134 136
135 for(unsigned int i = 0; i < data->buttons.count(); i++) { 137 for(unsigned int i = 0; i < data->buttons.count(); i++) {
136 Item *item = data->buttons.at(i); 138 Item *item = data->buttons.at(i);
137 QPushButton *b = item->button; 139 QPushButton *b = item->button;
138 if(b != 0) { 140 if(b != 0) {
139 if(item->noexpand) 141 if(item->noexpand)
140 b->setFixedSize(buttonSizeHint(b)); 142 b->setFixedSize(buttonSizeHint(b));
141 else 143 else
142 b->setFixedSize(bs); 144 b->setFixedSize(bs);
143 } 145 }
144 } 146 }
145 147
146 setMinimumSize(sizeHint()); 148 setMinimumSize(sizeHint());
147} 149}
148 150
149void KButtonBox::placeButtons() { 151void KButtonBox::placeButtons() {
150 unsigned int i; 152 unsigned int i;
151 153
152 if(data->orientation == Horizontal) { 154 if(data->orientation == Qt::Horizontal) {
153 // calculate free size and stretches 155 // calculate free size and stretches
154 int fs = width() - 2 * data->border; 156 int fs = width() - 2 * data->border;
155 int stretch = 0; 157 int stretch = 0;
156 for(i = 0; i < data->buttons.count(); i++) { 158 for(i = 0; i < data->buttons.count(); i++) {
157 Item *item = data->buttons.at(i); 159 Item *item = data->buttons.at(i);
158 if(item->button != 0) { 160 if(item->button != 0) {
159 fs -= item->button->width(); 161 fs -= item->button->width();
160 162
161 // Last button? 163 // Last button?
162 if(i != data->buttons.count() - 1) 164 if(i != data->buttons.count() - 1)
163 fs -= data->autoborder; 165 fs -= data->autoborder;
164 } else 166 } else
165 stretch +=item->stretch; 167 stretch +=item->stretch;
166 } 168 }
167 169
168 // distribute buttons 170 // distribute buttons
169 int x_pos = data->border; 171 int x_pos = data->border;
170 for(i = 0; i < data->buttons.count(); i++) { 172 for(i = 0; i < data->buttons.count(); i++) {
171 Item *item = data->buttons.at(i); 173 Item *item = data->buttons.at(i);
172 if(item->button != 0) { 174 if(item->button != 0) {
173 QPushButton *b = item->button; 175 QPushButton *b = item->button;
174 b->move(x_pos, (height() - b->height()) / 2); 176 b->move(x_pos, (height() - b->height()) / 2);
175 177
176 x_pos += b->width() + data->autoborder; 178 x_pos += b->width() + data->autoborder;
177 } else 179 } else
178 x_pos += (int)((((double)fs) * item->stretch) / stretch); 180 x_pos += (int)((((double)fs) * item->stretch) / stretch);
179 } 181 }
180 } else { // VERTICAL 182 } else { // VERTICAL
181 // calcualte free size and stretches 183 // calcualte free size and stretches
182 int fs = height() - 2 * data->border; 184 int fs = height() - 2 * data->border;
183 int stretch = 0; 185 int stretch = 0;
184 for(i = 0; i < data->buttons.count(); i++) { 186 for(i = 0; i < data->buttons.count(); i++) {
185 Item *item = data->buttons.at(i); 187 Item *item = data->buttons.at(i);
186 if(item->button != 0) 188 if(item->button != 0)
187 fs -= item->button->height() + data->autoborder; 189 fs -= item->button->height() + data->autoborder;
188 else 190 else
189 stretch +=item->stretch; 191 stretch +=item->stretch;
190 } 192 }
191 193
192 // distribute buttons 194 // distribute buttons
193 int y_pos = data->border; 195 int y_pos = data->border;
194 for(i = 0; i < data->buttons.count(); i++) { 196 for(i = 0; i < data->buttons.count(); i++) {
195 Item *item = data->buttons.at(i); 197 Item *item = data->buttons.at(i);
196 if(item->button != 0) { 198 if(item->button != 0) {
197 QPushButton *b = item->button; 199 QPushButton *b = item->button;
198 b->move((width() - b->width()) / 2, y_pos); 200 b->move((width() - b->width()) / 2, y_pos);
199 201
200 y_pos += b->height() + data->autoborder; 202 y_pos += b->height() + data->autoborder;
201 } else 203 } else
202 y_pos += (int)((((double)fs) * item->stretch) / stretch); 204 y_pos += (int)((((double)fs) * item->stretch) / stretch);
203 } 205 }
204 } 206 }
205} 207}
206 208
207void KButtonBox::resizeEvent(QResizeEvent *) { 209void KButtonBox::resizeEvent(QResizeEvent *) {
208 placeButtons(); 210 placeButtons();
209} 211}
210 212
211QSize KButtonBox::bestButtonSize() const { 213QSize KButtonBox::bestButtonSize() const {
212 QSize s(0, 0); 214 QSize s(0, 0);
213 unsigned int i; 215 unsigned int i;
214 216
215 // calculate optimal size 217 // calculate optimal size
216 for(i = 0; i < data->buttons.count(); i++) { 218 for(i = 0; i < data->buttons.count(); i++) {
217 KButtonBox *that = (KButtonBox*)this; // to remove the const ;( 219 KButtonBox *that = (KButtonBox*)this; // to remove the const ;(
218 Item *item = that->data->buttons.at(i); 220 Item *item = that->data->buttons.at(i);
219 QPushButton *b = item->button; 221 QPushButton *b = item->button;
220 222
221 if(b != 0 && !item->noexpand) { 223 if(b != 0 && !item->noexpand) {
222 QSize bs = buttonSizeHint(b); 224 QSize bs = buttonSizeHint(b);
223 225
224 if(bs.width() > s.width()) 226 if(bs.width() > s.width())
225 s.setWidth(bs.width()); 227 s.setWidth(bs.width());
226 if(bs.height() > s.height()) 228 if(bs.height() > s.height())
227 s.setHeight(bs.height()); 229 s.setHeight(bs.height());
228 } 230 }
229 } 231 }
230 232
231 return s; 233 return s;
232} 234}
233 235
234QSize KButtonBox::sizeHint() const { 236QSize KButtonBox::sizeHint() const {
235 unsigned int i, dw; 237 unsigned int i, dw;
236 238
237 if(data->buttons.count() == 0) 239 if(data->buttons.count() == 0)
238 return QSize(0, 0); 240 return QSize(0, 0);
239 else { 241 else {
240 dw = 2 * data->border; 242 dw = 2 * data->border;
241 243
242 QSize bs = bestButtonSize(); 244 QSize bs = bestButtonSize();
243 for(i = 0; i < data->buttons.count(); i++) { 245 for(i = 0; i < data->buttons.count(); i++) {
244 KButtonBox *that = (KButtonBox*)this; 246 KButtonBox *that = (KButtonBox*)this;
245 Item *item = that->data->buttons.at(i); 247 Item *item = that->data->buttons.at(i);
246 QPushButton *b = item->button; 248 QPushButton *b = item->button;
247 if(b != 0) { 249 if(b != 0) {
248 QSize s; 250 QSize s;
249 if(item->noexpand) 251 if(item->noexpand)
250 s = that->buttonSizeHint(b); 252 s = that->buttonSizeHint(b);
251 else 253 else
252 s = bs; 254 s = bs;
253 255
254 if(data->orientation == Horizontal) 256 if(data->orientation == Qt::Horizontal)
255 dw += s.width(); 257 dw += s.width();
256 else 258 else
257 dw += s.height(); 259 dw += s.height();
258 260
259 if( i != data->buttons.count() - 1 ) 261 if( i != data->buttons.count() - 1 )
260 dw += data->autoborder; 262 dw += data->autoborder;
261 } 263 }
262 } 264 }
263 265
264 if(data->orientation == Horizontal) 266 if(data->orientation == Qt::Horizontal)
265 return QSize(dw, bs.height() + 2 * data->border); 267 return QSize(dw, bs.height() + 2 * data->border);
266 else 268 else
267 return QSize(bs.width() + 2 * data->border, dw); 269 return QSize(bs.width() + 2 * data->border, dw);
268 } 270 }
269} 271}
270 272
271QSizePolicy KButtonBox::sizePolicy() const 273QSizePolicy KButtonBox::sizePolicy() const
272{ 274{
273 return data->orientation == Horizontal? 275 return data->orientation == Qt::Horizontal?
274 QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) : 276 QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ) :
275 QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum ); 277 QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Minimum );
276} 278}
277 279
278/* 280/*
279 * Returns the best size for a button. If a button is less than 281 * Returns the best size for a button. If a button is less than
280 * minButtonWidth pixels wide, return minButtonWidth pixels 282 * minButtonWidth pixels wide, return minButtonWidth pixels
281 * as minimum width 283 * as minimum width
282 */ 284 */
283QSize KButtonBox::buttonSizeHint(QPushButton *b) const { 285QSize KButtonBox::buttonSizeHint(QPushButton *b) const {
284 QSize s = b->sizeHint(); 286 QSize s = b->sizeHint();
285 QSize ms = b->minimumSize(); 287 QSize ms = b->minimumSize();
286 if(s.width() < minButtonWidth) 288 if(s.width() < minButtonWidth)
287 s.setWidth(minButtonWidth); 289 s.setWidth(minButtonWidth);
288 290
289 // allows the programmer to override the settings 291 // allows the programmer to override the settings
290 if(ms.width() > s.width()) 292 if(ms.width() > s.width())
291 s.setWidth(ms.width()); 293 s.setWidth(ms.width());
292 if(ms.height() > s.height()) 294 if(ms.height() > s.height())
293 s.setHeight(ms.height()); 295 s.setHeight(ms.height());
294 296
295 return s; 297 return s;
296} 298}
297 299
298void KButtonBox::virtual_hook( int, void* ) 300void KButtonBox::virtual_hook( int, void* )
299{ /*BASE::virtual_hook( id, data );*/ } 301{ /*BASE::virtual_hook( id, data );*/ }
300 302
diff --git a/microkde/kdeui/kbuttonbox.h b/microkde/kdeui/kbuttonbox.h
index 1104366..2e0f41d 100644
--- a/microkde/kdeui/kbuttonbox.h
+++ b/microkde/kdeui/kbuttonbox.h
@@ -1,139 +1,141 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com) 2 Copyright (C) 1997 Mario Weilguni (mweilguni@sime.com)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef __KBUTTONBOX__H__ 20#ifndef __KBUTTONBOX__H__
21#define __KBUTTONBOX__H__ 21#define __KBUTTONBOX__H__
22 22
23#include <qwidget.h> 23#include <qwidget.h>
24//Added by qt3to4:
25#include <QResizeEvent>
24class QPushButton; 26class QPushButton;
25 27
26class KButtonBoxPrivate; 28class KButtonBoxPrivate;
27/** 29/**
28 * Container widget for buttons. 30 * Container widget for buttons.
29 * 31 *
30 * This class uses Qt layout control to place the buttons; can handle 32 * This class uses Qt layout control to place the buttons; can handle
31 * both vertical and horizontal button placement. The default border 33 * both vertical and horizontal button placement. The default border
32 * is now @p 0 (making it easier to deal with layouts). The space 34 * is now @p 0 (making it easier to deal with layouts). The space
33 * between buttons is now more Motif compliant. 35 * between buttons is now more Motif compliant.
34 * 36 *
35 * @author Mario Weilguni <mweilguni@sime.com> 37 * @author Mario Weilguni <mweilguni@sime.com>
36 * @version $Id$ 38 * @version $Id$
37 **/ 39 **/
38 40
39class KButtonBox : public QWidget 41class KButtonBox : public QWidget
40{ 42{
41 Q_OBJECT 43 Q_OBJECT
42 44
43public: 45public:
44 /** 46 /**
45 * Create an empty container for buttons. 47 * Create an empty container for buttons.
46 * 48 *
47 * If @p _orientation is @p Vertical, the buttons inserted with 49 * If @p _orientation is @p Vertical, the buttons inserted with
48 * @ref addButton() are laid out from top to bottom, otherwise they 50 * @ref addButton() are laid out from top to bottom, otherwise they
49 * are laid out from left to right. 51 * are laid out from left to right.
50 */ 52 */
51 KButtonBox(QWidget *parent, Orientation _orientation = Horizontal, 53 KButtonBox(QWidget *parent, Qt::Orientation _orientation = Qt::Horizontal,
52 int border = 0, int _autoborder = 6); 54 int border = 0, int _autoborder = 6);
53 55
54 /** 56 /**
55 * Free private data field 57 * Free private data field
56 */ 58 */
57 ~KButtonBox(); 59 ~KButtonBox();
58 60
59 /** 61 /**
60 * @return The minimum size needed to fit all buttons. 62 * @return The minimum size needed to fit all buttons.
61 * 63 *
62 * This size is 64 * This size is
63 * calculated by the width/height of all buttons plus border/autoborder. 65 * calculated by the width/height of all buttons plus border/autoborder.
64 */ 66 */
65 virtual QSize sizeHint() const; 67 virtual QSize sizeHint() const;
66 /** 68 /**
67 * @reimplemented 69 * @reimplemented
68 */ 70 */
69 virtual QSizePolicy sizePolicy() const; 71 virtual QSizePolicy sizePolicy() const;
70 /** 72 /**
71 * @reimplemented 73 * @reimplemented
72 */ 74 */
73 virtual void resizeEvent(QResizeEvent *); 75 virtual void resizeEvent(QResizeEvent *);
74 76
75 /** 77 /**
76 * Add a new @ref QPushButton. 78 * Add a new @ref QPushButton.
77 * 79 *
78 * @param noexpand If @p noexpand is @p false, the width 80 * @param noexpand If @p noexpand is @p false, the width
79 * of the button is adjusted to fit the other buttons (the maximum 81 * of the button is adjusted to fit the other buttons (the maximum
80 * of all buttons is taken). If @p noexpand is @p true, the width of this 82 * of all buttons is taken). If @p noexpand is @p true, the width of this
81 * button will be set to the minimum width needed for the given text). 83 * button will be set to the minimum width needed for the given text).
82 * 84 *
83 * @return A pointer to the new button. 85 * @return A pointer to the new button.
84 */ 86 */
85 QPushButton *addButton(const QString& text, bool noexpand = FALSE); 87 QPushButton *addButton(const QString& text, bool noexpand = FALSE);
86 88
87 /** 89 /**
88 * Add a new @ref QPushButton. 90 * Add a new @ref QPushButton.
89 * 91 *
90 * @param receiver An object to connect to. 92 * @param receiver An object to connect to.
91 * @param slot A Qt slot to connect the 'clicked()' signal to. 93 * @param slot A Qt slot to connect the 'clicked()' signal to.
92 * @param noexpand If @p noexpand is @p false, the width 94 * @param noexpand If @p noexpand is @p false, the width
93 * of the button is adjusted to fit the other buttons (the maximum 95 * of the button is adjusted to fit the other buttons (the maximum
94 * of all buttons is taken). If @p noexpand @p true, the width of this 96 * of all buttons is taken). If @p noexpand @p true, the width of this
95 * button will be set to the minimum width needed for the given text). 97 * button will be set to the minimum width needed for the given text).
96 * 98 *
97 * @return A pointer to the new button. 99 * @return A pointer to the new button.
98 */ 100 */
99 QPushButton *addButton(const QString& text, QObject * receiver, const char * slot, bool noexpand = FALSE); 101 QPushButton *addButton(const QString& text, QObject * receiver, const char * slot, bool noexpand = FALSE);
100 102
101 /** 103 /**
102 * Add a stretch to the buttonbox. 104 * Add a stretch to the buttonbox.
103 * 105 *
104 * Can be used to separate buttons. That is, if you add the 106 * Can be used to separate buttons. That is, if you add the
105 * buttons OK and Cancel, add a stretch, and then add the button Help, 107 * buttons OK and Cancel, add a stretch, and then add the button Help,
106 * the buttons OK and Cancel will be left-aligned (or top-aligned 108 * the buttons OK and Cancel will be left-aligned (or top-aligned
107 * for vertical) whereas Help will be right-aligned (or 109 * for vertical) whereas Help will be right-aligned (or
108 * bottom-aligned for vertical). 110 * bottom-aligned for vertical).
109 * 111 *
110 * @see QBoxLayout 112 * @see QBoxLayout
111 */ 113 */
112 void addStretch(int scale = 1); 114 void addStretch(int scale = 1);
113 115
114 /** 116 /**
115 * This function must be called @em once after all buttons have been 117 * This function must be called @em once after all buttons have been
116 * inserted. 118 * inserted.
117 * 119 *
118 * It will start layout control. 120 * It will start layout control.
119 */ 121 */
120 void layout(); 122 void layout();
121 123
122public: // as PrivateData needs Item, it has to be exported 124public: // as PrivateData needs Item, it has to be exported
123 class Item; 125 class Item;
124protected: 126protected:
125 /** 127 /**
126 * @return the best size for a button. Checks all buttons and takes 128 * @return the best size for a button. Checks all buttons and takes
127 * the maximum width/height. 129 * the maximum width/height.
128 */ 130 */
129 QSize bestButtonSize() const; 131 QSize bestButtonSize() const;
130 void placeButtons(); 132 void placeButtons();
131 QSize buttonSizeHint(QPushButton *) const; 133 QSize buttonSizeHint(QPushButton *) const;
132 134
133protected: 135protected:
134 virtual void virtual_hook( int id, void* data ); 136 virtual void virtual_hook( int id, void* data );
135private: 137private:
136 KButtonBoxPrivate *data; 138 KButtonBoxPrivate *data;
137}; 139};
138 140
139#endif 141#endif
diff --git a/microkde/kdeui/kguiitem.cpp b/microkde/kdeui/kguiitem.cpp
index 828c5e6..c91ffb7 100644
--- a/microkde/kdeui/kguiitem.cpp
+++ b/microkde/kdeui/kguiitem.cpp
@@ -1,205 +1,205 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2001 Holger Freyther (freyher@yahoo.com) 2 Copyright (C) 2001 Holger Freyther (freyher@yahoo.com)
3 based on ideas from Martijn and Simon 3 based on ideas from Martijn and Simon
4 many thanks to Simon 4 many thanks to Simon
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation. 8 License version 2 as published by the Free Software Foundation.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qregexp.h> 21#include <qregexp.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qiconset.h> 23#include <qicon.h>
24#include <qpixmap.h> 24#include <qpixmap.h>
25 25
26#include <assert.h> 26#include <assert.h>
27//US #include <kiconloader.h> 27//US #include <kiconloader.h>
28#include <kdebug.h> 28#include <kdebug.h>
29 29
30#include "kguiitem.h" 30#include "kguiitem.h"
31 31
32class KGuiItem::KGuiItemPrivate 32class KGuiItem::KGuiItemPrivate
33{ 33{
34public: 34public:
35 KGuiItemPrivate() 35 KGuiItemPrivate()
36 { 36 {
37 m_enabled = true; 37 m_enabled = true;
38 m_hasIcon = false; 38 m_hasIcon = false;
39 } 39 }
40 40
41 KGuiItemPrivate( const KGuiItemPrivate &rhs ) 41 KGuiItemPrivate( const KGuiItemPrivate &rhs )
42 { 42 {
43 (*this ) = rhs; 43 (*this ) = rhs;
44 } 44 }
45 45
46 KGuiItemPrivate &operator=( const KGuiItemPrivate &rhs ) 46 KGuiItemPrivate &operator=( const KGuiItemPrivate &rhs )
47 { 47 {
48 m_text = rhs.m_text; 48 m_text = rhs.m_text;
49 m_iconSet = rhs.m_iconSet; 49 m_iconSet = rhs.m_iconSet;
50 m_iconName = rhs.m_iconName; 50 m_iconName = rhs.m_iconName;
51 m_toolTip = rhs.m_toolTip; 51 m_toolTip = rhs.m_toolTip;
52 m_whatsThis = rhs.m_whatsThis; 52 m_whatsThis = rhs.m_whatsThis;
53 m_statusText = rhs.m_statusText; 53 m_statusText = rhs.m_statusText;
54 m_enabled = rhs.m_enabled; 54 m_enabled = rhs.m_enabled;
55 m_hasIcon = rhs.m_hasIcon; 55 m_hasIcon = rhs.m_hasIcon;
56 56
57 return *this; 57 return *this;
58 } 58 }
59 59
60 QString m_text; 60 QString m_text;
61 QString m_toolTip; 61 QString m_toolTip;
62 QString m_whatsThis; 62 QString m_whatsThis;
63 QString m_statusText; 63 QString m_statusText;
64 QString m_iconName; 64 QString m_iconName;
65 QIconSet m_iconSet; 65 QIcon m_iconSet;
66 bool m_hasIcon : 1; 66 bool m_hasIcon : 1;
67 bool m_enabled : 1; 67 bool m_enabled : 1;
68}; 68};
69 69
70 70
71KGuiItem::KGuiItem() { 71KGuiItem::KGuiItem() {
72 d = new KGuiItemPrivate; 72 d = new KGuiItemPrivate;
73} 73}
74 74
75KGuiItem::KGuiItem( const QString &text, const QString &iconName, 75KGuiItem::KGuiItem( const QString &text, const QString &iconName,
76 const QString &toolTip, const QString &whatsThis ) 76 const QString &toolTip, const QString &whatsThis )
77{ 77{
78 d = new KGuiItemPrivate; 78 d = new KGuiItemPrivate;
79 d->m_text = text; 79 d->m_text = text;
80 d->m_toolTip = toolTip; 80 d->m_toolTip = toolTip;
81 d->m_whatsThis = whatsThis; 81 d->m_whatsThis = whatsThis;
82 setIconName( iconName ); 82 setIconName( iconName );
83} 83}
84 84
85KGuiItem::KGuiItem( const QString &text, const QIconSet &iconSet, 85KGuiItem::KGuiItem( const QString &text, const QIcon &iconSet,
86 const QString &toolTip, const QString &whatsThis ) 86 const QString &toolTip, const QString &whatsThis )
87{ 87{
88 d = new KGuiItemPrivate; 88 d = new KGuiItemPrivate;
89 d->m_text = text; 89 d->m_text = text;
90 d->m_toolTip = toolTip; 90 d->m_toolTip = toolTip;
91 d->m_whatsThis = whatsThis; 91 d->m_whatsThis = whatsThis;
92 setIconSet( iconSet ); 92 setIconSet( iconSet );
93} 93}
94 94
95KGuiItem::KGuiItem( const KGuiItem &rhs ) 95KGuiItem::KGuiItem( const KGuiItem &rhs )
96 : d( 0 ) 96 : d( 0 )
97{ 97{
98 (*this) = rhs; 98 (*this) = rhs;
99} 99}
100 100
101KGuiItem &KGuiItem::operator=( const KGuiItem &rhs ) { 101KGuiItem &KGuiItem::operator=( const KGuiItem &rhs ) {
102 if ( d == rhs.d ) 102 if ( d == rhs.d )
103 return *this; 103 return *this;
104 104
105 assert( rhs.d ); 105 assert( rhs.d );
106 106
107 delete d; 107 delete d;
108 d = new KGuiItemPrivate( *rhs.d ); 108 d = new KGuiItemPrivate( *rhs.d );
109 109
110 return *this; 110 return *this;
111} 111}
112 112
113KGuiItem::~KGuiItem() { 113KGuiItem::~KGuiItem() {
114 delete d; 114 delete d;
115} 115}
116 116
117QString KGuiItem::text() const { 117QString KGuiItem::text() const {
118 return d->m_text; 118 return d->m_text;
119} 119}
120QString KGuiItem::plainText() const { 120QString KGuiItem::plainText() const {
121 QString stripped( d->m_text ); 121 QString stripped( d->m_text );
122 stripped.replace( QRegExp( "&(?!&)" ), QString::null ); 122 stripped.replace( QRegExp( "&(?!&)" ), QString::null );
123 123
124 return stripped; 124 return stripped;
125} 125}
126 126
127QIconSet KGuiItem::iconSet( KIcon::Group group, int size /*US, KInstance* instance */ ) const 127QIcon KGuiItem::iconSet( KIcon::Group group, int size /*US, KInstance* instance */ ) const
128{ 128{
129 if( d->m_hasIcon ) 129 if( d->m_hasIcon )
130 { 130 {
131 if( !d->m_iconName.isEmpty()) 131 if( !d->m_iconName.isEmpty())
132 { 132 {
133// some caching here would(?) come handy 133// some caching here would(?) come handy
134//US return instance->iconLoader()->loadIconSet( d->m_iconName, group, size ); 134//US return instance->iconLoader()->loadIconSet( d->m_iconName, group, size );
135 return KGlobal::iconLoader()->loadIconSet( d->m_iconName); 135 return KGlobal::iconLoader()->loadIconSet( d->m_iconName);
136// here is a little problem that with delayed icon loading 136// here is a little problem that with delayed icon loading
137// we can't check if the icon really exists ... so what ... 137// we can't check if the icon really exists ... so what ...
138// if( set.isNull() ) 138// if( set.isNull() )
139// { 139// {
140// d->m_hasIcon = false; 140// d->m_hasIcon = false;
141// return QIconSet(); 141// return QIconSet();
142// } 142// }
143// return set; 143// return set;
144 } 144 }
145 else 145 else
146 { 146 {
147 return d->m_iconSet; 147 return d->m_iconSet;
148 } 148 }
149 } 149 }
150 else 150 else
151 return QIconSet(); 151 return QIcon();
152} 152}
153 153
154QString KGuiItem::iconName() const 154QString KGuiItem::iconName() const
155{ 155{
156 return d->m_iconName; 156 return d->m_iconName;
157} 157}
158 158
159QString KGuiItem::toolTip() const { 159QString KGuiItem::toolTip() const {
160 return d->m_toolTip; 160 return d->m_toolTip;
161} 161}
162QString KGuiItem::whatsThis() const { 162QString KGuiItem::whatsThis() const {
163 return d->m_whatsThis; 163 return d->m_whatsThis;
164} 164}
165 165
166bool KGuiItem::isEnabled() const 166bool KGuiItem::isEnabled() const
167{ 167{
168 return d->m_enabled; 168 return d->m_enabled;
169} 169}
170 170
171bool KGuiItem::hasIcon() const 171bool KGuiItem::hasIcon() const
172{ 172{
173 return d->m_hasIcon; 173 return d->m_hasIcon;
174} 174}
175 175
176void KGuiItem::setText( const QString &text ) { 176void KGuiItem::setText( const QString &text ) {
177 d->m_text=text; 177 d->m_text=text;
178} 178}
179 179
180void KGuiItem::setIconSet( const QIconSet &iconset ) 180void KGuiItem::setIconSet( const QIcon &iconset )
181{ 181{
182 d->m_iconSet = iconset; 182 d->m_iconSet = iconset;
183 d->m_iconName = QString::null; 183 d->m_iconName = QString::null;
184 d->m_hasIcon = !iconset.isNull(); 184 d->m_hasIcon = !iconset.isNull();
185} 185}
186 186
187void KGuiItem::setIconName( const QString &iconName ) 187void KGuiItem::setIconName( const QString &iconName )
188{ 188{
189 d->m_iconName = iconName; 189 d->m_iconName = iconName;
190 d->m_iconSet = QIconSet(); 190 d->m_iconSet = QIcon();
191 d->m_hasIcon = !iconName.isEmpty(); 191 d->m_hasIcon = !iconName.isEmpty();
192} 192}
193 193
194void KGuiItem::setToolTip( const QString &toolTip) { 194void KGuiItem::setToolTip( const QString &toolTip) {
195 d->m_toolTip = toolTip; 195 d->m_toolTip = toolTip;
196} 196}
197void KGuiItem::setWhatsThis( const QString &whatsThis ) { 197void KGuiItem::setWhatsThis( const QString &whatsThis ) {
198 d->m_whatsThis = whatsThis; 198 d->m_whatsThis = whatsThis;
199} 199}
200void KGuiItem::setEnabled( bool enabled ){ 200void KGuiItem::setEnabled( bool enabled ){
201 d->m_enabled = enabled; 201 d->m_enabled = enabled;
202} 202}
203 203
204/* vim: et sw=4 204/* vim: et sw=4
205 */ 205 */
diff --git a/microkde/kdeui/kguiitem.h b/microkde/kdeui/kguiitem.h
index 0079bb4..6f92137 100644
--- a/microkde/kdeui/kguiitem.h
+++ b/microkde/kdeui/kguiitem.h
@@ -1,87 +1,87 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2001 Holger Freyther (freyher@yahoo.com) 2 Copyright (C) 2001 Holger Freyther (freyher@yahoo.com)
3 based on ideas from Martijn and Simon 3 based on ideas from Martijn and Simon
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18 18
19 Many thanks to Simon tronical Hausmann 19 Many thanks to Simon tronical Hausmann
20*/ 20*/
21 21
22#ifndef __kguiitem_h__ 22#ifndef __kguiitem_h__
23#define __kguiitem_h__ 23#define __kguiitem_h__
24 24
25#include <qstring.h> 25#include <qstring.h>
26#include <qiconset.h> 26#include <qicon.h>
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qvaluelist.h> 28#include <q3valuelist.h>
29//US#include <kicontheme.h> 29//US#include <kicontheme.h>
30#include <kglobal.h> 30#include <kglobal.h>
31 31
32//US added the following files 32//US added the following files
33#include <kiconloader.h> 33#include <kiconloader.h>
34 34
35class KGuiItem 35class KGuiItem
36{ 36{
37public: 37public:
38 KGuiItem(); 38 KGuiItem();
39 39
40 KGuiItem( const QString &text, 40 KGuiItem( const QString &text,
41 const QString &iconName = QString::null, 41 const QString &iconName = QString::null,
42 const QString &toolTip = QString::null, 42 const QString &toolTip = QString::null,
43 const QString &whatsThis = QString::null ); 43 const QString &whatsThis = QString::null );
44 44
45 KGuiItem( const QString &text, const QIconSet &iconSet, 45 KGuiItem( const QString &text, const QIcon &iconSet,
46 const QString &toolTip = QString::null, 46 const QString &toolTip = QString::null,
47 const QString &whatsThis = QString::null ); 47 const QString &whatsThis = QString::null );
48 48
49 KGuiItem( const KGuiItem &rhs ); 49 KGuiItem( const KGuiItem &rhs );
50 KGuiItem &operator=( const KGuiItem &rhs ); 50 KGuiItem &operator=( const KGuiItem &rhs );
51 51
52 ~KGuiItem(); 52 ~KGuiItem();
53 53
54 QString text() const; 54 QString text() const;
55 QString plainText() const; 55 QString plainText() const;
56 QIconSet iconSet( KIcon::Group, int size = 0/*US , KInstance* instance = KGlobal::instance()*/) const; 56 QIcon iconSet( KIcon::Group, int size = 0/*US , KInstance* instance = KGlobal::instance()*/) const;
57 57
58#ifndef KDE_NO_COMPAT 58#ifndef KDE_NO_COMPAT
59 QIconSet iconSet() const { return iconSet( KIcon::Small); } 59 QIcon iconSet() const { return iconSet( KIcon::Small); }
60#endif 60#endif
61 61
62 QString iconName() const; 62 QString iconName() const;
63 QString toolTip() const; 63 QString toolTip() const;
64 QString whatsThis() const; 64 QString whatsThis() const;
65 bool isEnabled() const; 65 bool isEnabled() const;
66 bool hasIcon() const; 66 bool hasIcon() const;
67#ifndef KDE_NO_COMPAT 67#ifndef KDE_NO_COMPAT
68 bool hasIconSet() const { return hasIcon(); } 68 bool hasIconSet() const { return hasIcon(); }
69#endif 69#endif
70 70
71 void setText( const QString &text ); 71 void setText( const QString &text );
72 void setIconSet( const QIconSet &iconset ); 72 void setIconSet( const QIcon &iconset );
73 void setIconName( const QString &iconName ); 73 void setIconName( const QString &iconName );
74 void setToolTip( const QString &tooltip ); 74 void setToolTip( const QString &tooltip );
75 void setWhatsThis( const QString &whatsThis ); 75 void setWhatsThis( const QString &whatsThis );
76 void setEnabled( bool enable ); 76 void setEnabled( bool enable );
77 77
78private: 78private:
79 class KGuiItemPrivate; 79 class KGuiItemPrivate;
80 KGuiItemPrivate *d; 80 KGuiItemPrivate *d;
81}; 81};
82 82
83/* vim: et sw=4 83/* vim: et sw=4
84 */ 84 */
85 85
86#endif 86#endif
87 87
diff --git a/microkde/kdeui/kjanuswidget.cpp b/microkde/kdeui/kjanuswidget.cpp
index 462c44f..3d9173d 100644
--- a/microkde/kdeui/kjanuswidget.cpp
+++ b/microkde/kdeui/kjanuswidget.cpp
@@ -1,1177 +1,1185 @@
1/* This file is part of the KDE Libraries 1/* This file is part of the KDE Libraries
2 * Copyright (C) 1999-2000 Espen Sand (espensa@online.no) 2 * Copyright (C) 1999-2000 Espen Sand (espensa@online.no)
3 * Copyright (C) 2003 Ravikiran Rajagopal (ravi@kde.org) 3 * Copyright (C) 2003 Ravikiran Rajagopal (ravi@kde.org)
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details. 13 * Library General Public License for more details.
14 * 14 *
15 * You should have received a copy of the GNU Library General Public License 15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to 16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA. 18 * Boston, MA 02111-1307, USA.
19 */ 19 */
20 20
21#include <qpixmap.h> 21#include <qpixmap.h>
22#include <qbitmap.h> 22#include <qbitmap.h>
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qlabel.h> 24#include <qlabel.h>
25#include <qwidgetstack.h> 25#include <q3widgetstack.h>
26#include <qtabwidget.h> 26#include <qtabwidget.h>
27#include <qlistview.h> 27#include <q3listview.h>
28#include <qhbox.h> 28#include <q3hbox.h>
29#include <qvbox.h> 29#include <q3vbox.h>
30#include <qgrid.h> 30#include <q3grid.h>
31#include <qpainter.h> 31#include <qpainter.h>
32#include <qobjectlist.h> 32#include <qobject.h>
33#include <qstringlist.h> 33#include <qstringlist.h>
34//Added by qt3to4:
35#include <Q3HBoxLayout>
36#include <Q3GridLayout>
37#include <Q3PtrList>
38#include <Q3Frame>
39#include <QEvent>
40#include <Q3VBoxLayout>
41#include <QShowEvent>
34/*US 42/*US
35#include <qbitmap.h> 43#include <qbitmap.h>
36#include <qgrid.h> 44#include <qgrid.h>
37#include <qhbox.h> 45#include <qhbox.h>
38#include <qheader.h> 46#include <qheader.h>
39#include <qlabel.h> 47#include <qlabel.h>
40#include <qlayout.h> 48#include <qlayout.h>
41#include <qobjectlist.h> 49#include <qobjectlist.h>
42#include <qpixmap.h> 50#include <qpixmap.h>
43#include <qsplitter.h> 51#include <qsplitter.h>
44#include <qtabwidget.h> 52#include <qtabwidget.h>
45#include <qvbox.h> 53#include <qvbox.h>
46#include <qwidgetstack.h> 54#include <qwidgetstack.h>
47#include <qpainter.h> 55#include <qpainter.h>
48#include <qstyle.h> 56#include <qstyle.h>
49 57
50#include <kapplication.h> 58#include <kapplication.h>
51#include <klocale.h> 59#include <klocale.h>
52#include <kglobal.h> 60#include <kglobal.h>
53#include <kglobalsettings.h> 61#include <kglobalsettings.h>
54#include <kseparator.h> 62#include <kseparator.h>
55#include <kdebug.h> 63#include <kdebug.h>
56#include "kjanuswidget.h" 64#include "kjanuswidget.h"
57#include <klistview.h> 65#include <klistview.h>
58 66
59*/ 67*/
60 68
61#include <kseparator.h> 69#include <kseparator.h>
62#include <kdialog.h> // Access to some static members 70#include <kdialog.h> // Access to some static members
63#include <kdebug.h> 71#include <kdebug.h>
64#include <klistview.h> 72#include <klistview.h>
65 73
66#include "kjanuswidget.h" 74#include "kjanuswidget.h"
67 75
68class KJanusWidget::IconListItem : public QListBoxItem 76class KJanusWidget::IconListItem : public Q3ListBoxItem
69{ 77{
70 public: 78 public:
71 IconListItem( QListBox *listbox, const QPixmap &pixmap, 79 IconListItem( Q3ListBox *listbox, const QPixmap &pixmap,
72 const QString &text ); 80 const QString &text );
73 virtual int height( const QListBox *lb ) const; 81 virtual int height( const Q3ListBox *lb ) const;
74 virtual int width( const QListBox *lb ) const; 82 virtual int width( const Q3ListBox *lb ) const;
75 int expandMinimumWidth( int width ); 83 int expandMinimumWidth( int width );
76 84
77 protected: 85 protected:
78 const QPixmap &defaultPixmap(); 86 const QPixmap &defaultPixmap();
79 void paint( QPainter *painter ); 87 void paint( QPainter *painter );
80 88
81 private: 89 private:
82 QPixmap mPixmap; 90 QPixmap mPixmap;
83 int mMinimumWidth; 91 int mMinimumWidth;
84}; 92};
85 93
86class KJanusWidget::KJanusWidgetPrivate 94class KJanusWidget::KJanusWidgetPrivate
87{ 95{
88public: 96public:
89 KJanusWidgetPrivate() : mNextPageIndex(0) { } 97 KJanusWidgetPrivate() : mNextPageIndex(0) { }
90 98
91 int mNextPageIndex; // The next page index. 99 int mNextPageIndex; // The next page index.
92 100
93 // Dictionary for multipage modes. 101 // Dictionary for multipage modes.
94 QMap<int,QWidget*> mIntToPage; 102 QMap<int,QWidget*> mIntToPage;
95 // Reverse dictionary. Used because showPage() may be performance critical. 103 // Reverse dictionary. Used because showPage() may be performance critical.
96 QMap<QWidget*,int> mPageToInt; 104 QMap<QWidget*,int> mPageToInt;
97 // Dictionary of title string associated with page. 105 // Dictionary of title string associated with page.
98 QMap<int, QString> mIntToTitle; 106 QMap<int, QString> mIntToTitle;
99}; 107};
100 108
101template class QPtrList<QListViewItem>; 109template class Q3PtrList<Q3ListViewItem>;
102 110
103 111
104KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face ) 112KJanusWidget::KJanusWidget( QWidget *parent, const char *name, int face )
105 : QWidget( parent, name ), 113 : QWidget( parent, name ),
106 mValid(false), mPageList(0), 114 mValid(false), mPageList(0),
107 mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0), 115 mTitleList(0), mFace(face), mTitleLabel(0), mActivePageWidget(0),
108 mShowIconsInTreeList(false), d(0) 116 mShowIconsInTreeList(false), d(0)
109{ 117{
110 QVBoxLayout *topLayout = new QVBoxLayout( this ); 118 Q3VBoxLayout *topLayout = new Q3VBoxLayout( this );
111 if( mFace == TreeList || mFace == IconList ) 119 if( mFace == TreeList || mFace == IconList )
112 { 120 {
113 d = new KJanusWidgetPrivate; 121 d = new KJanusWidgetPrivate;
114 122
115 QFrame *page = 0; 123 Q3Frame *page = 0;
116 if( mFace == TreeList ) 124 if( mFace == TreeList )
117 { 125 {
118 //US 126 //US
119 qDebug("KJanusWidget::KJanusWidget TreeList not implemented yet"); 127 qDebug("KJanusWidget::KJanusWidget TreeList not implemented yet");
120/*US 128/*US
121 QSplitter *splitter = new QSplitter( this ); 129 QSplitter *splitter = new QSplitter( this );
122 topLayout->addWidget( splitter, 10 ); 130 topLayout->addWidget( splitter, 10 );
123 mTreeListResizeMode = QSplitter::KeepSize; 131 mTreeListResizeMode = QSplitter::KeepSize;
124 132
125 mTreeList = new KListView( splitter ); 133 mTreeList = new KListView( splitter );
126 mTreeList->addColumn( QString::null ); 134 mTreeList->addColumn( QString::null );
127 mTreeList->header()->hide(); 135 mTreeList->header()->hide();
128 mTreeList->setRootIsDecorated(true); 136 mTreeList->setRootIsDecorated(true);
129 mTreeList->setSorting( -1 ); 137 mTreeList->setSorting( -1 );
130 connect( mTreeList, SIGNAL(selectionChanged()), SLOT(slotShowPage()) ); 138 connect( mTreeList, SIGNAL(selectionChanged()), SLOT(slotShowPage()) );
131 connect( mTreeList, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *))); 139 connect( mTreeList, SIGNAL(clicked(QListViewItem *)), SLOT(slotItemClicked(QListViewItem *)));
132 140
133 // 141 //
134 // Page area. Title at top with a separator below and a pagestack using 142 // Page area. Title at top with a separator below and a pagestack using
135 // all available space at bottom. 143 // all available space at bottom.
136 // 144 //
137 QFrame *p = new QFrame( splitter ); 145 QFrame *p = new QFrame( splitter );
138 146
139 QHBoxLayout *hbox = new QHBoxLayout( p, 0, 0 ); 147 QHBoxLayout *hbox = new QHBoxLayout( p, 0, 0 );
140 hbox->addSpacing( KDialog::marginHint() ); 148 hbox->addSpacing( KDialog::marginHint() );
141 149
142 page = new QFrame( p ); 150 page = new QFrame( p );
143 hbox->addWidget( page, 10 ); 151 hbox->addWidget( page, 10 );
144*/ 152*/
145 } 153 }
146 else 154 else
147 { 155 {
148 QHBoxLayout *hbox = new QHBoxLayout( topLayout ); 156 Q3HBoxLayout *hbox = new Q3HBoxLayout( topLayout );
149 mIconList = new IconListBox( this ); 157 mIconList = new IconListBox( this );
150 158
151 QFont listFont( mIconList->font() ); 159 QFont listFont( mIconList->font() );
152 listFont.setBold( true ); 160 listFont.setBold( true );
153 mIconList->setFont( listFont ); 161 mIconList->setFont( listFont );
154 162
155 mIconList->verticalScrollBar()->installEventFilter( this ); 163 mIconList->verticalScrollBar()->installEventFilter( this );
156 hbox->addWidget( mIconList ); 164 hbox->addWidget( mIconList );
157 connect( mIconList, SIGNAL(selectionChanged()), SLOT(slotShowPage())); 165 connect( mIconList, SIGNAL(selectionChanged()), SLOT(slotShowPage()));
158 hbox->addSpacing( KDialog::marginHint() ); 166 hbox->addSpacing( KDialog::marginHint() );
159 page = new QFrame( this ); 167 page = new Q3Frame( this );
160 hbox->addWidget( page, 10 ); 168 hbox->addWidget( page, 10 );
161 } 169 }
162 170
163 // 171 //
164 // Rest of page area. Title at top with a separator below and a 172 // Rest of page area. Title at top with a separator below and a
165 // pagestack using all available space at bottom. 173 // pagestack using all available space at bottom.
166 // 174 //
167 175
168 QVBoxLayout *vbox = new QVBoxLayout( page, 0, KDialog::spacingHint() ); 176 Q3VBoxLayout *vbox = new Q3VBoxLayout( page, 0, KDialog::spacingHint() );
169 177
170 mTitleLabel = new QLabel( QString::fromLatin1("Empty page"), page, "KJanusWidgetTitleLabel" ); 178 mTitleLabel = new QLabel( QString::fromLatin1("Empty page"), page, "KJanusWidgetTitleLabel" );
171 vbox->addWidget( mTitleLabel ); 179 vbox->addWidget( mTitleLabel );
172 180
173 QFont titleFont( mTitleLabel->font() ); 181 QFont titleFont( mTitleLabel->font() );
174 titleFont.setBold( true ); 182 titleFont.setBold( true );
175 mTitleLabel->setFont( titleFont ); 183 mTitleLabel->setFont( titleFont );
176 184
177 mTitleSep = new KSeparator( page ); 185 mTitleSep = new KSeparator( page );
178 mTitleSep->setFrameStyle( QFrame::HLine|QFrame::Plain ); 186 mTitleSep->setFrameStyle( Q3Frame::HLine|Q3Frame::Plain );
179 vbox->addWidget( mTitleSep ); 187 vbox->addWidget( mTitleSep );
180 188
181 mPageStack = new QWidgetStack( page ); 189 mPageStack = new Q3WidgetStack( page );
182 connect(mPageStack, SIGNAL(aboutToShow(QWidget *)), 190 connect(mPageStack, SIGNAL(aboutToShow(QWidget *)),
183 SIGNAL(aboutToShowPage(QWidget *))); 191 SIGNAL(aboutToShowPage(QWidget *)));
184 vbox->addWidget( mPageStack, 10 ); 192 vbox->addWidget( mPageStack, 10 );
185 } 193 }
186 else if( mFace == Tabbed ) 194 else if( mFace == Tabbed )
187 { 195 {
188 d = new KJanusWidgetPrivate; 196 d = new KJanusWidgetPrivate;
189 197
190 mTabControl = new QTabWidget( this ); 198 mTabControl = new QTabWidget( this );
191 mTabControl->setMargin (KDialog::marginHint()); 199 mTabControl->setMargin (KDialog::marginHint());
192 topLayout->addWidget( mTabControl, 10 ); 200 topLayout->addWidget( mTabControl, 10 );
193 } 201 }
194 else if( mFace == Swallow ) 202 else if( mFace == Swallow )
195 { 203 {
196 mSwallowPage = new QWidget( this ); 204 mSwallowPage = new QWidget( this );
197 topLayout->addWidget( mSwallowPage, 10 ); 205 topLayout->addWidget( mSwallowPage, 10 );
198 } 206 }
199 else 207 else
200 { 208 {
201 mFace = Plain; 209 mFace = Plain;
202 mPlainPage = new QFrame( this ); 210 mPlainPage = new Q3Frame( this );
203 topLayout->addWidget( mPlainPage, 10 ); 211 topLayout->addWidget( mPlainPage, 10 );
204 } 212 }
205/*US 213/*US
206 if ( kapp ) 214 if ( kapp )
207 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged())); 215 connect(kapp,SIGNAL(kdisplayFontChanged()),SLOT(slotFontChanged()));
208*/ 216*/
209 mValid = true; 217 mValid = true;
210 setSwallowedWidget(0); // Set default size if 'mFace' is Swallow. 218 setSwallowedWidget(0); // Set default size if 'mFace' is Swallow.
211} 219}
212 220
213 221
214KJanusWidget::~KJanusWidget() 222KJanusWidget::~KJanusWidget()
215{ 223{
216 224
217/*US the destroyed signal caused a segmentation fault while closing the dialog and destructing 225/*US the destroyed signal caused a segmentation fault while closing the dialog and destructing
218 all pages. Why not just remove all pages in the destructor?? 226 all pages. Why not just remove all pages in the destructor??
219*/ 227*/
220// LR we have all subwidgets with parent-child relation 228// LR we have all subwidgets with parent-child relation
221// LR we do not need to delete here anything by the private class 229// LR we do not need to delete here anything by the private class
222/* 230/*
223 if( mFace == Tabbed ) 231 if( mFace == Tabbed )
224 { 232 {
225 QMap<QWidget*,int>::Iterator it; 233 QMap<QWidget*,int>::Iterator it;
226 for (it = d->mPageToInt.begin(); it != d->mPageToInt.end(); ++it) { 234 for (it = d->mPageToInt.begin(); it != d->mPageToInt.end(); ++it) {
227 QObject*page = (QObject*)it.key(); 235 QObject*page = (QObject*)it.key();
228 pageGone(page); 236 pageGone(page);
229 } 237 }
230 } 238 }
231 else 239 else
232 qDebug("KJanusWidget::~KJanusWidget so far "); 240 qDebug("KJanusWidget::~KJanusWidget so far ");
233*/ 241*/
234//US end 242//US end
235 243
236 delete d; 244 delete d;
237 245
238 246
239} 247}
240 248
241 249
242bool KJanusWidget::isValid() const 250bool KJanusWidget::isValid() const
243{ 251{
244 return( mValid ); 252 return( mValid );
245} 253}
246 254
247 255
248QFrame *KJanusWidget::plainPage() 256Q3Frame *KJanusWidget::plainPage()
249{ 257{
250 return( mPlainPage ); 258 return( mPlainPage );
251} 259}
252 260
253 261
254int KJanusWidget::face() const 262int KJanusWidget::face() const
255{ 263{
256 return( mFace ); 264 return( mFace );
257} 265}
258 266
259QWidget *KJanusWidget::FindParent() 267QWidget *KJanusWidget::FindParent()
260{ 268{
261 if( mFace == Tabbed ) { 269 if( mFace == Tabbed ) {
262 return mTabControl; 270 return mTabControl;
263 } 271 }
264 else { 272 else {
265 return this; 273 return this;
266 } 274 }
267} 275}
268 276
269QFrame *KJanusWidget::addPage( const QStringList &items, const QString &header, 277Q3Frame *KJanusWidget::addPage( const QStringList &items, const QString &header,
270 const QPixmap &pixmap ) 278 const QPixmap &pixmap )
271{ 279{
272 if( mValid == false ) 280 if( mValid == false )
273 { 281 {
274 kdDebug() << "addPage: Invalid object" << endl; 282 kdDebug() << "addPage: Invalid object" << endl;
275 return( 0 ); 283 return( 0 );
276 } 284 }
277 285
278 QFrame *page = new QFrame( FindParent(), "page" ); 286 Q3Frame *page = new Q3Frame( FindParent(), "page" );
279 addPageWidget( page, items, header, pixmap ); 287 addPageWidget( page, items, header, pixmap );
280 288
281 return page; 289 return page;
282} 290}
283 291
284void KJanusWidget::pageGone( QObject *obj ) 292void KJanusWidget::pageGone( QObject *obj )
285{ 293{
286// QObject* obj = (QObject*)sender(); 294// QObject* obj = (QObject*)sender();
287 removePage( static_cast<QWidget*>( obj ) ); 295 removePage( static_cast<QWidget*>( obj ) );
288} 296}
289 297
290void KJanusWidget::slotReopen( QListViewItem * item ) 298void KJanusWidget::slotReopen( Q3ListViewItem * item )
291{ 299{
292 if( item ) 300 if( item )
293 item->setOpen( true ); 301 item->setOpen( true );
294} 302}
295 303
296QFrame *KJanusWidget::addPage( const QString &itemName, const QString &header, 304Q3Frame *KJanusWidget::addPage( const QString &itemName, const QString &header,
297 const QPixmap &pixmap ) 305 const QPixmap &pixmap )
298{ 306{
299 307
300 QStringList items; 308 QStringList items;
301 items << itemName; 309 items << itemName;
302 return addPage(items, header, pixmap); 310 return addPage(items, header, pixmap);
303} 311}
304 312
305 313
306 314
307QVBox *KJanusWidget::addVBoxPage( const QStringList &items, 315Q3VBox *KJanusWidget::addVBoxPage( const QStringList &items,
308 const QString &header, 316 const QString &header,
309 const QPixmap &pixmap ) 317 const QPixmap &pixmap )
310{ 318{
311 if( mValid == false ) 319 if( mValid == false )
312 { 320 {
313 qDebug("addPage: Invalid object "); 321 qDebug("addPage: Invalid object ");
314 322
315 return( 0 ); 323 return( 0 );
316 } 324 }
317 325
318 QVBox *page = new QVBox(FindParent() , "vbox_page" ); 326 Q3VBox *page = new Q3VBox(FindParent() , "vbox_page" );
319 page->setSpacing( KDialog::spacingHintSmall() ); 327 page->setSpacing( KDialog::spacingHintSmall() );
320 addPageWidget( page, items, header, pixmap ); 328 addPageWidget( page, items, header, pixmap );
321 329
322 return page; 330 return page;
323} 331}
324 332
325QVBox *KJanusWidget::addVBoxPage( const QString &itemName, 333Q3VBox *KJanusWidget::addVBoxPage( const QString &itemName,
326 const QString &header, 334 const QString &header,
327 const QPixmap &pixmap ) 335 const QPixmap &pixmap )
328{ 336{
329 QStringList items; 337 QStringList items;
330 items << itemName; 338 items << itemName;
331 return addVBoxPage(items, header, pixmap); 339 return addVBoxPage(items, header, pixmap);
332} 340}
333 341
334QHBox *KJanusWidget::addHBoxPage( const QStringList &items, 342Q3HBox *KJanusWidget::addHBoxPage( const QStringList &items,
335 const QString &header, 343 const QString &header,
336 const QPixmap &pixmap ) 344 const QPixmap &pixmap )
337{ 345{
338 if( mValid == false ) { 346 if( mValid == false ) {
339 kdDebug() << "addPage: Invalid object" << endl; 347 kdDebug() << "addPage: Invalid object" << endl;
340 return( 0 ); 348 return( 0 );
341 } 349 }
342 350
343 QHBox *page = new QHBox(FindParent(), "hbox_page"); 351 Q3HBox *page = new Q3HBox(FindParent(), "hbox_page");
344 page->setSpacing( KDialog::spacingHint() ); 352 page->setSpacing( KDialog::spacingHint() );
345 addPageWidget( page, items, header, pixmap ); 353 addPageWidget( page, items, header, pixmap );
346 354
347 return page; 355 return page;
348} 356}
349 357
350QHBox *KJanusWidget::addHBoxPage( const QString &itemName, 358Q3HBox *KJanusWidget::addHBoxPage( const QString &itemName,
351 const QString &header, 359 const QString &header,
352 const QPixmap &pixmap ) 360 const QPixmap &pixmap )
353{ 361{
354 QStringList items; 362 QStringList items;
355 items << itemName; 363 items << itemName;
356 return addHBoxPage(items, header, pixmap); 364 return addHBoxPage(items, header, pixmap);
357} 365}
358 366
359QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, 367Q3Grid *KJanusWidget::addGridPage( int n, Qt::Orientation dir,
360 const QStringList &items, 368 const QStringList &items,
361 const QString &header, 369 const QString &header,
362 const QPixmap &pixmap ) 370 const QPixmap &pixmap )
363{ 371{
364 if( mValid == false ) 372 if( mValid == false )
365 { 373 {
366 kdDebug() << "addPage: Invalid object" << endl; 374 kdDebug() << "addPage: Invalid object" << endl;
367 return( 0 ); 375 return( 0 );
368 } 376 }
369 377
370 QGrid *page = new QGrid( n, dir, FindParent(), "page" ); 378 Q3Grid *page = new Q3Grid( n, dir, FindParent(), "page" );
371 page->setSpacing( KDialog::spacingHint() ); 379 page->setSpacing( KDialog::spacingHint() );
372 addPageWidget( page, items, header, pixmap ); 380 addPageWidget( page, items, header, pixmap );
373 381
374 return page; 382 return page;
375} 383}
376 384
377 385
378QGrid *KJanusWidget::addGridPage( int n, QGrid::Direction dir, 386Q3Grid *KJanusWidget::addGridPage( int n, Qt::Orientation dir,
379 const QString &itemName, 387 const QString &itemName,
380 const QString &header, 388 const QString &header,
381 const QPixmap &pixmap ) 389 const QPixmap &pixmap )
382{ 390{
383 QStringList items; 391 QStringList items;
384 items << itemName; 392 items << itemName;
385 return addGridPage(n, dir, items, header, pixmap); 393 return addGridPage(n, dir, items, header, pixmap);
386} 394}
387 395
388void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page) 396void KJanusWidget::InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, Q3Frame *page)
389{ 397{
390 bool isTop = true; 398 bool isTop = true;
391 QListViewItem *curTop = 0, *child, *last, *newChild; 399 Q3ListViewItem *curTop = 0, *child, *last, *newChild;
392 unsigned int index = 1; 400 unsigned int index = 1;
393 QStringList curPath; 401 QStringList curPath;
394 402
395 for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it, index++ ) { 403 for ( QStringList::ConstIterator it = items.begin(); it != items.end(); ++it, index++ ) {
396 QString name = (*it); 404 QString name = (*it);
397 bool isPath = ( index != items.count() ); 405 bool isPath = ( index != items.count() );
398 406
399 // Find the first child. 407 // Find the first child.
400 if (isTop) { 408 if (isTop) {
401 child = mTreeList->firstChild(); 409 child = mTreeList->firstChild();
402 } 410 }
403 else { 411 else {
404 child = curTop->firstChild(); 412 child = curTop->firstChild();
405 } 413 }
406 414
407 // Now search for a child with the current Name, and if it we doesn't 415 // Now search for a child with the current Name, and if it we doesn't
408 // find it, then remember the location of the last child. 416 // find it, then remember the location of the last child.
409 for (last = 0; child && child->text(0) != name ; last = child, child = child->nextSibling()); 417 for (last = 0; child && child->text(0) != name ; last = child, child = child->nextSibling());
410 418
411 if (last == 0 && child == 0) { 419 if (last == 0 && child == 0) {
412 // This node didn't have any children at all, lets just insert the 420 // This node didn't have any children at all, lets just insert the
413 // new child. 421 // new child.
414 if (isTop) 422 if (isTop)
415 newChild = new QListViewItem(mTreeList, name); 423 newChild = new Q3ListViewItem(mTreeList, name);
416 else 424 else
417 newChild = new QListViewItem(curTop, name); 425 newChild = new Q3ListViewItem(curTop, name);
418 426
419 } 427 }
420 else if (child != 0) { 428 else if (child != 0) {
421 // we found the given name in this child. 429 // we found the given name in this child.
422 if (!isPath) { 430 if (!isPath) {
423 kdDebug() << "The element inserted was already in the TreeList box!" << endl; 431 kdDebug() << "The element inserted was already in the TreeList box!" << endl;
424 return; 432 return;
425 } 433 }
426 else { 434 else {
427 // Ok we found the folder 435 // Ok we found the folder
428 newChild = child; 436 newChild = child;
429 } 437 }
430 } 438 }
431 else { 439 else {
432 // the node had some children, but we didn't find the given name 440 // the node had some children, but we didn't find the given name
433 if (isTop) 441 if (isTop)
434 newChild = new QListViewItem(mTreeList, last, name); 442 newChild = new Q3ListViewItem(mTreeList, last, name);
435 else 443 else
436 newChild = new QListViewItem(curTop, last, name); 444 newChild = new Q3ListViewItem(curTop, last, name);
437 } 445 }
438 446
439 // Now make the element expandable if it is a path component, and make 447 // Now make the element expandable if it is a path component, and make
440 // ready for next loop 448 // ready for next loop
441 if (isPath) { 449 if (isPath) {
442 newChild->setExpandable(true); 450 newChild->setExpandable(true);
443 curTop = newChild; 451 curTop = newChild;
444 isTop = false; 452 isTop = false;
445 curPath << name; 453 curPath << name;
446 454
447 QString key = curPath.join("_/_"); 455 QString key = curPath.join("_/_");
448 if (mFolderIconMap.contains(key)) { 456 if (mFolderIconMap.contains(key)) {
449 QPixmap p = mFolderIconMap[key]; 457 QPixmap p = mFolderIconMap[key];
450 newChild->setPixmap(0,p); 458 newChild->setPixmap(0,p);
451 } 459 }
452 } 460 }
453 else { 461 else {
454 if (mShowIconsInTreeList) { 462 if (mShowIconsInTreeList) {
455 newChild->setPixmap(0, pixmap); 463 newChild->setPixmap(0, pixmap);
456 } 464 }
457 mTreeListToPageStack.insert(newChild, page); 465 mTreeListToPageStack.insert(newChild, page);
458 } 466 }
459 } 467 }
460} 468}
461 469
462void KJanusWidget::addPageWidget( QFrame *page, const QStringList &items, 470void KJanusWidget::addPageWidget( Q3Frame *page, const QStringList &items,
463 const QString &header,const QPixmap &pixmap ) 471 const QString &header,const QPixmap &pixmap )
464{ 472{
465/*US the following signal causes a segmentation fault while closing the dialog. 473/*US the following signal causes a segmentation fault while closing the dialog.
466 Why not just remove all pages in the destructor?? 474 Why not just remove all pages in the destructor??
467*/ 475*/
468//US connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*))); 476//US connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*)));
469// we have the SIGNAL(destroyed(QObject*) only in Qt3 477// we have the SIGNAL(destroyed(QObject*) only in Qt3
470#ifdef DESKTOP_VERSION 478#ifdef DESKTOP_VERSION
471 // connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*))); 479 // connect(page, SIGNAL(destroyed(QObject*)), this, SLOT(pageGone(QObject*)));
472#endif 480#endif
473 if( mFace == Tabbed ) 481 if( mFace == Tabbed )
474 { 482 {
475 mTabControl->addTab (page, items.last()); 483 mTabControl->addTab (page, items.last());
476 d->mIntToPage[d->mNextPageIndex] = static_cast<QWidget*>(page); 484 d->mIntToPage[d->mNextPageIndex] = static_cast<QWidget*>(page);
477 d->mPageToInt[static_cast<QWidget*>(page)] = d->mNextPageIndex; 485 d->mPageToInt[static_cast<QWidget*>(page)] = d->mNextPageIndex;
478 d->mNextPageIndex++; 486 d->mNextPageIndex++;
479 } 487 }
480 else if( mFace == TreeList || mFace == IconList ) 488 else if( mFace == TreeList || mFace == IconList )
481 { 489 {
482 d->mIntToPage[d->mNextPageIndex] = static_cast<QWidget*>(page); 490 d->mIntToPage[d->mNextPageIndex] = static_cast<QWidget*>(page);
483 d->mPageToInt[static_cast<QWidget*>(page)] = d->mNextPageIndex; 491 d->mPageToInt[static_cast<QWidget*>(page)] = d->mNextPageIndex;
484 mPageStack->addWidget( page, 0 ); 492 mPageStack->addWidget( page, 0 );
485 493
486 if (items.count() == 0) { 494 if (items.count() == 0) {
487 kdDebug() << "Invalid QStringList, with zero items" << endl; 495 kdDebug() << "Invalid QStringList, with zero items" << endl;
488 return; 496 return;
489 } 497 }
490 498
491 if( mFace == TreeList ) 499 if( mFace == TreeList )
492 { 500 {
493 InsertTreeListItem(items, pixmap, page); 501 InsertTreeListItem(items, pixmap, page);
494 } 502 }
495 else // mFace == IconList 503 else // mFace == IconList
496 { 504 {
497 QString itemName = items.last(); 505 QString itemName = items.last();
498 IconListItem *item = new IconListItem( mIconList, pixmap, itemName ); 506 IconListItem *item = new IconListItem( mIconList, pixmap, itemName );
499 mIconListToPageStack.insert(item, page); 507 mIconListToPageStack.insert(item, page);
500 mIconList->invalidateHeight(); 508 mIconList->invalidateHeight();
501 mIconList->invalidateWidth(); 509 mIconList->invalidateWidth();
502 510
503 if (mIconList->isVisible()) 511 if (mIconList->isVisible())
504 mIconList->updateWidth(); 512 mIconList->updateWidth();
505 } 513 }
506 514
507 // 515 //
508 // Make sure the title label is sufficiently wide 516 // Make sure the title label is sufficiently wide
509 // 517 //
510 QString lastName = items.last(); 518 QString lastName = items.last();
511 const QString &title = (!header.isNull() ? header : lastName); 519 const QString &title = (!header.isNull() ? header : lastName);
512 QRect r = mTitleLabel->fontMetrics().boundingRect( title ); 520 QRect r = mTitleLabel->fontMetrics().boundingRect( title );
513 if( mTitleLabel->minimumWidth() < r.width() ) 521 if( mTitleLabel->minimumWidth() < r.width() )
514 { 522 {
515 mTitleLabel->setMinimumWidth( r.width() ); 523 mTitleLabel->setMinimumWidth( r.width() );
516 } 524 }
517 d->mIntToTitle[d->mNextPageIndex] = title; 525 d->mIntToTitle[d->mNextPageIndex] = title;
518 if( d->mIntToTitle.count() == 1 ) 526 if( d->mIntToTitle.count() == 1 )
519 { 527 {
520 showPage(0); 528 showPage(0);
521 } 529 }
522 d->mNextPageIndex++; 530 d->mNextPageIndex++;
523 } 531 }
524 else 532 else
525 { 533 {
526 kdDebug() << "KJanusWidget::addPageWidget: can only add a page in Tabbed, TreeList or IconList modes" << endl; 534 kdDebug() << "KJanusWidget::addPageWidget: can only add a page in Tabbed, TreeList or IconList modes" << endl;
527 } 535 }
528 536
529} 537}
530 538
531void KJanusWidget::setFolderIcon(const QStringList &path, const QPixmap &pixmap) 539void KJanusWidget::setFolderIcon(const QStringList &path, const QPixmap &pixmap)
532{ 540{
533 QString key = path.join("_/_"); 541 QString key = path.join("_/_");
534 mFolderIconMap.insert(key,pixmap); 542 mFolderIconMap.insert(key,pixmap);
535} 543}
536 544
537 545
538 546
539bool KJanusWidget::setSwallowedWidget( QWidget *widget ) 547bool KJanusWidget::setSwallowedWidget( QWidget *widget )
540{ 548{
541 if( mFace != Swallow || mValid == false ) 549 if( mFace != Swallow || mValid == false )
542 { 550 {
543 return( false ); 551 return( false );
544 } 552 }
545 553
546 // 554 //
547 // Remove current layout and make a new. 555 // Remove current layout and make a new.
548 // 556 //
549 if( mSwallowPage->layout() != 0 ) 557 if( mSwallowPage->layout() != 0 )
550 { 558 {
551 delete mSwallowPage->layout(); 559 delete mSwallowPage->layout();
552 } 560 }
553 QGridLayout *gbox = new QGridLayout( mSwallowPage, 1, 1, 0 ); 561 Q3GridLayout *gbox = new Q3GridLayout( mSwallowPage, 1, 1, 0 );
554 562
555 // 563 //
556 // Hide old children 564 // Hide old children
557 // 565 //
558 QObjectList *l = (QObjectList*)mSwallowPage->children(); // silence please 566 QObjectList l = mSwallowPage->children(); // silence please
559 for( uint i=0; i < l->count(); i++ ) 567 for( uint i=0; i < l.count(); i++ )
560 { 568 {
561 QObject *o = l->at(i); 569 QObject *o = l.at(i);
562 if( o->isWidgetType() ) 570 if( o->isWidgetType() )
563 { 571 {
564 ((QWidget*)o)->hide(); 572 ((QWidget*)o)->hide();
565 } 573 }
566 } 574 }
567 575
568 // 576 //
569 // Add new child or make default size 577 // Add new child or make default size
570 // 578 //
571 if( widget == 0 ) 579 if( widget == 0 )
572 { 580 {
573 gbox->addRowSpacing(0,100); 581 gbox->addRowSpacing(0,100);
574 gbox->addColSpacing(0,100); 582 gbox->addColSpacing(0,100);
575 mSwallowPage->setMinimumSize(100,100); 583 mSwallowPage->setMinimumSize(100,100);
576 } 584 }
577 else 585 else
578 { 586 {
579 if( widget->parent() != mSwallowPage ) 587 if( widget->parent() != mSwallowPage )
580 { 588 {
581 widget->reparent( mSwallowPage, 0, QPoint(0,0) ); 589 widget->reparent( mSwallowPage, 0, QPoint(0,0) );
582 } 590 }
583 gbox->addWidget(widget, 0, 0 ); 591 gbox->addWidget(widget, 0, 0 );
584 gbox->activate(); 592 gbox->activate();
585 mSwallowPage->setMinimumSize( widget->minimumSize() ); 593 mSwallowPage->setMinimumSize( widget->minimumSize() );
586 } 594 }
587 595
588 return( true ); 596 return( true );
589} 597}
590 598
591bool KJanusWidget::slotShowPage() 599bool KJanusWidget::slotShowPage()
592{ 600{
593 if( mValid == false ) 601 if( mValid == false )
594 { 602 {
595 return( false ); 603 return( false );
596 } 604 }
597 605
598 if( mFace == TreeList ) 606 if( mFace == TreeList )
599 { 607 {
600 QListViewItem *node = mTreeList->selectedItem(); 608 Q3ListViewItem *node = mTreeList->selectedItem();
601 if( node == 0 ) { return( false ); } 609 if( node == 0 ) { return( false ); }
602 610
603 QWidget *stackItem = mTreeListToPageStack[node]; 611 QWidget *stackItem = mTreeListToPageStack[node];
604 // Make sure to call through the virtual function showPage(int) 612 // Make sure to call through the virtual function showPage(int)
605 return showPage(d->mPageToInt[stackItem]); 613 return showPage(d->mPageToInt[stackItem]);
606 } 614 }
607 else if( mFace == IconList ) 615 else if( mFace == IconList )
608 { 616 {
609 QListBoxItem *node = mIconList->item( mIconList->currentItem() ); 617 Q3ListBoxItem *node = mIconList->item( mIconList->currentItem() );
610 if( node == 0 ) { return( false ); } 618 if( node == 0 ) { return( false ); }
611 QWidget *stackItem = mIconListToPageStack[node]; 619 QWidget *stackItem = mIconListToPageStack[node];
612 // Make sure to call through the virtual function showPage(int) 620 // Make sure to call through the virtual function showPage(int)
613 return showPage(d->mPageToInt[stackItem]); 621 return showPage(d->mPageToInt[stackItem]);
614 } 622 }
615 623
616 return( false ); 624 return( false );
617} 625}
618 626
619 627
620bool KJanusWidget::showPage( int index ) 628bool KJanusWidget::showPage( int index )
621{ 629{
622 if( d == 0 || mValid == false ) 630 if( d == 0 || mValid == false )
623 { 631 {
624 return( false ); 632 return( false );
625 } 633 }
626 else 634 else
627 { 635 {
628 return showPage(d->mIntToPage[index]); 636 return showPage(d->mIntToPage[index]);
629 } 637 }
630} 638}
631 639
632 640
633bool KJanusWidget::showPage( QWidget *w ) 641bool KJanusWidget::showPage( QWidget *w )
634{ 642{
635 if( w == 0 || mValid == false ) 643 if( w == 0 || mValid == false )
636 { 644 {
637 return( false ); 645 return( false );
638 } 646 }
639 647
640 if( mFace == TreeList || mFace == IconList ) 648 if( mFace == TreeList || mFace == IconList )
641 { 649 {
642 mPageStack->raiseWidget( w ); 650 mPageStack->raiseWidget( w );
643 mActivePageWidget = w; 651 mActivePageWidget = w;
644 652
645 int index = d->mPageToInt[w]; 653 int index = d->mPageToInt[w];
646 mTitleLabel->setText( d->mIntToTitle[index] ); 654 mTitleLabel->setText( d->mIntToTitle[index] );
647 if( mFace == TreeList ) 655 if( mFace == TreeList )
648 { 656 {
649 QMap<QListViewItem *, QWidget *>::Iterator it; 657 QMap<Q3ListViewItem *, QWidget *>::Iterator it;
650 for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){ 658 for (it = mTreeListToPageStack.begin(); it != mTreeListToPageStack.end(); ++it){
651 QListViewItem *key = it.key(); 659 Q3ListViewItem *key = it.key();
652 QWidget *val = it.data(); 660 QWidget *val = it.data();
653 if (val == w) { 661 if (val == w) {
654 mTreeList->setSelected(key, true ); 662 mTreeList->setSelected(key, true );
655 break; 663 break;
656 } 664 }
657 } 665 }
658 } 666 }
659 else 667 else
660 { 668 {
661 QMap<QListBoxItem *, QWidget *>::Iterator it; 669 QMap<Q3ListBoxItem *, QWidget *>::Iterator it;
662 for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){ 670 for (it = mIconListToPageStack.begin(); it != mIconListToPageStack.end(); ++it){
663 QListBoxItem *key = it.key(); 671 Q3ListBoxItem *key = it.key();
664 QWidget *val = it.data(); 672 QWidget *val = it.data();
665 if (val == w) { 673 if (val == w) {
666 mIconList->setSelected( key, true ); 674 mIconList->setSelected( key, true );
667 break; 675 break;
668 } 676 }
669 } 677 }
670 } 678 }
671 } 679 }
672 else if( mFace == Tabbed ) 680 else if( mFace == Tabbed )
673 { 681 {
674 mTabControl->showPage(w); 682 mTabControl->showPage(w);
675 mActivePageWidget = w; 683 mActivePageWidget = w;
676 } 684 }
677 else 685 else
678 { 686 {
679 return( false ); 687 return( false );
680 } 688 }
681 689
682 return( true ); 690 return( true );
683} 691}
684 692
685 693
686int KJanusWidget::activePageIndex() const 694int KJanusWidget::activePageIndex() const
687{ 695{
688 if( mFace == TreeList) { 696 if( mFace == TreeList) {
689 QListViewItem *node = mTreeList->selectedItem(); 697 Q3ListViewItem *node = mTreeList->selectedItem();
690 if( node == 0 ) { return -1; } 698 if( node == 0 ) { return -1; }
691 QWidget *stackItem = mTreeListToPageStack[node]; 699 QWidget *stackItem = mTreeListToPageStack[node];
692 return d->mPageToInt[stackItem]; 700 return d->mPageToInt[stackItem];
693 } 701 }
694 else if (mFace == IconList) { 702 else if (mFace == IconList) {
695 QListBoxItem *node = mIconList->item( mIconList->currentItem() ); 703 Q3ListBoxItem *node = mIconList->item( mIconList->currentItem() );
696 if( node == 0 ) { return( false ); } 704 if( node == 0 ) { return( false ); }
697 QWidget *stackItem = mIconListToPageStack[node]; 705 QWidget *stackItem = mIconListToPageStack[node];
698 return d->mPageToInt[stackItem]; 706 return d->mPageToInt[stackItem];
699 } 707 }
700 else if( mFace == Tabbed ) { 708 else if( mFace == Tabbed ) {
701 QWidget *widget = mTabControl->currentPage(); 709 QWidget *widget = mTabControl->currentPage();
702 return( widget == 0 ? -1 : d->mPageToInt[widget] ); 710 return( widget == 0 ? -1 : d->mPageToInt[widget] );
703 } 711 }
704 else { 712 else {
705 return( -1 ); 713 return( -1 );
706 } 714 }
707} 715}
708 716
709 717
710int KJanusWidget::pageIndex( QWidget *widget ) const 718int KJanusWidget::pageIndex( QWidget *widget ) const
711{ 719{
712 if( widget == 0 ) 720 if( widget == 0 )
713 { 721 {
714 return( -1 ); 722 return( -1 );
715 } 723 }
716 else if( mFace == TreeList || mFace == IconList ) 724 else if( mFace == TreeList || mFace == IconList )
717 { 725 {
718 return( d->mPageToInt[widget] ); 726 return( d->mPageToInt[widget] );
719 } 727 }
720 else if( mFace == Tabbed ) 728 else if( mFace == Tabbed )
721 { 729 {
722 // 730 //
723 // The user gets the real page widget with addVBoxPage(), addHBoxPage() 731 // The user gets the real page widget with addVBoxPage(), addHBoxPage()
724 // and addGridPage() but not with addPage() which returns a child of 732 // and addGridPage() but not with addPage() which returns a child of
725 // the toplevel page. addPage() returns a QFrame so I check for that. 733 // the toplevel page. addPage() returns a QFrame so I check for that.
726 // 734 //
727 if( widget->isA("QFrame") ) 735 if( widget->isA("QFrame") )
728 { 736 {
729 return( d->mPageToInt[widget->parentWidget()] ); 737 return( d->mPageToInt[widget->parentWidget()] );
730 } 738 }
731 else 739 else
732 { 740 {
733 return( d->mPageToInt[widget] ); 741 return( d->mPageToInt[widget] );
734 } 742 }
735 } 743 }
736 else 744 else
737 { 745 {
738 return( -1 ); 746 return( -1 );
739 } 747 }
740} 748}
741/*US not yet implemented 749/*US not yet implemented
742void KJanusWidget::slotFontChanged() 750void KJanusWidget::slotFontChanged()
743{ 751{
744 if( mTitleLabel != 0 ) 752 if( mTitleLabel != 0 )
745 { 753 {
746 mTitleLabel->setFont( KGlobalSettings::generalFont() ); 754 mTitleLabel->setFont( KGlobalSettings::generalFont() );
747 QFont titleFont( mTitleLabel->font() ); 755 QFont titleFont( mTitleLabel->font() );
748 titleFont.setBold( true ); 756 titleFont.setBold( true );
749 mTitleLabel->setFont( titleFont ); 757 mTitleLabel->setFont( titleFont );
750 } 758 }
751 759
752 if( mFace == IconList ) 760 if( mFace == IconList )
753 { 761 {
754 QFont listFont( mIconList->font() ); 762 QFont listFont( mIconList->font() );
755 listFont.setBold( true ); 763 listFont.setBold( true );
756 mIconList->setFont( listFont ); 764 mIconList->setFont( listFont );
757 mIconList->invalidateHeight(); 765 mIconList->invalidateHeight();
758 mIconList->invalidateWidth(); 766 mIconList->invalidateWidth();
759 } 767 }
760} 768}
761*/ 769*/
762 770
763// makes the treelist behave like the list of kcontrol 771// makes the treelist behave like the list of kcontrol
764void KJanusWidget::slotItemClicked(QListViewItem *it) 772void KJanusWidget::slotItemClicked(Q3ListViewItem *it)
765{ 773{
766 if(it && (it->childCount()>0)) 774 if(it && (it->childCount()>0))
767 it->setOpen(!it->isOpen()); 775 it->setOpen(!it->isOpen());
768} 776}
769 777
770void KJanusWidget::setFocus() 778void KJanusWidget::setFocus()
771{ 779{
772 if( mValid == false ) { return; } 780 if( mValid == false ) { return; }
773 if( mFace == TreeList ) 781 if( mFace == TreeList )
774 { 782 {
775 mTreeList->setFocus(); 783 mTreeList->setFocus();
776 } 784 }
777 if( mFace == IconList ) 785 if( mFace == IconList )
778 { 786 {
779 mIconList->setFocus(); 787 mIconList->setFocus();
780 } 788 }
781 else if( mFace == Tabbed ) 789 else if( mFace == Tabbed )
782 { 790 {
783 mTabControl->setFocus(); 791 mTabControl->setFocus();
784 } 792 }
785 else if( mFace == Swallow ) 793 else if( mFace == Swallow )
786 { 794 {
787 mSwallowPage->setFocus(); 795 mSwallowPage->setFocus();
788 } 796 }
789 else if( mFace == Plain ) 797 else if( mFace == Plain )
790 { 798 {
791 mPlainPage->setFocus(); 799 mPlainPage->setFocus();
792 } 800 }
793} 801}
794 802
795 803
796QSize KJanusWidget::minimumSizeHint() const 804QSize KJanusWidget::minimumSizeHint() const
797{ 805{
798 if( mFace == TreeList || mFace == IconList ) 806 if( mFace == TreeList || mFace == IconList )
799 { 807 {
800 QSize s1( KDialog::spacingHint(), KDialog::spacingHint()*2 ); 808 QSize s1( KDialog::spacingHint(), KDialog::spacingHint()*2 );
801 QSize s2(0,0); 809 QSize s2(0,0);
802 QSize s3(0,0); 810 QSize s3(0,0);
803 QSize s4( mPageStack->sizeHint() ); 811 QSize s4( mPageStack->sizeHint() );
804 812
805 if( mFace == TreeList ) 813 if( mFace == TreeList )
806 { 814 {
807/*US 815/*US
808 s1.rwidth() += style().pixelMetric( QStyle::PM_SplitterWidth ); 816 s1.rwidth() += style().pixelMetric( QStyle::PM_SplitterWidth );
809 s2 = mTreeList->minimumSize(); 817 s2 = mTreeList->minimumSize();
810*/ 818*/
811 } 819 }
812 else 820 else
813 { 821 {
814 mIconList->updateMinimumHeight(); 822 mIconList->updateMinimumHeight();
815 mIconList->updateWidth(); 823 mIconList->updateWidth();
816 s2 = mIconList->minimumSize(); 824 s2 = mIconList->minimumSize();
817 } 825 }
818 826
819 if( mTitleLabel->isVisible() == true ) 827 if( mTitleLabel->isVisible() == true )
820 { 828 {
821 s3 += mTitleLabel->sizeHint(); 829 s3 += mTitleLabel->sizeHint();
822 s3.rheight() += mTitleSep->minimumSize().height(); 830 s3.rheight() += mTitleSep->minimumSize().height();
823 } 831 }
824 832
825 // 833 //
826 // Select the tallest item. It has only effect in IconList mode 834 // Select the tallest item. It has only effect in IconList mode
827 // 835 //
828 int h1 = s1.rheight() + s3.rheight() + s4.height(); 836 int h1 = s1.rheight() + s3.rheight() + s4.height();
829 int h2 = QMAX( h1, s2.rheight() ); 837 int h2 = QMAX( h1, s2.rheight() );
830 838
831 return( QSize( s1.width()+s2.width()+QMAX(s3.width(),s4.width()), h2 ) ); 839 return( QSize( s1.width()+s2.width()+QMAX(s3.width(),s4.width()), h2 ) );
832 } 840 }
833 else if( mFace == Tabbed ) 841 else if( mFace == Tabbed )
834 { 842 {
835 return( mTabControl->sizeHint() ); 843 return( mTabControl->sizeHint() );
836 } 844 }
837 else if( mFace == Swallow ) 845 else if( mFace == Swallow )
838 { 846 {
839 return( mSwallowPage->minimumSize() ); 847 return( mSwallowPage->minimumSize() );
840 } 848 }
841 else if( mFace == Plain ) 849 else if( mFace == Plain )
842 { 850 {
843 return( mPlainPage->sizeHint() ); 851 return( mPlainPage->sizeHint() );
844 } 852 }
845 else 853 else
846 { 854 {
847 return( QSize( 100, 100 ) ); // Should never happen though. 855 return( QSize( 100, 100 ) ); // Should never happen though.
848 } 856 }
849 857
850} 858}
851 859
852 860
853QSize KJanusWidget::sizeHint() const 861QSize KJanusWidget::sizeHint() const
854{ 862{
855 return( minimumSizeHint() ); 863 return( minimumSizeHint() );
856} 864}
857 865
858 866
859void KJanusWidget::setTreeListAutoResize( bool state ) 867void KJanusWidget::setTreeListAutoResize( bool state )
860{ 868{
861 if( mFace == TreeList ) 869 if( mFace == TreeList )
862 { 870 {
863/*US 871/*US
864 mTreeListResizeMode = state == false ? 872 mTreeListResizeMode = state == false ?
865 QSplitter::KeepSize : QSplitter::Stretch; 873 QSplitter::KeepSize : QSplitter::Stretch;
866 QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); 874 QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget());
867 splitter->setResizeMode( mTreeList, mTreeListResizeMode ); 875 splitter->setResizeMode( mTreeList, mTreeListResizeMode );
868*/ 876*/
869 } 877 }
870} 878}
871 879
872 880
873void KJanusWidget::setIconListAllVisible( bool state ) 881void KJanusWidget::setIconListAllVisible( bool state )
874{ 882{
875 if( mFace == IconList ) 883 if( mFace == IconList )
876 { 884 {
877 mIconList->setShowAll( state ); 885 mIconList->setShowAll( state );
878 } 886 }
879} 887}
880 888
881void KJanusWidget::setShowIconsInTreeList( bool state ) 889void KJanusWidget::setShowIconsInTreeList( bool state )
882{ 890{
883 mShowIconsInTreeList = state; 891 mShowIconsInTreeList = state;
884} 892}
885 893
886void KJanusWidget::setRootIsDecorated( bool state ) 894void KJanusWidget::setRootIsDecorated( bool state )
887{ 895{
888 if( mFace == TreeList ) { 896 if( mFace == TreeList ) {
889 mTreeList->setRootIsDecorated(state); 897 mTreeList->setRootIsDecorated(state);
890 } 898 }
891} 899}
892 900
893void KJanusWidget::unfoldTreeList( bool persist ) 901void KJanusWidget::unfoldTreeList( bool persist )
894{ 902{
895 if( mFace == TreeList ) 903 if( mFace == TreeList )
896 { 904 {
897 if( persist ) 905 if( persist )
898 connect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); 906 connect( mTreeList, SIGNAL( collapsed( Q3ListViewItem * ) ), this, SLOT( slotReopen( Q3ListViewItem * ) ) );
899 else 907 else
900 disconnect( mTreeList, SIGNAL( collapsed( QListViewItem * ) ), this, SLOT( slotReopen( QListViewItem * ) ) ); 908 disconnect( mTreeList, SIGNAL( collapsed( Q3ListViewItem * ) ), this, SLOT( slotReopen( Q3ListViewItem * ) ) );
901 909
902 for( QListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() ) 910 for( Q3ListViewItem * item = mTreeList->firstChild(); item; item = item->itemBelow() )
903 item->setOpen( true ); 911 item->setOpen( true );
904 } 912 }
905} 913}
906 914
907void KJanusWidget::showEvent( QShowEvent * ) 915void KJanusWidget::showEvent( QShowEvent * )
908{ 916{
909 if( mFace == TreeList ) 917 if( mFace == TreeList )
910 { 918 {
911/*US 919/*US
912 QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget()); 920 QSplitter *splitter = (QSplitter*)(mTreeList->parentWidget());
913 splitter->setResizeMode( mTreeList, mTreeListResizeMode ); 921 splitter->setResizeMode( mTreeList, mTreeListResizeMode );
914*/ 922*/
915 } 923 }
916} 924}
917 925
918 926
919// 927//
920// 2000-13-02 Espen Sand 928// 2000-13-02 Espen Sand
921// It should be obvious that this eventfilter must only be 929// It should be obvious that this eventfilter must only be
922// be installed on the vertical scrollbar of the mIconList. 930// be installed on the vertical scrollbar of the mIconList.
923// 931//
924bool KJanusWidget::eventFilter( QObject *o, QEvent *e ) 932bool KJanusWidget::eventFilter( QObject *o, QEvent *e )
925{ 933{
926 if( e->type() == QEvent::Show ) 934 if( e->type() == QEvent::Show )
927 { 935 {
928 IconListItem *item = (IconListItem*)mIconList->item(0); 936 IconListItem *item = (IconListItem*)mIconList->item(0);
929 if( item != 0 ) 937 if( item != 0 )
930 { 938 {
931 int lw = item->width( mIconList ); 939 int lw = item->width( mIconList );
932 int sw = mIconList->verticalScrollBar()->sizeHint().width(); 940 int sw = mIconList->verticalScrollBar()->sizeHint().width();
933 mIconList->setFixedWidth( lw+sw+mIconList->frameWidth()*2 ); 941 mIconList->setFixedWidth( lw+sw+mIconList->frameWidth()*2 );
934 } 942 }
935 } 943 }
936 else if( e->type() == QEvent::Hide ) 944 else if( e->type() == QEvent::Hide )
937 { 945 {
938 IconListItem *item = (IconListItem*)mIconList->item(0); 946 IconListItem *item = (IconListItem*)mIconList->item(0);
939 if( item != 0 ) 947 if( item != 0 )
940 { 948 {
941 int lw = item->width( mIconList ); 949 int lw = item->width( mIconList );
942 mIconList->setFixedWidth( lw+mIconList->frameWidth()*2 ); 950 mIconList->setFixedWidth( lw+mIconList->frameWidth()*2 );
943 } 951 }
944 } 952 }
945 return QWidget::eventFilter( o, e ); 953 return QWidget::eventFilter( o, e );
946} 954}
947 955
948 956
949 957
950// 958//
951// Code for the icon list box 959// Code for the icon list box
952// 960//
953 961
954 962
955KJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name, 963KJanusWidget::IconListBox::IconListBox( QWidget *parent, const char *name,
956 WFlags f ) 964 Qt::WFlags f )
957 :KListBox( parent, name, f ), mShowAll(false), mHeightValid(false), 965 :KListBox( parent, name, f ), mShowAll(false), mHeightValid(false),
958 mWidthValid(false) 966 mWidthValid(false)
959{ 967{
960} 968}
961 969
962 970
963void KJanusWidget::IconListBox::updateMinimumHeight() 971void KJanusWidget::IconListBox::updateMinimumHeight()
964{ 972{
965 if( mShowAll == true && mHeightValid == false ) 973 if( mShowAll == true && mHeightValid == false )
966 { 974 {
967 int h = frameWidth()*2; 975 int h = frameWidth()*2;
968 for( QListBoxItem *i = item(0); i != 0; i = i->next() ) 976 for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() )
969 { 977 {
970 h += i->height( this ); 978 h += i->height( this );
971 } 979 }
972 setMinimumHeight( h ); 980 setMinimumHeight( h );
973 mHeightValid = true; 981 mHeightValid = true;
974 } 982 }
975} 983}
976 984
977 985
978void KJanusWidget::IconListBox::updateWidth() 986void KJanusWidget::IconListBox::updateWidth()
979{ 987{
980 if( mWidthValid == false ) 988 if( mWidthValid == false )
981 { 989 {
982 int maxWidth = 10; 990 int maxWidth = 10;
983 for( QListBoxItem *i = item(0); i != 0; i = i->next() ) 991 for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() )
984 { 992 {
985 int w = ((IconListItem *)i)->width(this); 993 int w = ((IconListItem *)i)->width(this);
986 maxWidth = QMAX( w, maxWidth ); 994 maxWidth = QMAX( w, maxWidth );
987 } 995 }
988 996
989 for( QListBoxItem *i = item(0); i != 0; i = i->next() ) 997 for( Q3ListBoxItem *i = item(0); i != 0; i = i->next() )
990 { 998 {
991 ((IconListItem *)i)->expandMinimumWidth( maxWidth ); 999 ((IconListItem *)i)->expandMinimumWidth( maxWidth );
992 } 1000 }
993 1001
994 if( verticalScrollBar()->isVisible() ) 1002 if( verticalScrollBar()->isVisible() )
995 { 1003 {
996 maxWidth += verticalScrollBar()->sizeHint().width(); 1004 maxWidth += verticalScrollBar()->sizeHint().width();
997 } 1005 }
998 1006
999 setFixedWidth( maxWidth + frameWidth()*2 ); 1007 setFixedWidth( maxWidth + frameWidth()*2 );
1000 mWidthValid = true; 1008 mWidthValid = true;
1001 } 1009 }
1002} 1010}
1003 1011
1004 1012
1005void KJanusWidget::IconListBox::invalidateHeight() 1013void KJanusWidget::IconListBox::invalidateHeight()
1006{ 1014{
1007 mHeightValid = false; 1015 mHeightValid = false;
1008} 1016}
1009 1017
1010 1018
1011void KJanusWidget::IconListBox::invalidateWidth() 1019void KJanusWidget::IconListBox::invalidateWidth()
1012{ 1020{
1013 mWidthValid = false; 1021 mWidthValid = false;
1014} 1022}
1015 1023
1016 1024
1017void KJanusWidget::IconListBox::setShowAll( bool showAll ) 1025void KJanusWidget::IconListBox::setShowAll( bool showAll )
1018{ 1026{
1019 mShowAll = showAll; 1027 mShowAll = showAll;
1020 mHeightValid = false; 1028 mHeightValid = false;
1021} 1029}
1022 1030
1023 1031
1024 1032
1025KJanusWidget::IconListItem::IconListItem( QListBox *listbox, const QPixmap &pixmap, 1033KJanusWidget::IconListItem::IconListItem( Q3ListBox *listbox, const QPixmap &pixmap,
1026 const QString &text ) 1034 const QString &text )
1027 : QListBoxItem( listbox ) 1035 : Q3ListBoxItem( listbox )
1028{ 1036{
1029 mPixmap = pixmap; 1037 mPixmap = pixmap;
1030 if( mPixmap.isNull() == true ) 1038 if( mPixmap.isNull() == true )
1031 { 1039 {
1032 mPixmap = defaultPixmap(); 1040 mPixmap = defaultPixmap();
1033 } 1041 }
1034 setText( text ); 1042 setText( text );
1035 mMinimumWidth = 0; 1043 mMinimumWidth = 0;
1036} 1044}
1037 1045
1038 1046
1039int KJanusWidget::IconListItem::expandMinimumWidth( int width ) 1047int KJanusWidget::IconListItem::expandMinimumWidth( int width )
1040{ 1048{
1041 mMinimumWidth = QMAX( mMinimumWidth, width ); 1049 mMinimumWidth = QMAX( mMinimumWidth, width );
1042 return( mMinimumWidth ); 1050 return( mMinimumWidth );
1043} 1051}
1044 1052
1045 1053
1046const QPixmap &KJanusWidget::IconListItem::defaultPixmap() 1054const QPixmap &KJanusWidget::IconListItem::defaultPixmap()
1047{ 1055{
1048 static QPixmap *pix=0; 1056 static QPixmap *pix=0;
1049 if( pix == 0 ) 1057 if( pix == 0 )
1050 { 1058 {
1051 pix = new QPixmap( 32, 32 ); 1059 pix = new QPixmap( 32, 32 );
1052 QPainter p( pix ); 1060 QPainter p( pix );
1053 p.eraseRect( 0, 0, pix->width(), pix->height() ); 1061 p.eraseRect( 0, 0, pix->width(), pix->height() );
1054 p.setPen( Qt::red ); 1062 p.setPen( Qt::red );
1055 p.drawRect ( 0, 0, pix->width(), pix->height() ); 1063 p.drawRect ( 0, 0, pix->width(), pix->height() );
1056 p.end(); 1064 p.end();
1057 1065
1058 QBitmap mask( pix->width(), pix->height(), true); 1066 QBitmap mask( pix->width(), pix->height(), true);
1059 mask.fill( Qt::black ); 1067 mask.fill( Qt::black );
1060 p.begin( &mask ); 1068 p.begin( &mask );
1061 p.setPen( Qt::white ); 1069 p.setPen( Qt::white );
1062 p.drawRect ( 0, 0, pix->width(), pix->height() ); 1070 p.drawRect ( 0, 0, pix->width(), pix->height() );
1063 p.end(); 1071 p.end();
1064 1072
1065 pix->setMask( mask ); 1073 pix->setMask( mask );
1066 } 1074 }
1067 return( *pix ); 1075 return( *pix );
1068} 1076}
1069 1077
1070 1078
1071void KJanusWidget::IconListItem::paint( QPainter *painter ) 1079void KJanusWidget::IconListItem::paint( QPainter *painter )
1072{ 1080{
1073 QFontMetrics fm = painter->fontMetrics(); 1081 QFontMetrics fm = painter->fontMetrics();
1074 //int wt = fm.boundingRect(text()).width(); 1082 //int wt = fm.boundingRect(text()).width();
1075 int wp = mPixmap.width(); 1083 int wp = mPixmap.width();
1076 int ht = fm.lineSpacing(); 1084 int ht = fm.lineSpacing();
1077 int hp = mPixmap.height(); 1085 int hp = mPixmap.height();
1078 1086
1079 painter->drawPixmap( (mMinimumWidth-wp)/2, 5, mPixmap ); 1087 painter->drawPixmap( (mMinimumWidth-wp)/2, 5, mPixmap );
1080 if( text().isEmpty() == false ) 1088 if( text().isEmpty() == false )
1081 { 1089 {
1082 painter->drawText( 0, hp+7, mMinimumWidth, ht, Qt::AlignCenter, text() ); 1090 painter->drawText( 0, hp+7, mMinimumWidth, ht, Qt::AlignCenter, text() );
1083 } 1091 }
1084} 1092}
1085 1093
1086int KJanusWidget::IconListItem::height( const QListBox *lb ) const 1094int KJanusWidget::IconListItem::height( const Q3ListBox *lb ) const
1087{ 1095{
1088 if( text().isEmpty() == true ) 1096 if( text().isEmpty() == true )
1089 { 1097 {
1090 return( mPixmap.height() ); 1098 return( mPixmap.height() );
1091 } 1099 }
1092 else 1100 else
1093 { 1101 {
1094 return( mPixmap.height() + lb->fontMetrics().lineSpacing()+10 ); 1102 return( mPixmap.height() + lb->fontMetrics().lineSpacing()+10 );
1095 } 1103 }
1096} 1104}
1097 1105
1098 1106
1099int KJanusWidget::IconListItem::width( const QListBox *lb ) const 1107int KJanusWidget::IconListItem::width( const Q3ListBox *lb ) const
1100{ 1108{
1101 int wt = lb->fontMetrics().boundingRect(text()).width()+10; 1109 int wt = lb->fontMetrics().boundingRect(text()).width()+10;
1102 int wp = mPixmap.width() + 10; 1110 int wp = mPixmap.width() + 10;
1103 int w = QMAX( wt, wp ); 1111 int w = QMAX( wt, wp );
1104 return( QMAX( w, mMinimumWidth ) ); 1112 return( QMAX( w, mMinimumWidth ) );
1105} 1113}
1106 1114
1107 1115
1108void KJanusWidget::virtual_hook( int, void* ) 1116void KJanusWidget::virtual_hook( int, void* )
1109{ /*BASE::virtual_hook( id, data );*/ } 1117{ /*BASE::virtual_hook( id, data );*/ }
1110 1118
1111// TODO: In TreeList, if the last child of a node is removed, and there is no corrsponding widget for that node, allow the caller to 1119// TODO: In TreeList, if the last child of a node is removed, and there is no corrsponding widget for that node, allow the caller to
1112// delete the node. 1120// delete the node.
1113void KJanusWidget::removePage( QWidget *page ) 1121void KJanusWidget::removePage( QWidget *page )
1114{ 1122{
1115//US qDebug("KJanusWidget::removePage 1 %lu , %lu, %lu", d, page, &(d->mPageToInt)); 1123//US qDebug("KJanusWidget::removePage 1 %lu , %lu, %lu", d, page, &(d->mPageToInt));
1116 if (!d || !(d->mPageToInt.contains(page))) 1124 if (!d || !(d->mPageToInt.contains(page)))
1117 { 1125 {
1118 return; 1126 return;
1119 } 1127 }
1120 1128
1121 int index = d->mPageToInt[page]; 1129 int index = d->mPageToInt[page];
1122 1130
1123 if ( mFace == TreeList ) 1131 if ( mFace == TreeList )
1124 { 1132 {
1125 QMap<QListViewItem*, QWidget *>::Iterator i; 1133 QMap<Q3ListViewItem*, QWidget *>::Iterator i;
1126 for( i = mTreeListToPageStack.begin(); i != mTreeListToPageStack.end(); ++i ) 1134 for( i = mTreeListToPageStack.begin(); i != mTreeListToPageStack.end(); ++i )
1127 if (i.data()==page) 1135 if (i.data()==page)
1128 { 1136 {
1129 delete i.key(); 1137 delete i.key();
1130 mPageStack->removeWidget(page); 1138 mPageStack->removeWidget(page);
1131 mTreeListToPageStack.remove(i); 1139 mTreeListToPageStack.remove(i);
1132 d->mIntToTitle.remove(index); 1140 d->mIntToTitle.remove(index);
1133 d->mPageToInt.remove(page); 1141 d->mPageToInt.remove(page);
1134 d->mIntToPage.remove(index); 1142 d->mIntToPage.remove(index);
1135 break; 1143 break;
1136 } 1144 }
1137 } 1145 }
1138 else if ( mFace == IconList ) 1146 else if ( mFace == IconList )
1139 { 1147 {
1140 QMap<QListBoxItem*, QWidget *>::Iterator i; 1148 QMap<Q3ListBoxItem*, QWidget *>::Iterator i;
1141 for( i = mIconListToPageStack.begin(); i != mIconListToPageStack.end(); ++i ) 1149 for( i = mIconListToPageStack.begin(); i != mIconListToPageStack.end(); ++i )
1142 if (i.data()==page) 1150 if (i.data()==page)
1143 { 1151 {
1144 delete i.key(); 1152 delete i.key();
1145 mPageStack->removeWidget(page); 1153 mPageStack->removeWidget(page);
1146 mIconListToPageStack.remove(i); 1154 mIconListToPageStack.remove(i);
1147 d->mIntToTitle.remove(index); 1155 d->mIntToTitle.remove(index);
1148 d->mPageToInt.remove(page); 1156 d->mPageToInt.remove(page);
1149 d->mIntToPage.remove(index); 1157 d->mIntToPage.remove(index);
1150 break; 1158 break;
1151 } 1159 }
1152 } 1160 }
1153 else // Tabbed 1161 else // Tabbed
1154 { 1162 {
1155 mTabControl->removePage(page); 1163 mTabControl->removePage(page);
1156 d->mPageToInt.remove(page); 1164 d->mPageToInt.remove(page);
1157 d->mIntToPage.remove(index); 1165 d->mIntToPage.remove(index);
1158 } 1166 }
1159} 1167}
1160 1168
1161QString KJanusWidget::pageTitle(int index) const 1169QString KJanusWidget::pageTitle(int index) const
1162{ 1170{
1163 if (!d || !d->mIntToTitle.contains(index)) 1171 if (!d || !d->mIntToTitle.contains(index))
1164 return QString::null; 1172 return QString::null;
1165 else 1173 else
1166 return d->mIntToTitle[index]; 1174 return d->mIntToTitle[index];
1167} 1175}
1168 1176
1169QWidget *KJanusWidget::pageWidget(int index) const 1177QWidget *KJanusWidget::pageWidget(int index) const
1170{ 1178{
1171 if (!d || !d->mIntToPage.contains(index)) 1179 if (!d || !d->mIntToPage.contains(index))
1172 return 0; 1180 return 0;
1173 else 1181 else
1174 return d->mIntToPage[index]; 1182 return d->mIntToPage[index];
1175} 1183}
1176 1184
1177//US #include "kjanuswidget.moc" 1185//US #include "kjanuswidget.moc"
diff --git a/microkde/kdeui/kjanuswidget.h b/microkde/kdeui/kjanuswidget.h
index 6d3f23d..72465ea 100644
--- a/microkde/kdeui/kjanuswidget.h
+++ b/microkde/kdeui/kjanuswidget.h
@@ -1,565 +1,571 @@
1/* This file is part of the KDE Libraries 1/* This file is part of the KDE Libraries
2 * Copyright (C) 1999-2000 Espen Sand (espen@kde.org) 2 * Copyright (C) 1999-2000 Espen Sand (espen@kde.org)
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA. 17 * Boston, MA 02111-1307, USA.
18 */ 18 */
19 19
20#ifndef _KJANUS_WIDGET_H_ 20#ifndef _KJANUS_WIDGET_H_
21#define _KJANUS_WIDGET_H_ 21#define _KJANUS_WIDGET_H_
22 22
23#include <qptrlist.h> 23#include <q3ptrlist.h>
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qmap.h> 25#include <qmap.h>
26#include <qgrid.h> 26#include <q3grid.h>
27//Added by qt3to4:
28#include <QShowEvent>
29#include <Q3Frame>
30#include <QPixmap>
31#include <QLabel>
32#include <QEvent>
27#include <klistbox.h> 33#include <klistbox.h>
28 34
29/*US 35/*US
30#include <qptrlist.h> 36#include <qptrlist.h>
31#include <qpixmap.h> 37#include <qpixmap.h>
32#include <qsplitter.h> 38#include <qsplitter.h>
33 39
34#include <qstringlist.h> 40#include <qstringlist.h>
35#include <qmap.h> 41#include <qmap.h>
36 42
37*/ 43*/
38 44
39class KSeparator; 45class KSeparator;
40class KListView; 46class KListView;
41class QWidgetStack; 47class Q3WidgetStack;
42class QLabel; 48class QLabel;
43class QTabWidget; 49class QTabWidget;
44class QListViewItem; 50class Q3ListViewItem;
45class QVBox; 51class Q3VBox;
46class QHBox; 52class Q3HBox;
47 53
48/** 54/**
49 * Provides a number of ready to use layouts (faces). It is used 55 * Provides a number of ready to use layouts (faces). It is used
50 * as an internal widget in @ref KDialogBase, but can also used as a 56 * as an internal widget in @ref KDialogBase, but can also used as a
51 * widget of its own. 57 * widget of its own.
52 * 58 *
53 * It provides TreeList, IconList, Tabbed, Plain and Swallow layouts. 59 * It provides TreeList, IconList, Tabbed, Plain and Swallow layouts.
54 * 60 *
55 * The TreeList face provides a list in the left area and pages in the 61 * The TreeList face provides a list in the left area and pages in the
56 * right. The area are separated by a movable splitter. The style is somewhat 62 * right. The area are separated by a movable splitter. The style is somewhat
57 * similar to the layout in the Control Center. A page is raised by 63 * similar to the layout in the Control Center. A page is raised by
58 * selecting the corresponding tree list item. 64 * selecting the corresponding tree list item.
59 * 65 *
60 * The IconList face provides an icon list in the left area and pages in the 66 * The IconList face provides an icon list in the left area and pages in the
61 * right. For each entry the Icon is on top with the text below. The style 67 * right. For each entry the Icon is on top with the text below. The style
62 * is somewhat similar to the layout of the Eudora configuation dialog box. 68 * is somewhat similar to the layout of the Eudora configuation dialog box.
63 * A page is raised by selecting the corresponding icon list item. The 69 * A page is raised by selecting the corresponding icon list item. The
64 * preferred icon size is 32x32 pixels. 70 * preferred icon size is 32x32 pixels.
65 * 71 *
66 * The Tabbed face is a common tabbed widget. The procedure for creating a 72 * The Tabbed face is a common tabbed widget. The procedure for creating a
67 * page is similar for creating a TreeList. This has the advantage that if 73 * page is similar for creating a TreeList. This has the advantage that if
68 * your widget contain too many pages it is trivial to convert it into a 74 * your widget contain too many pages it is trivial to convert it into a
69 * TreeList. Just change the face in the KJanusWidget constructor to 75 * TreeList. Just change the face in the KJanusWidget constructor to
70 * KJanusWidget::TreeList and you have a tree list layout instead. 76 * KJanusWidget::TreeList and you have a tree list layout instead.
71 * 77 *
72 * The Plain face provides an empty widget (QFrame) where you can place your 78 * The Plain face provides an empty widget (QFrame) where you can place your
73 * widgets. The KJanusWidget makes no assumptions regarding the contents so 79 * widgets. The KJanusWidget makes no assumptions regarding the contents so
74 * you are free to add whatever you want. 80 * you are free to add whatever you want.
75 * 81 *
76 * The Swallow face is provided in order to simplify the usage of existing 82 * The Swallow face is provided in order to simplify the usage of existing
77 * widgets and to allow changing the visible widget. You specify the widget 83 * widgets and to allow changing the visible widget. You specify the widget
78 * to be displayed by @ref #setSwallowedWidget(). Your widget will be 84 * to be displayed by @ref #setSwallowedWidget(). Your widget will be
79 * reparented inside the widget. You can specify a Null (0) widget. A empty 85 * reparented inside the widget. You can specify a Null (0) widget. A empty
80 * space is then displayed. 86 * space is then displayed.
81 * 87 *
82 * For all modes it is important that you specify the @ref QWidget::minimumSize() 88 * For all modes it is important that you specify the @ref QWidget::minimumSize()
83 * on the page, plain widget or the swallowed widget. If you use a QLayout 89 * on the page, plain widget or the swallowed widget. If you use a QLayout
84 * on the page, plain widget or the swallowed widget this will be taken care 90 * on the page, plain widget or the swallowed widget this will be taken care
85 * of automatically. The size is used when the KJanusWidget determines its 91 * of automatically. The size is used when the KJanusWidget determines its
86 * own minimum size. You get the minimum size by using the 92 * own minimum size. You get the minimum size by using the
87 * @ref #minimumSizeHint() or @ref #sizeHint() methods. 93 * @ref #minimumSizeHint() or @ref #sizeHint() methods.
88 * 94 *
89 * Pages that have been added in TreeList, IconList or Tabbed mode can be 95 * Pages that have been added in TreeList, IconList or Tabbed mode can be
90 * removed by simply deleting the page. However, it would be preferable to use 96 * removed by simply deleting the page. However, it would be preferable to use
91 * the QObject::deleteLater() function on the page as the main event loop 97 * the QObject::deleteLater() function on the page as the main event loop
92 * may have optimized UI update events of the page by scheduling them for later. 98 * may have optimized UI update events of the page by scheduling them for later.
93 * 99 *
94 * @short Easy to use widget with many layouts 100 * @short Easy to use widget with many layouts
95 * @author Espen Sand (espen@kde.org) 101 * @author Espen Sand (espen@kde.org)
96 */ 102 */
97class KJanusWidget : public QWidget 103class KJanusWidget : public QWidget
98{ 104{
99 Q_OBJECT 105 Q_OBJECT
100 106
101 private: 107 private:
102 class IconListBox : public KListBox 108 class IconListBox : public KListBox
103 { 109 {
104 public: 110 public:
105 IconListBox( QWidget *parent=0, const char *name=0, WFlags f=0 ); 111 IconListBox( QWidget *parent=0, const char *name=0, Qt::WFlags f=0 );
106 void updateMinimumHeight(); 112 void updateMinimumHeight();
107 void updateWidth(); 113 void updateWidth();
108 void invalidateHeight(); 114 void invalidateHeight();
109 void invalidateWidth(); 115 void invalidateWidth();
110 void setShowAll( bool showAll ); 116 void setShowAll( bool showAll );
111 117
112 private: 118 private:
113 bool mShowAll; 119 bool mShowAll;
114 bool mHeightValid; 120 bool mHeightValid;
115 bool mWidthValid; 121 bool mWidthValid;
116 }; 122 };
117 123
118 public: 124 public:
119 enum Face 125 enum Face
120 { 126 {
121 TreeList = 0, 127 TreeList = 0,
122 Tabbed, 128 Tabbed,
123 Plain, 129 Plain,
124 Swallow, 130 Swallow,
125 IconList 131 IconList
126 }; 132 };
127 133
128 public: 134 public:
129 135
130 /** 136 /**
131 * Constructor where you specify the face. 137 * Constructor where you specify the face.
132 * 138 *
133 * @param parent Parent of the widget. 139 * @param parent Parent of the widget.
134 * @param name Widget name. 140 * @param name Widget name.
135 * @param int face The kind of dialog, Use TreeList, Tabbed, Plain or 141 * @param int face The kind of dialog, Use TreeList, Tabbed, Plain or
136 * Swallow. 142 * Swallow.
137 */ 143 */
138 KJanusWidget( QWidget *parent=0, const char *name=0, int face=Plain ); 144 KJanusWidget( QWidget *parent=0, const char *name=0, int face=Plain );
139 145
140 /** 146 /**
141 * Destructor. 147 * Destructor.
142 */ 148 */
143 ~KJanusWidget(); 149 ~KJanusWidget();
144 150
145 /** 151 /**
146 * Raises the page which was added by @ref addPage(). 152 * Raises the page which was added by @ref addPage().
147 * 153 *
148 * @param index The index of the page you want to raise. 154 * @param index The index of the page you want to raise.
149 */ 155 */
150 virtual bool showPage( int index ); 156 virtual bool showPage( int index );
151 157
152 /** 158 /**
153 * Returns the index of the page that are currently displayed. 159 * Returns the index of the page that are currently displayed.
154 * 160 *
155 * @return The index or -1 if the face is not Tabbed, TreeList or 161 * @return The index or -1 if the face is not Tabbed, TreeList or
156 * IconList. 162 * IconList.
157 */ 163 */
158 virtual int activePageIndex() const; 164 virtual int activePageIndex() const;
159 165
160 /** 166 /**
161 * Use this to verify 167 * Use this to verify
162 * that no memory allocation failed. 168 * that no memory allocation failed.
163 * 169 *
164 * @return true if the widget was properly created. 170 * @return true if the widget was properly created.
165 */ 171 */
166 virtual bool isValid() const; 172 virtual bool isValid() const;
167 173
168 /** 174 /**
169 * Returns the face type. 175 * Returns the face type.
170 * 176 *
171 * @return The face type. 177 * @return The face type.
172 */ 178 */
173 virtual int face() const; 179 virtual int face() const;
174 180
175 /** 181 /**
176 * Returns the minimum size that must be made available for the widget 182 * Returns the minimum size that must be made available for the widget
177 * so that UIs can be displayed properly 183 * so that UIs can be displayed properly
178 * 184 *
179 * @return The minimum size. 185 * @return The minimum size.
180 */ 186 */
181 virtual QSize minimumSizeHint() const; 187 virtual QSize minimumSizeHint() const;
182 188
183 /** 189 /**
184 * Returns the recommended size for the widget in order to be displayed 190 * Returns the recommended size for the widget in order to be displayed
185 * properly. 191 * properly.
186 * 192 *
187 * @return The recommended size. 193 * @return The recommended size.
188 */ 194 */
189 virtual QSize sizeHint() const; 195 virtual QSize sizeHint() const;
190 196
191 /** 197 /**
192 * Returns the empty widget that is available in Plain mode. 198 * Returns the empty widget that is available in Plain mode.
193 * 199 *
194 * @return The widget or 0 if the face in not Plain. 200 * @return The widget or 0 if the face in not Plain.
195 */ 201 */
196 virtual QFrame *plainPage(); 202 virtual Q3Frame *plainPage();
197 203
198 /** 204 /**
199 * Add a new page when the class is used in TreeList, IconList or Tabbed 205 * Add a new page when the class is used in TreeList, IconList or Tabbed
200 * mode. The returned widget is empty and you must add your widgets 206 * mode. The returned widget is empty and you must add your widgets
201 * as children to this widget. In most cases you must create a layout 207 * as children to this widget. In most cases you must create a layout
202 * manager and associate it with this widget as well. 208 * manager and associate it with this widget as well.
203 * 209 *
204 * Deleting the returned frame will cause the listitem or tab to be 210 * Deleting the returned frame will cause the listitem or tab to be
205 * removed (you can re-add a page with the same name later. 211 * removed (you can re-add a page with the same name later.
206 * 212 *
207 * @param item String used in the list or Tab item. 213 * @param item String used in the list or Tab item.
208 * @param header A longer string used in TreeList and IconList mode to 214 * @param header A longer string used in TreeList and IconList mode to
209 * describe the contents of a page. If empty, the item string 215 * describe the contents of a page. If empty, the item string
210 * will be used instead. 216 * will be used instead.
211 * @param pixmap Used in IconList mode or in TreeList mode. You should 217 * @param pixmap Used in IconList mode or in TreeList mode. You should
212 * prefer a pixmap with size 32x32 pixels. 218 * prefer a pixmap with size 32x32 pixels.
213 * 219 *
214 * @return The empty page or 0 if the face is not TreeList, IconList or 220 * @return The empty page or 0 if the face is not TreeList, IconList or
215 * Tabbed. 221 * Tabbed.
216 */ 222 */
217 virtual QFrame *addPage(const QString &item,const QString &header=QString::null, 223 virtual Q3Frame *addPage(const QString &item,const QString &header=QString::null,
218 const QPixmap &pixmap=QPixmap() ); 224 const QPixmap &pixmap=QPixmap() );
219 225
220 /** 226 /**
221 * This is like addPage just above, with the difference that the first 227 * This is like addPage just above, with the difference that the first
222 * element is a list of strings. These strings are used to form a path 228 * element is a list of strings. These strings are used to form a path
223 * of folders down to the given page. The initial elements are names 229 * of folders down to the given page. The initial elements are names
224 * for the folders, while the last element is the name of the page. 230 * for the folders, while the last element is the name of the page.
225 * Note: This does yet only work for the TreeList face. Later this may 231 * Note: This does yet only work for the TreeList face. Later this may
226 * be added for the IconList face too. In other faces than the 232 * be added for the IconList face too. In other faces than the
227 * TreeList, all the strings except the last one is ignored. 233 * TreeList, all the strings except the last one is ignored.
228 * Deleting the returned frame will cause the listitem or tab to be 234 * Deleting the returned frame will cause the listitem or tab to be
229 * removed (you can re-add a page with the same name later. 235 * removed (you can re-add a page with the same name later.
230 * 236 *
231 * Deleting the returned frame will cause the listitem or tab to be 237 * Deleting the returned frame will cause the listitem or tab to be
232 * removed (you can re-add a page with the same name later. 238 * removed (you can re-add a page with the same name later.
233 **/ 239 **/
234 virtual QFrame *addPage(const QStringList &items, const QString &header=QString::null, 240 virtual Q3Frame *addPage(const QStringList &items, const QString &header=QString::null,
235 const QPixmap &pixmap=QPixmap() ); 241 const QPixmap &pixmap=QPixmap() );
236 242
237 /** 243 /**
238 * Add a new page when the class is used in TreeList, IconList or Tabbed 244 * Add a new page when the class is used in TreeList, IconList or Tabbed
239 * mode. The returned widget is empty and you must add your widgets 245 * mode. The returned widget is empty and you must add your widgets
240 * as children to this widget. The returned widget is a @ref QVBox 246 * as children to this widget. The returned widget is a @ref QVBox
241 * so it contains a QVBoxLayout layout that lines up the child widgets 247 * so it contains a QVBoxLayout layout that lines up the child widgets
242 * are vertically. 248 * are vertically.
243 * 249 *
244 * Deleting the returned frame will cause the listitem or tab to be 250 * Deleting the returned frame will cause the listitem or tab to be
245 * removed (you can re-add a page with the same name later. 251 * removed (you can re-add a page with the same name later.
246 * 252 *
247 * @param item String used in the list or Tab item. 253 * @param item String used in the list or Tab item.
248 * @param header A longer string used in TreeList and IconList mode to 254 * @param header A longer string used in TreeList and IconList mode to
249 * describe the contents of a page. If empty, the item string 255 * describe the contents of a page. If empty, the item string
250 * will be used instead. 256 * will be used instead.
251 * @param pixmap Used in IconList mode or in TreeList mode. You should 257 * @param pixmap Used in IconList mode or in TreeList mode. You should
252 * prefer a pixmap with size 32x32 pixels. 258 * prefer a pixmap with size 32x32 pixels.
253 * 259 *
254 * @return The empty page or 0 if the face is not TreeList, IconList or 260 * @return The empty page or 0 if the face is not TreeList, IconList or
255 * Tabbed. */ 261 * Tabbed. */
256 virtual QVBox *addVBoxPage( const QString &item, 262 virtual Q3VBox *addVBoxPage( const QString &item,
257 const QString &header=QString::null, 263 const QString &header=QString::null,
258 const QPixmap &pixmap=QPixmap() ); 264 const QPixmap &pixmap=QPixmap() );
259 265
260 /** 266 /**
261 * This is like addVBoxPage just above, with the difference that the first 267 * This is like addVBoxPage just above, with the difference that the first
262 * element is a list of strings. These strings are used to form a path 268 * element is a list of strings. These strings are used to form a path
263 * of folders down to the given page. The initial elements are names 269 * of folders down to the given page. The initial elements are names
264 * for the folders, while the last element is the name of the page. 270 * for the folders, while the last element is the name of the page.
265 * Note: This does yet only work for the TreeList face. Later this may 271 * Note: This does yet only work for the TreeList face. Later this may
266 * be added for the IconList face too. In other faces than the 272 * be added for the IconList face too. In other faces than the
267 * TreeList, all the strings except the last one is ignored. 273 * TreeList, all the strings except the last one is ignored.
268 * 274 *
269 * Deleting the returned frame will cause the listitem or tab to be 275 * Deleting the returned frame will cause the listitem or tab to be
270 * removed (you can re-add a page with the same name later. 276 * removed (you can re-add a page with the same name later.
271 **/ 277 **/
272 virtual QVBox *addVBoxPage( const QStringList &items, 278 virtual Q3VBox *addVBoxPage( const QStringList &items,
273 const QString &header=QString::null, 279 const QString &header=QString::null,
274 const QPixmap &pixmap=QPixmap() ); 280 const QPixmap &pixmap=QPixmap() );
275 281
276 /** 282 /**
277 * Add a new page when the class is used in TreeList, IconList or Tabbed 283 * Add a new page when the class is used in TreeList, IconList or Tabbed
278 * mode. The returned widget is empty and you must add your widgets 284 * mode. The returned widget is empty and you must add your widgets
279 * as children to this widget. The returned widget is a @ref QHBox 285 * as children to this widget. The returned widget is a @ref QHBox
280 * so it contains a QHBoxLayout layout that lines up the child widgets 286 * so it contains a QHBoxLayout layout that lines up the child widgets
281 * are horizontally. 287 * are horizontally.
282 * 288 *
283 * Deleting the returned frame will cause the listitem or tab to be 289 * Deleting the returned frame will cause the listitem or tab to be
284 * removed (you can re-add a page with the same name later. 290 * removed (you can re-add a page with the same name later.
285 * 291 *
286 * @param item String used in the list or Tab item. 292 * @param item String used in the list or Tab item.
287 * @param header A longer string used in TreeList and IconList mode to 293 * @param header A longer string used in TreeList and IconList mode to
288 * describe the contents of a page. If empty, the item string 294 * describe the contents of a page. If empty, the item string
289 * will be used instead. 295 * will be used instead.
290 * @param pixmap Used in IconList mode or in TreeList mode. You should 296 * @param pixmap Used in IconList mode or in TreeList mode. You should
291 * prefer a pixmap with size 32x32 pixels. 297 * prefer a pixmap with size 32x32 pixels.
292 * 298 *
293 * @return The empty page or 0 if the face is not TreeList, IconList or 299 * @return The empty page or 0 if the face is not TreeList, IconList or
294 * Tabbed. 300 * Tabbed.
295 */ 301 */
296 virtual QHBox *addHBoxPage( const QString &itemName, 302 virtual Q3HBox *addHBoxPage( const QString &itemName,
297 const QString &header=QString::null, 303 const QString &header=QString::null,
298 const QPixmap &pixmap=QPixmap() ); 304 const QPixmap &pixmap=QPixmap() );
299 305
300 /** 306 /**
301 * This is like addHBoxPage just above, with the difference that the first 307 * This is like addHBoxPage just above, with the difference that the first
302 * element is a list of strings. These strings are used to form a path 308 * element is a list of strings. These strings are used to form a path
303 * of folders down to the given page. The initial elements are names 309 * of folders down to the given page. The initial elements are names
304 * for the folders, while the last element is the name of the page. 310 * for the folders, while the last element is the name of the page.
305 * Note: This does yet only work for the TreeList face. Later this may 311 * Note: This does yet only work for the TreeList face. Later this may
306 * be added for the IconList face too. In other faces than the 312 * be added for the IconList face too. In other faces than the
307 * TreeList, all the strings except the last one is ignored. 313 * TreeList, all the strings except the last one is ignored.
308 * 314 *
309 * Deleting the returned frame will cause the listitem or tab to be 315 * Deleting the returned frame will cause the listitem or tab to be
310 * removed (you can re-add a page with the same name later. 316 * removed (you can re-add a page with the same name later.
311 **/ 317 **/
312 virtual QHBox *addHBoxPage( const QStringList &items, 318 virtual Q3HBox *addHBoxPage( const QStringList &items,
313 const QString &header=QString::null, 319 const QString &header=QString::null,
314 const QPixmap &pixmap=QPixmap() ); 320 const QPixmap &pixmap=QPixmap() );
315 321
316 /** 322 /**
317 * Add a new page when the class is used in either TreeList or Tabbed 323 * Add a new page when the class is used in either TreeList or Tabbed
318 * mode. The returned widget is empty and you must add your widgets 324 * mode. The returned widget is empty and you must add your widgets
319 * as children to this widget. The returned widget is a @ref QGrid 325 * as children to this widget. The returned widget is a @ref QGrid
320 * so it contains a QGridLayout layout that places up the child widgets 326 * so it contains a QGridLayout layout that places up the child widgets
321 * in a grid. 327 * in a grid.
322 * 328 *
323 * Deleting the returned frame will cause the listitem or tab to be 329 * Deleting the returned frame will cause the listitem or tab to be
324 * removed (you can re-add a page with the same name later. 330 * removed (you can re-add a page with the same name later.
325 * 331 *
326 * @param n Specifies the number of columns if 'dir' is QGrid::Horizontal 332 * @param n Specifies the number of columns if 'dir' is QGrid::Horizontal
327 * or the number of rows if 'dir' is QGrid::Vertical. 333 * or the number of rows if 'dir' is QGrid::Vertical.
328 * @param dir Can be QGrid::Horizontal or QGrid::Vertical. 334 * @param dir Can be QGrid::Horizontal or QGrid::Vertical.
329 * @param item String used in the list or Tab item. 335 * @param item String used in the list or Tab item.
330 * @param header A longer string used in TreeList and IconList mode to 336 * @param header A longer string used in TreeList and IconList mode to
331 * describe the contents of a page. If empty, the item string 337 * describe the contents of a page. If empty, the item string
332 * will be used instead. 338 * will be used instead.
333 * @param pixmap Used in IconList mode or in TreeList mode. You should 339 * @param pixmap Used in IconList mode or in TreeList mode. You should
334 * prefer a pixmap with size 32x32 pixels. 340 * prefer a pixmap with size 32x32 pixels.
335 * 341 *
336 * @return The empty page or 0 if the face is not TreeList, IconList or 342 * @return The empty page or 0 if the face is not TreeList, IconList or
337 * Tabbed. 343 * Tabbed.
338 */ 344 */
339//US changed Orientation into Direction for compatibility 345//US changed Orientation into Direction for compatibility
340 virtual QGrid *addGridPage( int n, QGrid::Direction dir, 346 virtual Q3Grid *addGridPage( int n, Qt::Orientation dir,
341 const QString &itemName, 347 const QString &itemName,
342 const QString &header=QString::null, 348 const QString &header=QString::null,
343 const QPixmap &pixmap=QPixmap() ); 349 const QPixmap &pixmap=QPixmap() );
344 350
345 /** 351 /**
346 * This is like addGridPage just above, with the difference that the first 352 * This is like addGridPage just above, with the difference that the first
347 * element is a list of strings. These strings are used to form a path 353 * element is a list of strings. These strings are used to form a path
348 * of folders down to the given page. The initial elements are names 354 * of folders down to the given page. The initial elements are names
349 * for the folders, while the last element is the name of the page. 355 * for the folders, while the last element is the name of the page.
350 * Note: This does yet only work for the TreeList face. Later this may 356 * Note: This does yet only work for the TreeList face. Later this may
351 * be added for the IconList face too. In other faces than the 357 * be added for the IconList face too. In other faces than the
352 * TreeList, all the strings except the last one is ignored. 358 * TreeList, all the strings except the last one is ignored.
353 * 359 *
354 * Deleting the returned frame will cause the listitem or tab to be 360 * Deleting the returned frame will cause the listitem or tab to be
355 * removed (you can re-add a page with the same name later. 361 * removed (you can re-add a page with the same name later.
356 **/ 362 **/
357//US changed Orientation into Direction for compatibility 363//US changed Orientation into Direction for compatibility
358 virtual QGrid *addGridPage( int n, QGrid::Direction dir, 364 virtual Q3Grid *addGridPage( int n, Qt::Orientation dir,
359 const QStringList &items, 365 const QStringList &items,
360 const QString &header=QString::null, 366 const QString &header=QString::null,
361 const QPixmap &pixmap=QPixmap() ); 367 const QPixmap &pixmap=QPixmap() );
362 368
363 /** 369 /**
364 * @short Removes a page created with @ref addPage, @ref addVBoxPage, 370 * @short Removes a page created with @ref addPage, @ref addVBoxPage,
365 * @ref addHBoxPage or @ref addGridPage. If the page has already 371 * @ref addHBoxPage or @ref addGridPage. If the page has already
366 * been deleted or has already been removed, nothing happens. The widget 372 * been deleted or has already been removed, nothing happens. The widget
367 * itself is not deleted. 373 * itself is not deleted.
368 * 374 *
369 * @param page The widget returned by @ref addPage , @ref addVBoxPage , 375 * @param page The widget returned by @ref addPage , @ref addVBoxPage ,
370 * @ref addHBoxPage or @ref addGridPage . 376 * @ref addHBoxPage or @ref addGridPage .
371 */ 377 */
372 void removePage( QWidget *page ); 378 void removePage( QWidget *page );
373 379
374 380
375 /** 381 /**
376 * Returns the index of a page created with @ref addPage , 382 * Returns the index of a page created with @ref addPage ,
377 * @ref addVBoxPage , @ref addHBoxPage or @ref addGridPage . 383 * @ref addVBoxPage , @ref addHBoxPage or @ref addGridPage .
378 * You can can compare this index with the value returned from 384 * You can can compare this index with the value returned from
379 * @ref activePageIndex if you need to do some page specific actions 385 * @ref activePageIndex if you need to do some page specific actions
380 * in your code. 386 * in your code.
381 * 387 *
382 * The returned index will never change so you can safely use this 388 * The returned index will never change so you can safely use this
383 * function once and save the value. 389 * function once and save the value.
384 * 390 *
385 * @param widget The widget returned by @ref addPage , @ref addVBoxPage , 391 * @param widget The widget returned by @ref addPage , @ref addVBoxPage ,
386 * @ref addHBoxPage or @ref addGridPage . 392 * @ref addHBoxPage or @ref addGridPage .
387 * 393 *
388 * @return The index or -1 if the face is not Tabbed, TreeList or 394 * @return The index or -1 if the face is not Tabbed, TreeList or
389 * IconList 395 * IconList
390 */ 396 */
391 virtual int pageIndex( QWidget *widget ) const; 397 virtual int pageIndex( QWidget *widget ) const;
392 398
393 /** 399 /**
394 * Defines the widget to be swallowed. 400 * Defines the widget to be swallowed.
395 * 401 *
396 * This method can be used several 402 * This method can be used several
397 * times. Only the latest defined widget will be shown. 403 * times. Only the latest defined widget will be shown.
398 * 404 *
399 * @param widget The widget to be swallowed. If 0, then an empty rectangle 405 * @param widget The widget to be swallowed. If 0, then an empty rectangle
400 * is displayed. 406 * is displayed.
401 */ 407 */
402 virtual bool setSwallowedWidget( QWidget *widget ); 408 virtual bool setSwallowedWidget( QWidget *widget );
403 409
404 /** 410 /**
405 * This function has only effect in TreeList mode. 411 * This function has only effect in TreeList mode.
406 * 412 *
407 * Defines how the tree list is resized when the widget is resized 413 * Defines how the tree list is resized when the widget is resized
408 * horizontally. By default the tree list keeps its width when the 414 * horizontally. By default the tree list keeps its width when the
409 * widget becomes wider. 415 * widget becomes wider.
410 * 416 *
411 * @param state The resize mode. If false (default) the TreeList keeps 417 * @param state The resize mode. If false (default) the TreeList keeps
412 * its current width when the widget becomes wider. 418 * its current width when the widget becomes wider.
413 */ 419 */
414 virtual void setTreeListAutoResize( bool state ); 420 virtual void setTreeListAutoResize( bool state );
415 421
416 /** 422 /**
417 * This function has only effect in TreeList mode. 423 * This function has only effect in TreeList mode.
418 * 424 *
419 * This tells the widgets whether the icons given in the @ref addPage, 425 * This tells the widgets whether the icons given in the @ref addPage,
420 * @ref addVBoxPage, @ref addHBoxPage, or @ref addGridPage methods should 426 * @ref addVBoxPage, @ref addHBoxPage, or @ref addGridPage methods should
421 * be shown in the TreeList. 427 * be shown in the TreeList.
422 * 428 *
423 * Note: This method must be called before calling any of the methods 429 * Note: This method must be called before calling any of the methods
424 * which add icons to the page. 430 * which add icons to the page.
425 * 431 *
426 * @param state If true the icons are shown. 432 * @param state If true the icons are shown.
427 **/ 433 **/
428 virtual void setShowIconsInTreeList(bool state); 434 virtual void setShowIconsInTreeList(bool state);
429 435
430 /** 436 /**
431 * This function has only effect in TreeList mode. 437 * This function has only effect in TreeList mode.
432 * 438 *
433 * This tells the widgets whether the root should be decorated. 439 * This tells the widgets whether the root should be decorated.
434 * For details see @ref QListView::setRootIsDecorated 440 * For details see @ref QListView::setRootIsDecorated
435 * 441 *
436 * @param state Root will be decorated if true. 442 * @param state Root will be decorated if true.
437 **/ 443 **/
438 virtual void setRootIsDecorated( bool state ); 444 virtual void setRootIsDecorated( bool state );
439 445
440 /** 446 /**
441 * This function has only effect in TreeList mode. 447 * This function has only effect in TreeList mode.
442 * 448 *
443 * This tells the TreeList to unfold the whole tree so that all entries 449 * This tells the TreeList to unfold the whole tree so that all entries
444 * are visible. 450 * are visible.
445 * 451 *
446 * If the list is empty when you call this method newly created entries 452 * If the list is empty when you call this method newly created entries
447 * will not automatically be opened. If the @p persist flag is set opened 453 * will not automatically be opened. If the @p persist flag is set opened
448 * entries cannot be closed again, though. 454 * entries cannot be closed again, though.
449 * 455 *
450 * @param persist If true the tree always stays unfolded. 456 * @param persist If true the tree always stays unfolded.
451 * @since 3.2 457 * @since 3.2
452 */ 458 */
453 /*virtual*/ void unfoldTreeList( bool persist = false ); //### KDE4 BIC add virtual 459 /*virtual*/ void unfoldTreeList( bool persist = false ); //### KDE4 BIC add virtual
454 460
455 /** 461 /**
456 * This function has only effect in IconList mode. 462 * This function has only effect in IconList mode.
457 * 463 *
458 * Defines how the icon list widget is displayed. By default it is 464 * Defines how the icon list widget is displayed. By default it is
459 * the widgets in the pages that decide the minimum height 465 * the widgets in the pages that decide the minimum height
460 * of the toplevel widget. A vertical scrollbar can be used in 466 * of the toplevel widget. A vertical scrollbar can be used in
461 * the icon list area. 467 * the icon list area.
462 * 468 *
463 * @param state The visibility mode. If true, the minimum height is 469 * @param state The visibility mode. If true, the minimum height is
464 * adjusted so that every icon in the list is visible at the 470 * adjusted so that every icon in the list is visible at the
465 * same time. The vertical scrollbar will never be visible. 471 * same time. The vertical scrollbar will never be visible.
466 */ 472 */
467 virtual void setIconListAllVisible( bool state ); 473 virtual void setIconListAllVisible( bool state );
468 474
469 /** 475 /**
470 * Sets the icon used in TreeList Mode for the given path. 476 * Sets the icon used in TreeList Mode for the given path.
471 * @param path The path for which this icon should be shown. 477 * @param path The path for which this icon should be shown.
472 * @param pixmap The icon used. 478 * @param pixmap The icon used.
473 **/ 479 **/
474 virtual void setFolderIcon(const QStringList &path, const QPixmap &pixmap); 480 virtual void setFolderIcon(const QStringList &path, const QPixmap &pixmap);
475 /** 481 /**
476 * Returns the title string associated with a page index in TreeList or IconList mode. 482 * Returns the title string associated with a page index in TreeList or IconList mode.
477 * @param index The index of the page or null if there is no such page. 483 * @param index The index of the page or null if there is no such page.
478 * @see @ref #pageIndex() 484 * @see @ref #pageIndex()
479 * @since 3.2 485 * @since 3.2
480 */ 486 */
481 /*virtual*/ QString pageTitle(int index) const; 487 /*virtual*/ QString pageTitle(int index) const;
482 /** 488 /**
483 * Returns the page widget associated with a page index or null if there is 489 * Returns the page widget associated with a page index or null if there is
484 * no such page. 490 * no such page.
485 * @param index The index of the page. 491 * @param index The index of the page.
486 * @see @ref #pageIndex() 492 * @see @ref #pageIndex()
487 * @since 3.2 493 * @since 3.2
488 */ 494 */
489 /*virtual*/ QWidget *pageWidget(int index) const; 495 /*virtual*/ QWidget *pageWidget(int index) const;
490 496
491 signals: 497 signals:
492 void aboutToShowPage(QWidget *page); 498 void aboutToShowPage(QWidget *page);
493 499
494 public slots: 500 public slots:
495 /** 501 /**
496 * Give the keyboard input focus to the widget. 502 * Give the keyboard input focus to the widget.
497 */ 503 */
498 virtual void setFocus(); 504 virtual void setFocus();
499 505
500 protected: 506 protected:
501 /** 507 /**
502 * Reimplemented to handle the splitter width when the the face 508 * Reimplemented to handle the splitter width when the the face
503 * is TreeList 509 * is TreeList
504 */ 510 */
505 virtual void showEvent( QShowEvent * ); 511 virtual void showEvent( QShowEvent * );
506 512
507 /** 513 /**
508 * This function is used internally when in IconList mode. If you 514 * This function is used internally when in IconList mode. If you
509 * reimplement this class a make your own event filter, make sure to 515 * reimplement this class a make your own event filter, make sure to
510 * call this function from your filter. 516 * call this function from your filter.
511 * 517 *
512 * @param o Object that has received an event. 518 * @param o Object that has received an event.
513 * @param e The event. 519 * @param e The event.
514 */ 520 */
515 virtual bool eventFilter( QObject *o, QEvent *e ); 521 virtual bool eventFilter( QObject *o, QEvent *e );
516 522
517 private slots: 523 private slots:
518 bool slotShowPage(); 524 bool slotShowPage();
519//US not yet implemented void slotFontChanged(); 525//US not yet implemented void slotFontChanged();
520 void slotItemClicked(QListViewItem *it); 526 void slotItemClicked(Q3ListViewItem *it);
521 void pageGone( QObject *obj); // signal from the added page's "destroyed" signal 527 void pageGone( QObject *obj); // signal from the added page's "destroyed" signal
522 void slotReopen(QListViewItem *item); 528 void slotReopen(Q3ListViewItem *item);
523 529
524 protected: 530 protected:
525 bool showPage( QWidget *w ); 531 bool showPage( QWidget *w );
526 void addPageWidget( QFrame *page, const QStringList &items, 532 void addPageWidget( Q3Frame *page, const QStringList &items,
527 const QString &header, const QPixmap &pixmap ); 533 const QString &header, const QPixmap &pixmap );
528 void InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, QFrame *page); 534 void InsertTreeListItem(const QStringList &items, const QPixmap &pixmap, Q3Frame *page);
529 QWidget *FindParent(); 535 QWidget *FindParent();
530 536
531 private: 537 private:
532 bool mValid; 538 bool mValid;
533 539
534 // Obsolete members. Remove in KDE 4. 540 // Obsolete members. Remove in KDE 4.
535 QPtrList<QWidget> *mPageList; 541 Q3PtrList<QWidget> *mPageList;
536 QStringList *mTitleList; 542 QStringList *mTitleList;
537 543
538 int mFace; 544 int mFace;
539 KListView *mTreeList; 545 KListView *mTreeList;
540 IconListBox *mIconList; 546 IconListBox *mIconList;
541 QWidgetStack *mPageStack; 547 Q3WidgetStack *mPageStack;
542 QLabel *mTitleLabel; 548 QLabel *mTitleLabel;
543 QTabWidget *mTabControl; 549 QTabWidget *mTabControl;
544 QFrame *mPlainPage; 550 Q3Frame *mPlainPage;
545 QWidget *mSwallowPage; 551 QWidget *mSwallowPage;
546 QWidget *mActivePageWidget; 552 QWidget *mActivePageWidget;
547 KSeparator *mTitleSep; 553 KSeparator *mTitleSep;
548//US QSplitter::ResizeMode mTreeListResizeMode; 554//US QSplitter::ResizeMode mTreeListResizeMode;
549 bool mShowIconsInTreeList; 555 bool mShowIconsInTreeList;
550 QMap<QListViewItem *, QWidget *> mTreeListToPageStack; 556 QMap<Q3ListViewItem *, QWidget *> mTreeListToPageStack;
551 QMap<QListBoxItem *, QWidget *> mIconListToPageStack; 557 QMap<Q3ListBoxItem *, QWidget *> mIconListToPageStack;
552 QMap<QString, QPixmap> mFolderIconMap; 558 QMap<QString, QPixmap> mFolderIconMap;
553 QMap<QString, QStringList> mChildrenNames; 559 QMap<QString, QStringList> mChildrenNames;
554 QMap<QString, QWidget *> mChildPages; 560 QMap<QString, QWidget *> mChildPages;
555 561
556 public: 562 public:
557 class IconListItem; 563 class IconListItem;
558 protected: 564 protected:
559 virtual void virtual_hook( int id, void* data ); 565 virtual void virtual_hook( int id, void* data );
560 private: 566 private:
561 class KJanusWidgetPrivate; 567 class KJanusWidgetPrivate;
562 KJanusWidgetPrivate *d; 568 KJanusWidgetPrivate *d;
563}; 569};
564 570
565#endif 571#endif
diff --git a/microkde/kdeui/klistbox.cpp b/microkde/kdeui/klistbox.cpp
index c65b892..71020b3 100644
--- a/microkde/kdeui/klistbox.cpp
+++ b/microkde/kdeui/klistbox.cpp
@@ -1,314 +1,320 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18#include <qtimer.h> 18#include <qtimer.h>
19//Added by qt3to4:
20#include <QEvent>
21#include <QMouseEvent>
22#include <QKeyEvent>
23#include <QFocusEvent>
19 24
20#include <kglobalsettings.h> 25#include <kglobalsettings.h>
21//US#include <kcursor.h> 26//US#include <kcursor.h>
22#include <kapplication.h> 27#include <kapplication.h>
23//US#include <kipc.h> 28//US#include <kipc.h>
24#include <kdebug.h> 29#include <kdebug.h>
25 30
26#include "klistbox.h" 31#include "klistbox.h"
27 32
28#ifdef Q_WS_X11 33#ifdef Q_WS_X11
34#include <QX11Info>
29#include <X11/Xlib.h> 35#include <X11/Xlib.h>
30#endif 36#endif
31#ifdef _WIN32_ 37#ifdef _WIN32_
32#define Q_WS_QWS 38#define Q_WS_QWS
33#endif 39#endif
34KListBox::KListBox( QWidget *parent, const char *name, WFlags f ) 40KListBox::KListBox( QWidget *parent, const char *name, Qt::WFlags f )
35 : QListBox( parent, name, f ) 41 : Q3ListBox( parent, name, f )
36{ 42{
37 connect( this, SIGNAL( onViewport() ), 43 connect( this, SIGNAL( onViewport() ),
38 this, SLOT( slotOnViewport() ) ); 44 this, SLOT( slotOnViewport() ) );
39 connect( this, SIGNAL( onItem( QListBoxItem * ) ), 45 connect( this, SIGNAL( onItem( Q3ListBoxItem * ) ),
40 this, SLOT( slotOnItem( QListBoxItem * ) ) ); 46 this, SLOT( slotOnItem( Q3ListBoxItem * ) ) );
41 47
42 connect( this, SIGNAL( mouseButtonClicked( int, QListBoxItem *, 48 connect( this, SIGNAL( mouseButtonClicked( int, Q3ListBoxItem *,
43 const QPoint & ) ), 49 const QPoint & ) ),
44 this, SLOT( slotMouseButtonClicked( int, QListBoxItem *, 50 this, SLOT( slotMouseButtonClicked( int, Q3ListBoxItem *,
45 const QPoint & ) ) ); 51 const QPoint & ) ) );
46/*US 52/*US
47 53
48 slotSettingsChanged(KApplication::SETTINGS_MOUSE); 54 slotSettingsChanged(KApplication::SETTINGS_MOUSE);
49 if (kapp) 55 if (kapp)
50 { 56 {
51 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); 57 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) );
52 kapp->addKipcEventMask( KIPC::SettingsChanged ); 58 kapp->addKipcEventMask( KIPC::SettingsChanged );
53 } 59 }
54*/ 60*/
55 m_pCurrentItem = 0L; 61 m_pCurrentItem = 0L;
56//US set single to true 62//US set single to true
57 m_bUseSingle = true; 63 m_bUseSingle = true;
58 m_pAutoSelect = new QTimer( this ); 64 m_pAutoSelect = new QTimer( this );
59 connect( m_pAutoSelect, SIGNAL( timeout() ), 65 connect( m_pAutoSelect, SIGNAL( timeout() ),
60 this, SLOT( slotAutoSelect() ) ); 66 this, SLOT( slotAutoSelect() ) );
61} 67}
62 68
63void KListBox::slotOnItem( QListBoxItem *item ) 69void KListBox::slotOnItem( Q3ListBoxItem *item )
64{ 70{
65/*US 71/*US
66 if ( item && m_bChangeCursorOverItem && m_bUseSingle ) 72 if ( item && m_bChangeCursorOverItem && m_bUseSingle )
67 viewport()->setCursor( KCursor().handCursor() ); 73 viewport()->setCursor( KCursor().handCursor() );
68*/ 74*/
69 if ( item && (m_autoSelectDelay > -1) && m_bUseSingle ) { 75 if ( item && (m_autoSelectDelay > -1) && m_bUseSingle ) {
70 m_pAutoSelect->start( m_autoSelectDelay, true ); 76 m_pAutoSelect->start( m_autoSelectDelay, true );
71 m_pCurrentItem = item; 77 m_pCurrentItem = item;
72 } 78 }
73} 79}
74 80
75void KListBox::slotOnViewport() 81void KListBox::slotOnViewport()
76{ 82{
77/*US 83/*US
78 if ( m_bChangeCursorOverItem ) 84 if ( m_bChangeCursorOverItem )
79 viewport()->unsetCursor(); 85 viewport()->unsetCursor();
80*/ 86*/
81 m_pAutoSelect->stop(); 87 m_pAutoSelect->stop();
82 m_pCurrentItem = 0L; 88 m_pCurrentItem = 0L;
83} 89}
84 90
85 91
86/*US 92/*US
87void KListBox::slotSettingsChanged(int category) 93void KListBox::slotSettingsChanged(int category)
88{ 94{
89 if (category != KApplication::SETTINGS_MOUSE) 95 if (category != KApplication::SETTINGS_MOUSE)
90 return; 96 return;
91 97
92 m_bUseSingle = KGlobalSettings::singleClick(); 98 m_bUseSingle = KGlobalSettings::singleClick();
93 m_bUseSingle = true; 99 m_bUseSingle = true;
94 100
95 disconnect( this, SIGNAL( mouseButtonClicked( int, QListBoxItem *, 101 disconnect( this, SIGNAL( mouseButtonClicked( int, QListBoxItem *,
96 const QPoint & ) ), 102 const QPoint & ) ),
97 this, SLOT( slotMouseButtonClicked( int, QListBoxItem *, 103 this, SLOT( slotMouseButtonClicked( int, QListBoxItem *,
98 const QPoint & ) ) ); 104 const QPoint & ) ) );
99// disconnect( this, SIGNAL( doubleClicked( QListBoxItem *, 105// disconnect( this, SIGNAL( doubleClicked( QListBoxItem *,
100 // const QPoint & ) ), 106 // const QPoint & ) ),
101 // this, SLOT( slotExecute( QListBoxItem *, 107 // this, SLOT( slotExecute( QListBoxItem *,
102 // const QPoint & ) ) ); 108 // const QPoint & ) ) );
103 109
104 if( m_bUseSingle ) 110 if( m_bUseSingle )
105 { 111 {
106 connect( this, SIGNAL( mouseButtonClicked( int, QListBoxItem *, 112 connect( this, SIGNAL( mouseButtonClicked( int, QListBoxItem *,
107 const QPoint & ) ), 113 const QPoint & ) ),
108 this, SLOT( slotMouseButtonClicked( int, QListBoxItem *, 114 this, SLOT( slotMouseButtonClicked( int, QListBoxItem *,
109 const QPoint & ) ) ); 115 const QPoint & ) ) );
110 } 116 }
111 else 117 else
112 { 118 {
113// connect( this, SIGNAL( doubleClicked( QListBoxItem *, 119// connect( this, SIGNAL( doubleClicked( QListBoxItem *,
114 // const QPoint & ) ), 120 // const QPoint & ) ),
115// this, SLOT( slotExecute( QListBoxItem *, 121// this, SLOT( slotExecute( QListBoxItem *,
116 // const QPoint & ) ) ); 122 // const QPoint & ) ) );
117 } 123 }
118 124
119 m_bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); 125 m_bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon();
120 m_autoSelectDelay = KGlobalSettings::autoSelectDelay(); 126 m_autoSelectDelay = KGlobalSettings::autoSelectDelay();
121 127
122 if( !m_bUseSingle || !m_bChangeCursorOverItem ) 128 if( !m_bUseSingle || !m_bChangeCursorOverItem )
123 viewport()->unsetCursor(); 129 viewport()->unsetCursor();
124 130
125} 131}
126*/ 132*/
127void KListBox::slotAutoSelect() 133void KListBox::slotAutoSelect()
128{ 134{
129 // check that the item still exists 135 // check that the item still exists
130 if( index( m_pCurrentItem ) == -1 ) 136 if( index( m_pCurrentItem ) == -1 )
131 return; 137 return;
132 138
133 //Give this widget the keyboard focus. 139 //Give this widget the keyboard focus.
134 if( !hasFocus() ) 140 if( !hasFocus() )
135 setFocus(); 141 setFocus();
136 142
137#ifdef Q_WS_X11 //FIXME 143#ifdef Q_WS_X11 //FIXME
138 Window root; 144 Window root;
139 Window child; 145 Window child;
140 int root_x, root_y, win_x, win_y; 146 int root_x, root_y, win_x, win_y;
141 uint keybstate; 147 uint keybstate;
142 XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, 148 XQueryPointer( x11Info().display(), x11Info().appRootWindow(), &root, &child,
143 &root_x, &root_y, &win_x, &win_y, &keybstate ); 149 &root_x, &root_y, &win_x, &win_y, &keybstate );
144#endif 150#endif
145 151
146 QListBoxItem* previousItem = item( currentItem() ); 152 Q3ListBoxItem* previousItem = item( currentItem() );
147 setCurrentItem( m_pCurrentItem ); 153 setCurrentItem( m_pCurrentItem );
148 154
149 if( m_pCurrentItem ) { 155 if( m_pCurrentItem ) {
150#ifndef Q_WS_QWS //FIXME 156#ifndef Q_WS_QWS //FIXME
151 //Shift pressed? 157 //Shift pressed?
152 if( (keybstate & ShiftMask) ) { 158 if( (keybstate & ShiftMask) ) {
153#endif 159#endif
154 bool block = signalsBlocked(); 160 bool block = signalsBlocked();
155 blockSignals( true ); 161 blockSignals( true );
156 162
157#ifndef Q_WS_QWS //FIXME 163#ifndef Q_WS_QWS //FIXME
158 //No Ctrl? Then clear before! 164 //No Ctrl? Then clear before!
159 if( !(keybstate & ControlMask) ) 165 if( !(keybstate & ControlMask) )
160 clearSelection(); 166 clearSelection();
161#endif 167#endif
162 168
163//US in my QT version it is called isSelected() So what is right? 169//US in my QT version it is called isSelected() So what is right?
164//US bool select = !m_pCurrentItem->isSelected(); 170//US bool select = !m_pCurrentItem->isSelected();
165 bool select = !m_pCurrentItem->selected(); 171 bool select = !m_pCurrentItem->selected();
166 bool update = viewport()->isUpdatesEnabled(); 172 bool update = viewport()->isUpdatesEnabled();
167 viewport()->setUpdatesEnabled( false ); 173 viewport()->setUpdatesEnabled( false );
168 174
169 bool down = index( previousItem ) < index( m_pCurrentItem ); 175 bool down = index( previousItem ) < index( m_pCurrentItem );
170 QListBoxItem* it = down ? previousItem : m_pCurrentItem; 176 Q3ListBoxItem* it = down ? previousItem : m_pCurrentItem;
171 for (;it ; it = it->next() ) { 177 for (;it ; it = it->next() ) {
172 if ( down && it == m_pCurrentItem ) { 178 if ( down && it == m_pCurrentItem ) {
173 setSelected( m_pCurrentItem, select ); 179 setSelected( m_pCurrentItem, select );
174 break; 180 break;
175 } 181 }
176 if ( !down && it == previousItem ) { 182 if ( !down && it == previousItem ) {
177 setSelected( previousItem, select ); 183 setSelected( previousItem, select );
178 break; 184 break;
179 } 185 }
180 setSelected( it, select ); 186 setSelected( it, select );
181 } 187 }
182 188
183 blockSignals( block ); 189 blockSignals( block );
184 viewport()->setUpdatesEnabled( update ); 190 viewport()->setUpdatesEnabled( update );
185 triggerUpdate( false ); 191 triggerUpdate( false );
186 192
187 emit selectionChanged(); 193 emit selectionChanged();
188 194
189 if( selectionMode() == QListBox::Single ) 195 if( selectionMode() == Q3ListBox::Single )
190 emit selectionChanged( m_pCurrentItem ); 196 emit selectionChanged( m_pCurrentItem );
191 } 197 }
192#ifndef Q_WS_QWS //FIXME 198#ifndef Q_WS_QWS //FIXME
193 else if( (keybstate & ControlMask) ) 199 else if( (keybstate & ControlMask) )
194 setSelected( m_pCurrentItem, !m_pCurrentItem->isSelected() ); 200 setSelected( m_pCurrentItem, !m_pCurrentItem->isSelected() );
195#endif 201#endif
196 else { 202 else {
197 bool block = signalsBlocked(); 203 bool block = signalsBlocked();
198 blockSignals( true ); 204 blockSignals( true );
199 205
200//US in my QT version it is called isSelected() So what is right? 206//US in my QT version it is called isSelected() So what is right?
201//US if( !m_pCurrentItem->isSelected() ) 207//US if( !m_pCurrentItem->isSelected() )
202 if( !m_pCurrentItem->selected() ) 208 if( !m_pCurrentItem->selected() )
203 clearSelection(); 209 clearSelection();
204 210
205 blockSignals( block ); 211 blockSignals( block );
206 212
207 setSelected( m_pCurrentItem, true ); 213 setSelected( m_pCurrentItem, true );
208 } 214 }
209#ifndef Q_WS_QWS //FIXME 215#ifndef Q_WS_QWS //FIXME
210 } 216 }
211 else 217 else
212 kdDebug() << "Thats not supposed to happen!!!!" << endl; 218 kdDebug() << "Thats not supposed to happen!!!!" << endl;
213#endif 219#endif
214} 220}
215 221
216void KListBox::emitExecute( QListBoxItem *item, const QPoint &pos ) 222void KListBox::emitExecute( Q3ListBoxItem *item, const QPoint &pos )
217{ 223{
218#ifdef Q_WS_X11 //FIXME 224#ifdef Q_WS_X11 //FIXME
219 Window root; 225 Window root;
220 Window child; 226 Window child;
221 int root_x, root_y, win_x, win_y; 227 int root_x, root_y, win_x, win_y;
222 uint keybstate; 228 uint keybstate;
223 XQueryPointer( qt_xdisplay(), qt_xrootwin(), &root, &child, 229 XQueryPointer( x11Info().display(), x11Info().appRootWindow(), &root, &child,
224 &root_x, &root_y, &win_x, &win_y, &keybstate ); 230 &root_x, &root_y, &win_x, &win_y, &keybstate );
225#endif 231#endif
226 232
227 m_pAutoSelect->stop(); 233 m_pAutoSelect->stop();
228 234
229#ifndef Q_WS_QWS //FIXME 235#ifndef Q_WS_QWS //FIXME
230 //Dont emit executed if in SC mode and Shift or Ctrl are pressed 236 //Dont emit executed if in SC mode and Shift or Ctrl are pressed
231 if( !( m_bUseSingle && ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { 237 if( !( m_bUseSingle && ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) {
232#endif 238#endif
233 emit executed( item ); 239 emit executed( item );
234 emit executed( item, pos ); 240 emit executed( item, pos );
235#ifndef Q_WS_QWS //FIXME 241#ifndef Q_WS_QWS //FIXME
236 } 242 }
237#endif 243#endif
238} 244}
239 245
240// 246//
241// 2000-16-01 Espen Sand 247// 2000-16-01 Espen Sand
242// This widget is used in dialogs. It should ignore 248// This widget is used in dialogs. It should ignore
243// F1 (and combinations) and Escape since these are used 249// F1 (and combinations) and Escape since these are used
244// to start help or close the dialog. This functionality 250// to start help or close the dialog. This functionality
245// should be done in QListView but it is not (at least now) 251// should be done in QListView but it is not (at least now)
246// 252//
247void KListBox::keyPressEvent(QKeyEvent *e) 253void KListBox::keyPressEvent(QKeyEvent *e)
248{ 254{
249 if( e->key() == Key_Escape ) 255 if( e->key() == Qt::Key_Escape )
250 { 256 {
251 e->ignore(); 257 e->ignore();
252 } 258 }
253 else if( e->key() == Key_F1 ) 259 else if( e->key() == Qt::Key_F1 )
254 { 260 {
255 e->ignore(); 261 e->ignore();
256 } 262 }
257 else 263 else
258 { 264 {
259 QListBox::keyPressEvent(e); 265 Q3ListBox::keyPressEvent(e);
260 } 266 }
261} 267}
262 268
263void KListBox::focusOutEvent( QFocusEvent *fe ) 269void KListBox::focusOutEvent( QFocusEvent *fe )
264{ 270{
265 m_pAutoSelect->stop(); 271 m_pAutoSelect->stop();
266 272
267 QListBox::focusOutEvent( fe ); 273 Q3ListBox::focusOutEvent( fe );
268} 274}
269 275
270void KListBox::leaveEvent( QEvent *e ) 276void KListBox::leaveEvent( QEvent *e )
271{ 277{
272 m_pAutoSelect->stop(); 278 m_pAutoSelect->stop();
273 279
274 QListBox::leaveEvent( e ); 280 Q3ListBox::leaveEvent( e );
275} 281}
276 282
277void KListBox::contentsMousePressEvent( QMouseEvent *e ) 283void KListBox::contentsMousePressEvent( QMouseEvent *e )
278{ 284{
279 if( (selectionMode() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) { 285 if( (selectionMode() == Extended) && (e->state() & Qt::ShiftButton) && !(e->state() & Qt::ControlButton) ) {
280 bool block = signalsBlocked(); 286 bool block = signalsBlocked();
281 blockSignals( true ); 287 blockSignals( true );
282 288
283 clearSelection(); 289 clearSelection();
284 290
285 blockSignals( block ); 291 blockSignals( block );
286 } 292 }
287 293
288 QListBox::contentsMousePressEvent( e ); 294 Q3ListBox::contentsMousePressEvent( e );
289} 295}
290 296
291void KListBox::contentsMouseDoubleClickEvent ( QMouseEvent * e ) 297void KListBox::contentsMouseDoubleClickEvent ( QMouseEvent * e )
292{ 298{
293 QListBox::contentsMouseDoubleClickEvent( e ); 299 Q3ListBox::contentsMouseDoubleClickEvent( e );
294 300
295 QListBoxItem* item = itemAt( e->pos() ); 301 Q3ListBoxItem* item = itemAt( e->pos() );
296 302
297 if( item ) { 303 if( item ) {
298 emit doubleClicked( item, e->globalPos() ); 304 emit doubleClicked( item, e->globalPos() );
299 305
300 if( (e->button() == LeftButton) && !m_bUseSingle ) 306 if( (e->button() == Qt::LeftButton) && !m_bUseSingle )
301 emitExecute( item, e->globalPos() ); 307 emitExecute( item, e->globalPos() );
302 } 308 }
303} 309}
304 310
305void KListBox::slotMouseButtonClicked( int btn, QListBoxItem *item, const QPoint &pos ) 311void KListBox::slotMouseButtonClicked( int btn, Q3ListBoxItem *item, const QPoint &pos )
306{ 312{
307 if( (btn == LeftButton) && item ) 313 if( (btn == Qt::LeftButton) && item )
308 emitExecute( item, pos ); 314 emitExecute( item, pos );
309} 315}
310 316
311void KListBox::virtual_hook( int, void* ) 317void KListBox::virtual_hook( int, void* )
312{ /*BASE::virtual_hook( id, data );*/ } 318{ /*BASE::virtual_hook( id, data );*/ }
313 319
314//US #include "klistbox.moc" 320//US #include "klistbox.moc"
diff --git a/microkde/kdeui/klistbox.h b/microkde/kdeui/klistbox.h
index 8023780..5ec514b 100644
--- a/microkde/kdeui/klistbox.h
+++ b/microkde/kdeui/klistbox.h
@@ -1,141 +1,146 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18#ifndef KLISTBOX_H 18#ifndef KLISTBOX_H
19#define KLISTBOX_H 19#define KLISTBOX_H
20 20
21#include <qlistbox.h> 21#include <q3listbox.h>
22//Added by qt3to4:
23#include <QMouseEvent>
24#include <QFocusEvent>
25#include <QKeyEvent>
26#include <QEvent>
22 27
23/** 28/**
24 * Extends the functionality of @ref QListBox to honor the system 29 * Extends the functionality of @ref QListBox to honor the system
25 * wide settings for Single Click/Double Click mode, Auto Selection and 30 * wide settings for Single Click/Double Click mode, Auto Selection and
26 * Change Cursor over Link. 31 * Change Cursor over Link.
27 * 32 *
28 * There is a new signal @ref executed(). It gets connected to either 33 * There is a new signal @ref executed(). It gets connected to either
29 * @ref QListBox::clicked() or @ref QListBox::doubleClicked() 34 * @ref QListBox::clicked() or @ref QListBox::doubleClicked()
30 * depending on the KDE wide Single Click/Double Click settings. It is 35 * depending on the KDE wide Single Click/Double Click settings. It is
31 * strongly recomended that you use this signal instead of the above 36 * strongly recomended that you use this signal instead of the above
32 * mentioned. This way you don't need to care about the current 37 * mentioned. This way you don't need to care about the current
33 * settings. If you want to get informed when the user selects 38 * settings. If you want to get informed when the user selects
34 * something connect to the @ref QListBox::selectionChanged() signal. 39 * something connect to the @ref QListBox::selectionChanged() signal.
35 * 40 *
36 * @short A variant of @ref QListBox that honors KDE's system-wide settings. 41 * @short A variant of @ref QListBox that honors KDE's system-wide settings.
37 **/ 42 **/
38class KListBox : public QListBox 43class KListBox : public Q3ListBox
39{ 44{
40 Q_OBJECT 45 Q_OBJECT
41 46
42public: 47public:
43 KListBox( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); 48 KListBox( QWidget *parent = 0, const char *name = 0, Qt::WFlags f = 0 );
44 49
45signals: 50signals:
46 51
47 /** 52 /**
48 * Emitted whenever the user executes an listbox item. 53 * Emitted whenever the user executes an listbox item.
49 * 54 *
50 * That means depending on the KDE wide Single Click/Double Click 55 * That means depending on the KDE wide Single Click/Double Click
51 * setting the user clicked or double clicked on that item. 56 * setting the user clicked or double clicked on that item.
52 * @param item is the pointer to the executed listbox item. 57 * @param item is the pointer to the executed listbox item.
53 * 58 *
54 * Note that you may not delete any @ref QListBoxItem objects in slots 59 * Note that you may not delete any @ref QListBoxItem objects in slots
55 * connected to this signal. 60 * connected to this signal.
56 */ 61 */
57 void executed( QListBoxItem *item ); 62 void executed( Q3ListBoxItem *item );
58 63
59 /** 64 /**
60 * Emitted whenever the user executes an listbox item. 65 * Emitted whenever the user executes an listbox item.
61 * 66 *
62 * That means depending on the KDE wide Single Click/Double Click 67 * That means depending on the KDE wide Single Click/Double Click
63 * setting the user clicked or double clicked on that item. 68 * setting the user clicked or double clicked on that item.
64 * @param item is the pointer to the executed listbox item. 69 * @param item is the pointer to the executed listbox item.
65 * @param pos is the position where the user has clicked 70 * @param pos is the position where the user has clicked
66 * 71 *
67 * Note that you may not delete any @ref QListBoxItem objects in slots 72 * Note that you may not delete any @ref QListBoxItem objects in slots
68 * connected to this signal. 73 * connected to this signal.
69 */ 74 */
70 void executed( QListBoxItem *item, const QPoint &pos ); 75 void executed( Q3ListBoxItem *item, const QPoint &pos );
71 76
72 /** 77 /**
73 * This signal gets emitted whenever the user double clicks into the 78 * This signal gets emitted whenever the user double clicks into the
74 * listbox. 79 * listbox.
75 * 80 *
76 * @param item The pointer to the clicked listbox item. 81 * @param item The pointer to the clicked listbox item.
77 * @param pos The position where the user has clicked. 82 * @param pos The position where the user has clicked.
78 * 83 *
79 * Note that you may not delete any @ref QListBoxItem objects in slots 84 * Note that you may not delete any @ref QListBoxItem objects in slots
80 * connected to this signal. 85 * connected to this signal.
81 * 86 *
82 * This signal is more or less here for the sake of completeness. 87 * This signal is more or less here for the sake of completeness.
83 * You should normally not need to use this. In most cases it's better 88 * You should normally not need to use this. In most cases it's better
84 * to use @ref executed() instead. 89 * to use @ref executed() instead.
85 */ 90 */
86 void doubleClicked( QListBoxItem *item, const QPoint &pos ); 91 void doubleClicked( Q3ListBoxItem *item, const QPoint &pos );
87 92
88protected slots: 93protected slots:
89 void slotOnItem( QListBoxItem *item ); 94 void slotOnItem( Q3ListBoxItem *item );
90 void slotOnViewport(); 95 void slotOnViewport();
91 96
92//US void slotSettingsChanged(int); 97//US void slotSettingsChanged(int);
93 98
94 /** 99 /**
95 * Auto selection happend. 100 * Auto selection happend.
96 */ 101 */
97 void slotAutoSelect(); 102 void slotAutoSelect();
98 103
99protected: 104protected:
100 void emitExecute( QListBoxItem *item, const QPoint &pos ); 105 void emitExecute( Q3ListBoxItem *item, const QPoint &pos );
101 106
102 /** 107 /**
103 * @reimplemented 108 * @reimplemented
104 */ 109 */
105 virtual void keyPressEvent(QKeyEvent *e); 110 virtual void keyPressEvent(QKeyEvent *e);
106 /** 111 /**
107 * @reimplemented 112 * @reimplemented
108 */ 113 */
109 virtual void focusOutEvent( QFocusEvent *fe ); 114 virtual void focusOutEvent( QFocusEvent *fe );
110 /** 115 /**
111 * @reimplemented 116 * @reimplemented
112 */ 117 */
113 virtual void leaveEvent( QEvent *e ); 118 virtual void leaveEvent( QEvent *e );
114 /** 119 /**
115 * @reimplemented 120 * @reimplemented
116 */ 121 */
117 virtual void contentsMousePressEvent( QMouseEvent *e ); 122 virtual void contentsMousePressEvent( QMouseEvent *e );
118 /** 123 /**
119 * @reimplemented 124 * @reimplemented
120 */ 125 */
121 virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); 126 virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e );
122 127
123 bool m_bUseSingle; 128 bool m_bUseSingle;
124//US bool m_bChangeCursorOverItem; 129//US bool m_bChangeCursorOverItem;
125 130
126 QListBoxItem* m_pCurrentItem; 131 Q3ListBoxItem* m_pCurrentItem;
127 132
128 QTimer* m_pAutoSelect; 133 QTimer* m_pAutoSelect;
129 int m_autoSelectDelay; 134 int m_autoSelectDelay;
130 135
131private slots: 136private slots:
132 void slotMouseButtonClicked( int btn, QListBoxItem *item, const QPoint &pos ); 137 void slotMouseButtonClicked( int btn, Q3ListBoxItem *item, const QPoint &pos );
133 138
134protected: 139protected:
135 virtual void virtual_hook( int id, void* data ); 140 virtual void virtual_hook( int id, void* data );
136private: 141private:
137 class KListBoxPrivate; 142 class KListBoxPrivate;
138 KListBoxPrivate *d; 143 KListBoxPrivate *d;
139}; 144};
140 145
141#endif 146#endif
diff --git a/microkde/kdeui/klistview.cpp b/microkde/kdeui/klistview.cpp
index 60f3084..0e98160 100644
--- a/microkde/kdeui/klistview.cpp
+++ b/microkde/kdeui/klistview.cpp
@@ -1,2238 +1,2253 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2000 Charles Samuels <charles@kde.org> 3 Copyright (C) 2000 Charles Samuels <charles@kde.org>
4 Copyright (C) 2000 Peter Putzer 4 Copyright (C) 2000 Peter Putzer
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation. 8 License version 2 as published by the Free Software Foundation.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qdragobject.h> 21#include <q3dragobject.h>
22#include <qtimer.h> 22#include <qtimer.h>
23#include <qheader.h> 23#include <q3header.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qtooltip.h> 25#include <qtooltip.h>
26#include <qstyle.h> 26#include <qstyle.h>
27#include <qpainter.h> 27#include <qpainter.h>
28//Added by qt3to4:
29#include <QDragLeaveEvent>
30#include <QKeyEvent>
31#include <Q3ValueList>
32#include <Q3PtrList>
33#include <QPixmap>
34#include <QDragEnterEvent>
35#include <QDragMoveEvent>
36#include <QDropEvent>
37#include <QResizeEvent>
38#include <QFocusEvent>
39#include <QMouseEvent>
40#include <QEvent>
41#include <QPaintEvent>
28 42
29#include <kglobalsettings.h> 43#include <kglobalsettings.h>
30#include <kconfig.h> 44#include <kconfig.h>
31#include <kconfigbase.h> 45#include <kconfigbase.h>
32//US #include <kcursor.h> 46//US #include <kcursor.h>
33#include <kapplication.h> 47#include <kapplication.h>
34//US #include <kipc.h> 48//US #include <kipc.h>
35#include <kdebug.h> 49#include <kdebug.h>
36#ifdef _WIN32_ 50#ifdef _WIN32_
37#define Q_WS_QWS 51#define Q_WS_QWS
38#endif 52#endif
39#ifndef _WIN32_ 53#ifndef _WIN32_
40#define private public 54#define private public
41#include <qlistview.h> 55#include <q3listview.h>
42#undef private 56#undef private
43#endif 57#endif
44#include "klistview.h" 58#include "klistview.h"
45//US #include "klistviewlineedit.h" 59//US #include "klistviewlineedit.h"
46#ifndef DESKTOP_VERSION 60#ifndef DESKTOP_VERSION
47#include <qpe/qpeapplication.h> 61#include <qpe/qpeapplication.h>
48#endif 62#endif
63#include <Q3Action>
49 64
50// /*US 65// /*US
51class KListView::Tooltip : public QToolTip 66class KListView::Tooltip /* TODO:hacker:TODO: : public QToolTip */
52{ 67{
53public: 68public:
54 Tooltip (KListView* parent, QToolTipGroup* group = 0L); 69 Tooltip (KListView* parent, QToolTipGroup* group = 0L);
55 virtual ~Tooltip () {} 70 virtual ~Tooltip () {}
56 71
57protected: 72protected:
58 // */ 73 // */
59 /** 74 /**
60 * Reimplemented from QToolTip for internal reasons. 75 * Reimplemented from QToolTip for internal reasons.
61 */ 76 */
62 // /*US 77 // /*US
63 virtual void maybeTip (const QPoint&); 78 virtual void maybeTip (const QPoint&);
64 79
65private: 80private:
66 KListView* mParent; 81 KListView* mParent;
67}; 82};
68 83
69KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group) 84KListView::Tooltip::Tooltip (KListView* parent, QToolTipGroup* group)
70 : QToolTip (parent, group), 85 : /* XXX:hacker:XXX: QToolTip (parent, group), */
71 mParent (parent) 86 mParent (parent)
72{ 87{
73} 88}
74 89
75void KListView::Tooltip::maybeTip (const QPoint&) 90void KListView::Tooltip::maybeTip (const QPoint&)
76{ 91{
77 // FIXME 92 // FIXME
78} 93}
79// */ 94// */
80 95
81class KListView::KListViewPrivate 96class KListView::KListViewPrivate
82{ 97{
83public: 98public:
84 KListViewPrivate (KListView* listview) 99 KListViewPrivate (KListView* listview)
85 : pCurrentItem (0L), 100 : pCurrentItem (0L),
86 autoSelectDelay(1), 101 autoSelectDelay(1),
87//US dragDelay (KGlobalSettings::dndEventDelay()), 102//US dragDelay (KGlobalSettings::dndEventDelay()),
88 103
89 dragDelay (10), 104 dragDelay (10),
90//US editor (new KListViewLineEdit (listview)), 105//US editor (new KListViewLineEdit (listview)),
91 cursorInExecuteArea(false), 106 cursorInExecuteArea(false),
92 bUseSingle(false), 107 bUseSingle(false),
93 bChangeCursorOverItem(false), 108 bChangeCursorOverItem(false),
94 itemsMovable (true), 109 itemsMovable (true),
95 selectedBySimpleMove(false), 110 selectedBySimpleMove(false),
96 selectedUsingMouse(false), 111 selectedUsingMouse(false),
97 itemsRenameable (false), 112 itemsRenameable (false),
98 validDrag (false), 113 validDrag (false),
99 dragEnabled (false), 114 dragEnabled (false),
100 autoOpen (true), 115 autoOpen (true),
101 dropVisualizer (true), 116 dropVisualizer (true),
102 dropHighlighter (false), 117 dropHighlighter (false),
103 createChildren (true), 118 createChildren (true),
104 pressedOnSelected (false), 119 pressedOnSelected (false),
105 wasShiftEvent (false), 120 wasShiftEvent (false),
106 fullWidth (false), 121 fullWidth (false),
107 sortAscending(true), 122 sortAscending(true),
108 tabRename(true), 123 tabRename(true),
109 sortColumn(0), 124 sortColumn(0),
110 selectionDirection(0), 125 selectionDirection(0),
111 tooltipColumn (0), 126 tooltipColumn (0),
112 selectionMode (Single), 127 selectionMode (Single),
113 contextMenuKey ( Qt::Key_Menu ),//KGlobalSettings::contextMenuKey()), 128 contextMenuKey ( Qt::Key_Menu ),//KGlobalSettings::contextMenuKey()),
114 showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()), 129 showContextMenusOnPress (true),//showContextMenusOnPress (KGlobalSettings::showContextMenusOnPress()),
115 mDropVisualizerWidth (4) 130 mDropVisualizerWidth (4)
116 { 131 {
117 renameable += 0; 132 renameable += 0;
118//US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int))); 133//US connect(editor, SIGNAL(done(QListViewItem*,int)), listview, SLOT(doneEditing(QListViewItem*,int)));
119 } 134 }
120 135
121 ~KListViewPrivate () 136 ~KListViewPrivate ()
122 { 137 {
123//US delete editor; 138//US delete editor;
124 } 139 }
125 140
126 QListViewItem* pCurrentItem; 141 Q3ListViewItem* pCurrentItem;
127 142
128 QTimer autoSelect; 143 QTimer autoSelect;
129 int autoSelectDelay; 144 int autoSelectDelay;
130 145
131 QTimer dragExpand; 146 QTimer dragExpand;
132 QListViewItem* dragOverItem; 147 Q3ListViewItem* dragOverItem;
133 QPoint dragOverPoint; 148 QPoint dragOverPoint;
134 149
135 QPoint startDragPos; 150 QPoint startDragPos;
136 int dragDelay; 151 int dragDelay;
137 152
138//US KListViewLineEdit *editor; 153//US KListViewLineEdit *editor;
139 QValueList<int> renameable; 154 Q3ValueList<int> renameable;
140 155
141 bool cursorInExecuteArea:1; 156 bool cursorInExecuteArea:1;
142 bool bUseSingle:1; 157 bool bUseSingle:1;
143 bool bChangeCursorOverItem:1; 158 bool bChangeCursorOverItem:1;
144 bool itemsMovable:1; 159 bool itemsMovable:1;
145 bool selectedBySimpleMove : 1; 160 bool selectedBySimpleMove : 1;
146 bool selectedUsingMouse:1; 161 bool selectedUsingMouse:1;
147 bool itemsRenameable:1; 162 bool itemsRenameable:1;
148 bool validDrag:1; 163 bool validDrag:1;
149 bool dragEnabled:1; 164 bool dragEnabled:1;
150 bool autoOpen:1; 165 bool autoOpen:1;
151 bool dropVisualizer:1; 166 bool dropVisualizer:1;
152 bool dropHighlighter:1; 167 bool dropHighlighter:1;
153 bool createChildren:1; 168 bool createChildren:1;
154 bool pressedOnSelected:1; 169 bool pressedOnSelected:1;
155 bool wasShiftEvent:1; 170 bool wasShiftEvent:1;
156 bool fullWidth:1; 171 bool fullWidth:1;
157 bool sortAscending:1; 172 bool sortAscending:1;
158 bool tabRename:1; 173 bool tabRename:1;
159 174
160 int sortColumn; 175 int sortColumn;
161 176
162 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX 177 //+1 means downwards (y increases, -1 means upwards, 0 means not selected), aleXXX
163 int selectionDirection; 178 int selectionDirection;
164 int tooltipColumn; 179 int tooltipColumn;
165 180
166 SelectionModeExt selectionMode; 181 SelectionModeExt selectionMode;
167 int contextMenuKey; 182 int contextMenuKey;
168 bool showContextMenusOnPress; 183 bool showContextMenusOnPress;
169 184
170 QRect mOldDropVisualizer; 185 QRect mOldDropVisualizer;
171 int mDropVisualizerWidth; 186 int mDropVisualizerWidth;
172 QRect mOldDropHighlighter; 187 QRect mOldDropHighlighter;
173 QListViewItem *afterItemDrop; 188 Q3ListViewItem *afterItemDrop;
174 QListViewItem *parentItemDrop; 189 Q3ListViewItem *parentItemDrop;
175 190
176 QColor alternateBackground; 191 QColor alternateBackground;
177}; 192};
178 193
179/*US 194/*US
180KListViewLineEdit::KListViewLineEdit(KListView *parent) 195KListViewLineEdit::KListViewLineEdit(KListView *parent)
181 : KLineEdit(parent->viewport()), item(0), col(0), p(parent) 196 : KLineEdit(parent->viewport()), item(0), col(0), p(parent)
182{ 197{
183 setFrame( false ); 198 setFrame( false );
184 hide(); 199 hide();
185 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() )); 200 connect( parent, SIGNAL( selectionChanged() ), SLOT( slotSelectionChanged() ));
186} 201}
187 202
188KListViewLineEdit::~KListViewLineEdit() 203KListViewLineEdit::~KListViewLineEdit()
189{ 204{
190} 205}
191 206
192void KListViewLineEdit::load(QListViewItem *i, int c) 207void KListViewLineEdit::load(QListViewItem *i, int c)
193{ 208{
194 item=i; 209 item=i;
195 col=c; 210 col=c;
196 211
197 QRect rect(p->itemRect(i)); 212 QRect rect(p->itemRect(i));
198 setText(item->text(c)); 213 setText(item->text(c));
199 214
200 int fieldX = rect.x() - 1; 215 int fieldX = rect.x() - 1;
201 int fieldW = p->columnWidth(col) + 2; 216 int fieldW = p->columnWidth(col) + 2;
202 217
203 int pos = p->header()->mapToIndex(col); 218 int pos = p->header()->mapToIndex(col);
204 for ( int index = 0; index < pos; index++ ) 219 for ( int index = 0; index < pos; index++ )
205 fieldX += p->columnWidth( p->header()->mapToSection( index )); 220 fieldX += p->columnWidth( p->header()->mapToSection( index ));
206 221
207 if ( col == 0 ) { 222 if ( col == 0 ) {
208 int d = i->depth() + (p->rootIsDecorated() ? 1 : 0); 223 int d = i->depth() + (p->rootIsDecorated() ? 1 : 0);
209 d *= p->treeStepSize(); 224 d *= p->treeStepSize();
210 fieldX += d; 225 fieldX += d;
211 fieldW -= d; 226 fieldW -= d;
212 } 227 }
213 228
214 if ( i->pixmap( col ) ) {// add width of pixmap 229 if ( i->pixmap( col ) ) {// add width of pixmap
215 int d = i->pixmap( col )->width(); 230 int d = i->pixmap( col )->width();
216 fieldX += d; 231 fieldX += d;
217 fieldW -= d; 232 fieldW -= d;
218 } 233 }
219 234
220 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2); 235 setGeometry(fieldX, rect.y() - 1, fieldW, rect.height() + 2);
221 show(); 236 show();
222 setFocus(); 237 setFocus();
223} 238}
224*/ 239*/
225 /*Helper functions to for 240 /*Helper functions to for
226 *tabOrderedRename functionality. 241 *tabOrderedRename functionality.
227 */ 242 */
228 243
229static int nextCol (KListView *pl, QListViewItem *pi, int start, int dir) 244static int nextCol (KListView *pl, Q3ListViewItem *pi, int start, int dir)
230{ 245{
231 if (pi) 246 if (pi)
232 { 247 {
233 //Find the next renameable column in the current row 248 //Find the next renameable column in the current row
234 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir) 249 for (; ((dir == +1) ? (start < pl->columns()) : (start >= 0)); start += dir)
235 if (pl->isRenameable(start)) 250 if (pl->isRenameable(start))
236 return start; 251 return start;
237 } 252 }
238 253
239 return -1; 254 return -1;
240} 255}
241 256
242static QListViewItem *prevItem (QListViewItem *pi) 257static Q3ListViewItem *prevItem (Q3ListViewItem *pi)
243{ 258{
244 QListViewItem *pa = pi->itemAbove(); 259 Q3ListViewItem *pa = pi->itemAbove();
245 260
246 /*Does what the QListViewItem::previousSibling() 261 /*Does what the QListViewItem::previousSibling()
247 *of my dreams would do. 262 *of my dreams would do.
248 */ 263 */
249 if (pa && pa->parent() == pi->parent()) 264 if (pa && pa->parent() == pi->parent())
250 return pa; 265 return pa;
251 266
252 return NULL; 267 return NULL;
253} 268}
254 269
255static QListViewItem *lastQChild (QListViewItem *pi) 270static Q3ListViewItem *lastQChild (Q3ListViewItem *pi)
256{ 271{
257 if (pi) 272 if (pi)
258 { 273 {
259 /*Since there's no QListViewItem::lastChild(). 274 /*Since there's no QListViewItem::lastChild().
260 *This finds the last sibling for the given 275 *This finds the last sibling for the given
261 *item. 276 *item.
262 */ 277 */
263 for (QListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling()) 278 for (Q3ListViewItem *pt = pi->nextSibling(); pt; pt = pt->nextSibling())
264 pi = pt; 279 pi = pt;
265 } 280 }
266 281
267 return pi; 282 return pi;
268} 283}
269/*US 284/*US
270void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward) 285void KListViewLineEdit::selectNextCell (QListViewItem *pitem, int column, bool forward)
271{ 286{
272 const int ncols = p->columns(); 287 const int ncols = p->columns();
273 const int dir = forward ? +1 : -1; 288 const int dir = forward ? +1 : -1;
274 const int restart = forward ? 0 : (ncols - 1); 289 const int restart = forward ? 0 : (ncols - 1);
275 QListViewItem *top = (pitem && pitem->parent()) 290 QListViewItem *top = (pitem && pitem->parent())
276 ? pitem->parent()->firstChild() 291 ? pitem->parent()->firstChild()
277 : p->firstChild(); 292 : p->firstChild();
278 QListViewItem *pi = pitem; 293 QListViewItem *pi = pitem;
279 294
280 terminate(); //Save current changes 295 terminate(); //Save current changes
281 296
282 do 297 do
283 { 298 {
284*/ 299*/
285 /*Check the rest of the current row for an editable column, 300 /*Check the rest of the current row for an editable column,
286 *if that fails, check the entire next/previous row. The 301 *if that fails, check the entire next/previous row. The
287 *last case goes back to the first item in the current branch 302 *last case goes back to the first item in the current branch
288 *or the last item in the current branch depending on the 303 *or the last item in the current branch depending on the
289 *direction. 304 *direction.
290 */ 305 */
291/*US 306/*US
292 if ((column = nextCol(p, pi, column + dir, dir)) != -1 || 307 if ((column = nextCol(p, pi, column + dir, dir)) != -1 ||
293 (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 || 308 (column = nextCol(p, (pi = (forward ? pi->nextSibling() : prevItem(pi))), restart, dir)) != -1 ||
294 (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1) 309 (column = nextCol(p, (pi = (forward ? top : lastQChild(pitem))), restart, dir)) != -1)
295 { 310 {
296 if (pi) 311 if (pi)
297 { 312 {
298 p->setCurrentItem(pi); //Calls terminate 313 p->setCurrentItem(pi); //Calls terminate
299 p->rename(pi, column); 314 p->rename(pi, column);
300*/ 315*/
301 /*Some listviews may override rename() to 316 /*Some listviews may override rename() to
302 *prevent certain items from being renamed, 317 *prevent certain items from being renamed,
303 *if this is done, [m_]item will be NULL 318 *if this is done, [m_]item will be NULL
304 *after the rename() call... try again. 319 *after the rename() call... try again.
305 */ 320 */
306/*US 321/*US
307 if (!item) 322 if (!item)
308 continue; 323 continue;
309 324
310 break; 325 break;
311 } 326 }
312 } 327 }
313 } 328 }
314 while (pi && !item); 329 while (pi && !item);
315} 330}
316*/ 331*/
317 332
318/*US 333/*US
319#ifdef KeyPress 334#ifdef KeyPress
320#undef KeyPress 335#undef KeyPress
321#endif 336#endif
322 337
323bool KListViewLineEdit::event (QEvent *pe) 338bool KListViewLineEdit::event (QEvent *pe)
324{ 339{
325 if (pe->type() == QEvent::KeyPress) 340 if (pe->type() == QEvent::KeyPress)
326 { 341 {
327 QKeyEvent *k = (QKeyEvent *) pe; 342 QKeyEvent *k = (QKeyEvent *) pe;
328 343
329 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) && 344 if ((k->key() == Qt::Key_Backtab || k->key() == Qt::Key_Tab) &&
330 p->tabOrderedRenaming() && p->itemsRenameable() && 345 p->tabOrderedRenaming() && p->itemsRenameable() &&
331 !(k->state() & ControlButton || k->state() & AltButton)) 346 !(k->state() & Qt::ControlButton || k->state() & AltButton))
332 { 347 {
333 selectNextCell(item, col, 348 selectNextCell(item, col,
334 (k->key() == Key_Tab && !(k->state() & ShiftButton))); 349 (k->key() == Key_Tab && !(k->state() & Qt::ShiftButton)));
335 return true; 350 return true;
336 } 351 }
337 } 352 }
338 353
339 return KLineEdit::event(pe); 354 return KLineEdit::event(pe);
340} 355}
341 356
342void KListViewLineEdit::keyPressEvent(QKeyEvent *e) 357void KListViewLineEdit::keyPressEvent(QKeyEvent *e)
343{ 358{
344 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter ) 359 if(e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter )
345 terminate(true); 360 terminate(true);
346 else if(e->key() == Qt::Key_Escape) 361 else if(e->key() == Qt::Key_Escape)
347 terminate(false); 362 terminate(false);
348 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up) 363 else if (e->key() == Qt::Key_Down || e->key() == Qt::Key_Up)
349 { 364 {
350 terminate(true); 365 terminate(true);
351 KLineEdit::keyPressEvent(e); 366 KLineEdit::keyPressEvent(e);
352 } 367 }
353 else 368 else
354 KLineEdit::keyPressEvent(e); 369 KLineEdit::keyPressEvent(e);
355} 370}
356 371
357void KListViewLineEdit::terminate() 372void KListViewLineEdit::terminate()
358{ 373{
359 terminate(true); 374 terminate(true);
360} 375}
361 376
362void KListViewLineEdit::terminate(bool commit) 377void KListViewLineEdit::terminate(bool commit)
363{ 378{
364 if ( item ) 379 if ( item )
365 { 380 {
366 //kdDebug() << "KListViewLineEdit::terminate " << commit << endl; 381 //kdDebug() << "KListViewLineEdit::terminate " << commit << endl;
367 if (commit) 382 if (commit)
368 item->setText(col, text()); 383 item->setText(col, text());
369 int c=col; 384 int c=col;
370 QListViewItem *i=item; 385 QListViewItem *i=item;
371 col=0; 386 col=0;
372 item=0; 387 item=0;
373 hide(); // will call focusOutEvent, that's why we set item=0 before 388 hide(); // will call focusOutEvent, that's why we set item=0 before
374 emit done(i,c); 389 emit done(i,c);
375 } 390 }
376} 391}
377 392
378void KListViewLineEdit::focusOutEvent(QFocusEvent *ev) 393void KListViewLineEdit::focusOutEvent(QFocusEvent *ev)
379{ 394{
380 QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev); 395 QFocusEvent * focusEv = static_cast<QFocusEvent*>(ev);
381 // Don't let a RMB close the editor 396 // Don't let a RMB close the editor
382 if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow) 397 if (focusEv->reason() != QFocusEvent::Popup && focusEv->reason() != QFocusEvent::ActiveWindow)
383 terminate(true); 398 terminate(true);
384} 399}
385 400
386void KListViewLineEdit::paintEvent( QPaintEvent *e ) 401void KListViewLineEdit::paintEvent( QPaintEvent *e )
387{ 402{
388 KLineEdit::paintEvent( e ); 403 KLineEdit::paintEvent( e );
389 404
390 if ( !frame() ) { 405 if ( !frame() ) {
391 QPainter p( this ); 406 QPainter p( this );
392 p.setClipRegion( e->region() ); 407 p.setClipRegion( e->region() );
393 p.drawRect( rect() ); 408 p.drawRect( rect() );
394 } 409 }
395} 410}
396 411
397// selection changed -> terminate. As our "item" can be already deleted, 412// selection changed -> terminate. As our "item" can be already deleted,
398// we can't call terminate(false), because that would emit done() with 413// we can't call terminate(false), because that would emit done() with
399// a dangling pointer to "item". 414// a dangling pointer to "item".
400void KListViewLineEdit::slotSelectionChanged() 415void KListViewLineEdit::slotSelectionChanged()
401{ 416{
402 item = 0; 417 item = 0;
403 col = 0; 418 col = 0;
404 hide(); 419 hide();
405} 420}
406*/ 421*/
407 422
408KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse ) 423KListView::KListView( QWidget *parent, const char *name ,bool emulateRightMouse )
409 : QListView( parent, name ), 424 : Q3ListView( parent, name ),
410 d (new KListViewPrivate (this)) 425 d (new KListViewPrivate (this))
411{ 426{
412#ifndef DESKTOP_VERSION 427#ifndef DESKTOP_VERSION
413 if ( emulateRightMouse ) 428 if ( emulateRightMouse )
414 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold ); 429 QPEApplication::setStylusOperation( viewport(), QPEApplication::RightOnHold );
415#endif 430#endif
416//US setDragAutoScroll(true); 431//US setDragAutoScroll(true);
417 432
418 connect( this, SIGNAL( onViewport() ), 433 connect( this, SIGNAL( onViewport() ),
419 this, SLOT( slotOnViewport() ) ); 434 this, SLOT( slotOnViewport() ) );
420 connect( this, SIGNAL( onItem( QListViewItem * ) ), 435 connect( this, SIGNAL( onItem( Q3ListViewItem * ) ),
421 this, SLOT( slotOnItem( QListViewItem * ) ) ); 436 this, SLOT( slotOnItem( Q3ListViewItem * ) ) );
422 437
423 connect (this, SIGNAL(contentsMoving(int,int)), 438 connect (this, SIGNAL(contentsMoving(int,int)),
424 this, SLOT(cleanDropVisualizer())); 439 this, SLOT(cleanDropVisualizer()));
425 connect (this, SIGNAL(contentsMoving(int,int)), 440 connect (this, SIGNAL(contentsMoving(int,int)),
426 this, SLOT(cleanItemHighlighter())); 441 this, SLOT(cleanItemHighlighter()));
427 442
428/*US 443/*US
429 slotSettingsChanged(KApplication::SETTINGS_MOUSE); 444 slotSettingsChanged(KApplication::SETTINGS_MOUSE);
430 445
431 if (kapp) 446 if (kapp)
432 { 447 {
433 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) ); 448 connect( kapp, SIGNAL( settingsChanged(int) ), SLOT( slotSettingsChanged(int) ) );
434 kapp->addKipcEventMask( KIPC::SettingsChanged ); 449 kapp->addKipcEventMask( KIPC::SettingsChanged );
435 } 450 }
436*/ 451*/
437 slotSettingsChanged(1); //US do this to initialize the connections 452 slotSettingsChanged(1); //US do this to initialize the connections
438 453
439 454
440 connect(&d->autoSelect, SIGNAL( timeout() ), 455 connect(&d->autoSelect, SIGNAL( timeout() ),
441 this, SLOT( slotAutoSelect() ) ); 456 this, SLOT( slotAutoSelect() ) );
442 connect(&d->dragExpand, SIGNAL( timeout() ), 457 connect(&d->dragExpand, SIGNAL( timeout() ),
443 this, SLOT( slotDragExpand() ) ); 458 this, SLOT( slotDragExpand() ) );
444 459
445 // context menu handling 460 // context menu handling
446 if (d->showContextMenusOnPress) 461 if (d->showContextMenusOnPress)
447 { 462 {
448 connect (this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), 463 connect (this, SIGNAL (rightButtonPressed (Q3ListViewItem*, const QPoint&, int)),
449 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 464 this, SLOT (emitContextMenu (Q3ListViewItem*, const QPoint&, int)));
450 } 465 }
451 else 466 else
452 { 467 {
453 connect (this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), 468 connect (this, SIGNAL (rightButtonClicked (Q3ListViewItem*, const QPoint&, int)),
454 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 469 this, SLOT (emitContextMenu (Q3ListViewItem*, const QPoint&, int)));
455 } 470 }
456 471
457 connect (this, SIGNAL (menuShortCutPressed (KListView*, QListViewItem*)), 472 connect (this, SIGNAL (menuShortCutPressed (KListView*, Q3ListViewItem*)),
458 this, SLOT (emitContextMenu (KListView*, QListViewItem*))); 473 this, SLOT (emitContextMenu (KListView*, Q3ListViewItem*)));
459 474
460 475
461 //qDebug("KListView::KListView make alternate color configurable"); 476 //qDebug("KListView::KListView make alternate color configurable");
462 d->alternateBackground = KGlobalSettings::alternateBackgroundColor(); 477 d->alternateBackground = KGlobalSettings::alternateBackgroundColor();
463} 478}
464 479
465 480
466 481
467KListView::~KListView() 482KListView::~KListView()
468{ 483{
469 delete d; 484 delete d;
470} 485}
471 486
472bool KListView::isExecuteArea( const QPoint& point ) 487bool KListView::isExecuteArea( const QPoint& point )
473{ 488{
474 if ( itemAt( point ) ) 489 if ( itemAt( point ) )
475 return isExecuteArea( point.x() ); 490 return isExecuteArea( point.x() );
476 491
477 return false; 492 return false;
478} 493}
479QSize KListView::sizeHint() const 494QSize KListView::sizeHint() const
480{ 495{
481 //qDebug("KListView::QSize sizeHint() "); 496 //qDebug("KListView::QSize sizeHint() ");
482#ifdef DESKTOP_VERSION 497#ifdef DESKTOP_VERSION
483 return QListView::sizeHint(); 498 return Q3ListView::sizeHint();
484#else 499#else
485 return QSize ( 40, 40 ); 500 return QSize ( 40, 40 );
486#endif 501#endif
487 502
488} 503}
489bool KListView::isExecuteArea( int x ) 504bool KListView::isExecuteArea( int x )
490{ 505{
491 if( allColumnsShowFocus() ) 506 if( allColumnsShowFocus() )
492 return true; 507 return true;
493 else { 508 else {
494 int offset = 0; 509 int offset = 0;
495 int width = columnWidth( 0 ); 510 int width = columnWidth( 0 );
496 int pos = header()->mapToIndex( 0 ); 511 int pos = header()->mapToIndex( 0 );
497 512
498 for ( int index = 0; index < pos; index++ ) 513 for ( int index = 0; index < pos; index++ )
499 offset += columnWidth( header()->mapToSection( index ) ); 514 offset += columnWidth( header()->mapToSection( index ) );
500 515
501 x += contentsX(); // in case of a horizontal scrollbar 516 x += contentsX(); // in case of a horizontal scrollbar
502 return ( x > offset && x < ( offset + width ) ); 517 return ( x > offset && x < ( offset + width ) );
503 } 518 }
504} 519}
505 520
506void KListView::slotOnItem( QListViewItem *item ) 521void KListView::slotOnItem( Q3ListViewItem *item )
507{ 522{
508 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() ); 523 QPoint vp = viewport()->mapFromGlobal( QCursor::pos() );
509 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) { 524 if ( item && isExecuteArea( vp.x() ) && (d->autoSelectDelay > -1) && d->bUseSingle ) {
510 d->autoSelect.start( d->autoSelectDelay, true ); 525 d->autoSelect.start( d->autoSelectDelay, true );
511 d->pCurrentItem = item; 526 d->pCurrentItem = item;
512 } 527 }
513} 528}
514 529
515void KListView::slotOnViewport() 530void KListView::slotOnViewport()
516{ 531{
517 if ( d->bChangeCursorOverItem ) 532 if ( d->bChangeCursorOverItem )
518 viewport()->unsetCursor(); 533 viewport()->unsetCursor();
519 534
520 d->autoSelect.stop(); 535 d->autoSelect.stop();
521 d->pCurrentItem = 0L; 536 d->pCurrentItem = 0L;
522} 537}
523 538
524void KListView::slotSettingsChanged(int category) 539void KListView::slotSettingsChanged(int category)
525{ 540{
526 //qDebug("KListView::slotSettingsChanged has to be verified"); 541 //qDebug("KListView::slotSettingsChanged has to be verified");
527 542
528 543
529 switch (category) 544 switch (category)
530 { 545 {
531 //US I create my private category (=1) to set the settings 546 //US I create my private category (=1) to set the settings
532 case 1: 547 case 1:
533 d->dragDelay = 2; 548 d->dragDelay = 2;
534 //US set explicitly d->bUseSingle = KGlobalSettings::singleClick(); 549 //US set explicitly d->bUseSingle = KGlobalSettings::singleClick();
535 // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle); 550 // qDebug("KListView::slotSettingsChanged: single%i", d->bUseSingle);
536 551
537 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 552 disconnect(this, SIGNAL (mouseButtonClicked (int, Q3ListViewItem*, const QPoint &, int)),
538 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); 553 this, SLOT (slotMouseButtonClicked (int, Q3ListViewItem*, const QPoint &, int)));
539 554
540 if( d->bUseSingle ) 555 if( d->bUseSingle )
541 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 556 connect (this, SIGNAL (mouseButtonClicked (int, Q3ListViewItem*, const QPoint &, int)),
542 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); 557 this, SLOT (slotMouseButtonClicked( int, Q3ListViewItem*, const QPoint &, int)));
543 558
544 //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); 559 //US d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon();
545 //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); 560 //US d->autoSelectDelay = KGlobalSettings::autoSelectDelay();
546 561
547 if( !d->bUseSingle || !d->bChangeCursorOverItem ) 562 if( !d->bUseSingle || !d->bChangeCursorOverItem )
548 viewport()->unsetCursor(); 563 viewport()->unsetCursor();
549 564
550 break; 565 break;
551 566
552 /*US 567 /*US
553 case KApplication::SETTINGS_MOUSE: 568 case KApplication::SETTINGS_MOUSE:
554 d->dragDelay = KGlobalSettings::dndEventDelay(); 569 d->dragDelay = KGlobalSettings::dndEventDelay();
555 d->bUseSingle = KGlobalSettings::singleClick(); 570 d->bUseSingle = KGlobalSettings::singleClick();
556 571
557 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 572 disconnect(this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
558 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int))); 573 this, SLOT (slotMouseButtonClicked (int, QListViewItem*, const QPoint &, int)));
559 574
560 if( d->bUseSingle ) 575 if( d->bUseSingle )
561 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)), 576 connect (this, SIGNAL (mouseButtonClicked (int, QListViewItem*, const QPoint &, int)),
562 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int))); 577 this, SLOT (slotMouseButtonClicked( int, QListViewItem*, const QPoint &, int)));
563 578
564 d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon(); 579 d->bChangeCursorOverItem = KGlobalSettings::changeCursorOverIcon();
565 d->autoSelectDelay = KGlobalSettings::autoSelectDelay(); 580 d->autoSelectDelay = KGlobalSettings::autoSelectDelay();
566 581
567 if( !d->bUseSingle || !d->bChangeCursorOverItem ) 582 if( !d->bUseSingle || !d->bChangeCursorOverItem )
568 viewport()->unsetCursor(); 583 viewport()->unsetCursor();
569 584
570 break; 585 break;
571 case KApplication::SETTINGS_POPUPMENU: 586 case KApplication::SETTINGS_POPUPMENU:
572 d->contextMenuKey = KGlobalSettings::contextMenuKey (); 587 d->contextMenuKey = KGlobalSettings::contextMenuKey ();
573 d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress (); 588 d->showContextMenusOnPress = KGlobalSettings::showContextMenusOnPress ();
574 589
575 if (d->showContextMenusOnPress) 590 if (d->showContextMenusOnPress)
576 { 591 {
577 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 592 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
578 593
579 connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)), 594 connect(this, SIGNAL (rightButtonPressed (QListViewItem*, const QPoint&, int)),
580 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 595 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
581 } 596 }
582 else 597 else
583 { 598 {
584 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 599 disconnect (0L, 0L, this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
585 600
586 connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)), 601 connect(this, SIGNAL (rightButtonClicked (QListViewItem*, const QPoint&, int)),
587 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int))); 602 this, SLOT (emitContextMenu (QListViewItem*, const QPoint&, int)));
588 } 603 }
589 break; 604 break;
590 */ 605 */
591 606
592 default: 607 default:
593 break; 608 break;
594 } 609 }
595 610
596} 611}
597 612
598void KListView::slotAutoSelect() 613void KListView::slotAutoSelect()
599{ 614{
600 // check that the item still exists 615 // check that the item still exists
601 if( itemIndex( d->pCurrentItem ) == -1 ) 616 if( itemIndex( d->pCurrentItem ) == -1 )
602 return; 617 return;
603 618
604 if (!isActiveWindow()) 619 if (!isActiveWindow())
605 { 620 {
606 d->autoSelect.stop(); 621 d->autoSelect.stop();
607 return; 622 return;
608 } 623 }
609 624
610 //Give this widget the keyboard focus. 625 //Give this widget the keyboard focus.
611 if( !hasFocus() ) 626 if( !hasFocus() )
612 setFocus(); 627 setFocus();
613 628
614 QListViewItem* previousItem = currentItem(); 629 Q3ListViewItem* previousItem = currentItem();
615 setCurrentItem( d->pCurrentItem ); 630 setCurrentItem( d->pCurrentItem );
616 631
617#if 0 632#if 0
618#ifndef Q_WS_QWS 633#ifndef Q_WS_QWS
619 // FIXME(E): Implement for Qt Embedded 634 // FIXME(E): Implement for Qt Embedded
620 if( d->pCurrentItem ) { 635 if( d->pCurrentItem ) {
621 //Shift pressed? 636 //Shift pressed?
622 if( (keybstate & ShiftMask) ) { 637 if( (keybstate & ShiftMask) ) {
623 bool block = signalsBlocked(); 638 bool block = signalsBlocked();
624 blockSignals( true ); 639 blockSignals( true );
625 640
626 //No Ctrl? Then clear before! 641 //No Ctrl? Then clear before!
627 if( !(keybstate & ControlMask) ) 642 if( !(keybstate & ControlMask) )
628 clearSelection(); 643 clearSelection();
629 644
630 bool select = !d->pCurrentItem->isSelected(); 645 bool select = !d->pCurrentItem->isSelected();
631 bool update = viewport()->isUpdatesEnabled(); 646 bool update = viewport()->isUpdatesEnabled();
632 viewport()->setUpdatesEnabled( false ); 647 viewport()->setUpdatesEnabled( false );
633 648
634 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos(); 649 bool down = previousItem->itemPos() < d->pCurrentItem->itemPos();
635 QListViewItemIterator lit( down ? previousItem : d->pCurrentItem ); 650 Q3ListViewItemIterator lit( down ? previousItem : d->pCurrentItem );
636 for ( ; lit.current(); ++lit ) { 651 for ( ; lit.current(); ++lit ) {
637 if ( down && lit.current() == d->pCurrentItem ) { 652 if ( down && lit.current() == d->pCurrentItem ) {
638 d->pCurrentItem->setSelected( select ); 653 d->pCurrentItem->setSelected( select );
639 break; 654 break;
640 } 655 }
641 if ( !down && lit.current() == previousItem ) { 656 if ( !down && lit.current() == previousItem ) {
642 previousItem->setSelected( select ); 657 previousItem->setSelected( select );
643 break; 658 break;
644 } 659 }
645 lit.current()->setSelected( select ); 660 lit.current()->setSelected( select );
646 } 661 }
647 662
648 blockSignals( block ); 663 blockSignals( block );
649 viewport()->setUpdatesEnabled( update ); 664 viewport()->setUpdatesEnabled( update );
650 triggerUpdate(); 665 triggerUpdate();
651 666
652 emit selectionChanged(); 667 emit selectionChanged();
653 668
654 if( selectionMode() == QListView::Single ) 669 if( selectionMode() == Q3ListView::Single )
655 emit selectionChanged( d->pCurrentItem ); 670 emit selectionChanged( d->pCurrentItem );
656 } 671 }
657 else if( (keybstate & ControlMask) ) 672 else if( (keybstate & ControlMask) )
658 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() ); 673 setSelected( d->pCurrentItem, !d->pCurrentItem->isSelected() );
659 else { 674 else {
660 bool block = signalsBlocked(); 675 bool block = signalsBlocked();
661 blockSignals( true ); 676 blockSignals( true );
662 677
663 if( !d->pCurrentItem->isSelected() ) 678 if( !d->pCurrentItem->isSelected() )
664 clearSelection(); 679 clearSelection();
665 680
666 blockSignals( block ); 681 blockSignals( block );
667 682
668 setSelected( d->pCurrentItem, true ); 683 setSelected( d->pCurrentItem, true );
669 } 684 }
670 } 685 }
671 else 686 else
672 kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl; 687 kdDebug() << "KListView::slotAutoSelect: Thats not supposed to happen!!!!" << endl;
673#endif 688#endif
674#endif 689#endif
675} 690}
676 691
677void KListView::slotHeaderChanged() 692void KListView::slotHeaderChanged()
678{ 693{
679 if (d->fullWidth && columns()) 694 if (d->fullWidth && columns())
680 { 695 {
681 int w = 0; 696 int w = 0;
682 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i); 697 for (int i = 0; i < columns() - 1; ++i) w += columnWidth(i);
683 setColumnWidth( columns() - 1, viewport()->width() - w - 1 ); 698 setColumnWidth( columns() - 1, viewport()->width() - w - 1 );
684 } 699 }
685} 700}
686 701
687void KListView::emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c) 702void KListView::emitExecute( int buttonstate, Q3ListViewItem *item, const QPoint &pos, int c)
688{ 703{
689 // qDebug("KListView::emitExecute buttonstate=%i", buttonstate); 704 // qDebug("KListView::emitExecute buttonstate=%i", buttonstate);
690 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) { 705 if( isExecuteArea( viewport()->mapFromGlobal(pos) ) ) {
691 706
692 // Double click mode ? 707 // Double click mode ?
693 if ( !d->bUseSingle ) 708 if ( !d->bUseSingle )
694 { 709 {
695 emit executed( item ); 710 emit executed( item );
696 emit executed( item, pos, c ); 711 emit executed( item, pos, c );
697 } 712 }
698 else 713 else
699 { 714 {
700 //US special implementation for embedded systems 715 //US special implementation for embedded systems
701 d->autoSelect.stop(); 716 d->autoSelect.stop();
702 717
703 //Dont emit executed if in SC mode and Shift or Ctrl are pressed 718 //Dont emit executed if in SC mode and Shift or Ctrl are pressed
704 if( !( (buttonstate==ShiftButton) || (buttonstate==ControlButton) )) { 719 if( !( (buttonstate==Qt::ShiftButton) || (buttonstate==Qt::ControlButton) )) {
705 // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) { 720 // if( !( ((keybstate & ShiftMask) || (keybstate & ControlMask)) ) ) {
706 721
707 emit executed( item ); 722 emit executed( item );
708 emit executed( item, pos, c ); 723 emit executed( item, pos, c );
709 } 724 }
710 } 725 }
711 } 726 }
712} 727}
713 728
714void KListView::focusInEvent( QFocusEvent *fe ) 729void KListView::focusInEvent( QFocusEvent *fe )
715{ 730{
716 // kdDebug()<<"KListView::focusInEvent()"<<endl; 731 // kdDebug()<<"KListView::focusInEvent()"<<endl;
717 QListView::focusInEvent( fe ); 732 Q3ListView::focusInEvent( fe );
718 if ((d->selectedBySimpleMove) 733 if ((d->selectedBySimpleMove)
719 && (d->selectionMode == FileManager) 734 && (d->selectionMode == FileManager)
720 && (fe->reason()!=QFocusEvent::Popup) 735 && (fe->reason()!=QFocusEvent::Popup)
721 && (fe->reason()!=QFocusEvent::ActiveWindow) 736 && (fe->reason()!=QFocusEvent::ActiveWindow)
722 && (currentItem()!=0)) 737 && (currentItem()!=0))
723 { 738 {
724 currentItem()->setSelected(true); 739 currentItem()->setSelected(true);
725 currentItem()->repaint(); 740 currentItem()->repaint();
726 emit selectionChanged(); 741 emit selectionChanged();
727 }; 742 };
728} 743}
729 744
730void KListView::focusOutEvent( QFocusEvent *fe ) 745void KListView::focusOutEvent( QFocusEvent *fe )
731{ 746{
732 cleanDropVisualizer(); 747 cleanDropVisualizer();
733 cleanItemHighlighter(); 748 cleanItemHighlighter();
734 749
735 d->autoSelect.stop(); 750 d->autoSelect.stop();
736 751
737 if ((d->selectedBySimpleMove) 752 if ((d->selectedBySimpleMove)
738 && (d->selectionMode == FileManager) 753 && (d->selectionMode == FileManager)
739 && (fe->reason()!=QFocusEvent::Popup) 754 && (fe->reason()!=QFocusEvent::Popup)
740 && (fe->reason()!=QFocusEvent::ActiveWindow) 755 && (fe->reason()!=QFocusEvent::ActiveWindow)
741 && (currentItem()!=0) 756 && (currentItem()!=0)
742/*US && (!d->editor->isVisible()) */ 757/*US && (!d->editor->isVisible()) */
743 ) 758 )
744 { 759 {
745 currentItem()->setSelected(false); 760 currentItem()->setSelected(false);
746 currentItem()->repaint(); 761 currentItem()->repaint();
747 emit selectionChanged(); 762 emit selectionChanged();
748 }; 763 };
749 764
750 QListView::focusOutEvent( fe ); 765 Q3ListView::focusOutEvent( fe );
751} 766}
752 767
753void KListView::leaveEvent( QEvent *e ) 768void KListView::leaveEvent( QEvent *e )
754{ 769{
755 d->autoSelect.stop(); 770 d->autoSelect.stop();
756 771
757 QListView::leaveEvent( e ); 772 Q3ListView::leaveEvent( e );
758} 773}
759 774
760bool KListView::event( QEvent *e ) 775bool KListView::event( QEvent *e )
761{ 776{
762 if (e->type() == QEvent::ApplicationPaletteChange) { 777 if (e->type() == QEvent::ApplicationPaletteChange) {
763 //qDebug("KListView::event make alternate color configurable"); 778 //qDebug("KListView::event make alternate color configurable");
764//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor(); 779//US d->alternateBackground=KGlobalSettings::alternateBackgroundColor();
765 d->alternateBackground = QColor(240, 240, 240); 780 d->alternateBackground = QColor(240, 240, 240);
766 } 781 }
767 782
768 return QListView::event(e); 783 return Q3ListView::event(e);
769} 784}
770 785
771void KListView::contentsMousePressEvent( QMouseEvent *e ) 786void KListView::contentsMousePressEvent( QMouseEvent *e )
772{ 787{
773 //qDebug("KListView::contentsMousePressEvent"); 788 //qDebug("KListView::contentsMousePressEvent");
774 if( (selectionModeExt() == Extended) && (e->state() & ShiftButton) && !(e->state() & ControlButton) ) 789 if( (selectionModeExt() == Extended) && (e->state() & Qt::ShiftButton) && !(e->state() & Qt::ControlButton) )
775 { 790 {
776 bool block = signalsBlocked(); 791 bool block = signalsBlocked();
777 blockSignals( true ); 792 blockSignals( true );
778 793
779 clearSelection(); 794 clearSelection();
780 795
781 blockSignals( block ); 796 blockSignals( block );
782 } 797 }
783 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove)) 798 else if ((selectionModeExt()==FileManager) && (d->selectedBySimpleMove))
784 { 799 {
785 d->selectedBySimpleMove=false; 800 d->selectedBySimpleMove=false;
786 d->selectedUsingMouse=true; 801 d->selectedUsingMouse=true;
787 if (currentItem()!=0) 802 if (currentItem()!=0)
788 { 803 {
789 currentItem()->setSelected(false); 804 currentItem()->setSelected(false);
790 currentItem()->repaint(); 805 currentItem()->repaint();
791// emit selectionChanged(); 806// emit selectionChanged();
792 }; 807 };
793 }; 808 };
794 809
795 QPoint p( contentsToViewport( e->pos() ) ); 810 QPoint p( contentsToViewport( e->pos() ) );
796 QListViewItem *at = itemAt (p); 811 Q3ListViewItem *at = itemAt (p);
797 812
798 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) 813 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
799 bool rootDecoClicked = at 814 bool rootDecoClicked = at
800 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + 815 && ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
801 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) 816 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
802 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); 817 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
803 818
804 if (e->button() == LeftButton && !rootDecoClicked) 819 if (e->button() == Qt::LeftButton && !rootDecoClicked)
805 { 820 {
806 //Start a drag 821 //Start a drag
807 d->startDragPos = e->pos(); 822 d->startDragPos = e->pos();
808 823
809 if (at) 824 if (at)
810 { 825 {
811 d->validDrag = true; 826 d->validDrag = true;
812 d->pressedOnSelected = at->isSelected(); 827 d->pressedOnSelected = at->isSelected();
813 } 828 }
814 } 829 }
815 830
816 QListView::contentsMousePressEvent( e ); 831 Q3ListView::contentsMousePressEvent( e );
817} 832}
818 833
819void KListView::contentsMouseMoveEvent( QMouseEvent *e ) 834void KListView::contentsMouseMoveEvent( QMouseEvent *e )
820{ 835{
821 if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) { 836 if (!dragEnabled() || d->startDragPos.isNull() || !d->validDrag) {
822 QListView::contentsMouseMoveEvent (e); 837 Q3ListView::contentsMouseMoveEvent (e);
823 return; 838 return;
824 } 839 }
825 840
826 QPoint vp = contentsToViewport(e->pos()); 841 QPoint vp = contentsToViewport(e->pos());
827 QListViewItem *item = itemAt( vp ); 842 Q3ListViewItem *item = itemAt( vp );
828 843
829 //do we process cursor changes at all? 844 //do we process cursor changes at all?
830 if ( item && d->bChangeCursorOverItem && d->bUseSingle ) 845 if ( item && d->bChangeCursorOverItem && d->bUseSingle )
831 { 846 {
832 //Cursor moved on a new item or in/out the execute area 847 //Cursor moved on a new item or in/out the execute area
833 if( (item != d->pCurrentItem) || 848 if( (item != d->pCurrentItem) ||
834 (isExecuteArea(vp) != d->cursorInExecuteArea) ) 849 (isExecuteArea(vp) != d->cursorInExecuteArea) )
835 { 850 {
836 d->cursorInExecuteArea = isExecuteArea(vp); 851 d->cursorInExecuteArea = isExecuteArea(vp);
837 //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet"); 852 //qDebug("KListView::contentsMouseMoveEvent drag&drop not supported yet");
838/*US 853/*US
839 if( d->cursorInExecuteArea ) //cursor moved in execute area 854 if( d->cursorInExecuteArea ) //cursor moved in execute area
840 viewport()->setCursor( KCursor::handCursor() ); 855 viewport()->setCursor( KCursor::handCursor() );
841 else //cursor moved out of execute area 856 else //cursor moved out of execute area
842 viewport()->unsetCursor(); 857 viewport()->unsetCursor();
843*/ 858*/
844 } 859 }
845 } 860 }
846 861
847 bool dragOn = dragEnabled(); 862 bool dragOn = dragEnabled();
848 QPoint newPos = e->pos(); 863 QPoint newPos = e->pos();
849 if (dragOn && d->validDrag && 864 if (dragOn && d->validDrag &&
850 (newPos.x() > d->startDragPos.x()+d->dragDelay || 865 (newPos.x() > d->startDragPos.x()+d->dragDelay ||
851 newPos.x() < d->startDragPos.x()-d->dragDelay || 866 newPos.x() < d->startDragPos.x()-d->dragDelay ||
852 newPos.y() > d->startDragPos.y()+d->dragDelay || 867 newPos.y() > d->startDragPos.y()+d->dragDelay ||
853 newPos.y() < d->startDragPos.y()-d->dragDelay)) 868 newPos.y() < d->startDragPos.y()-d->dragDelay))
854 //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance()) 869 //(d->startDragPos - e->pos()).manhattanLength() > QApplication::startDragDistance())
855 { 870 {
856 QListView::contentsMouseReleaseEvent( 0 ); 871 Q3ListView::contentsMouseReleaseEvent( 0 );
857 startDrag(); 872 startDrag();
858 d->startDragPos = QPoint(); 873 d->startDragPos = QPoint();
859 d->validDrag = false; 874 d->validDrag = false;
860 } 875 }
861} 876}
862 877
863void KListView::contentsMouseReleaseEvent( QMouseEvent *e ) 878void KListView::contentsMouseReleaseEvent( QMouseEvent *e )
864{ 879{
865 if (e->button() == LeftButton) 880 if (e->button() == Qt::LeftButton)
866 { 881 {
867 // If the row was already selected, maybe we want to start an in-place editing 882 // If the row was already selected, maybe we want to start an in-place editing
868 if ( d->pressedOnSelected && itemsRenameable() ) 883 if ( d->pressedOnSelected && itemsRenameable() )
869 { 884 {
870 QPoint p( contentsToViewport( e->pos() ) ); 885 QPoint p( contentsToViewport( e->pos() ) );
871 QListViewItem *at = itemAt (p); 886 Q3ListViewItem *at = itemAt (p);
872 if ( at ) 887 if ( at )
873 { 888 {
874 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign) 889 // true if the root decoration of the item "at" was clicked (i.e. the +/- sign)
875 bool rootDecoClicked = 890 bool rootDecoClicked =
876 ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) + 891 ( p.x() <= header()->cellPos( header()->mapToActual( 0 ) ) +
877 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() ) 892 treeStepSize() * ( at->depth() + ( rootIsDecorated() ? 1 : 0) ) + itemMargin() )
878 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) ); 893 && ( p.x() >= header()->cellPos( header()->mapToActual( 0 ) ) );
879 894
880 if (!rootDecoClicked) 895 if (!rootDecoClicked)
881 { 896 {
882 int col = header()->mapToLogical( header()->cellAt( p.x() ) ); 897 int col = header()->mapToLogical( header()->cellAt( p.x() ) );
883 if ( d->renameable.contains(col) ) 898 if ( d->renameable.contains(col) )
884 rename(at, col); 899 rename(at, col);
885 } 900 }
886 } 901 }
887 } 902 }
888 903
889 d->pressedOnSelected = false; 904 d->pressedOnSelected = false;
890 d->validDrag = false; 905 d->validDrag = false;
891 d->startDragPos = QPoint(); 906 d->startDragPos = QPoint();
892 } 907 }
893 QListView::contentsMouseReleaseEvent( e ); 908 Q3ListView::contentsMouseReleaseEvent( e );
894} 909}
895 910
896void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e ) 911void KListView::contentsMouseDoubleClickEvent ( QMouseEvent *e )
897{ 912{
898 //qDebug("KListView::contentsMouseDoubleClickEvent"); 913 //qDebug("KListView::contentsMouseDoubleClickEvent");
899 // We don't want to call the parent method because it does setOpen, 914 // We don't want to call the parent method because it does setOpen,
900 // whereas we don't do it in single click mode... (David) 915 // whereas we don't do it in single click mode... (David)
901 //QListView::contentsMouseDoubleClickEvent( e ); 916 //QListView::contentsMouseDoubleClickEvent( e );
902 917
903 QPoint vp = contentsToViewport(e->pos()); 918 QPoint vp = contentsToViewport(e->pos());
904 QListViewItem *item = itemAt( vp ); 919 Q3ListViewItem *item = itemAt( vp );
905 emit QListView::doubleClicked( item ); // we do it now 920 emit Q3ListView::doubleClicked( item ); // we do it now
906 921
907 int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1; 922 int col = item ? header()->mapToLogical( header()->cellAt( vp.x() ) ) : -1;
908 923
909 if( item ) { 924 if( item ) {
910 //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked"); 925 //qDebug("KListView::contentsMouseDoubleClickEvent: emit doubleClicked");
911 926
912 emit doubleClicked( item, e->globalPos(), col ); 927 emit doubleClicked( item, e->globalPos(), col );
913 928
914 if( (e->button() == LeftButton) && !d->bUseSingle ) { 929 if( (e->button() == Qt::LeftButton) && !d->bUseSingle ) {
915 //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute"); 930 //qDebug("KListView::contentsMouseDoubleClickEvent: emitExecute");
916 931
917 emitExecute( e->button(), item, e->globalPos(), col); 932 emitExecute( e->button(), item, e->globalPos(), col);
918 } 933 }
919 } 934 }
920} 935}
921 936
922void KListView::slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ) 937void KListView::slotMouseButtonClicked( int btn, Q3ListViewItem *item, const QPoint &pos, int c )
923{ 938{
924 //qDebug("KListView::slotMouseButtonClicked"); 939 //qDebug("KListView::slotMouseButtonClicked");
925 940
926 if( (btn == LeftButton) && item ) { 941 if( (btn == Qt::LeftButton) && item ) {
927 //qDebug("KListView::slotMouseButtonClicked: emitExecute"); 942 //qDebug("KListView::slotMouseButtonClicked: emitExecute");
928 943
929 emitExecute(btn, item, pos, c); 944 emitExecute(btn, item, pos, c);
930 } 945 }
931} 946}
932 947
933void KListView::contentsDropEvent(QDropEvent* e) 948void KListView::contentsDropEvent(QDropEvent* e)
934{ 949{
935qDebug("KListView::contentsDropEvent drag&drop not supported yet"); 950qDebug("KListView::contentsDropEvent drag&drop not supported yet");
936/*US 951/*US
937 cleanDropVisualizer(); 952 cleanDropVisualizer();
938 cleanItemHighlighter(); 953 cleanItemHighlighter();
939 d->dragExpand.stop(); 954 d->dragExpand.stop();
940 955
941 if (acceptDrag (e)) 956 if (acceptDrag (e))
942 { 957 {
943 e->acceptAction(); 958 e->acceptAction();
944 QListViewItem *afterme; 959 QListViewItem *afterme;
945 QListViewItem *parent; 960 QListViewItem *parent;
946 findDrop(e->pos(), parent, afterme); 961 findDrop(e->pos(), parent, afterme);
947 962
948 if (e->source() == viewport() && itemsMovable()) 963 if (e->source() == viewport() && itemsMovable())
949 movableDropEvent(parent, afterme); 964 movableDropEvent(parent, afterme);
950 else 965 else
951 { 966 {
952 967
953 emit dropped(e, afterme); 968 emit dropped(e, afterme);
954 emit dropped(this, e, afterme); 969 emit dropped(this, e, afterme);
955 emit dropped(e, parent, afterme); 970 emit dropped(e, parent, afterme);
956 emit dropped(this, e, parent, afterme); 971 emit dropped(this, e, parent, afterme);
957 972
958 } 973 }
959 } 974 }
960*/ 975*/
961 976
962} 977}
963 978
964void KListView::movableDropEvent (QListViewItem* parent, QListViewItem* afterme) 979void KListView::movableDropEvent (Q3ListViewItem* parent, Q3ListViewItem* afterme)
965{ 980{
966 QPtrList<QListViewItem> items, afterFirsts, afterNows; 981 Q3PtrList<Q3ListViewItem> items, afterFirsts, afterNows;
967 QListViewItem *current=currentItem(); 982 Q3ListViewItem *current=currentItem();
968 bool hasMoved=false; 983 bool hasMoved=false;
969 for (QListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext) 984 for (Q3ListViewItem *i = firstChild(), *iNext=0; i != 0; i = iNext)
970 { 985 {
971 iNext=i->itemBelow(); 986 iNext=i->itemBelow();
972 if (!i->isSelected()) 987 if (!i->isSelected())
973 continue; 988 continue;
974 989
975 // don't drop an item after itself, or else 990 // don't drop an item after itself, or else
976 // it moves to the top of the list 991 // it moves to the top of the list
977 if (i==afterme) 992 if (i==afterme)
978 continue; 993 continue;
979 994
980 i->setSelected(false); 995 i->setSelected(false);
981 996
982 QListViewItem *afterFirst = i->itemAbove(); 997 Q3ListViewItem *afterFirst = i->itemAbove();
983 998
984 if (!hasMoved) 999 if (!hasMoved)
985 { 1000 {
986 emit aboutToMove(); 1001 emit aboutToMove();
987 hasMoved=true; 1002 hasMoved=true;
988 } 1003 }
989 1004
990 moveItem(i, parent, afterme); 1005 moveItem(i, parent, afterme);
991 1006
992 // ###### This should include the new parent !!! -> KDE 3.0 1007 // ###### This should include the new parent !!! -> KDE 3.0
993 // If you need this right now, have a look at keditbookmarks. 1008 // If you need this right now, have a look at keditbookmarks.
994 emit moved(i, afterFirst, afterme); 1009 emit moved(i, afterFirst, afterme);
995 1010
996 items.append (i); 1011 items.append (i);
997 afterFirsts.append (afterFirst); 1012 afterFirsts.append (afterFirst);
998 afterNows.append (afterme); 1013 afterNows.append (afterme);
999 1014
1000 afterme = i; 1015 afterme = i;
1001 } 1016 }
1002 clearSelection(); 1017 clearSelection();
1003 for (QListViewItem *i=items.first(); i != 0; i=items.next() ) 1018 for (Q3ListViewItem *i=items.first(); i != 0; i=items.next() )
1004 i->setSelected(true); 1019 i->setSelected(true);
1005 if (current) 1020 if (current)
1006 setCurrentItem(current); 1021 setCurrentItem(current);
1007 1022
1008 emit moved(items,afterFirsts,afterNows); 1023 emit moved(items,afterFirsts,afterNows);
1009 1024
1010 if (firstChild()) 1025 if (firstChild())
1011 emit moved(); 1026 emit moved();
1012} 1027}
1013 1028
1014void KListView::contentsDragMoveEvent(QDragMoveEvent *event) 1029void KListView::contentsDragMoveEvent(QDragMoveEvent *event)
1015{ 1030{
1016 qDebug("KListView::contentsDropEvent drag&drop not supported yet"); 1031 qDebug("KListView::contentsDropEvent drag&drop not supported yet");
1017/*US 1032/*US
1018 if (acceptDrag(event)) 1033 if (acceptDrag(event))
1019 { 1034 {
1020 event->acceptAction(); 1035 event->acceptAction();
1021 //Clean up the view 1036 //Clean up the view
1022 1037
1023 findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop); 1038 findDrop(event->pos(), d->parentItemDrop, d->afterItemDrop);
1024 QPoint vp = contentsToViewport( event->pos() ); 1039 QPoint vp = contentsToViewport( event->pos() );
1025 QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L; 1040 QListViewItem *item = isExecuteArea( vp ) ? itemAt( vp ) : 0L;
1026 1041
1027 if ( item != d->dragOverItem ) 1042 if ( item != d->dragOverItem )
1028 { 1043 {
1029 d->dragExpand.stop(); 1044 d->dragExpand.stop();
1030 d->dragOverItem = item; 1045 d->dragOverItem = item;
1031 d->dragOverPoint = vp; 1046 d->dragOverPoint = vp;
1032 if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() ) 1047 if ( d->dragOverItem && d->dragOverItem->isExpandable() && !d->dragOverItem->isOpen() )
1033 d->dragExpand.start( QApplication::startDragTime(), true ); 1048 d->dragExpand.start( QApplication::startDragTime(), true );
1034 } 1049 }
1035 if (dropVisualizer()) 1050 if (dropVisualizer())
1036 { 1051 {
1037 QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop); 1052 QRect tmpRect = drawDropVisualizer(0, d->parentItemDrop, d->afterItemDrop);
1038 if (tmpRect != d->mOldDropVisualizer) 1053 if (tmpRect != d->mOldDropVisualizer)
1039 { 1054 {
1040 cleanDropVisualizer(); 1055 cleanDropVisualizer();
1041 d->mOldDropVisualizer=tmpRect; 1056 d->mOldDropVisualizer=tmpRect;
1042 viewport()->repaint(tmpRect); 1057 viewport()->repaint(tmpRect);
1043 } 1058 }
1044 } 1059 }
1045 if (dropHighlighter()) 1060 if (dropHighlighter())
1046 { 1061 {
1047 QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop); 1062 QRect tmpRect = drawItemHighlighter(0, d->afterItemDrop);
1048 if (tmpRect != d->mOldDropHighlighter) 1063 if (tmpRect != d->mOldDropHighlighter)
1049 { 1064 {
1050 cleanItemHighlighter(); 1065 cleanItemHighlighter();
1051 d->mOldDropHighlighter=tmpRect; 1066 d->mOldDropHighlighter=tmpRect;
1052 viewport()->repaint(tmpRect); 1067 viewport()->repaint(tmpRect);
1053 } 1068 }
1054 } 1069 }
1055 } 1070 }
1056 else 1071 else
1057 event->ignore(); 1072 event->ignore();
1058*/ 1073*/
1059} 1074}
1060 1075
1061void KListView::slotDragExpand() 1076void KListView::slotDragExpand()
1062{ 1077{
1063 if ( itemAt( d->dragOverPoint ) == d->dragOverItem ) 1078 if ( itemAt( d->dragOverPoint ) == d->dragOverItem )
1064 d->dragOverItem->setOpen( true ); 1079 d->dragOverItem->setOpen( true );
1065} 1080}
1066 1081
1067void KListView::contentsDragLeaveEvent (QDragLeaveEvent*) 1082void KListView::contentsDragLeaveEvent (QDragLeaveEvent*)
1068{ 1083{
1069 d->dragExpand.stop(); 1084 d->dragExpand.stop();
1070 cleanDropVisualizer(); 1085 cleanDropVisualizer();
1071 cleanItemHighlighter(); 1086 cleanItemHighlighter();
1072} 1087}
1073 1088
1074void KListView::cleanDropVisualizer() 1089void KListView::cleanDropVisualizer()
1075{ 1090{
1076 if (d->mOldDropVisualizer.isValid()) 1091 if (d->mOldDropVisualizer.isValid())
1077 { 1092 {
1078 QRect rect=d->mOldDropVisualizer; 1093 QRect rect=d->mOldDropVisualizer;
1079 d->mOldDropVisualizer = QRect(); 1094 d->mOldDropVisualizer = QRect();
1080 viewport()->repaint(rect, true); 1095 viewport()->repaint(rect, true);
1081 } 1096 }
1082} 1097}
1083 1098
1084int KListView::depthToPixels( int depth ) 1099int KListView::depthToPixels( int depth )
1085{ 1100{
1086 return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin(); 1101 return treeStepSize() * ( depth + (rootIsDecorated() ? 1 : 0) ) + itemMargin();
1087} 1102}
1088 1103
1089void KListView::findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after) 1104void KListView::findDrop(const QPoint &pos, Q3ListViewItem *&parent, Q3ListViewItem *&after)
1090{ 1105{
1091 QPoint p (contentsToViewport(pos)); 1106 QPoint p (contentsToViewport(pos));
1092 1107
1093 // Get the position to put it in 1108 // Get the position to put it in
1094 QListViewItem *atpos = itemAt(p); 1109 Q3ListViewItem *atpos = itemAt(p);
1095 1110
1096 QListViewItem *above; 1111 Q3ListViewItem *above;
1097 if (!atpos) // put it at the end 1112 if (!atpos) // put it at the end
1098 above = lastItem(); 1113 above = lastItem();
1099 else 1114 else
1100 { 1115 {
1101 // Get the closest item before us ('atpos' or the one above, if any) 1116 // Get the closest item before us ('atpos' or the one above, if any)
1102 if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2)) 1117 if (p.y() - itemRect(atpos).topLeft().y() < (atpos->height()/2))
1103 above = atpos->itemAbove(); 1118 above = atpos->itemAbove();
1104 else 1119 else
1105 above = atpos; 1120 above = atpos;
1106 } 1121 }
1107 1122
1108 if (above) 1123 if (above)
1109 { 1124 {
1110 // Now, we know we want to go after "above". But as a child or as a sibling ? 1125 // Now, we know we want to go after "above". But as a child or as a sibling ?
1111 // We have to ask the "above" item if it accepts children. 1126 // We have to ask the "above" item if it accepts children.
1112 if (above->isExpandable()) 1127 if (above->isExpandable())
1113 { 1128 {
1114 // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children 1129 // The mouse is sufficiently on the right ? - doesn't matter if 'above' has visible children
1115 if (p.x() >= depthToPixels( above->depth() + 1 ) || 1130 if (p.x() >= depthToPixels( above->depth() + 1 ) ||
1116 (above->isOpen() && above->childCount() > 0) ) 1131 (above->isOpen() && above->childCount() > 0) )
1117 { 1132 {
1118 parent = above; 1133 parent = above;
1119 after = 0L; 1134 after = 0L;
1120 return; 1135 return;
1121 } 1136 }
1122 } 1137 }
1123 1138
1124 // Ok, there's one more level of complexity. We may want to become a new 1139 // Ok, there's one more level of complexity. We may want to become a new
1125 // sibling, but of an upper-level group, rather than the "above" item 1140 // sibling, but of an upper-level group, rather than the "above" item
1126 QListViewItem * betterAbove = above->parent(); 1141 Q3ListViewItem * betterAbove = above->parent();
1127 QListViewItem * last = above; 1142 Q3ListViewItem * last = above;
1128 while ( betterAbove ) 1143 while ( betterAbove )
1129 { 1144 {
1130 // We are allowed to become a sibling of "betterAbove" only if we are 1145 // We are allowed to become a sibling of "betterAbove" only if we are
1131 // after its last child 1146 // after its last child
1132 if ( last->nextSibling() == 0 ) 1147 if ( last->nextSibling() == 0 )
1133 { 1148 {
1134 if (p.x() < depthToPixels ( betterAbove->depth() + 1 )) 1149 if (p.x() < depthToPixels ( betterAbove->depth() + 1 ))
1135 above = betterAbove; // store this one, but don't stop yet, there may be a better one 1150 above = betterAbove; // store this one, but don't stop yet, there may be a better one
1136 else 1151 else
1137 break; // not enough on the left, so stop 1152 break; // not enough on the left, so stop
1138 last = betterAbove; 1153 last = betterAbove;
1139 betterAbove = betterAbove->parent(); // up one level 1154 betterAbove = betterAbove->parent(); // up one level
1140 } else 1155 } else
1141 break; // we're among the child of betterAbove, not after the last one 1156 break; // we're among the child of betterAbove, not after the last one
1142 } 1157 }
1143 } 1158 }
1144 // set as sibling 1159 // set as sibling
1145 after = above; 1160 after = above;
1146 parent = after ? after->parent() : 0L ; 1161 parent = after ? after->parent() : 0L ;
1147} 1162}
1148 1163
1149QListViewItem* KListView::lastChild () const 1164Q3ListViewItem* KListView::lastChild () const
1150{ 1165{
1151 QListViewItem* lastchild = firstChild(); 1166 Q3ListViewItem* lastchild = firstChild();
1152 1167
1153 if (lastchild) 1168 if (lastchild)
1154 for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling()); 1169 for (; lastchild->nextSibling(); lastchild = lastchild->nextSibling());
1155 1170
1156 return lastchild; 1171 return lastchild;
1157} 1172}
1158 1173
1159QListViewItem *KListView::lastItem() const 1174Q3ListViewItem *KListView::lastItem() const
1160{ 1175{
1161 QListViewItem* last = lastChild(); 1176 Q3ListViewItem* last = lastChild();
1162 1177
1163 for (QListViewItemIterator it (last); it.current(); ++it) 1178 for (Q3ListViewItemIterator it (last); it.current(); ++it)
1164 last = it.current(); 1179 last = it.current();
1165 1180
1166 return last; 1181 return last;
1167} 1182}
1168 1183
1169KLineEdit *KListView::renameLineEdit() const 1184KLineEdit *KListView::renameLineEdit() const
1170{ 1185{
1171//US return d->editor; 1186//US return d->editor;
1172qDebug("KListView::renameLineEdit returns 0. Might crash"); 1187qDebug("KListView::renameLineEdit returns 0. Might crash");
1173return 0; 1188return 0;
1174} 1189}
1175 1190
1176void KListView::startDrag() 1191void KListView::startDrag()
1177{ 1192{
1178qDebug("KListView::startDrag drag&drop not supported yet."); 1193qDebug("KListView::startDrag drag&drop not supported yet.");
1179/*US 1194/*US
1180 QDragObject *drag = dragObject(); 1195 QDragObject *drag = dragObject();
1181 1196
1182 if (!drag) 1197 if (!drag)
1183 return; 1198 return;
1184 1199
1185 if (drag->drag() && drag->target() != viewport()) 1200 if (drag->drag() && drag->target() != viewport())
1186 emit moved(); 1201 emit moved();
1187*/ 1202*/
1188} 1203}
1189 1204
1190QDragObject *KListView::dragObject() 1205Q3DragObject *KListView::dragObject()
1191{ 1206{
1192 if (!currentItem()) 1207 if (!currentItem())
1193 return 0; 1208 return 0;
1194 1209
1195 return new QStoredDrag("application/x-qlistviewitem", viewport()); 1210 return new Q3StoredDrag("application/x-qlistviewitem", viewport());
1196} 1211}
1197 1212
1198void KListView::setItemsMovable(bool b) 1213void KListView::setItemsMovable(bool b)
1199{ 1214{
1200 d->itemsMovable=b; 1215 d->itemsMovable=b;
1201} 1216}
1202 1217
1203bool KListView::itemsMovable() const 1218bool KListView::itemsMovable() const
1204{ 1219{
1205 return d->itemsMovable; 1220 return d->itemsMovable;
1206} 1221}
1207 1222
1208void KListView::setItemsRenameable(bool b) 1223void KListView::setItemsRenameable(bool b)
1209{ 1224{
1210 d->itemsRenameable=b; 1225 d->itemsRenameable=b;
1211} 1226}
1212 1227
1213bool KListView::itemsRenameable() const 1228bool KListView::itemsRenameable() const
1214{ 1229{
1215 return d->itemsRenameable; 1230 return d->itemsRenameable;
1216} 1231}
1217 1232
1218 1233
1219void KListView::setDragEnabled(bool b) 1234void KListView::setDragEnabled(bool b)
1220{ 1235{
1221 d->dragEnabled=b; 1236 d->dragEnabled=b;
1222} 1237}
1223 1238
1224bool KListView::dragEnabled() const 1239bool KListView::dragEnabled() const
1225{ 1240{
1226 return d->dragEnabled; 1241 return d->dragEnabled;
1227} 1242}
1228 1243
1229void KListView::setAutoOpen(bool b) 1244void KListView::setAutoOpen(bool b)
1230{ 1245{
1231 d->autoOpen=b; 1246 d->autoOpen=b;
1232} 1247}
1233 1248
1234bool KListView::autoOpen() const 1249bool KListView::autoOpen() const
1235{ 1250{
1236 return d->autoOpen; 1251 return d->autoOpen;
1237} 1252}
1238 1253
1239bool KListView::dropVisualizer() const 1254bool KListView::dropVisualizer() const
1240{ 1255{
1241 return d->dropVisualizer; 1256 return d->dropVisualizer;
1242} 1257}
1243 1258
1244void KListView::setDropVisualizer(bool b) 1259void KListView::setDropVisualizer(bool b)
1245{ 1260{
1246 d->dropVisualizer=b; 1261 d->dropVisualizer=b;
1247} 1262}
1248 1263
1249QPtrList<QListViewItem> KListView::selectedItems() const 1264Q3PtrList<Q3ListViewItem> KListView::selectedItems() const
1250{ 1265{
1251 QPtrList<QListViewItem> list; 1266 Q3PtrList<Q3ListViewItem> list;
1252 for (QListViewItem *i=firstChild(); i!=0; i=i->itemBelow()) 1267 for (Q3ListViewItem *i=firstChild(); i!=0; i=i->itemBelow())
1253 if (i->isSelected()) list.append(i); 1268 if (i->isSelected()) list.append(i);
1254 return list; 1269 return list;
1255} 1270}
1256 1271
1257 1272
1258void KListView::moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after) 1273void KListView::moveItem(Q3ListViewItem *item, Q3ListViewItem *parent, Q3ListViewItem *after)
1259{ 1274{
1260 // sanity check - don't move a item into it's own child structure 1275 // sanity check - don't move a item into it's own child structure
1261 QListViewItem *i = parent; 1276 Q3ListViewItem *i = parent;
1262 while(i) 1277 while(i)
1263 { 1278 {
1264 if(i == item) 1279 if(i == item)
1265 return; 1280 return;
1266 i = i->parent(); 1281 i = i->parent();
1267 } 1282 }
1268 1283
1269 // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor 1284 // Basically reimplementing the QListViewItem(QListViewItem*, QListViewItem*) constructor
1270 // in here, without ever deleting the item. 1285 // in here, without ever deleting the item.
1271 if (item->parent()) 1286 if (item->parent())
1272 item->parent()->takeItem(item); 1287 item->parent()->takeItem(item);
1273 else 1288 else
1274 takeItem(item); 1289 takeItem(item);
1275 1290
1276 if (parent) 1291 if (parent)
1277 parent->insertItem(item); 1292 parent->insertItem(item);
1278 else 1293 else
1279 insertItem(item); 1294 insertItem(item);
1280 1295
1281 if (after) 1296 if (after)
1282 ;//item->moveToJustAfter(after); 1297 ;//item->moveToJustAfter(after);
1283} 1298}
1284 1299
1285void KListView::contentsDragEnterEvent(QDragEnterEvent *event) 1300void KListView::contentsDragEnterEvent(QDragEnterEvent *event)
1286{ 1301{
1287qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet."); 1302qDebug("KListView::contentsDragEnterEvent drag&drop not supported yet.");
1288/*US 1303/*US
1289 if (acceptDrag (event)) 1304 if (acceptDrag (event))
1290 event->accept(); 1305 event->accept();
1291*/ 1306*/
1292} 1307}
1293 1308
1294void KListView::setDropVisualizerWidth (int w) 1309void KListView::setDropVisualizerWidth (int w)
1295{ 1310{
1296 d->mDropVisualizerWidth = w > 0 ? w : 1; 1311 d->mDropVisualizerWidth = w > 0 ? w : 1;
1297} 1312}
1298 1313
1299QRect KListView::drawDropVisualizer(QPainter *p, QListViewItem *parent, 1314QRect KListView::drawDropVisualizer(QPainter *p, Q3ListViewItem *parent,
1300 QListViewItem *after) 1315 Q3ListViewItem *after)
1301{ 1316{
1302 QRect insertmarker; 1317 QRect insertmarker;
1303 1318
1304 if (!after && !parent) 1319 if (!after && !parent)
1305 insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2); 1320 insertmarker = QRect (0, 0, viewport()->width(), d->mDropVisualizerWidth/2);
1306 else 1321 else
1307 { 1322 {
1308 int level = 0; 1323 int level = 0;
1309 if (after) 1324 if (after)
1310 { 1325 {
1311 QListViewItem* it = 0L; 1326 Q3ListViewItem* it = 0L;
1312 if (after->isOpen()) 1327 if (after->isOpen())
1313 { 1328 {
1314 // Look for the last child (recursively) 1329 // Look for the last child (recursively)
1315 it = after->firstChild(); 1330 it = after->firstChild();
1316 if (it) 1331 if (it)
1317 while (it->nextSibling() || it->firstChild()) 1332 while (it->nextSibling() || it->firstChild())
1318 if ( it->nextSibling() ) 1333 if ( it->nextSibling() )
1319 it = it->nextSibling(); 1334 it = it->nextSibling();
1320 else 1335 else
1321 it = it->firstChild(); 1336 it = it->firstChild();
1322 } 1337 }
1323 1338
1324 insertmarker = itemRect (it ? it : after); 1339 insertmarker = itemRect (it ? it : after);
1325 level = after->depth(); 1340 level = after->depth();
1326 } 1341 }
1327 else if (parent) 1342 else if (parent)
1328 { 1343 {
1329 insertmarker = itemRect (parent); 1344 insertmarker = itemRect (parent);
1330 level = parent->depth() + 1; 1345 level = parent->depth() + 1;
1331 } 1346 }
1332 insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() ); 1347 insertmarker.setLeft( treeStepSize() * ( level + (rootIsDecorated() ? 1 : 0) ) + itemMargin() );
1333 insertmarker.setRight (viewport()->width()); 1348 insertmarker.setRight (viewport()->width());
1334 insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1); 1349 insertmarker.setTop (insertmarker.bottom() - d->mDropVisualizerWidth/2 + 1);
1335 insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2); 1350 insertmarker.setBottom (insertmarker.bottom() + d->mDropVisualizerWidth/2);
1336 } 1351 }
1337 1352
1338 // This is not used anymore, at least by KListView itself (see viewportPaintEvent) 1353 // This is not used anymore, at least by KListView itself (see viewportPaintEvent)
1339 // Remove for KDE 3.0. 1354 // Remove for KDE 3.0.
1340 if (p) 1355 if (p)
1341 p->fillRect(insertmarker, Dense4Pattern); 1356 p->fillRect(insertmarker, Qt::Dense4Pattern);
1342 1357
1343 return insertmarker; 1358 return insertmarker;
1344} 1359}
1345 1360
1346QRect KListView::drawItemHighlighter(QPainter *painter, QListViewItem *item) 1361QRect KListView::drawItemHighlighter(QPainter *painter, Q3ListViewItem *item)
1347{ 1362{
1348 QRect r; 1363 QRect r;
1349 1364
1350 if (item) 1365 if (item)
1351 { 1366 {
1352 r = itemRect(item); 1367 r = itemRect(item);
1353 r.setLeft(r.left()+(item->depth()+1)*treeStepSize()); 1368 r.setLeft(r.left()+(item->depth()+1)*treeStepSize());
1354 if (painter) { 1369 if (painter) {
1355//US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(), 1370//US style().drawPrimitive(QStyle::PE_FocusRect, painter, r, colorGroup(),
1356//US QStyle::Style_FocusAtBorder, colorGroup().highlight()); 1371//US QStyle::Style_FocusAtBorder, colorGroup().highlight());
1357 const QColor* pHighl = &(colorGroup().highlight()); 1372 const QColor* pHighl = &(colorGroup().highlight());
1358 //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true); 1373 //LR style().drawFocusRect(painter, r, colorGroup(), pHighl, true);
1359 1374
1360qDebug("KListView::drawItemHighlighter has to be verified"); 1375qDebug("KListView::drawItemHighlighter has to be verified");
1361 1376
1362 } 1377 }
1363 1378
1364 } 1379 }
1365 1380
1366 return r; 1381 return r;
1367} 1382}
1368 1383
1369void KListView::cleanItemHighlighter () 1384void KListView::cleanItemHighlighter ()
1370{ 1385{
1371 if (d->mOldDropHighlighter.isValid()) 1386 if (d->mOldDropHighlighter.isValid())
1372 { 1387 {
1373 QRect rect=d->mOldDropHighlighter; 1388 QRect rect=d->mOldDropHighlighter;
1374 d->mOldDropHighlighter = QRect(); 1389 d->mOldDropHighlighter = QRect();
1375 viewport()->repaint(rect, true); 1390 viewport()->repaint(rect, true);
1376 } 1391 }
1377} 1392}
1378 1393
1379void KListView::rename(QListViewItem *item, int c) 1394void KListView::rename(Q3ListViewItem *item, int c)
1380{ 1395{
1381 if (d->renameable.contains(c)) 1396 if (d->renameable.contains(c))
1382 { 1397 {
1383 ensureItemVisible(item); 1398 ensureItemVisible(item);
1384//US d->editor->load(item,c); 1399//US d->editor->load(item,c);
1385qDebug("KListView::rename has to be verified"); 1400qDebug("KListView::rename has to be verified");
1386 1401
1387 } 1402 }
1388} 1403}
1389 1404
1390bool KListView::isRenameable (int col) const 1405bool KListView::isRenameable (int col) const
1391{ 1406{
1392 return d->renameable.contains(col); 1407 return d->renameable.contains(col);
1393} 1408}
1394 1409
1395void KListView::setRenameable (int col, bool yesno) 1410void KListView::setRenameable (int col, bool yesno)
1396{ 1411{
1397 if (col>=header()->count()) return; 1412 if (col>=header()->count()) return;
1398 1413
1399 d->renameable.remove(col); 1414 d->renameable.remove(col);
1400 if (yesno && d->renameable.find(col)==d->renameable.end()) 1415 if (yesno && d->renameable.find(col)==d->renameable.end())
1401 d->renameable+=col; 1416 d->renameable+=col;
1402 else if (!yesno && d->renameable.find(col)!=d->renameable.end()) 1417 else if (!yesno && d->renameable.find(col)!=d->renameable.end())
1403 d->renameable.remove(col); 1418 d->renameable.remove(col);
1404} 1419}
1405 1420
1406void KListView::doneEditing(QListViewItem *item, int row) 1421void KListView::doneEditing(Q3ListViewItem *item, int row)
1407{ 1422{
1408 emit itemRenamed(item, item->text(row), row); 1423 emit itemRenamed(item, item->text(row), row);
1409 emit itemRenamed(item); 1424 emit itemRenamed(item);
1410} 1425}
1411 1426
1412bool KListView::acceptDrag(QDropEvent* e) const 1427bool KListView::acceptDrag(QDropEvent* e) const
1413{ 1428{
1414qDebug("KListView::acceptDrag drag&drop not supported yet"); 1429qDebug("KListView::acceptDrag drag&drop not supported yet");
1415//US return acceptDrops() && itemsMovable() && (e->source()==viewport()); 1430//US return acceptDrops() && itemsMovable() && (e->source()==viewport());
1416return false; 1431return false;
1417} 1432}
1418 1433
1419void KListView::setCreateChildren(bool b) 1434void KListView::setCreateChildren(bool b)
1420{ 1435{
1421 d->createChildren=b; 1436 d->createChildren=b;
1422} 1437}
1423 1438
1424bool KListView::createChildren() const 1439bool KListView::createChildren() const
1425{ 1440{
1426 return d->createChildren; 1441 return d->createChildren;
1427} 1442}
1428 1443
1429 1444
1430int KListView::tooltipColumn() const 1445int KListView::tooltipColumn() const
1431{ 1446{
1432 return d->tooltipColumn; 1447 return d->tooltipColumn;
1433} 1448}
1434 1449
1435void KListView::setTooltipColumn(int column) 1450void KListView::setTooltipColumn(int column)
1436{ 1451{
1437 d->tooltipColumn=column; 1452 d->tooltipColumn=column;
1438} 1453}
1439 1454
1440void KListView::setDropHighlighter(bool b) 1455void KListView::setDropHighlighter(bool b)
1441{ 1456{
1442 d->dropHighlighter=b; 1457 d->dropHighlighter=b;
1443} 1458}
1444 1459
1445bool KListView::dropHighlighter() const 1460bool KListView::dropHighlighter() const
1446{ 1461{
1447 return d->dropHighlighter; 1462 return d->dropHighlighter;
1448} 1463}
1449 1464
1450bool KListView::showTooltip(QListViewItem *item, const QPoint &, int column) const 1465bool KListView::showTooltip(Q3ListViewItem *item, const QPoint &, int column) const
1451{ 1466{
1452 return ((tooltip(item, column).length()>0) && (column==tooltipColumn())); 1467 return ((tooltip(item, column).length()>0) && (column==tooltipColumn()));
1453} 1468}
1454 1469
1455QString KListView::tooltip(QListViewItem *item, int column) const 1470QString KListView::tooltip(Q3ListViewItem *item, int column) const
1456{ 1471{
1457 return item->text(column); 1472 return item->text(column);
1458} 1473}
1459 1474
1460void KListView::setTabOrderedRenaming(bool b) 1475void KListView::setTabOrderedRenaming(bool b)
1461{ 1476{
1462 d->tabRename = b; 1477 d->tabRename = b;
1463} 1478}
1464 1479
1465bool KListView::tabOrderedRenaming() const 1480bool KListView::tabOrderedRenaming() const
1466{ 1481{
1467 return d->tabRename; 1482 return d->tabRename;
1468} 1483}
1469 1484
1470void KListView::keyPressEvent (QKeyEvent* e) 1485void KListView::keyPressEvent (QKeyEvent* e)
1471{ 1486{
1472 //don't we need a contextMenuModifier too ? (aleXXX) 1487 //don't we need a contextMenuModifier too ? (aleXXX)
1473 if (e->key() == d->contextMenuKey) 1488 if (e->key() == d->contextMenuKey)
1474 { 1489 {
1475 emit menuShortCutPressed (this, currentItem()); 1490 emit menuShortCutPressed (this, currentItem());
1476 return; 1491 return;
1477 } 1492 }
1478 if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace) 1493 if (e->key() == Qt::Key_Delete || e->key() == Qt::Key_Backspace)
1479 { 1494 {
1480 emit signalDelete ( ); 1495 emit signalDelete ( );
1481 return; 1496 return;
1482 } 1497 }
1483 1498
1484 if (d->selectionMode != FileManager) 1499 if (d->selectionMode != FileManager)
1485 QListView::keyPressEvent (e); 1500 Q3ListView::keyPressEvent (e);
1486 else 1501 else
1487 fileManagerKeyPressEvent (e); 1502 fileManagerKeyPressEvent (e);
1488} 1503}
1489 1504
1490void KListView::activateAutomaticSelection() 1505void KListView::activateAutomaticSelection()
1491{ 1506{
1492 d->selectedBySimpleMove=true; 1507 d->selectedBySimpleMove=true;
1493 d->selectedUsingMouse=false; 1508 d->selectedUsingMouse=false;
1494 if (currentItem()!=0) 1509 if (currentItem()!=0)
1495 { 1510 {
1496 selectAll(false); 1511 selectAll(false);
1497 currentItem()->setSelected(true); 1512 currentItem()->setSelected(true);
1498 currentItem()->repaint(); 1513 currentItem()->repaint();
1499 emit selectionChanged(); 1514 emit selectionChanged();
1500 }; 1515 };
1501} 1516}
1502 1517
1503void KListView::deactivateAutomaticSelection() 1518void KListView::deactivateAutomaticSelection()
1504{ 1519{
1505 d->selectedBySimpleMove=false; 1520 d->selectedBySimpleMove=false;
1506} 1521}
1507 1522
1508bool KListView::automaticSelection() const 1523bool KListView::automaticSelection() const
1509{ 1524{
1510 return d->selectedBySimpleMove; 1525 return d->selectedBySimpleMove;
1511} 1526}
1512 1527
1513void KListView::fileManagerKeyPressEvent (QKeyEvent* e) 1528void KListView::fileManagerKeyPressEvent (QKeyEvent* e)
1514{ 1529{
1515 //don't care whether it's on the keypad or not 1530 //don't care whether it's on the keypad or not
1516 int e_state=(e->state() & ~Keypad); 1531 int e_state=(e->state() & ~Qt::Keypad);
1517 1532
1518 int oldSelectionDirection(d->selectionDirection); 1533 int oldSelectionDirection(d->selectionDirection);
1519 1534
1520 if ((e->key()!=Key_Shift) && (e->key()!=Key_Control) 1535 if ((e->key()!=Qt::Key_Shift) && (e->key()!=Qt::Key_Control)
1521 && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)) 1536 && (e->key()!=Qt::Key_Meta) && (e->key()!=Qt::Key_Alt))
1522 { 1537 {
1523 if ((e_state==ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove)) 1538 if ((e_state==Qt::ShiftButton) && (!d->wasShiftEvent) && (!d->selectedBySimpleMove))
1524 selectAll(FALSE); 1539 selectAll(FALSE);
1525 d->selectionDirection=0; 1540 d->selectionDirection=0;
1526 d->wasShiftEvent = (e_state == ShiftButton); 1541 d->wasShiftEvent = (e_state == Qt::ShiftButton);
1527 }; 1542 };
1528 1543
1529 //d->wasShiftEvent = (e_state == ShiftButton); 1544 //d->wasShiftEvent = (e_state == Qt::ShiftButton);
1530 1545
1531 1546
1532 QListViewItem* item = currentItem(); 1547 Q3ListViewItem* item = currentItem();
1533 if (item==0) return; 1548 if (item==0) return;
1534 1549
1535 QListViewItem* repaintItem1 = item; 1550 Q3ListViewItem* repaintItem1 = item;
1536 QListViewItem* repaintItem2 = 0L; 1551 Q3ListViewItem* repaintItem2 = 0L;
1537 QListViewItem* visItem = 0L; 1552 Q3ListViewItem* visItem = 0L;
1538 1553
1539 QListViewItem* nextItem = 0L; 1554 Q3ListViewItem* nextItem = 0L;
1540 int items = 0; 1555 int items = 0;
1541 1556
1542 bool shiftOrCtrl((e_state==ControlButton) || (e_state==ShiftButton)); 1557 bool shiftOrCtrl((e_state==Qt::ControlButton) || (e_state==Qt::ShiftButton));
1543 int selectedItems(0); 1558 int selectedItems(0);
1544 for (QListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling()) 1559 for (Q3ListViewItem *tmpItem=firstChild(); tmpItem!=0; tmpItem=tmpItem->nextSibling())
1545 if (tmpItem->isSelected()) selectedItems++; 1560 if (tmpItem->isSelected()) selectedItems++;
1546 1561
1547 if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse))) 1562 if (((selectedItems==0) || ((selectedItems==1) && (d->selectedUsingMouse)))
1548 && (e_state==NoButton) 1563 && (e_state==Qt::NoButton)
1549 && ((e->key()==Key_Down) 1564 && ((e->key()==Qt::Key_Down)
1550 || (e->key()==Key_Up) 1565 || (e->key()==Qt::Key_Up)
1551 || (e->key()==Key_Next) 1566 || (e->key()==Qt::Key_Next)
1552 || (e->key()==Key_Prior) 1567 || (e->key()==Qt::Key_Prior)
1553 || (e->key()==Key_Home) 1568 || (e->key()==Qt::Key_Home)
1554 || (e->key()==Key_End))) 1569 || (e->key()==Qt::Key_End)))
1555 { 1570 {
1556 d->selectedBySimpleMove=true; 1571 d->selectedBySimpleMove=true;
1557 d->selectedUsingMouse=false; 1572 d->selectedUsingMouse=false;
1558 } 1573 }
1559 else if (selectedItems>1) 1574 else if (selectedItems>1)
1560 d->selectedBySimpleMove=false; 1575 d->selectedBySimpleMove=false;
1561 1576
1562 bool emitSelectionChanged(false); 1577 bool emitSelectionChanged(false);
1563 1578
1564 switch (e->key()) 1579 switch (e->key())
1565 { 1580 {
1566 case Key_Escape: 1581 case Qt::Key_Escape:
1567 selectAll(FALSE); 1582 selectAll(FALSE);
1568 emitSelectionChanged=TRUE; 1583 emitSelectionChanged=TRUE;
1569 break; 1584 break;
1570 1585
1571 case Key_Space: 1586 case Qt::Key_Space:
1572 //toggle selection of current item 1587 //toggle selection of current item
1573 if (d->selectedBySimpleMove) 1588 if (d->selectedBySimpleMove)
1574 d->selectedBySimpleMove=false; 1589 d->selectedBySimpleMove=false;
1575 item->setSelected(!item->isSelected()); 1590 item->setSelected(!item->isSelected());
1576 emitSelectionChanged=TRUE; 1591 emitSelectionChanged=TRUE;
1577 break; 1592 break;
1578 1593
1579 case Key_Insert: 1594 case Qt::Key_Insert:
1580 //toggle selection of current item and move to the next item 1595 //toggle selection of current item and move to the next item
1581 if (d->selectedBySimpleMove) 1596 if (d->selectedBySimpleMove)
1582 { 1597 {
1583 d->selectedBySimpleMove=false; 1598 d->selectedBySimpleMove=false;
1584 if (!item->isSelected()) item->setSelected(TRUE); 1599 if (!item->isSelected()) item->setSelected(TRUE);
1585 } 1600 }
1586 else 1601 else
1587 { 1602 {
1588 item->setSelected(!item->isSelected()); 1603 item->setSelected(!item->isSelected());
1589 }; 1604 };
1590 1605
1591 nextItem=item->itemBelow(); 1606 nextItem=item->itemBelow();
1592 1607
1593 if (nextItem!=0) 1608 if (nextItem!=0)
1594 { 1609 {
1595 repaintItem2=nextItem; 1610 repaintItem2=nextItem;
1596 visItem=nextItem; 1611 visItem=nextItem;
1597 setCurrentItem(nextItem); 1612 setCurrentItem(nextItem);
1598 }; 1613 };
1599 d->selectionDirection=1; 1614 d->selectionDirection=1;
1600 emitSelectionChanged=TRUE; 1615 emitSelectionChanged=TRUE;
1601 break; 1616 break;
1602 1617
1603 case Key_Down: 1618 case Qt::Key_Down:
1604 nextItem=item->itemBelow(); 1619 nextItem=item->itemBelow();
1605 //toggle selection of current item and move to the next item 1620 //toggle selection of current item and move to the next item
1606 if (shiftOrCtrl) 1621 if (shiftOrCtrl)
1607 { 1622 {
1608 d->selectionDirection=1; 1623 d->selectionDirection=1;
1609 if (d->selectedBySimpleMove) 1624 if (d->selectedBySimpleMove)
1610 d->selectedBySimpleMove=false; 1625 d->selectedBySimpleMove=false;
1611 else 1626 else
1612 { 1627 {
1613 if (oldSelectionDirection!=-1) 1628 if (oldSelectionDirection!=-1)
1614 { 1629 {
1615 item->setSelected(!item->isSelected()); 1630 item->setSelected(!item->isSelected());
1616 emitSelectionChanged=TRUE; 1631 emitSelectionChanged=TRUE;
1617 }; 1632 };
1618 }; 1633 };
1619 } 1634 }
1620 else if ((d->selectedBySimpleMove) && (nextItem!=0)) 1635 else if ((d->selectedBySimpleMove) && (nextItem!=0))
1621 { 1636 {
1622 item->setSelected(false); 1637 item->setSelected(false);
1623 emitSelectionChanged=TRUE; 1638 emitSelectionChanged=TRUE;
1624 }; 1639 };
1625 1640
1626 if (nextItem!=0) 1641 if (nextItem!=0)
1627 { 1642 {
1628 if (d->selectedBySimpleMove) 1643 if (d->selectedBySimpleMove)
1629 nextItem->setSelected(true); 1644 nextItem->setSelected(true);
1630 repaintItem2=nextItem; 1645 repaintItem2=nextItem;
1631 visItem=nextItem; 1646 visItem=nextItem;
1632 setCurrentItem(nextItem); 1647 setCurrentItem(nextItem);
1633 }; 1648 };
1634 break; 1649 break;
1635 1650
1636 case Key_Up: 1651 case Qt::Key_Up:
1637 nextItem=item->itemAbove(); 1652 nextItem=item->itemAbove();
1638 d->selectionDirection=-1; 1653 d->selectionDirection=-1;
1639 //move to the prev. item and toggle selection of this one 1654 //move to the prev. item and toggle selection of this one
1640 // => No, can't select the last item, with this. For symmetry, let's 1655 // => No, can't select the last item, with this. For symmetry, let's
1641 // toggle selection and THEN move up, just like we do in down (David) 1656 // toggle selection and THEN move up, just like we do in down (David)
1642 if (shiftOrCtrl) 1657 if (shiftOrCtrl)
1643 { 1658 {
1644 if (d->selectedBySimpleMove) 1659 if (d->selectedBySimpleMove)
1645 d->selectedBySimpleMove=false; 1660 d->selectedBySimpleMove=false;
1646 else 1661 else
1647 { 1662 {
1648 if (oldSelectionDirection!=1) 1663 if (oldSelectionDirection!=1)
1649 { 1664 {
1650 item->setSelected(!item->isSelected()); 1665 item->setSelected(!item->isSelected());
1651 emitSelectionChanged=TRUE; 1666 emitSelectionChanged=TRUE;
1652 }; 1667 };
1653 } 1668 }
1654 } 1669 }
1655 else if ((d->selectedBySimpleMove) && (nextItem!=0)) 1670 else if ((d->selectedBySimpleMove) && (nextItem!=0))
1656 { 1671 {
1657 item->setSelected(false); 1672 item->setSelected(false);
1658 emitSelectionChanged=TRUE; 1673 emitSelectionChanged=TRUE;
1659 }; 1674 };
1660 1675
1661 if (nextItem!=0) 1676 if (nextItem!=0)
1662 { 1677 {
1663 if (d->selectedBySimpleMove) 1678 if (d->selectedBySimpleMove)
1664 nextItem->setSelected(true); 1679 nextItem->setSelected(true);
1665 repaintItem2=nextItem; 1680 repaintItem2=nextItem;
1666 visItem=nextItem; 1681 visItem=nextItem;
1667 setCurrentItem(nextItem); 1682 setCurrentItem(nextItem);
1668 }; 1683 };
1669 break; 1684 break;
1670 1685
1671 case Key_End: 1686 case Qt::Key_End:
1672 //move to the last item and toggle selection of all items inbetween 1687 //move to the last item and toggle selection of all items inbetween
1673 nextItem=item; 1688 nextItem=item;
1674 if (d->selectedBySimpleMove) 1689 if (d->selectedBySimpleMove)
1675 item->setSelected(false); 1690 item->setSelected(false);
1676 if (shiftOrCtrl) 1691 if (shiftOrCtrl)
1677 d->selectedBySimpleMove=false; 1692 d->selectedBySimpleMove=false;
1678 1693
1679 while(nextItem!=0) 1694 while(nextItem!=0)
1680 { 1695 {
1681 if (shiftOrCtrl) 1696 if (shiftOrCtrl)
1682 nextItem->setSelected(!nextItem->isSelected()); 1697 nextItem->setSelected(!nextItem->isSelected());
1683 if (nextItem->itemBelow()==0) 1698 if (nextItem->itemBelow()==0)
1684 { 1699 {
1685 if (d->selectedBySimpleMove) 1700 if (d->selectedBySimpleMove)
1686 nextItem->setSelected(true); 1701 nextItem->setSelected(true);
1687 repaintItem2=nextItem; 1702 repaintItem2=nextItem;
1688 visItem=nextItem; 1703 visItem=nextItem;
1689 setCurrentItem(nextItem); 1704 setCurrentItem(nextItem);
1690 } 1705 }
1691 nextItem=nextItem->itemBelow(); 1706 nextItem=nextItem->itemBelow();
1692 } 1707 }
1693 emitSelectionChanged=TRUE; 1708 emitSelectionChanged=TRUE;
1694 break; 1709 break;
1695 1710
1696 case Key_Home: 1711 case Qt::Key_Home:
1697 // move to the first item and toggle selection of all items inbetween 1712 // move to the first item and toggle selection of all items inbetween
1698 nextItem = firstChild(); 1713 nextItem = firstChild();
1699 visItem = nextItem; 1714 visItem = nextItem;
1700 repaintItem2 = visItem; 1715 repaintItem2 = visItem;
1701 if (d->selectedBySimpleMove) 1716 if (d->selectedBySimpleMove)
1702 item->setSelected(false); 1717 item->setSelected(false);
1703 if (shiftOrCtrl) 1718 if (shiftOrCtrl)
1704 { 1719 {
1705 d->selectedBySimpleMove=false; 1720 d->selectedBySimpleMove=false;
1706 1721
1707 while ( nextItem != item ) 1722 while ( nextItem != item )
1708 { 1723 {
1709 nextItem->setSelected( !nextItem->isSelected() ); 1724 nextItem->setSelected( !nextItem->isSelected() );
1710 nextItem = nextItem->itemBelow(); 1725 nextItem = nextItem->itemBelow();
1711 } 1726 }
1712 item->setSelected( !item->isSelected() ); 1727 item->setSelected( !item->isSelected() );
1713 } 1728 }
1714 setCurrentItem( firstChild() ); 1729 setCurrentItem( firstChild() );
1715 emitSelectionChanged=TRUE; 1730 emitSelectionChanged=TRUE;
1716 break; 1731 break;
1717 1732
1718 case Key_Next: 1733 case Qt::Key_Next:
1719 items=visibleHeight()/item->height(); 1734 items=visibleHeight()/item->height();
1720 nextItem=item; 1735 nextItem=item;
1721 if (d->selectedBySimpleMove) 1736 if (d->selectedBySimpleMove)
1722 item->setSelected(false); 1737 item->setSelected(false);
1723 if (shiftOrCtrl) 1738 if (shiftOrCtrl)
1724 { 1739 {
1725 d->selectedBySimpleMove=false; 1740 d->selectedBySimpleMove=false;
1726 d->selectionDirection=1; 1741 d->selectionDirection=1;
1727 }; 1742 };
1728 1743
1729 for (int i=0; i<items; i++) 1744 for (int i=0; i<items; i++)
1730 { 1745 {
1731 if (shiftOrCtrl) 1746 if (shiftOrCtrl)
1732 nextItem->setSelected(!nextItem->isSelected()); 1747 nextItem->setSelected(!nextItem->isSelected());
1733 //the end 1748 //the end
1734 if ((i==items-1) || (nextItem->itemBelow()==0)) 1749 if ((i==items-1) || (nextItem->itemBelow()==0))
1735 1750
1736 { 1751 {
1737 if (shiftOrCtrl) 1752 if (shiftOrCtrl)
1738 nextItem->setSelected(!nextItem->isSelected()); 1753 nextItem->setSelected(!nextItem->isSelected());
1739 if (d->selectedBySimpleMove) 1754 if (d->selectedBySimpleMove)
1740 nextItem->setSelected(true); 1755 nextItem->setSelected(true);
1741 ensureItemVisible(nextItem); 1756 ensureItemVisible(nextItem);
1742 setCurrentItem(nextItem); 1757 setCurrentItem(nextItem);
1743 update(); 1758 update();
1744 if ((shiftOrCtrl) || (d->selectedBySimpleMove)) 1759 if ((shiftOrCtrl) || (d->selectedBySimpleMove))
1745 { 1760 {
1746 emit selectionChanged(); 1761 emit selectionChanged();
1747 } 1762 }
1748 return; 1763 return;
1749 } 1764 }
1750 nextItem=nextItem->itemBelow(); 1765 nextItem=nextItem->itemBelow();
1751 } 1766 }
1752 break; 1767 break;
1753 1768
1754 case Key_Prior: 1769 case Qt::Key_Prior:
1755 items=visibleHeight()/item->height(); 1770 items=visibleHeight()/item->height();
1756 nextItem=item; 1771 nextItem=item;
1757 if (d->selectedBySimpleMove) 1772 if (d->selectedBySimpleMove)
1758 item->setSelected(false); 1773 item->setSelected(false);
1759 if (shiftOrCtrl) 1774 if (shiftOrCtrl)
1760 { 1775 {
1761 d->selectionDirection=-1; 1776 d->selectionDirection=-1;
1762 d->selectedBySimpleMove=false; 1777 d->selectedBySimpleMove=false;
1763 }; 1778 };
1764 1779
1765 for (int i=0; i<items; i++) 1780 for (int i=0; i<items; i++)
1766 { 1781 {
1767 if ((nextItem!=item) &&(shiftOrCtrl)) 1782 if ((nextItem!=item) &&(shiftOrCtrl))
1768 nextItem->setSelected(!nextItem->isSelected()); 1783 nextItem->setSelected(!nextItem->isSelected());
1769 //the end 1784 //the end
1770 if ((i==items-1) || (nextItem->itemAbove()==0)) 1785 if ((i==items-1) || (nextItem->itemAbove()==0))
1771 1786
1772 { 1787 {
1773 if (d->selectedBySimpleMove) 1788 if (d->selectedBySimpleMove)
1774 nextItem->setSelected(true); 1789 nextItem->setSelected(true);
1775 ensureItemVisible(nextItem); 1790 ensureItemVisible(nextItem);
1776 setCurrentItem(nextItem); 1791 setCurrentItem(nextItem);
1777 update(); 1792 update();
1778 if ((shiftOrCtrl) || (d->selectedBySimpleMove)) 1793 if ((shiftOrCtrl) || (d->selectedBySimpleMove))
1779 { 1794 {
1780 emit selectionChanged(); 1795 emit selectionChanged();
1781 } 1796 }
1782 return; 1797 return;
1783 } 1798 }
1784 nextItem=nextItem->itemAbove(); 1799 nextItem=nextItem->itemAbove();
1785 } 1800 }
1786 break; 1801 break;
1787 1802
1788 case Key_Minus: 1803 case Qt::Key_Minus:
1789 if ( item->isOpen() ) 1804 if ( item->isOpen() )
1790 setOpen( item, FALSE ); 1805 setOpen( item, FALSE );
1791 break; 1806 break;
1792 case Key_Plus: 1807 case Qt::Key_Plus:
1793 if ( !item->isOpen() && (item->isExpandable() || item->childCount()) ) 1808 if ( !item->isOpen() && (item->isExpandable() || item->childCount()) )
1794 setOpen( item, TRUE ); 1809 setOpen( item, TRUE );
1795 break; 1810 break;
1796 default: 1811 default:
1797 bool realKey = ((e->key()!=Key_Shift) && (e->key()!=Key_Control) 1812 bool realKey = ((e->key()!=Qt::Key_Shift) && (e->key()!=Qt::Key_Control)
1798 && (e->key()!=Key_Meta) && (e->key()!=Key_Alt)); 1813 && (e->key()!=Qt::Key_Meta) && (e->key()!=Qt::Key_Alt));
1799 1814
1800 bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected()); 1815 bool selectCurrentItem = (d->selectedBySimpleMove) && (item->isSelected());
1801 if (realKey && selectCurrentItem) 1816 if (realKey && selectCurrentItem)
1802 item->setSelected(false); 1817 item->setSelected(false);
1803 //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX) 1818 //this is mainly for the "goto filename beginning with pressed char" feature (aleXXX)
1804 QListView::SelectionMode oldSelectionMode = selectionMode(); 1819 Q3ListView::SelectionMode oldSelectionMode = selectionMode();
1805 setSelectionMode (QListView::Multi); 1820 setSelectionMode (Q3ListView::Multi);
1806 QListView::keyPressEvent (e); 1821 Q3ListView::keyPressEvent (e);
1807 setSelectionMode (oldSelectionMode); 1822 setSelectionMode (oldSelectionMode);
1808 if (realKey && selectCurrentItem) 1823 if (realKey && selectCurrentItem)
1809 { 1824 {
1810 currentItem()->setSelected(true); 1825 currentItem()->setSelected(true);
1811 emitSelectionChanged=TRUE; 1826 emitSelectionChanged=TRUE;
1812 } 1827 }
1813 repaintItem2=currentItem(); 1828 repaintItem2=currentItem();
1814 if (realKey) 1829 if (realKey)
1815 visItem=currentItem(); 1830 visItem=currentItem();
1816 break; 1831 break;
1817 } 1832 }
1818 1833
1819 if (visItem) 1834 if (visItem)
1820 ensureItemVisible(visItem); 1835 ensureItemVisible(visItem);
1821 1836
1822 QRect ir; 1837 QRect ir;
1823 if (repaintItem1) 1838 if (repaintItem1)
1824 ir = ir.unite( itemRect(repaintItem1) ); 1839 ir = ir.unite( itemRect(repaintItem1) );
1825 if (repaintItem2) 1840 if (repaintItem2)
1826 ir = ir.unite( itemRect(repaintItem2) ); 1841 ir = ir.unite( itemRect(repaintItem2) );
1827 1842
1828 if ( !ir.isEmpty() ) 1843 if ( !ir.isEmpty() )
1829 { // rectangle to be repainted 1844 { // rectangle to be repainted
1830 if ( ir.x() < 0 ) 1845 if ( ir.x() < 0 )
1831 ir.moveBy( -ir.x(), 0 ); 1846 ir.moveBy( -ir.x(), 0 );
1832 viewport()->repaint( ir, FALSE ); 1847 viewport()->repaint( ir, FALSE );
1833 } 1848 }
1834 /*if (repaintItem1) 1849 /*if (repaintItem1)
1835 repaintItem1->repaint(); 1850 repaintItem1->repaint();
1836 if (repaintItem2) 1851 if (repaintItem2)
1837 repaintItem2->repaint();*/ 1852 repaintItem2->repaint();*/
1838 update(); 1853 update();
1839 if (emitSelectionChanged) 1854 if (emitSelectionChanged)
1840 emit selectionChanged(); 1855 emit selectionChanged();
1841} 1856}
1842 1857
1843void KListView::setSelectionModeExt (SelectionModeExt mode) 1858void KListView::setSelectionModeExt (SelectionModeExt mode)
1844{ 1859{
1845 d->selectionMode = mode; 1860 d->selectionMode = mode;
1846 1861
1847 switch (mode) 1862 switch (mode)
1848 { 1863 {
1849 case Single: 1864 case Single:
1850 case Multi: 1865 case Multi:
1851 case Extended: 1866 case Extended:
1852 case NoSelection: 1867 case NoSelection:
1853 setSelectionMode (static_cast<QListView::SelectionMode>(static_cast<int>(mode))); 1868 setSelectionMode (static_cast<Q3ListView::SelectionMode>(static_cast<int>(mode)));
1854 break; 1869 break;
1855 1870
1856 case FileManager: 1871 case FileManager:
1857 setSelectionMode (QListView::Extended); 1872 setSelectionMode (Q3ListView::Extended);
1858 break; 1873 break;
1859 1874
1860 default: 1875 default:
1861 kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl; 1876 kdWarning () << "Warning: illegal selection mode " << int(mode) << " set!" << endl;
1862 break; 1877 break;
1863 } 1878 }
1864} 1879}
1865 1880
1866KListView::SelectionModeExt KListView::selectionModeExt () const 1881KListView::SelectionModeExt KListView::selectionModeExt () const
1867{ 1882{
1868 return d->selectionMode; 1883 return d->selectionMode;
1869} 1884}
1870 1885
1871int KListView::itemIndex( const QListViewItem *item ) const 1886int KListView::itemIndex( const Q3ListViewItem *item ) const
1872{ 1887{
1873 if ( !item ) 1888 if ( !item )
1874 return -1; 1889 return -1;
1875 1890
1876 if ( item == firstChild() ) 1891 if ( item == firstChild() )
1877 return 0; 1892 return 0;
1878 else { 1893 else {
1879 QListViewItemIterator it(firstChild()); 1894 Q3ListViewItemIterator it(firstChild());
1880 uint j = 0; 1895 uint j = 0;
1881 for (; it.current() && it.current() != item; ++it, ++j ); 1896 for (; it.current() && it.current() != item; ++it, ++j );
1882 1897
1883 if( !it.current() ) 1898 if( !it.current() )
1884 return -1; 1899 return -1;
1885 1900
1886 return j; 1901 return j;
1887 } 1902 }
1888} 1903}
1889 1904
1890QListViewItem* KListView::itemAtIndex(int index) 1905Q3ListViewItem* KListView::itemAtIndex(int index)
1891{ 1906{
1892 if (index<0) 1907 if (index<0)
1893 return 0; 1908 return 0;
1894 1909
1895 int j(0); 1910 int j(0);
1896 for (QListViewItemIterator it=firstChild(); it.current(); it++) 1911 for (Q3ListViewItemIterator it=firstChild(); it.current(); it++)
1897 { 1912 {
1898 if (j==index) 1913 if (j==index)
1899 return it.current(); 1914 return it.current();
1900 j++; 1915 j++;
1901 }; 1916 };
1902 return 0; 1917 return 0;
1903} 1918}
1904 1919
1905 1920
1906void KListView::emitContextMenu (KListView*, QListViewItem* i) 1921void KListView::emitContextMenu (KListView*, Q3ListViewItem* i)
1907{ 1922{
1908 QPoint p; 1923 QPoint p;
1909 // qDebug("KListView::emitContextMenu "); 1924 // qDebug("KListView::emitContextMenu ");
1910 1925
1911 if (i) 1926 if (i)
1912 p = viewport()->mapToGlobal(itemRect(i).center()); 1927 p = viewport()->mapToGlobal(itemRect(i).center());
1913 else 1928 else
1914 p = mapToGlobal(rect().center()); 1929 p = mapToGlobal(rect().center());
1915 1930
1916 emit contextMenu (this, i, p); 1931 emit contextMenu (this, i, p);
1917} 1932}
1918 1933
1919void KListView::emitContextMenu (QListViewItem* i, const QPoint& p, int col) 1934void KListView::emitContextMenu (Q3ListViewItem* i, const QPoint& p, int col)
1920{ 1935{
1921 QListViewItem* item = i; 1936 Q3ListViewItem* item = i;
1922 int c = col; 1937 int c = col;
1923 // do not trust the values for QListViewItem* i and int col; 1938 // do not trust the values for QListViewItem* i and int col;
1924 // qDebug("KListView::emitContextMenu col"); 1939 // qDebug("KListView::emitContextMenu col");
1925 if ( col == -1 ) { 1940 if ( col == -1 ) {
1926 QPoint pp = viewport()->mapFromGlobal(p); 1941 QPoint pp = viewport()->mapFromGlobal(p);
1927 item = itemAt( pp); 1942 item = itemAt( pp);
1928 c = header()->sectionAt(pp.x() ); 1943 c = header()->sectionAt(pp.x() );
1929 } 1944 }
1930 emit contextRequest( item, p, c ); 1945 emit contextRequest( item, p, c );
1931 emit contextMenu (this, item, p); 1946 emit contextMenu (this, item, p);
1932} 1947}
1933 1948
1934void KListView::setAcceptDrops (bool val) 1949void KListView::setAcceptDrops (bool val)
1935{ 1950{
1936 QListView::setAcceptDrops (val); 1951 Q3ListView::setAcceptDrops (val);
1937 viewport()->setAcceptDrops (val); 1952 viewport()->setAcceptDrops (val);
1938} 1953}
1939 1954
1940int KListView::dropVisualizerWidth () const 1955int KListView::dropVisualizerWidth () const
1941{ 1956{
1942 return d->mDropVisualizerWidth; 1957 return d->mDropVisualizerWidth;
1943} 1958}
1944 1959
1945 1960
1946void KListView::viewportPaintEvent(QPaintEvent *e) 1961void KListView::viewportPaintEvent(QPaintEvent *e)
1947{ 1962{
1948 QListView::viewportPaintEvent(e); 1963 Q3ListView::viewportPaintEvent(e);
1949 1964
1950 if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer)) 1965 if (d->mOldDropVisualizer.isValid() && e->rect().intersects(d->mOldDropVisualizer))
1951 { 1966 {
1952 QPainter painter(viewport()); 1967 QPainter painter(viewport());
1953 1968
1954 // This is where we actually draw the drop-visualizer 1969 // This is where we actually draw the drop-visualizer
1955 painter.fillRect(d->mOldDropVisualizer, Dense4Pattern); 1970 painter.fillRect(d->mOldDropVisualizer, Qt::Dense4Pattern);
1956 } 1971 }
1957 if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter)) 1972 if (d->mOldDropHighlighter.isValid() && e->rect().intersects(d->mOldDropHighlighter))
1958 { 1973 {
1959 QPainter painter(viewport()); 1974 QPainter painter(viewport());
1960 1975
1961qDebug("KListView::viewportPaintEvent has to be verified"); 1976qDebug("KListView::viewportPaintEvent has to be verified");
1962 1977
1963 // This is where we actually draw the drop-highlighter 1978 // This is where we actually draw the drop-highlighter
1964//US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(), 1979//US style().drawPrimitive(QStyle::PE_FocusRect, &painter, d->mOldDropHighlighter, colorGroup(),
1965//US QStyle::Style_FocusAtBorder); 1980//US QStyle::Style_FocusAtBorder);
1966 1981
1967//LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true); 1982//LR style().drawFocusRect(&painter, d->mOldDropHighlighter, colorGroup(), (const QColor*)0, true);
1968 1983
1969 1984
1970 } 1985 }
1971} 1986}
1972 1987
1973void KListView::setFullWidth() 1988void KListView::setFullWidth()
1974{ 1989{
1975 setFullWidth(true); 1990 setFullWidth(true);
1976} 1991}
1977 1992
1978void KListView::setFullWidth(bool fullWidth) 1993void KListView::setFullWidth(bool fullWidth)
1979{ 1994{
1980 d->fullWidth = fullWidth; 1995 d->fullWidth = fullWidth;
1981//US header()->setStretchEnabled(fullWidth, columns()-1); 1996//US header()->setStretchEnabled(fullWidth, columns()-1);
1982} 1997}
1983 1998
1984bool KListView::fullWidth() const 1999bool KListView::fullWidth() const
1985{ 2000{
1986 return d->fullWidth; 2001 return d->fullWidth;
1987} 2002}
1988 2003
1989int KListView::addColumn(const QString& label, int width) 2004int KListView::addColumn(const QString& label, int width)
1990{ 2005{
1991 int result = QListView::addColumn(label, width); 2006 int result = Q3ListView::addColumn(label, width);
1992 if (d->fullWidth) { 2007 if (d->fullWidth) {
1993//US header()->setStretchEnabled(false, columns()-2); 2008//US header()->setStretchEnabled(false, columns()-2);
1994//US header()->setStretchEnabled(true, columns()-1); 2009//US header()->setStretchEnabled(true, columns()-1);
1995 } 2010 }
1996 return result; 2011 return result;
1997} 2012}
1998 2013
1999int KListView::addColumn(const QIconSet& iconset, const QString& label, int width) 2014int KListView::addColumn(const QIcon& iconset, const QString& label, int width)
2000{ 2015{
2001 int result = QListView::addColumn(iconset, label, width); 2016 int result = Q3ListView::addColumn(iconset, label, width);
2002 if (d->fullWidth) { 2017 if (d->fullWidth) {
2003//US header()->setStretchEnabled(false, columns()-2); 2018//US header()->setStretchEnabled(false, columns()-2);
2004//US header()->setStretchEnabled(true, columns()-1); 2019//US header()->setStretchEnabled(true, columns()-1);
2005 } 2020 }
2006 return result; 2021 return result;
2007} 2022}
2008 2023
2009void KListView::removeColumn(int index) 2024void KListView::removeColumn(int index)
2010{ 2025{
2011 QListView::removeColumn(index); 2026 Q3ListView::removeColumn(index);
2012//US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1); 2027//US if (d->fullWidth && index == columns()) header()->setStretchEnabled(true, columns()-1);
2013} 2028}
2014 2029
2015void KListView::viewportResizeEvent(QResizeEvent* e) 2030void KListView::viewportResizeEvent(QResizeEvent* e)
2016{ 2031{
2017 QListView::viewportResizeEvent(e); 2032 Q3ListView::viewportResizeEvent(e);
2018} 2033}
2019 2034
2020const QColor &KListView::alternateBackground() const 2035const QColor &KListView::alternateBackground() const
2021{ 2036{
2022 return d->alternateBackground; 2037 return d->alternateBackground;
2023} 2038}
2024 2039
2025void KListView::setAlternateBackground(const QColor &c) 2040void KListView::setAlternateBackground(const QColor &c)
2026{ 2041{
2027 d->alternateBackground = c; 2042 d->alternateBackground = c;
2028 repaint(); 2043 repaint();
2029} 2044}
2030 2045
2031void KListView::saveLayout(KConfig *config, const QString &group) const 2046void KListView::saveLayout(KConfig *config, const QString &group) const
2032{ 2047{
2033 KConfigGroupSaver saver(config, group); 2048 KConfigGroupSaver saver(config, group);
2034 QStringList widths, order; 2049 QStringList widths, order;
2035 for (int i = 0; i < columns(); ++i) 2050 for (int i = 0; i < columns(); ++i)
2036 { 2051 {
2037 widths << QString::number(columnWidth(i)); 2052 widths << QString::number(columnWidth(i));
2038 order << QString::number(header()->mapToIndex(i)); 2053 order << QString::number(header()->mapToIndex(i));
2039 } 2054 }
2040 config->writeEntry("ColumnWidths", widths); 2055 config->writeEntry("ColumnWidths", widths);
2041 config->writeEntry("ColumnOrder", order); 2056 config->writeEntry("ColumnOrder", order);
2042 config->writeEntry("SortColumn", d->sortColumn); 2057 config->writeEntry("SortColumn", d->sortColumn);
2043 config->writeEntry("SortAscending", d->sortAscending); 2058 config->writeEntry("SortAscending", d->sortAscending);
2044} 2059}
2045 2060
2046void KListView::restoreLayout(KConfig *config, const QString &group) 2061void KListView::restoreLayout(KConfig *config, const QString &group)
2047{ 2062{
2048 KConfigGroupSaver saver(config, group); 2063 KConfigGroupSaver saver(config, group);
2049 QStringList cols = config->readListEntry("ColumnWidths"); 2064 QStringList cols = config->readListEntry("ColumnWidths");
2050 int i = 0; 2065 int i = 0;
2051 for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) 2066 for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it)
2052 setColumnWidth(i++, (*it).toInt()); 2067 setColumnWidth(i++, (*it).toInt());
2053 2068
2054 cols = config->readListEntry("ColumnOrder"); 2069 cols = config->readListEntry("ColumnOrder");
2055 i = 0; 2070 i = 0;
2056 for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it) 2071 for (QStringList::ConstIterator it = cols.begin(); it != cols.end(); ++it)
2057 header()->moveSection(i++, (*it).toInt()); 2072 header()->moveSection(i++, (*it).toInt());
2058 2073
2059/*US I changed the following code, because hasKey is not available. 2074/*US I changed the following code, because hasKey is not available.
2060!!! check if my version is correct 2075!!! check if my version is correct
2061 if (config->hasKey("SortColumn")) 2076 if (config->hasKey("SortColumn"))
2062 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); 2077 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true));
2063*/ 2078*/
2064 QStringList langLst = config->readListEntry( "SortColumn" ); 2079 QStringList langLst = config->readListEntry( "SortColumn" );
2065 if (!langLst.isEmpty()) 2080 if (!langLst.isEmpty())
2066 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true)); 2081 setSorting(config->readNumEntry("SortColumn"), config->readBoolEntry("SortAscending", true));
2067} 2082}
2068 2083
2069void KListView::setSorting(int column, bool ascending) 2084void KListView::setSorting(int column, bool ascending)
2070{ 2085{
2071 d->sortColumn = column; 2086 d->sortColumn = column;
2072 d->sortAscending = ascending; 2087 d->sortAscending = ascending;
2073 QListView::setSorting(column, ascending); 2088 Q3ListView::setSorting(column, ascending);
2074} 2089}
2075 2090
2076int KListView::columnSorted(void) const 2091int KListView::columnSorted(void) const
2077{ 2092{
2078 return d->sortColumn; 2093 return d->sortColumn;
2079} 2094}
2080 2095
2081bool KListView::ascendingSort(void) const 2096bool KListView::ascendingSort(void) const
2082{ 2097{
2083 return d->sortAscending; 2098 return d->sortAscending;
2084} 2099}
2085 2100
2086KListViewItem::KListViewItem(QListView *parent) 2101KListViewItem::KListViewItem(Q3ListView *parent)
2087 : QListViewItem(parent) 2102 : Q3ListViewItem(parent)
2088{ 2103{
2089 init(); 2104 init();
2090} 2105}
2091 2106
2092KListViewItem::KListViewItem(QListViewItem *parent) 2107KListViewItem::KListViewItem(Q3ListViewItem *parent)
2093 : QListViewItem(parent) 2108 : Q3ListViewItem(parent)
2094{ 2109{
2095 init(); 2110 init();
2096} 2111}
2097 2112
2098KListViewItem::KListViewItem(QListView *parent, QListViewItem *after) 2113KListViewItem::KListViewItem(Q3ListView *parent, Q3ListViewItem *after)
2099 : QListViewItem(parent, after) 2114 : Q3ListViewItem(parent, after)
2100{ 2115{
2101 init(); 2116 init();
2102} 2117}
2103 2118
2104KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after) 2119KListViewItem::KListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after)
2105 : QListViewItem(parent, after) 2120 : Q3ListViewItem(parent, after)
2106{ 2121{
2107 init(); 2122 init();
2108} 2123}
2109 2124
2110KListViewItem::KListViewItem(QListView *parent, 2125KListViewItem::KListViewItem(Q3ListView *parent,
2111 QString label1, QString label2, QString label3, QString label4, 2126 QString label1, QString label2, QString label3, QString label4,
2112 QString label5, QString label6, QString label7, QString label8) 2127 QString label5, QString label6, QString label7, QString label8)
2113 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 2128 : Q3ListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
2114{ 2129{
2115 init(); 2130 init();
2116} 2131}
2117 2132
2118KListViewItem::KListViewItem(QListViewItem *parent, 2133KListViewItem::KListViewItem(Q3ListViewItem *parent,
2119 QString label1, QString label2, QString label3, QString label4, 2134 QString label1, QString label2, QString label3, QString label4,
2120 QString label5, QString label6, QString label7, QString label8) 2135 QString label5, QString label6, QString label7, QString label8)
2121 : QListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8) 2136 : Q3ListViewItem(parent, label1, label2, label3, label4, label5, label6, label7, label8)
2122{ 2137{
2123 init(); 2138 init();
2124} 2139}
2125 2140
2126KListViewItem::KListViewItem(QListView *parent, QListViewItem *after, 2141KListViewItem::KListViewItem(Q3ListView *parent, Q3ListViewItem *after,
2127 QString label1, QString label2, QString label3, QString label4, 2142 QString label1, QString label2, QString label3, QString label4,
2128 QString label5, QString label6, QString label7, QString label8) 2143 QString label5, QString label6, QString label7, QString label8)
2129 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 2144 : Q3ListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
2130{ 2145{
2131 init(); 2146 init();
2132} 2147}
2133 2148
2134KListViewItem::KListViewItem(QListViewItem *parent, QListViewItem *after, 2149KListViewItem::KListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after,
2135 QString label1, QString label2, QString label3, QString label4, 2150 QString label1, QString label2, QString label3, QString label4,
2136 QString label5, QString label6, QString label7, QString label8) 2151 QString label5, QString label6, QString label7, QString label8)
2137 : QListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8) 2152 : Q3ListViewItem(parent, after, label1, label2, label3, label4, label5, label6, label7, label8)
2138{ 2153{
2139 init(); 2154 init();
2140} 2155}
2141 2156
2142KListViewItem::~KListViewItem() 2157KListViewItem::~KListViewItem()
2143{ 2158{
2144} 2159}
2145 2160
2146void KListViewItem::init() 2161void KListViewItem::init()
2147{ 2162{
2148 m_known = false; 2163 m_known = false;
2149} 2164}
2150 2165
2151const QColor &KListViewItem::backgroundColor() 2166const QColor &KListViewItem::backgroundColor()
2152{ 2167{
2153 if (isAlternate()) 2168 if (isAlternate())
2154 return static_cast< KListView* >(listView())->alternateBackground(); 2169 return static_cast< KListView* >(listView())->alternateBackground();
2155 return listView()->viewport()->colorGroup().base(); 2170 return listView()->viewport()->colorGroup().base();
2156} 2171}
2157 2172
2158bool KListViewItem::isAlternate() 2173bool KListViewItem::isAlternate()
2159{ 2174{
2160 KListView *lv = static_cast<KListView *>(listView()); 2175 KListView *lv = static_cast<KListView *>(listView());
2161 if (lv && lv->alternateBackground().isValid()) 2176 if (lv && lv->alternateBackground().isValid())
2162 { 2177 {
2163 KListViewItem *above = 0; 2178 KListViewItem *above = 0;
2164//US above = dynamic_cast<KListViewItem *>(itemAbove()); 2179//US above = dynamic_cast<KListViewItem *>(itemAbove());
2165 above = (KListViewItem *)(itemAbove()); 2180 above = (KListViewItem *)(itemAbove());
2166 m_known = above ? above->m_known : true; 2181 m_known = above ? above->m_known : true;
2167 if (m_known) 2182 if (m_known)
2168 { 2183 {
2169 m_odd = above ? !above->m_odd : false; 2184 m_odd = above ? !above->m_odd : false;
2170 } 2185 }
2171 else 2186 else
2172 { 2187 {
2173 KListViewItem *item; 2188 KListViewItem *item;
2174 bool previous = true; 2189 bool previous = true;
2175 if (parent()) 2190 if (parent())
2176 { 2191 {
2177//US item = dynamic_cast<KListViewItem *>(parent()); 2192//US item = dynamic_cast<KListViewItem *>(parent());
2178 item = (KListViewItem *)(parent()); 2193 item = (KListViewItem *)(parent());
2179 if (item) 2194 if (item)
2180 previous = item->m_odd; 2195 previous = item->m_odd;
2181//US item = dynamic_cast<KListViewItem *>(parent()->firstChild()); 2196//US item = dynamic_cast<KListViewItem *>(parent()->firstChild());
2182 item = (KListViewItem *)(parent()->firstChild()); 2197 item = (KListViewItem *)(parent()->firstChild());
2183 } 2198 }
2184 else 2199 else
2185 { 2200 {
2186//US item = dynamic_cast<KListViewItem *>(lv->firstChild()); 2201//US item = dynamic_cast<KListViewItem *>(lv->firstChild());
2187 item = (KListViewItem *)(lv->firstChild()); 2202 item = (KListViewItem *)(lv->firstChild());
2188 } 2203 }
2189 2204
2190 while(item) 2205 while(item)
2191 { 2206 {
2192 item->m_odd = previous = !previous; 2207 item->m_odd = previous = !previous;
2193 item->m_known = true; 2208 item->m_known = true;
2194//US item = dynamic_cast<KListViewItem *>(item->nextSibling()); 2209//US item = dynamic_cast<KListViewItem *>(item->nextSibling());
2195 item = (KListViewItem *)(item->nextSibling()); 2210 item = (KListViewItem *)(item->nextSibling());
2196 } 2211 }
2197 } 2212 }
2198 return m_odd; 2213 return m_odd;
2199 } 2214 }
2200 return false; 2215 return false;
2201} 2216}
2202 2217
2203void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment) 2218void KListViewItem::paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int alignment)
2204{ 2219{
2205 QColorGroup _cg = cg; 2220 QColorGroup _cg = cg;
2206 const QPixmap *pm = listView()->viewport()->backgroundPixmap(); 2221 const QPixmap *pm = listView()->viewport()->backgroundPixmap();
2207 if (pm && !pm->isNull()) 2222 if (pm && !pm->isNull())
2208 { 2223 {
2209 _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm)); 2224 _cg.setBrush(QColorGroup::Base, QBrush(backgroundColor(), *pm));
2210 QPoint o = p->brushOrigin(); 2225 QPoint o = p->brushOrigin();
2211 p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() ); 2226 p->setBrushOrigin( o.x()-listView()->contentsX(), o.y()-listView()->contentsY() );
2212 } 2227 }
2213 else if (isAlternate()) { 2228 else if (isAlternate()) {
2214//US if (listView()->viewport()->backgroundMode()==Qt::FixedColor) 2229//US if (listView()->viewport()->backgroundMode()==Qt::FixedColor)
2215 if (listView()->viewport()->backgroundMode()==QWidget::PaletteBackground) 2230 if (listView()->viewport()->backgroundMode()==Qt::PaletteBackground)
2216 _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground()); 2231 _cg.setColor(QColorGroup::Background, static_cast< KListView* >(listView())->alternateBackground());
2217 else 2232 else
2218 _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground()); 2233 _cg.setColor(QColorGroup::Base, static_cast< KListView* >(listView())->alternateBackground());
2219 } 2234 }
2220 QListViewItem::paintCell(p, _cg, column, width, alignment); 2235 Q3ListViewItem::paintCell(p, _cg, column, width, alignment);
2221} 2236}
2222 2237
2223//US we do not have a "global KDE" variable to setup singleClick functionality 2238//US we do not have a "global KDE" variable to setup singleClick functionality
2224void KListView::setSingleClick(bool s) 2239void KListView::setSingleClick(bool s)
2225{ 2240{
2226 d->bUseSingle = s; 2241 d->bUseSingle = s;
2227 slotSettingsChanged(1); 2242 slotSettingsChanged(1);
2228 // qDebug("KListView::setSingleClick: single %i", d->bUseSingle); 2243 // qDebug("KListView::setSingleClick: single %i", d->bUseSingle);
2229} 2244}
2230 2245
2231 2246
2232void KListView::virtual_hook( int, void* ) 2247void KListView::virtual_hook( int, void* )
2233{ /*BASE::virtual_hook( id, data );*/ } 2248{ /*BASE::virtual_hook( id, data );*/ }
2234 2249
2235//US #include "klistview.moc" 2250//US #include "klistview.moc"
2236//US #include "klistviewlineedit.moc" 2251//US #include "klistviewlineedit.moc"
2237 2252
2238// vim: ts=2 sw=2 et 2253// vim: ts=2 sw=2 et
diff --git a/microkde/kdeui/klistview.h b/microkde/kdeui/klistview.h
index 9f0d9fd..2176525 100644
--- a/microkde/kdeui/klistview.h
+++ b/microkde/kdeui/klistview.h
@@ -1,1040 +1,1051 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org> 2 Copyright (C) 2000 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2000 Charles Samuels <charles@kde.org> 3 Copyright (C) 2000 Charles Samuels <charles@kde.org>
4 Copyright (C) 2000 Peter Putzer <putzer@kde.org> 4 Copyright (C) 2000 Peter Putzer <putzer@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License version 2 as published by the Free Software Foundation. 8 License version 2 as published by the Free Software Foundation.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20#ifndef KLISTVIEW_H 20#ifndef KLISTVIEW_H
21#define KLISTVIEW_H 21#define KLISTVIEW_H
22 22
23#include <qlistview.h> 23#include <q3listview.h>
24 24
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26//Added by qt3to4:
27#include <QDragMoveEvent>
28#include <QDropEvent>
29#include <QDragLeaveEvent>
30#include <QPaintEvent>
31#include <QResizeEvent>
32#include <QFocusEvent>
33#include <QMouseEvent>
34#include <QKeyEvent>
35#include <QEvent>
36#include <QDragEnterEvent>
26 37
27//US 38//US
28class QDropEvent; 39class QDropEvent;
29class QDragLeaveEvent; 40class QDragLeaveEvent;
30class QDragMoveEvent; 41class QDragMoveEvent;
31class QDragEnterEvent; 42class QDragEnterEvent;
32 43
33class QDragObject; 44class Q3DragObject;
34class KConfig; 45class KConfig;
35class KLineEdit; 46class KLineEdit;
36/** 47/**
37 * This Widget extends the functionality of QListView to honor the system 48 * This Widget extends the functionality of QListView to honor the system
38 * wide settings for Single Click/Double Click mode, AutoSelection and 49 * wide settings for Single Click/Double Click mode, AutoSelection and
39 * ChangeCursorOverLink (TM). 50 * ChangeCursorOverLink (TM).
40 * 51 *
41 * There is a new signal executed(). It gets connected to either 52 * There is a new signal executed(). It gets connected to either
42 * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE 53 * @ref QListView::clicked() or @ref QListView::doubleClicked() depending on the KDE
43 * wide Single Click/Double Click settings. It is strongly recommended that 54 * wide Single Click/Double Click settings. It is strongly recommended that
44 * you use this signal instead of the above mentioned. This way you dont 55 * you use this signal instead of the above mentioned. This way you dont
45 * need to care about the current settings. 56 * need to care about the current settings.
46 * If you want to get informed when the user selects something connect to the 57 * If you want to get informed when the user selects something connect to the
47 * QListView::selectionChanged() signal. 58 * QListView::selectionChanged() signal.
48 * 59 *
49 * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true) 60 * Drag-and-Drop is supported with the signal @ref #dropped(), just @ref #setAcceptDrops(true)
50 * and connect it to a suitable slot. 61 * and connect it to a suitable slot.
51 * To see where you are dropping, @ref setDropVisualizer(true). 62 * To see where you are dropping, @ref setDropVisualizer(true).
52 * And also you'll need @ref acceptDrag(QDropEvent*) 63 * And also you'll need @ref acceptDrag(QDropEvent*)
53 * 64 *
54 * KListView is drag-enabled, too: to benefit from that you've got derive from it. 65 * KListView is drag-enabled, too: to benefit from that you've got derive from it.
55 * Reimplement @ref dragObject() and (possibly) @ref startDrag(), 66 * Reimplement @ref dragObject() and (possibly) @ref startDrag(),
56 * and @ref setDragEnabled(true). 67 * and @ref setDragEnabled(true).
57 * 68 *
58 * @version $Id$ 69 * @version $Id$
59 */ 70 */
60class KListView : public QListView 71class KListView : public Q3ListView
61{ 72{
62 Q_OBJECT 73 Q_OBJECT
63 Q_ENUMS( SelectionModeExt ) 74 Q_ENUMS( SelectionModeExt )
64 Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth ) 75 Q_PROPERTY( bool fullWidth READ fullWidth WRITE setFullWidth )
65 Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable ) 76 Q_PROPERTY( bool itemsMovable READ itemsMovable WRITE setItemsMovable )
66 Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable ) 77 Q_PROPERTY( bool itemsRenameable READ itemsRenameable WRITE setItemsRenameable )
67 Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled ) 78 Q_PROPERTY( bool dragEnabled READ dragEnabled WRITE setDragEnabled )
68 Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen ) 79 Q_PROPERTY( bool autoOpen READ autoOpen WRITE setAutoOpen )
69 Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer ) 80 Q_PROPERTY( bool dropVisualizer READ dropVisualizer WRITE setDropVisualizer )
70//US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn ) 81//US Q_PROPERTY( int tooltipColumn READ tooltipColumn WRITE setTooltipColumn )
71 Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth ) 82 Q_PROPERTY( int dropVisualizerWidth READ dropVisualizerWidth WRITE setDropVisualizerWidth )
72 Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground ) 83 Q_PROPERTY( QColor alternateBackground READ alternateBackground WRITE setAlternateBackground )
73 84
74 Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt ) 85 Q_OVERRIDE( SelectionModeExt selectionMode READ selectionModeExt WRITE setSelectionModeExt )
75 86
76public: 87public:
77 /** 88 /**
78 * Possible selection modes. 89 * Possible selection modes.
79 * 90 *
80 * The first four correspond directly to QListView::SelectionMode, while 91 * The first four correspond directly to QListView::SelectionMode, while
81 * the FileManager selection mode is defined as follows: 92 * the FileManager selection mode is defined as follows:
82 * @li home: move to the first 93 * @li home: move to the first
83 * @li end: move to the last 94 * @li end: move to the last
84 * @li PgUp/PgDn: move one page up/down 95 * @li PgUp/PgDn: move one page up/down
85 * @li up/down: move one item up/down 96 * @li up/down: move one item up/down
86 * @li insert: toggle selection of current and move to the next 97 * @li insert: toggle selection of current and move to the next
87 * @li space: toggle selection of the current 98 * @li space: toggle selection of the current
88 * @li CTRL+up: move to the previous item and toggle selection of this one 99 * @li CTRL+up: move to the previous item and toggle selection of this one
89 * @li CTRL+down: toggle selection of the current item and move to the next 100 * @li CTRL+down: toggle selection of the current item and move to the next
90 * @li CTRL+end: toggle selection from (including) the current 101 * @li CTRL+end: toggle selection from (including) the current
91 * item to (including) the last item 102 * item to (including) the last item
92 * @li CTRL+home: toggle selection from (including) the current 103 * @li CTRL+home: toggle selection from (including) the current
93 * item to the (including) the first item 104 * item to the (including) the first item
94 * @li CTRL+PgDn: toggle selection from (including) the current 105 * @li CTRL+PgDn: toggle selection from (including) the current
95 * item to (excluding) the item one page down 106 * item to (excluding) the item one page down
96 * @li CTRL+PgUp: toggle selection from (excluding) the current 107 * @li CTRL+PgUp: toggle selection from (excluding) the current
97 * item to (including) the item one page up 108 * item to (including) the item one page up
98 * 109 *
99 * The combinations work the same with SHIFT instead of CTRL, except 110 * The combinations work the same with SHIFT instead of CTRL, except
100 * that if you start selecting something using SHIFT everything selected 111 * that if you start selecting something using SHIFT everything selected
101 * before will be deselected first. 112 * before will be deselected first.
102 * 113 *
103 * Additionally the current item is always selected automatically when 114 * Additionally the current item is always selected automatically when
104 * navigating using the keyboard, except other items were selected explicitely. 115 * navigating using the keyboard, except other items were selected explicitely.
105 * 116 *
106 * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected 117 * This way e.g. SHIFT+up/PgUp then SHIFT+down/PgDn leaves no item selected
107 */ 118 */
108 enum SelectionModeExt { 119 enum SelectionModeExt {
109 Single = QListView::Single, 120 Single = Q3ListView::Single,
110 Multi = QListView::Multi, 121 Multi = Q3ListView::Multi,
111 Extended = QListView::Extended, 122 Extended = Q3ListView::Extended,
112 NoSelection = QListView::NoSelection, 123 NoSelection = Q3ListView::NoSelection,
113 FileManager 124 FileManager
114 }; 125 };
115 void repaintContents( bool erase = true ) 126 void repaintContents( bool erase = true )
116 { 127 {
117 QScrollView::repaintContents( contentsX(), contentsY(), 128 Q3ScrollView::repaintContents( contentsX(), contentsY(),
118 visibleWidth(), visibleHeight(), erase ); 129 visibleWidth(), visibleHeight(), erase );
119 }; 130 };
120 /** 131 /**
121 * Constructor. 132 * Constructor.
122 * 133 *
123 * The parameters @p parent and @p name are handled by 134 * The parameters @p parent and @p name are handled by
124 * @ref QListView, as usual. 135 * @ref QListView, as usual.
125 */ 136 */
126 KListView (QWidget *parent = 0, const char *name = 0, bool emulateRightMouse = true ); 137 KListView (QWidget *parent = 0, const char *name = 0, bool emulateRightMouse = true );
127 138
128 /** 139 /**
129 * Destructor. 140 * Destructor.
130 */ 141 */
131 virtual ~KListView(); 142 virtual ~KListView();
132 143
133 virtual QSize sizeHint() const; 144 virtual QSize sizeHint() const;
134 /** 145 /**
135 * Reimplemented for internal reasons. 146 * Reimplemented for internal reasons.
136 * Further reimplementations should call this function or else 147 * Further reimplementations should call this function or else
137 * some features may not work correctly. 148 * some features may not work correctly.
138 * 149 *
139 * The API is unaffected. 150 * The API is unaffected.
140 */ 151 */
141 virtual void setAcceptDrops (bool); 152 virtual void setAcceptDrops (bool);
142 153
143 /** 154 /**
144 * This function determines whether the given coordinates are within the 155 * This function determines whether the given coordinates are within the
145 * execute area. The execute area is the part of a @ref QListViewItem where mouse 156 * execute area. The execute area is the part of a @ref QListViewItem where mouse
146 * clicks or double clicks respectively generate a @ref #executed() signal. 157 * clicks or double clicks respectively generate a @ref #executed() signal.
147 * Depending on @ref QListView::allColumnsShowFocus() this is either the 158 * Depending on @ref QListView::allColumnsShowFocus() this is either the
148 * whole item or only the first column. 159 * whole item or only the first column.
149 * @return true if point is inside execute area of an item, false in all 160 * @return true if point is inside execute area of an item, false in all
150 * other cases including the case that it is over the viewport. 161 * other cases including the case that it is over the viewport.
151 */ 162 */
152 virtual bool isExecuteArea( const QPoint& point ); 163 virtual bool isExecuteArea( const QPoint& point );
153 164
154 /** 165 /**
155 * Same thing, but from an x coordinate only. This only checks if x is in 166 * Same thing, but from an x coordinate only. This only checks if x is in
156 * the first column (if all columns don't show focus), without testing if 167 * the first column (if all columns don't show focus), without testing if
157 * the y coordinate is over an item or not. 168 * the y coordinate is over an item or not.
158 */ 169 */
159 bool isExecuteArea( int x ); 170 bool isExecuteArea( int x );
160 171
161 /** 172 /**
162 * @return a list containing the currently selected items. 173 * @return a list containing the currently selected items.
163 */ 174 */
164 QPtrList<QListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?) 175 Q3PtrList<Q3ListViewItem> selectedItems() const; // ### BIC: KDE 4: use an implicitly shared class! (QValueList?)
165 176
166 /** 177 /**
167 * Arbitrarily move @p item to @p parent, positioned immediately after item @p after. 178 * Arbitrarily move @p item to @p parent, positioned immediately after item @p after.
168 */ 179 */
169 void moveItem(QListViewItem *item, QListViewItem *parent, QListViewItem *after); 180 void moveItem(Q3ListViewItem *item, Q3ListViewItem *parent, Q3ListViewItem *after);
170 181
171 /** 182 /**
172 * @return the last item (not child!) of this listview. 183 * @return the last item (not child!) of this listview.
173 * 184 *
174 * @see lastChild() 185 * @see lastChild()
175 */ 186 */
176 QListViewItem *lastItem() const; 187 Q3ListViewItem *lastItem() const;
177 188
178 /** 189 /**
179 * @return the last child of this listview. 190 * @return the last child of this listview.
180 * 191 *
181 * @see lastItem() 192 * @see lastItem()
182 */ 193 */
183 QListViewItem* lastChild () const; 194 Q3ListViewItem* lastChild () const;
184 195
185 /** 196 /**
186 * @return the lineedit used for inline renaming. 197 * @return the lineedit used for inline renaming.
187 * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit 198 * Use that to setup a @ref KCompletion or @ref QValidator for the lineedit
188 * 199 *
189 * @since 3.2 200 * @since 3.2
190 */ 201 */
191 KLineEdit* renameLineEdit() const; 202 KLineEdit* renameLineEdit() const;
192 203
193 /** 204 /**
194 * @returns if it is legal to move items in the list view. True by default. 205 * @returns if it is legal to move items in the list view. True by default.
195 * 206 *
196 * @see #setDragEnabled() 207 * @see #setDragEnabled()
197 * @see #setItemsMovable() 208 * @see #setItemsMovable()
198 */ 209 */
199 bool itemsMovable() const; 210 bool itemsMovable() const;
200 211
201 /** 212 /**
202 * @return whether inplace-renaming has been enabled. False by default. 213 * @return whether inplace-renaming has been enabled. False by default.
203 * 214 *
204 * @see #setItemsRenameable() 215 * @see #setItemsRenameable()
205 */ 216 */
206 bool itemsRenameable() const; 217 bool itemsRenameable() const;
207 218
208 /** 219 /**
209 * @return whether dragging is enabled. False by default. 220 * @return whether dragging is enabled. False by default.
210 * 221 *
211 * @see #setDragEnabled() 222 * @see #setDragEnabled()
212 */ 223 */
213 bool dragEnabled() const; 224 bool dragEnabled() const;
214 225
215 /** 226 /**
216 * @return true if AutoOpen is enabled (not implemented currently). 227 * @return true if AutoOpen is enabled (not implemented currently).
217 * 228 *
218 * @see #setAutoOpen() 229 * @see #setAutoOpen()
219 */ 230 */
220 bool autoOpen() const; 231 bool autoOpen() const;
221 232
222 /** 233 /**
223 * @return true if @p column is renamable. 234 * @return true if @p column is renamable.
224 * 235 *
225 * @see #setRenameable() 236 * @see #setRenameable()
226 */ 237 */
227 bool isRenameable (int column) const; 238 bool isRenameable (int column) const;
228 239
229 /** 240 /**
230 * @return true if drawing of the drop-visualizer has been enabled. True by default. 241 * @return true if drawing of the drop-visualizer has been enabled. True by default.
231 * 242 *
232 * @see #setDropVisualizer() 243 * @see #setDropVisualizer()
233 */ 244 */
234 bool dropVisualizer() const; 245 bool dropVisualizer() const;
235 246
236 /** 247 /**
237 * @return the column for which tooltips are displayed (or -1 if none set). 248 * @return the column for which tooltips are displayed (or -1 if none set).
238 * 249 *
239 * @see #setTooltipColumn() 250 * @see #setTooltipColumn()
240 */ 251 */
241 int tooltipColumn() const; 252 int tooltipColumn() const;
242 253
243 /** 254 /**
244 * For future expansions. 255 * For future expansions.
245 * 256 *
246 * Do not use. 257 * Do not use.
247 * @deprecated 258 * @deprecated
248 */ 259 */
249 bool createChildren() const; 260 bool createChildren() const;
250 261
251 /** 262 /**
252 * @return true if drawing of the drop-highlighter has been enabled. False by default. 263 * @return true if drawing of the drop-highlighter has been enabled. False by default.
253 * 264 *
254 * @see #setDropHighlighter() 265 * @see #setDropHighlighter()
255 */ 266 */
256 bool dropHighlighter() const; 267 bool dropHighlighter() const;
257 268
258 /** 269 /**
259 * The dropVisualizerWidth defaults to 4. 270 * The dropVisualizerWidth defaults to 4.
260 * 271 *
261 * @see #setDropVisualizerWidth() 272 * @see #setDropVisualizerWidth()
262 * @return the current width of the drop-visualizer. 273 * @return the current width of the drop-visualizer.
263 */ 274 */
264 int dropVisualizerWidth () const; 275 int dropVisualizerWidth () const;
265 276
266 /** 277 /**
267 * @return the "extended" selection mode of this listview. 278 * @return the "extended" selection mode of this listview.
268 * 279 *
269 * @see SelectionModeExt 280 * @see SelectionModeExt
270 * @see setSelectionModeExt 281 * @see setSelectionModeExt
271 */ 282 */
272 SelectionModeExt selectionModeExt () const; 283 SelectionModeExt selectionModeExt () const;
273 284
274 /** 285 /**
275 * Returns the index of @p item within the item tree or -1 if 286 * Returns the index of @p item within the item tree or -1 if
276 * @p item doesn't exist in this list view. This function takes 287 * @p item doesn't exist in this list view. This function takes
277 * all items into account not only the visible ones. 288 * all items into account not only the visible ones.
278 */ 289 */
279 int itemIndex( const QListViewItem *item ) const; 290 int itemIndex( const Q3ListViewItem *item ) const;
280 291
281 /** 292 /**
282 * Returns the item of @p index within the item tree or 0 if 293 * Returns the item of @p index within the item tree or 0 if
283 * @p index doesn't exist in this list view. This function takes 294 * @p index doesn't exist in this list view. This function takes
284 * all items into account not only the visible ones. 295 * all items into account not only the visible ones.
285 */ 296 */
286 QListViewItem* itemAtIndex(int index); 297 Q3ListViewItem* itemAtIndex(int index);
287 298
288 /** 299 /**
289 * @deprecated 300 * @deprecated
290 * @see #setFullWidth() 301 * @see #setFullWidth()
291 */ 302 */
292 void setFullWidth(); 303 void setFullWidth();
293 304
294 /** 305 /**
295 * Let the last column fit exactly all the available width. 306 * Let the last column fit exactly all the available width.
296 * 307 *
297 * @see #fullWidth() 308 * @see #fullWidth()
298 */ 309 */
299 void setFullWidth(bool fullWidth); 310 void setFullWidth(bool fullWidth);
300 311
301 /** 312 /**
302 * Returns whether the last column is set to fit the available width. 313 * Returns whether the last column is set to fit the available width.
303 * 314 *
304 * @see #setFullWidth() 315 * @see #setFullWidth()
305 */ 316 */
306 bool fullWidth() const; 317 bool fullWidth() const;
307 318
308 /** 319 /**
309 * Reimplemented for full width support 320 * Reimplemented for full width support
310 * 321 *
311 * @see #removeColumn() 322 * @see #removeColumn()
312 */ 323 */
313 virtual int addColumn(const QString& label, int width = -1); 324 virtual int addColumn(const QString& label, int width = -1);
314 /** 325 /**
315 * Reimplemented for full width support 326 * Reimplemented for full width support
316 */ 327 */
317 virtual int addColumn(const QIconSet& iconset, const QString& label, int width = -1); 328 virtual int addColumn(const QIcon& iconset, const QString& label, int width = -1);
318 /** 329 /**
319 * Reimplemented for full width support 330 * Reimplemented for full width support
320 * 331 *
321 * @see #addColumn() 332 * @see #addColumn()
322 */ 333 */
323 virtual void removeColumn(int index); 334 virtual void removeColumn(int index);
324 335
325 /** 336 /**
326 * sets the alternate background background color. 337 * sets the alternate background background color.
327 * This only has an effect if the items are KListViewItems 338 * This only has an effect if the items are KListViewItems
328 * 339 *
329 * @param c the color to use for every other item. Set to an invalid 340 * @param c the color to use for every other item. Set to an invalid
330 * colour to disable alternate colours. 341 * colour to disable alternate colours.
331 * 342 *
332 * @see #alternateBackground() 343 * @see #alternateBackground()
333 **/ 344 **/
334 void setAlternateBackground(const QColor &c); 345 void setAlternateBackground(const QColor &c);
335 /** 346 /**
336 * @return the alternate background color 347 * @return the alternate background color
337 * 348 *
338 * @see #setAlternateBackground() 349 * @see #setAlternateBackground()
339 */ 350 */
340 const QColor &alternateBackground() const; 351 const QColor &alternateBackground() const;
341 352
342 /** 353 /**
343 * Saves the list view's layout (column widtsh, column order, sort column) 354 * Saves the list view's layout (column widtsh, column order, sort column)
344 * to a KConfig group 355 * to a KConfig group
345 * 356 *
346 * @param config the @ref KConfig object to write to 357 * @param config the @ref KConfig object to write to
347 * @param group the config group to use 358 * @param group the config group to use
348 */ 359 */
349 void saveLayout(KConfig *config, const QString &group) const; 360 void saveLayout(KConfig *config, const QString &group) const;
350 /** 361 /**
351 * Reads the list view's layout from a KConfig group as stored with 362 * Reads the list view's layout from a KConfig group as stored with
352 * @ref #saveLayout 363 * @ref #saveLayout
353 * 364 *
354 * @param config the @ref KConfig object to read from 365 * @param config the @ref KConfig object to read from
355 * @param group the config group to use 366 * @param group the config group to use
356 */ 367 */
357 void restoreLayout(KConfig *config, const QString &group); 368 void restoreLayout(KConfig *config, const QString &group);
358 /** 369 /**
359 * Reimplemented to remember the current sort column and order. 370 * Reimplemented to remember the current sort column and order.
360 * @param column is the column to be sorted, or -1 to sort in order of 371 * @param column is the column to be sorted, or -1 to sort in order of
361 * insertion 372 * insertion
362 * @param whether to sort ascending (or descending) 373 * @param whether to sort ascending (or descending)
363 */ 374 */
364 virtual void setSorting(int column, bool ascending = true); 375 virtual void setSorting(int column, bool ascending = true);
365 376
366 /** 377 /**
367 * @return the currently sorted column, or -1 if none is sorted 378 * @return the currently sorted column, or -1 if none is sorted
368 */ 379 */
369 int columnSorted(void) const; 380 int columnSorted(void) const;
370 381
371 /** 382 /**
372 * @return whether the current sort is ascending (or descending) 383 * @return whether the current sort is ascending (or descending)
373 */ 384 */
374 bool ascendingSort(void) const; 385 bool ascendingSort(void) const;
375 386
376 //US we do not have a "global KDE" variable to setup singleClick functionality 387 //US we do not have a "global KDE" variable to setup singleClick functionality
377 void setSingleClick(bool s); 388 void setSingleClick(bool s);
378 389
379 390
380signals: 391signals:
381 392
382 /** 393 /**
383 * This signal is emitted whenever the user executes an listview item. 394 * This signal is emitted whenever the user executes an listview item.
384 * That means depending on the KDE wide Single Click/Double Click 395 * That means depending on the KDE wide Single Click/Double Click
385 * setting the user clicked or double clicked on that item. 396 * setting the user clicked or double clicked on that item.
386 * @param item is the pointer to the executed listview item. 397 * @param item is the pointer to the executed listview item.
387 * 398 *
388 * Note that you may not delete any @ref QListViewItem objects in slots 399 * Note that you may not delete any @ref QListViewItem objects in slots
389 * connected to this signal. 400 * connected to this signal.
390 */ 401 */
391 void executed( QListViewItem *item ); 402 void executed( Q3ListViewItem *item );
392 403
393 /** 404 /**
394 * This signal is emitted whenever the user executes an listview item. 405 * This signal is emitted whenever the user executes an listview item.
395 * That means depending on the KDE wide Single Click/Double Click 406 * That means depending on the KDE wide Single Click/Double Click
396 * setting the user clicked or double clicked on that item. 407 * setting the user clicked or double clicked on that item.
397 * @param item is the pointer to the executed listview item. 408 * @param item is the pointer to the executed listview item.
398 * @param pos is the position where the user has clicked 409 * @param pos is the position where the user has clicked
399 * @param c is the column into which the user clicked. 410 * @param c is the column into which the user clicked.
400 * 411 *
401 * Note that you may not delete any @ref QListViewItem objects in slots 412 * Note that you may not delete any @ref QListViewItem objects in slots
402 * connected to this signal. 413 * connected to this signal.
403 */ 414 */
404 void executed( QListViewItem *item, const QPoint &pos, int c ); 415 void executed( Q3ListViewItem *item, const QPoint &pos, int c );
405 416
406 /** 417 /**
407 * This signal gets emitted whenever the user double clicks into the 418 * This signal gets emitted whenever the user double clicks into the
408 * listview. 419 * listview.
409 * @param item is the pointer to the clicked listview item. 420 * @param item is the pointer to the clicked listview item.
410 * @param pos is the position where the user has clicked, and 421 * @param pos is the position where the user has clicked, and
411 * @param c is the column into which the user clicked. 422 * @param c is the column into which the user clicked.
412 * 423 *
413 * Note that you may not delete any @ref QListViewItem objects in slots 424 * Note that you may not delete any @ref QListViewItem objects in slots
414 * connected to this signal. 425 * connected to this signal.
415 * 426 *
416 * This signal is more or less here for the sake of completeness. 427 * This signal is more or less here for the sake of completeness.
417 * You should normally not need to use this. In most cases its better 428 * You should normally not need to use this. In most cases its better
418 * to use @ref #executed() instead. 429 * to use @ref #executed() instead.
419 */ 430 */
420 void doubleClicked( QListViewItem *item, const QPoint &pos, int c ); 431 void doubleClicked( Q3ListViewItem *item, const QPoint &pos, int c );
421 void contextRequest( QListViewItem *item, const QPoint &pos, int c ); 432 void contextRequest( Q3ListViewItem *item, const QPoint &pos, int c );
422 433
423 /** 434 /**
424 * This signal gets emitted whenever something acceptable is 435 * This signal gets emitted whenever something acceptable is
425 * dropped onto the listview. 436 * dropped onto the listview.
426 * 437 *
427 * @param e is the drop event itself (it has already been accepted) 438 * @param e is the drop event itself (it has already been accepted)
428 * @param after is the item after which the drop occured (or 0L, if 439 * @param after is the item after which the drop occured (or 0L, if
429 * the drop was above all items) 440 * the drop was above all items)
430 * 441 *
431 * @see #acceptDrop() 442 * @see #acceptDrop()
432 */ 443 */
433 void dropped (QDropEvent * e, QListViewItem *after); 444 void dropped (QDropEvent * e, Q3ListViewItem *after);
434 445
435 /** 446 /**
436 * This signal gets emitted whenever something acceptable is 447 * This signal gets emitted whenever something acceptable is
437 * dropped onto the listview. 448 * dropped onto the listview.
438 * 449 *
439 * This is an overloaded version of the above (provided to simplify 450 * This is an overloaded version of the above (provided to simplify
440 * processing drops outside of the class). 451 * processing drops outside of the class).
441 * 452 *
442 * @param list is the listview 453 * @param list is the listview
443 * @param e is the drop event itself (it has already been accepted) 454 * @param e is the drop event itself (it has already been accepted)
444 * @param after is the item after which the drop occured (or 0L, if 455 * @param after is the item after which the drop occured (or 0L, if
445 * the drop was above all items 456 * the drop was above all items
446 */ 457 */
447 void dropped (KListView* list, QDropEvent* e, QListViewItem* after); 458 void dropped (KListView* list, QDropEvent* e, Q3ListViewItem* after);
448 459
449 /** 460 /**
450 * This signal gets emitted whenever something acceptable is 461 * This signal gets emitted whenever something acceptable is
451 * dropped onto the listview. 462 * dropped onto the listview.
452 * 463 *
453 * This function also provides a parent, in the event that your listview 464 * This function also provides a parent, in the event that your listview
454 * is a tree 465 * is a tree
455 * @param list is the listview 466 * @param list is the listview
456 * @param e is the drop event itself (it has already been accepted) 467 * @param e is the drop event itself (it has already been accepted)
457 * @param parent the item that is to be the parent of the new item 468 * @param parent the item that is to be the parent of the new item
458 * @param after is the item after which the drop occured (or 0L, if 469 * @param after is the item after which the drop occured (or 0L, if
459 * the drop was above all items 470 * the drop was above all items
460 */ 471 */
461 void dropped (KListView* list, QDropEvent* e, QListViewItem* parent, QListViewItem* after); 472 void dropped (KListView* list, QDropEvent* e, Q3ListViewItem* parent, Q3ListViewItem* after);
462 473
463 /** 474 /**
464 * This signal gets emitted whenever something acceptable is 475 * This signal gets emitted whenever something acceptable is
465 * dropped onto the listview. 476 * dropped onto the listview.
466 * 477 *
467 * This function also provides a parent, in the event that your listview 478 * This function also provides a parent, in the event that your listview
468 * is a tree 479 * is a tree
469 * @param e is the drop event itself (it has already been accepted) 480 * @param e is the drop event itself (it has already been accepted)
470 * @param parent the item that is to be the parent of the new item 481 * @param parent the item that is to be the parent of the new item
471 * @param after is the item after which the drop occured (or 0L, if 482 * @param after is the item after which the drop occured (or 0L, if
472 * the drop was above all items 483 * the drop was above all items
473 */ 484 */
474 void dropped (QDropEvent* e, QListViewItem* parent, QListViewItem* after); 485 void dropped (QDropEvent* e, Q3ListViewItem* parent, Q3ListViewItem* after);
475 486
476 /** 487 /**
477 * This signal is emitted when ever the user moves an item in the list via 488 * This signal is emitted when ever the user moves an item in the list via
478 * DnD. 489 * DnD.
479 * If more than one item is moved at the same time, this signal is only emitted 490 * If more than one item is moved at the same time, this signal is only emitted
480 * once. 491 * once.
481 */ 492 */
482 void moved(); 493 void moved();
483 494
484 /** 495 /**
485 * Connect to this signal if you want to do some preprocessing before 496 * Connect to this signal if you want to do some preprocessing before
486 * a move is made, for example, to disable sorting 497 * a move is made, for example, to disable sorting
487 * 498 *
488 * This is sent only once per each groups of moves. That is, for each 499 * This is sent only once per each groups of moves. That is, for each
489 * drop that is a move this will be emitted once, before KListView calls 500 * drop that is a move this will be emitted once, before KListView calls
490 * @see moveItem() 501 * @see moveItem()
491 */ 502 */
492 void aboutToMove(); 503 void aboutToMove();
493 504
494 /** 505 /**
495 * This signal is emitted when ever the user moves an item in the list via 506 * This signal is emitted when ever the user moves an item in the list via
496 * DnD. 507 * DnD.
497 * If more than one item is moved at the same time, @p afterFirst and 508 * If more than one item is moved at the same time, @p afterFirst and
498 * @p afterNow will reflect what was true before the move. 509 * @p afterNow will reflect what was true before the move.
499 * This differs from @ref moved(), so be careful. All the items will have been 510 * This differs from @ref moved(), so be careful. All the items will have been
500 * moved before @ref moved() is emitted, which is not true in this method. // FIXME 511 * moved before @ref moved() is emitted, which is not true in this method. // FIXME
501 * @param item the item that was moved 512 * @param item the item that was moved
502 * @param afterFirst the item that parameter item was in before the move, in the list 513 * @param afterFirst the item that parameter item was in before the move, in the list
503 * @param afterNow the item it's currently after. 514 * @param afterNow the item it's currently after.
504 */ 515 */
505 void moved (QListViewItem *item, QListViewItem *afterFirst, QListViewItem *afterNow); 516 void moved (Q3ListViewItem *item, Q3ListViewItem *afterFirst, Q3ListViewItem *afterNow);
506 517
507 518
508 /** 519 /**
509 * This signal is emitted after all the items have been moved. It reports info for 520 * This signal is emitted after all the items have been moved. It reports info for
510 * each and every item moved, in order. The first element in @p items associates 521 * each and every item moved, in order. The first element in @p items associates
511 * with the first of afterFirst and afterNow. 522 * with the first of afterFirst and afterNow.
512 */ 523 */
513 void moved(QPtrList<QListViewItem> &items, QPtrList<QListViewItem> &afterFirst, QPtrList<QListViewItem> &afterNow); 524 void moved(Q3PtrList<Q3ListViewItem> &items, Q3PtrList<Q3ListViewItem> &afterFirst, Q3PtrList<Q3ListViewItem> &afterNow);
514 525
515 /** 526 /**
516 * This signal gets emitted when an item is renamed via in-place renaming. 527 * This signal gets emitted when an item is renamed via in-place renaming.
517 * 528 *
518 * @param item is the renamed item. 529 * @param item is the renamed item.
519 * @param str is the new value of column @p col. 530 * @param str is the new value of column @p col.
520 * @param col is the renamed column. 531 * @param col is the renamed column.
521 */ 532 */
522 void itemRenamed(QListViewItem* item, const QString &str, int col); 533 void itemRenamed(Q3ListViewItem* item, const QString &str, int col);
523 534
524 /** 535 /**
525 * Same as above, but without the extra information. 536 * Same as above, but without the extra information.
526 */ 537 */
527 void itemRenamed(QListViewItem* item); 538 void itemRenamed(Q3ListViewItem* item);
528 void signalDelete(); 539 void signalDelete();
529 540
530 /** 541 /**
531 * This signal is emitted when the shortcut key for popup-menus is pressed. 542 * This signal is emitted when the shortcut key for popup-menus is pressed.
532 * 543 *
533 * Normally you should not use this, just connect a slot to signal 544 * Normally you should not use this, just connect a slot to signal
534 * @ref contextMenu (KListView*, QListViewItem*, const QPoint&) to correctly 545 * @ref contextMenu (KListView*, QListViewItem*, const QPoint&) to correctly
535 * handle showing context menus regardless of settings. 546 * handle showing context menus regardless of settings.
536 * 547 *
537 * @param list is this listview. 548 * @param list is this listview.
538 * @param item is the @ref currentItem() at the time the key was pressed. May be 0L. 549 * @param item is the @ref currentItem() at the time the key was pressed. May be 0L.
539 */ 550 */
540 void menuShortCutPressed (KListView* list, QListViewItem* item); 551 void menuShortCutPressed (KListView* list, Q3ListViewItem* item);
541 552
542 /** 553 /**
543 * This signal is emitted whenever a context-menu should be shown for item @p i. 554 * This signal is emitted whenever a context-menu should be shown for item @p i.
544 * It automatically adjusts for all settings involved (Menu key, showMenuOnPress/Click). 555 * It automatically adjusts for all settings involved (Menu key, showMenuOnPress/Click).
545 * 556 *
546 * @param l is this listview. 557 * @param l is this listview.
547 * @param i is the item for which the menu should be shown. May be 0L. 558 * @param i is the item for which the menu should be shown. May be 0L.
548 * @param p is the point at which the menu should be shown. 559 * @param p is the point at which the menu should be shown.
549 */ 560 */
550 void contextMenu (KListView* l, QListViewItem* i, const QPoint& p); 561 void contextMenu (KListView* l, Q3ListViewItem* i, const QPoint& p);
551 562
552public slots: 563public slots:
553 /** 564 /**
554 * Rename column @p c of @p item. 565 * Rename column @p c of @p item.
555 */ 566 */
556 virtual void rename(QListViewItem *item, int c); 567 virtual void rename(Q3ListViewItem *item, int c);
557 568
558 /** 569 /**
559 * By default, if you called setItemsRenameable(true), 570 * By default, if you called setItemsRenameable(true),
560 * only the first column is renameable. 571 * only the first column is renameable.
561 * Use this function to enable the feature on other columns. 572 * Use this function to enable the feature on other columns.
562 * 573 *
563 * If you want more intelligent (dynamic) selection, 574 * If you want more intelligent (dynamic) selection,
564 * you'll have to derive from KListView, 575 * you'll have to derive from KListView,
565 * and override @ref rename() and call only call it 576 * and override @ref rename() and call only call it
566 * if you want the item to be renamed. 577 * if you want the item to be renamed.
567 */ 578 */
568 void setRenameable (int column, bool yesno=true); 579 void setRenameable (int column, bool yesno=true);
569 580
570 /** 581 /**
571 * Set whether items in the list view can be moved. 582 * Set whether items in the list view can be moved.
572 * It is enabled by default. 583 * It is enabled by default.
573 * 584 *
574 * @see itemsMovable() 585 * @see itemsMovable()
575 */ 586 */
576 virtual void setItemsMovable(bool b); 587 virtual void setItemsMovable(bool b);
577 588
578 /** 589 /**
579 * Enables inplace-renaming of items. 590 * Enables inplace-renaming of items.
580 * It is disabled by default. 591 * It is disabled by default.
581 * 592 *
582 * @see itemsRenameable() 593 * @see itemsRenameable()
583 * @see setRenameable() 594 * @see setRenameable()
584 */ 595 */
585 virtual void setItemsRenameable(bool b); 596 virtual void setItemsRenameable(bool b);
586 597
587 /** 598 /**
588 * Enable/Disable the dragging of items. 599 * Enable/Disable the dragging of items.
589 * It is disabled by default. 600 * It is disabled by default.
590 */ 601 */
591 virtual void setDragEnabled(bool b); 602 virtual void setDragEnabled(bool b);
592 603
593 /** 604 /**
594 * Enable/Disable AutoOpen (not implemented currently). 605 * Enable/Disable AutoOpen (not implemented currently).
595 */ 606 */
596 virtual void setAutoOpen(bool b); 607 virtual void setAutoOpen(bool b);
597 608
598 /** 609 /**
599 * Enable/Disable the drawing of a drop-visualizer 610 * Enable/Disable the drawing of a drop-visualizer
600 * (a bar that shows where a dropped item would be inserted). 611 * (a bar that shows where a dropped item would be inserted).
601 * It is enabled by default, if dragging is enabled 612 * It is enabled by default, if dragging is enabled
602 */ 613 */
603 virtual void setDropVisualizer(bool b); 614 virtual void setDropVisualizer(bool b);
604 615
605 /** 616 /**
606 * Set the width of the (default) drop-visualizer. 617 * Set the width of the (default) drop-visualizer.
607 * If you don't call this method, the width is set to 4. 618 * If you don't call this method, the width is set to 4.
608 */ 619 */
609 void setDropVisualizerWidth (int w); 620 void setDropVisualizerWidth (int w);
610 621
611 /** 622 /**
612 * Set which column should be used for automatic tooltips. 623 * Set which column should be used for automatic tooltips.
613 * 624 *
614 * @param column is the column for which tooltips will be shown. 625 * @param column is the column for which tooltips will be shown.
615 * Set -1 to disable this feature. 626 * Set -1 to disable this feature.
616 */ 627 */
617 virtual void setTooltipColumn(int column); 628 virtual void setTooltipColumn(int column);
618 629
619 /** 630 /**
620 * Enable/Disable the drawing of a drop-highlighter 631 * Enable/Disable the drawing of a drop-highlighter
621 * (a rectangle around the item under the mouse cursor). 632 * (a rectangle around the item under the mouse cursor).
622 * It is disabled by default. 633 * It is disabled by default.
623 */ 634 */
624 virtual void setDropHighlighter(bool b); 635 virtual void setDropHighlighter(bool b);
625 636
626 /** 637 /**
627 * For future expansions. 638 * For future expansions.
628 * 639 *
629 * Do not use. 640 * Do not use.
630 * @deprecated 641 * @deprecated
631 */ 642 */
632 virtual void setCreateChildren(bool b); 643 virtual void setCreateChildren(bool b);
633 644
634 /** 645 /**
635 * Set the selection mode. 646 * Set the selection mode.
636 * 647 *
637 * A different name was chosen to avoid API-clashes with @ref QListView::setSelectionMode(). 648 * A different name was chosen to avoid API-clashes with @ref QListView::setSelectionMode().
638 */ 649 */
639 void setSelectionModeExt (SelectionModeExt mode); 650 void setSelectionModeExt (SelectionModeExt mode);
640 651
641 /** 652 /**
642 * Enable/disable tabbing between editable cells 653 * Enable/disable tabbing between editable cells
643 * @since 3.1 654 * @since 3.1
644 */ 655 */
645 void setTabOrderedRenaming(bool b); 656 void setTabOrderedRenaming(bool b);
646 657
647 /** 658 /**
648 * Returns whether tab ordered renaming is enabled 659 * Returns whether tab ordered renaming is enabled
649 * @since 3.1 660 * @since 3.1
650 */ 661 */
651 bool tabOrderedRenaming() const; 662 bool tabOrderedRenaming() const;
652 663
653protected: 664protected:
654 /** 665 /**
655 * Determine whether a drop on position @p p would count as 666 * Determine whether a drop on position @p p would count as
656 * being above or below the QRect @p rect. 667 * being above or below the QRect @p rect.
657 * 668 *
658 * @param rect is the rectangle we examine. 669 * @param rect is the rectangle we examine.
659 * @param p is the point located in the rectangle, p is assumed to be in 670 * @param p is the point located in the rectangle, p is assumed to be in
660 * viewport coordinates. 671 * viewport coordinates.
661 */ 672 */
662 inline bool below (const QRect& rect, const QPoint& p) 673 inline bool below (const QRect& rect, const QPoint& p)
663 { 674 {
664 return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2)); 675 return (p.y() > (rect.top() + (rect.bottom() - rect.top())/2));
665 } 676 }
666 677
667 /** 678 /**
668 * An overloaded version of below(const QRect&, const QPoint&). 679 * An overloaded version of below(const QRect&, const QPoint&).
669 * 680 *
670 * It differs from the above only in what arguments it takes. 681 * It differs from the above only in what arguments it takes.
671 * 682 *
672 * @param i the item whose rect() is passed to the above function. 683 * @param i the item whose rect() is passed to the above function.
673 * @param p is translated from contents coordinates to viewport coordinates 684 * @param p is translated from contents coordinates to viewport coordinates
674 * before being passed to the above function. 685 * before being passed to the above function.
675 */ 686 */
676 inline bool below (QListViewItem* i, const QPoint& p) 687 inline bool below (Q3ListViewItem* i, const QPoint& p)
677 { 688 {
678 return below (itemRect(i), contentsToViewport(p)); 689 return below (itemRect(i), contentsToViewport(p));
679 } 690 }
680 691
681 /** 692 /**
682 * Reimplemented to reload the alternate background in palette changes. 693 * Reimplemented to reload the alternate background in palette changes.
683 * @internal 694 * @internal
684 */ 695 */
685 virtual bool event( QEvent * ); 696 virtual bool event( QEvent * );
686 697
687 /** 698 /**
688 * Emit signal @ref #executed. 699 * Emit signal @ref #executed.
689 * @internal 700 * @internal
690 */ 701 */
691 //US I added buttonstate to pass the current keyboard status 702 //US I added buttonstate to pass the current keyboard status
692 void emitExecute( int buttonstate, QListViewItem *item, const QPoint &pos, int c); 703 void emitExecute( int buttonstate, Q3ListViewItem *item, const QPoint &pos, int c);
693 704
694 /** 705 /**
695 * Reimplemented for internal reasons. 706 * Reimplemented for internal reasons.
696 * Further reimplementations should call this function or else 707 * Further reimplementations should call this function or else
697 * some features may not work correctly. 708 * some features may not work correctly.
698 * 709 *
699 * The API is unaffected. 710 * The API is unaffected.
700 */ 711 */
701 virtual void focusInEvent(QFocusEvent* fe); 712 virtual void focusInEvent(QFocusEvent* fe);
702 713
703 /** 714 /**
704 * Reimplemented for internal reasons. 715 * Reimplemented for internal reasons.
705 * Further reimplementations should call this function or else 716 * Further reimplementations should call this function or else
706 * some features may not work correctly. 717 * some features may not work correctly.
707 * 718 *
708 * The API is unaffected. 719 * The API is unaffected.
709 */ 720 */
710 virtual void focusOutEvent( QFocusEvent *fe ); 721 virtual void focusOutEvent( QFocusEvent *fe );
711 722
712 /** 723 /**
713 * Reimplemented for internal reasons. 724 * Reimplemented for internal reasons.
714 * Further reimplementations should call this function or else 725 * Further reimplementations should call this function or else
715 * some features may not work correctly. 726 * some features may not work correctly.
716 * 727 *
717 * The API is unaffected. 728 * The API is unaffected.
718 */ 729 */
719 virtual void leaveEvent( QEvent *e ); 730 virtual void leaveEvent( QEvent *e );
720 731
721 /** 732 /**
722 * @return the tooltip for @p column of @p item. 733 * @return the tooltip for @p column of @p item.
723 */ 734 */
724 virtual QString tooltip(QListViewItem* item, int column) const; 735 virtual QString tooltip(Q3ListViewItem* item, int column) const;
725 736
726 /** 737 /**
727 * @return whether the tooltip for @p column of @p item shall be shown at point @p pos. 738 * @return whether the tooltip for @p column of @p item shall be shown at point @p pos.
728 */ 739 */
729 virtual bool showTooltip(QListViewItem *item, const QPoint &pos, int column) const; 740 virtual bool showTooltip(Q3ListViewItem *item, const QPoint &pos, int column) const;
730 741
731 /** 742 /**
732 * Reimplemented for internal reasons. 743 * Reimplemented for internal reasons.
733 * Further reimplementations should call this function or else 744 * Further reimplementations should call this function or else
734 * some features may not work correctly. 745 * some features may not work correctly.
735 * 746 *
736 * The API is unaffected. 747 * The API is unaffected.
737 */ 748 */
738 virtual void contentsDragMoveEvent (QDragMoveEvent *event); 749 virtual void contentsDragMoveEvent (QDragMoveEvent *event);
739 750
740 /** 751 /**
741 * Reimplemented for internal reasons. 752 * Reimplemented for internal reasons.
742 * Further reimplementations should call this function or else 753 * Further reimplementations should call this function or else
743 * some features may not work correctly. 754 * some features may not work correctly.
744 * 755 *
745 * The API is unaffected. 756 * The API is unaffected.
746 */ 757 */
747 virtual void contentsMousePressEvent( QMouseEvent *e ); 758 virtual void contentsMousePressEvent( QMouseEvent *e );
748 759
749 /** 760 /**
750 * Reimplemented for internal reasons. 761 * Reimplemented for internal reasons.
751 * Further reimplementations should call this function or else 762 * Further reimplementations should call this function or else
752 * some features may not work correctly. 763 * some features may not work correctly.
753 * 764 *
754 * The API is unaffected. 765 * The API is unaffected.
755 */ 766 */
756 virtual void contentsMouseMoveEvent( QMouseEvent *e ); 767 virtual void contentsMouseMoveEvent( QMouseEvent *e );
757 768
758 /** 769 /**
759 * Reimplemented for internal reasons. 770 * Reimplemented for internal reasons.
760 * Further reimplementations should call this function or else 771 * Further reimplementations should call this function or else
761 * some features may not work correctly. 772 * some features may not work correctly.
762 * 773 *
763 * The API is unaffected. 774 * The API is unaffected.
764 */ 775 */
765 virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e ); 776 virtual void contentsMouseDoubleClickEvent ( QMouseEvent *e );
766 777
767 /** 778 /**
768 * Reimplemented for internal reasons. 779 * Reimplemented for internal reasons.
769 * Further reimplementations should call this function or else 780 * Further reimplementations should call this function or else
770 * some features may not work correctly. 781 * some features may not work correctly.
771 * 782 *
772 * The API is unaffected. 783 * The API is unaffected.
773 */ 784 */
774 virtual void contentsDragLeaveEvent (QDragLeaveEvent *event); 785 virtual void contentsDragLeaveEvent (QDragLeaveEvent *event);
775 786
776 /** 787 /**
777 * Reimplemented for internal reasons. 788 * Reimplemented for internal reasons.
778 * Further reimplementations should call this function or else 789 * Further reimplementations should call this function or else
779 * some features may not work correctly. 790 * some features may not work correctly.
780 * 791 *
781 * The API is unaffected. 792 * The API is unaffected.
782 */ 793 */
783 virtual void contentsMouseReleaseEvent (QMouseEvent*); 794 virtual void contentsMouseReleaseEvent (QMouseEvent*);
784 795
785 /** 796 /**
786 * Reimplemented for internal reasons. 797 * Reimplemented for internal reasons.
787 * Further reimplementations should call this function or else 798 * Further reimplementations should call this function or else
788 * some features may not work correctly. 799 * some features may not work correctly.
789 * 800 *
790 * The API is unaffected. 801 * The API is unaffected.
791 */ 802 */
792 virtual void contentsDropEvent (QDropEvent*); 803 virtual void contentsDropEvent (QDropEvent*);
793 804
794 /** 805 /**
795 * Reimplemented for internal reasons. 806 * Reimplemented for internal reasons.
796 * Further reimplementations should call this function or else 807 * Further reimplementations should call this function or else
797 * some features may not work correctly. 808 * some features may not work correctly.
798 * 809 *
799 * The API is unaffected. 810 * The API is unaffected.
800 */ 811 */
801 virtual void contentsDragEnterEvent (QDragEnterEvent *); 812 virtual void contentsDragEnterEvent (QDragEnterEvent *);
802 813
803 /** 814 /**
804 * @return a dragobject encoding the current selection. 815 * @return a dragobject encoding the current selection.
805 * 816 *
806 * @see setDragEnabled() 817 * @see setDragEnabled()
807 */ 818 */
808 virtual QDragObject *dragObject(); 819 virtual Q3DragObject *dragObject();
809 820
810 /** 821 /**
811 * @return true if the @p event provides some acceptable 822 * @return true if the @p event provides some acceptable
812 * format. 823 * format.
813 * A common mistake is to forget the "const" in your reimplementation 824 * A common mistake is to forget the "const" in your reimplementation
814 */ 825 */
815 virtual bool acceptDrag (QDropEvent* event) const; 826 virtual bool acceptDrag (QDropEvent* event) const;
816 827
817 /** 828 /**
818 * Paint the drag line. If painter is null, don't try to :) 829 * Paint the drag line. If painter is null, don't try to :)
819 * 830 *
820 * If after == 0 then the marker should be drawn at the top. 831 * If after == 0 then the marker should be drawn at the top.
821 * 832 *
822 * @return the rectangle that you painted to. 833 * @return the rectangle that you painted to.
823 */ 834 */
824 virtual QRect drawDropVisualizer (QPainter *p, QListViewItem *parent, QListViewItem *after); 835 virtual QRect drawDropVisualizer (QPainter *p, Q3ListViewItem *parent, Q3ListViewItem *after);
825 836
826 /** 837 /**
827 * Paint the drag rectangle. If painter is null, don't try to :) 838 * Paint the drag rectangle. If painter is null, don't try to :)
828 * 839 *
829 * 840 *
830 * @return the rectangle that you painted to. 841 * @return the rectangle that you painted to.
831 */ 842 */
832 virtual QRect drawItemHighlighter(QPainter *painter, QListViewItem *item); 843 virtual QRect drawItemHighlighter(QPainter *painter, Q3ListViewItem *item);
833 844
834 /** 845 /**
835 * This method calls @ref dragObject() and starts the drag. 846 * This method calls @ref dragObject() and starts the drag.
836 * 847 *
837 * Reimplement it to do fancy stuff like setting a pixmap or 848 * Reimplement it to do fancy stuff like setting a pixmap or
838 * using a non-default DragMode 849 * using a non-default DragMode
839 */ 850 */
840 virtual void startDrag(); 851 virtual void startDrag();
841 852
842 /** 853 /**
843 * Reimplemented for internal reasons. 854 * Reimplemented for internal reasons.
844 * Further reimplementations should call this function or else 855 * Further reimplementations should call this function or else
845 * some features may not work correctly. 856 * some features may not work correctly.
846 * 857 *
847 * The API is unaffected. 858 * The API is unaffected.
848 */ 859 */
849 virtual void keyPressEvent (QKeyEvent*); 860 virtual void keyPressEvent (QKeyEvent*);
850 861
851 /** 862 /**
852 * Reimplemented for internal reasons. 863 * Reimplemented for internal reasons.
853 * Further reimplementations should call this function or else 864 * Further reimplementations should call this function or else
854 * some features may not work correctly. 865 * some features may not work correctly.
855 * 866 *
856 * The API is unaffected. 867 * The API is unaffected.
857 */ 868 */
858 virtual void viewportPaintEvent(QPaintEvent*); 869 virtual void viewportPaintEvent(QPaintEvent*);
859 870
860 /** 871 /**
861 * In FileManager selection mode: explicitely activate the mode 872 * In FileManager selection mode: explicitely activate the mode
862 * in which the current item is automatically selected. 873 * in which the current item is automatically selected.
863 */ 874 */
864 void activateAutomaticSelection(); 875 void activateAutomaticSelection();
865 /** 876 /**
866 * In FileManager selection mode: explicitely deactivate the mode 877 * In FileManager selection mode: explicitely deactivate the mode
867 * in which the current item is automatically selected. 878 * in which the current item is automatically selected.
868 */ 879 */
869 void deactivateAutomaticSelection(); 880 void deactivateAutomaticSelection();
870 /** 881 /**
871 * In FileManager selection mode: return whether it is currently in the mode 882 * In FileManager selection mode: return whether it is currently in the mode
872 * where the current item is selected automatically. 883 * where the current item is selected automatically.
873 * Returns false if items were selected explicitely, e.g. using the mouse. 884 * Returns false if items were selected explicitely, e.g. using the mouse.
874 */ 885 */
875 bool automaticSelection() const; 886 bool automaticSelection() const;
876 887
877 /** 888 /**
878 * Reimplemented for setFullWidth() 889 * Reimplemented for setFullWidth()
879 */ 890 */
880 virtual void viewportResizeEvent(QResizeEvent* e); 891 virtual void viewportResizeEvent(QResizeEvent* e);
881 892
882protected slots: 893protected slots:
883 /** 894 /**
884 * Update internal settings whenever the global ones change. 895 * Update internal settings whenever the global ones change.
885 * @internal 896 * @internal
886 */ 897 */
887 void slotSettingsChanged(int); 898 void slotSettingsChanged(int);
888 899
889 void slotMouseButtonClicked( int btn, QListViewItem *item, const QPoint &pos, int c ); 900 void slotMouseButtonClicked( int btn, Q3ListViewItem *item, const QPoint &pos, int c );
890 void doneEditing(QListViewItem *item, int row); 901 void doneEditing(Q3ListViewItem *item, int row);
891 902
892 /** 903 /**
893 * Repaint the rect where I was drawing the drop line. 904 * Repaint the rect where I was drawing the drop line.
894 */ 905 */
895 void cleanDropVisualizer(); 906 void cleanDropVisualizer();
896 907
897 /** 908 /**
898 * Repaint the rect where I was drawing the drop rectangle. 909 * Repaint the rect where I was drawing the drop rectangle.
899 */ 910 */
900 void cleanItemHighlighter(); 911 void cleanItemHighlighter();
901 912
902 /** 913 /**
903 * Emit the @ref contextMenu signal. This slot is for mouse actions. 914 * Emit the @ref contextMenu signal. This slot is for mouse actions.
904 */ 915 */
905 void emitContextMenu (QListViewItem*, const QPoint&, int); 916 void emitContextMenu (Q3ListViewItem*, const QPoint&, int);
906 917
907 /** 918 /**
908 * Emit the @ref #contextMenu signal. This slot is for key presses. 919 * Emit the @ref #contextMenu signal. This slot is for key presses.
909 */ 920 */
910 void emitContextMenu (KListView*, QListViewItem*); 921 void emitContextMenu (KListView*, Q3ListViewItem*);
911 922
912 /** 923 /**
913 * Accessory slot for AutoSelect 924 * Accessory slot for AutoSelect
914 * @internal 925 * @internal
915 */ 926 */
916 void slotOnItem( QListViewItem *item ); 927 void slotOnItem( Q3ListViewItem *item );
917 928
918 /** 929 /**
919 * Accessory slot for AutoSelect/ChangeCursorOverItem 930 * Accessory slot for AutoSelect/ChangeCursorOverItem
920 * @internal 931 * @internal
921 */ 932 */
922 void slotOnViewport(); 933 void slotOnViewport();
923 934
924 /** 935 /**
925 * Process AutoSelection. 936 * Process AutoSelection.
926 * @internal 937 * @internal
927 */ 938 */
928 void slotAutoSelect(); 939 void slotAutoSelect();
929 940
930 void slotDragExpand(); 941 void slotDragExpand();
931 942
932 /** 943 /**
933 * Reacts to header changes in full width mode 944 * Reacts to header changes in full width mode
934 * @internal 945 * @internal
935 */ 946 */
936 void slotHeaderChanged(); 947 void slotHeaderChanged();
937 948
938protected: 949protected:
939 /** 950 /**
940 * Handle dropEvent when itemsMovable() is set to true. 951 * Handle dropEvent when itemsMovable() is set to true.
941 */ 952 */
942 virtual void movableDropEvent (QListViewItem* parent, QListViewItem* afterme); 953 virtual void movableDropEvent (Q3ListViewItem* parent, Q3ListViewItem* afterme);
943 954
944 /** 955 /**
945 * Where is the nearest QListViewItem that I'm going to drop? 956 * Where is the nearest QListViewItem that I'm going to drop?
946 * 957 *
947 * FIXME KDE 4.0: Make this method const so it can be called from an 958 * FIXME KDE 4.0: Make this method const so it can be called from an
948 * acceptDrag method without ugly casts 959 * acceptDrag method without ugly casts
949 */ 960 */
950 virtual void findDrop(const QPoint &pos, QListViewItem *&parent, QListViewItem *&after); 961 virtual void findDrop(const QPoint &pos, Q3ListViewItem *&parent, Q3ListViewItem *&after);
951 962
952 /** 963 /**
953 * A special keyPressEvent (for FileManager selection mode). 964 * A special keyPressEvent (for FileManager selection mode).
954 */ 965 */
955 void fileManagerKeyPressEvent (QKeyEvent*); 966 void fileManagerKeyPressEvent (QKeyEvent*);
956 967
957 /** 968 /**
958 * Convert the depth of an item into its indentation in pixels 969 * Convert the depth of an item into its indentation in pixels
959 */ 970 */
960 int depthToPixels( int depth ); 971 int depthToPixels( int depth );
961 972
962private: 973private:
963 class Tooltip; 974 class Tooltip;
964protected: 975protected:
965 virtual void virtual_hook( int id, void* data ); 976 virtual void virtual_hook( int id, void* data );
966private: 977private:
967 class KListViewPrivate; 978 class KListViewPrivate;
968 KListViewPrivate *d; 979 KListViewPrivate *d;
969}; 980};
970 981
971/** 982/**
972 * A listview item with support for alternate background colours. It is 983 * A listview item with support for alternate background colours. It is
973 * a drop-in replacement for @ref QListViewItem 984 * a drop-in replacement for @ref QListViewItem
974 * 985 *
975 * @short listview item with alternate background colour support 986 * @short listview item with alternate background colour support
976 */ 987 */
977class KListViewItem : public QListViewItem 988class KListViewItem : public Q3ListViewItem
978{ 989{
979public: 990public:
980 /** 991 /**
981 * constructors. The semantics remain as in @ref QListViewItem. 992 * constructors. The semantics remain as in @ref QListViewItem.
982 * Although they accept a @ref QListViewItem as parent, please 993 * Although they accept a @ref QListViewItem as parent, please
983 * don't mix KListViewItem (or subclasses) with QListViewItem 994 * don't mix KListViewItem (or subclasses) with QListViewItem
984 * (or subclasses). 995 * (or subclasses).
985 */ 996 */
986 KListViewItem(QListView *parent); 997 KListViewItem(Q3ListView *parent);
987 KListViewItem(QListViewItem *parent); 998 KListViewItem(Q3ListViewItem *parent);
988 KListViewItem(QListView *parent, QListViewItem *after); 999 KListViewItem(Q3ListView *parent, Q3ListViewItem *after);
989 KListViewItem(QListViewItem *parent, QListViewItem *after); 1000 KListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after);
990 1001
991 KListViewItem(QListView *parent, 1002 KListViewItem(Q3ListView *parent,
992 QString, QString = QString::null, 1003 QString, QString = QString::null,
993 QString = QString::null, QString = QString::null, 1004 QString = QString::null, QString = QString::null,
994 QString = QString::null, QString = QString::null, 1005 QString = QString::null, QString = QString::null,
995 QString = QString::null, QString = QString::null); 1006 QString = QString::null, QString = QString::null);
996 1007
997 KListViewItem(QListViewItem *parent, 1008 KListViewItem(Q3ListViewItem *parent,
998 QString, QString = QString::null, 1009 QString, QString = QString::null,
999 QString = QString::null, QString = QString::null, 1010 QString = QString::null, QString = QString::null,
1000 QString = QString::null, QString = QString::null, 1011 QString = QString::null, QString = QString::null,
1001 QString = QString::null, QString = QString::null); 1012 QString = QString::null, QString = QString::null);
1002 1013
1003 KListViewItem(QListView *parent, QListViewItem *after, 1014 KListViewItem(Q3ListView *parent, Q3ListViewItem *after,
1004 QString, QString = QString::null, 1015 QString, QString = QString::null,
1005 QString = QString::null, QString = QString::null, 1016 QString = QString::null, QString = QString::null,
1006 QString = QString::null, QString = QString::null, 1017 QString = QString::null, QString = QString::null,
1007 QString = QString::null, QString = QString::null); 1018 QString = QString::null, QString = QString::null);
1008 1019
1009 KListViewItem(QListViewItem *parent, QListViewItem *after, 1020 KListViewItem(Q3ListViewItem *parent, Q3ListViewItem *after,
1010 QString, QString = QString::null, 1021 QString, QString = QString::null,
1011 QString = QString::null, QString = QString::null, 1022 QString = QString::null, QString = QString::null,
1012 QString = QString::null, QString = QString::null, 1023 QString = QString::null, QString = QString::null,
1013 QString = QString::null, QString = QString::null); 1024 QString = QString::null, QString = QString::null);
1014 1025
1015 virtual ~KListViewItem(); 1026 virtual ~KListViewItem();
1016 1027
1017 /** 1028 /**
1018 * retuns true if this item is to be drawn with the alternate background 1029 * retuns true if this item is to be drawn with the alternate background
1019 */ 1030 */
1020 bool isAlternate(); 1031 bool isAlternate();
1021 /** 1032 /**
1022 * returns the background colour for this item 1033 * returns the background colour for this item
1023 */ 1034 */
1024 const QColor &backgroundColor(); 1035 const QColor &backgroundColor();
1025 1036
1026 virtual void paintCell(QPainter *p, const QColorGroup &cg, 1037 virtual void paintCell(QPainter *p, const QColorGroup &cg,
1027 int column, int width, int alignment); 1038 int column, int width, int alignment);
1028 1039
1029private: 1040private:
1030 void init(); 1041 void init();
1031 1042
1032private: 1043private:
1033 uint m_odd : 1; 1044 uint m_odd : 1;
1034 uint m_known : 1; 1045 uint m_known : 1;
1035 uint m_unused : 30; 1046 uint m_unused : 30;
1036}; 1047};
1037 1048
1038#endif 1049#endif
1039 1050
1040// vim: ts=2 sw=2 et 1051// vim: ts=2 sw=2 et
diff --git a/microkde/kdeui/kmainwindow.cpp b/microkde/kdeui/kmainwindow.cpp
index fa678f2..bac0db8 100644
--- a/microkde/kdeui/kmainwindow.cpp
+++ b/microkde/kdeui/kmainwindow.cpp
@@ -1,996 +1,993 @@
1 /* This file is part of the KDE libraries 1 /* This file is part of the KDE libraries
2 Copyright 2 Copyright
3 (C) 2000 Reginald Stadlbauer (reggie@kde.org) 3 (C) 2000 Reginald Stadlbauer (reggie@kde.org)
4 (C) 1997 Stephan Kulow (coolo@kde.org) 4 (C) 1997 Stephan Kulow (coolo@kde.org)
5 (C) 1997-2000 Sven Radej (radej@kde.org) 5 (C) 1997-2000 Sven Radej (radej@kde.org)
6 (C) 1997-2000 Matthias Ettrich (ettrich@kde.org) 6 (C) 1997-2000 Matthias Ettrich (ettrich@kde.org)
7 (C) 1999 Chris Schlaeger (cs@kde.org) 7 (C) 1999 Chris Schlaeger (cs@kde.org)
8 (C) 2002 Joseph Wenninger (jowenn@kde.org) 8 (C) 2002 Joseph Wenninger (jowenn@kde.org)
9 9
10 This library is free software; you can redistribute it and/or 10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Library General Public 11 modify it under the terms of the GNU Library General Public
12 License version 2 as published by the Free Software Foundation. 12 License version 2 as published by the Free Software Foundation.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23 */ 23 */
24#include <qobjectlist.h> 24#include <qobject.h>
25#include <qstringlist.h> 25#include <qstringlist.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qmenubar.h> 27#include <qmenubar.h>
28#include <qstatusbar.h> 28#include <qstatusbar.h>
29#include <qapplication.h> 29#include <qapplication.h>
30//Added by qt3to4:
31#include <QCloseEvent>
32#include <QPaintEvent>
33#include <QResizeEvent>
34#include <QChildEvent>
35#include <Q3PtrList>
30 36
31 37
32#include "kdebug.h" 38#include "kdebug.h"
33#include "kmainwindow.h" 39#include "kmainwindow.h"
34#include "kglobalsettings.h" 40#include "kglobalsettings.h"
35#include "kactioncollection.h" 41#include "kactioncollection.h"
36 42
37class KMainWindowPrivate { 43class KMainWindowPrivate {
38public: 44public:
39//US bool showHelpMenu:1; 45//US bool showHelpMenu:1;
40 46
41 bool autoSaveSettings:1; 47 bool autoSaveSettings:1;
42 bool settingsDirty:1; 48 bool settingsDirty:1;
43 bool autoSaveWindowSize:1; 49 bool autoSaveWindowSize:1;
44 bool care_about_geometry:1; 50 bool care_about_geometry:1;
45 QString autoSaveGroup; 51 QString autoSaveGroup;
46//US KAccel * kaccel; 52//US KAccel * kaccel;
47//US KMainWindowInterface *m_interface; 53//US KMainWindowInterface *m_interface;
48 KDEPrivate::ToolBarHandler *toolBarHandler; 54 KDEPrivate::ToolBarHandler *toolBarHandler;
49 QTimer* settingsTimer; 55 QTimer* settingsTimer;
50 KToggleAction *showStatusBarAction; 56 KToggleAction *showStatusBarAction;
51 QRect defaultWindowSize; 57 QRect defaultWindowSize;
52}; 58};
53 59
54static bool no_query_exit = false; 60static bool no_query_exit = false;
55 61
56KMainWindow::KMainWindow( QWidget* parent, const char *name ) 62KMainWindow::KMainWindow( QWidget* parent, const char *name )
57 : QMainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/ 63 : Q3MainWindow( parent, name ) /*LR, f ) with the default widget flag we cannot have fastload */ /*US, KXMLGUIBuilder( this ), helpMenu2( 0 ), factory_( 0 )*/
58{ 64{
59 mQToolBar = 0; 65 mQToolBar = 0;
60 initKMainWindow(name); 66 initKMainWindow(name);
61} 67}
62 68
63void KMainWindow::parseGeometry(bool parsewidth) 69void KMainWindow::parseGeometry(bool parsewidth)
64{ 70{
65//US the following code is not getting used in the embedded version !! So disable it for now 71//US the following code is not getting used in the embedded version !! So disable it for now
66/*US 72/*US
67 73
68 assert ( !kapp->geometryArgument().isNull() ); 74 assert ( !kapp->geometryArgument().isNull() );
69 assert ( d->care_about_geometry ); 75 assert ( d->care_about_geometry );
70 76
71#ifndef Q_WS_QWS 77#ifndef Q_WS_QWS
72 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it) 78 // FIXME: (E) Implement something similar for Qt Embedded (or decide we don't need it)
73 int x, y; 79 int x, y;
74 int w, h; 80 int w, h;
75 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h); 81 int m = XParseGeometry( kapp->geometryArgument().latin1(), &x, &y, (unsigned int*)&w, (unsigned int*)&h);
76 if (parsewidth) { 82 if (parsewidth) {
77 QSize minSize = minimumSize(); 83 QSize minSize = minimumSize();
78 QSize maxSize = maximumSize(); 84 QSize maxSize = maximumSize();
79 if ( (m & WidthValue) == 0 ) 85 if ( (m & WidthValue) == 0 )
80 w = width(); 86 w = width();
81 if ( (m & HeightValue) == 0 ) 87 if ( (m & HeightValue) == 0 )
82 h = height(); 88 h = height();
83 w = QMIN(w,maxSize.width()); 89 w = QMIN(w,maxSize.width());
84 h = QMIN(h,maxSize.height()); 90 h = QMIN(h,maxSize.height());
85 w = QMAX(w,minSize.width()); 91 w = QMAX(w,minSize.width());
86 h = QMAX(h,minSize.height()); 92 h = QMAX(h,minSize.height());
87 resize(w, h); 93 resize(w, h);
88 } else { 94 } else {
89 if ( parsewidth && (m & XValue) == 0 ) 95 if ( parsewidth && (m & XValue) == 0 )
90 x = geometry().x(); 96 x = geometry().x();
91 if ( parsewidth && (m & YValue) == 0 ) 97 if ( parsewidth && (m & YValue) == 0 )
92 y = geometry().y(); 98 y = geometry().y();
93 if ( (m & XNegative) ) 99 if ( (m & XNegative) )
94 x = KApplication::desktop()->width() + x - w; 100 x = KApplication::desktop()->width() + x - w;
95 if ( (m & YNegative) ) 101 if ( (m & YNegative) )
96 y = KApplication::desktop()->height() + y - h; 102 y = KApplication::desktop()->height() + y - h;
97 move(x, y); 103 move(x, y);
98 } 104 }
99#endif 105#endif
100*/ 106*/
101} 107}
102 108
103KMainWindow::~KMainWindow() 109KMainWindow::~KMainWindow()
104{ 110{
105 delete d->settingsTimer; 111 delete d->settingsTimer;
106 QMenuBar* mb = internalMenuBar(); 112 QMenuBar* mb = internalMenuBar();
107 delete mb; 113 delete mb;
108//US delete d->m_interface; 114//US delete d->m_interface;
109 115
110 delete d; 116 delete d;
111//US memberList->remove( this ); 117//US memberList->remove( this );
112} 118}
113 119
114void KMainWindow::initKMainWindow(const char *name) 120void KMainWindow::initKMainWindow(const char *name)
115{ 121{
116 setDockMenuEnabled( FALSE ); 122 setDockMenuEnabled( FALSE );
117//US mHelpMenu = 0; 123//US mHelpMenu = 0;
118 124
119//US kapp->setTopWidget( this ); 125//US kapp->setTopWidget( this );
120 actionCollection()->setWidget( this ); 126 actionCollection()->setWidget( this );
121//US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 127//US connect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
122//US if( !memberList ) 128//US if( !memberList )
123//US memberList = new QPtrList<KMainWindow>; 129//US memberList = new QPtrList<KMainWindow>;
124/*US 130/*US
125 131
126 if ( !ksm ) 132 if ( !ksm )
127 ksm = ksmd.setObject(new KMWSessionManaged()); 133 ksm = ksmd.setObject(new KMWSessionManaged());
128 // set a unique object name. Required by session management. 134 // set a unique object name. Required by session management.
129 QCString objname; 135 QCString objname;
130 QCString s; 136 QCString s;
131 int unusedNumber; 137 int unusedNumber;
132 if ( !name ) 138 if ( !name )
133 { // no name given 139 { // no name given
134 objname = kapp->instanceName() + "-mainwindow#"; 140 objname = kapp->instanceName() + "-mainwindow#";
135 s = objname + '1'; // start adding number immediately 141 s = objname + '1'; // start adding number immediately
136 unusedNumber = 1; 142 unusedNumber = 1;
137 } 143 }
138 else if( name[ strlen( name ) - 1 ] == '#' ) 144 else if( name[ strlen( name ) - 1 ] == '#' )
139 { // trailing # - always add a number 145 { // trailing # - always add a number
140 objname = name; 146 objname = name;
141 s = objname + '1'; // start adding number immediately 147 s = objname + '1'; // start adding number immediately
142 unusedNumber = 1; 148 unusedNumber = 1;
143 } 149 }
144 else 150 else
145 { 151 {
146 objname = name; 152 objname = name;
147 s = objname; 153 s = objname;
148 unusedNumber = 0; // add numbers only when needed 154 unusedNumber = 0; // add numbers only when needed
149 } 155 }
150 for(;;) { 156 for(;;) {
151 QWidgetList* list = kapp->topLevelWidgets(); 157 QWidgetList* list = kapp->topLevelWidgets();
152 QWidgetListIt it( *list ); 158 QWidgetListIt it( *list );
153 bool found = false; 159 bool found = false;
154 for( QWidget* w = it.current(); 160 for( QWidget* w = it.current();
155 w != NULL; 161 w != NULL;
156 ++it, w = it.current()) 162 ++it, w = it.current())
157 if( w != this && w->name() == s ) 163 if( w != this && w->name() == s )
158 { 164 {
159 found = true; 165 found = true;
160 break; 166 break;
161 } 167 }
162 delete list; 168 delete list;
163 if( !found ) 169 if( !found )
164 break; 170 break;
165 s.setNum( ++unusedNumber ); 171 s.setNum( ++unusedNumber );
166 s = objname + s; 172 s = objname + s;
167 } 173 }
168 setName( s ); 174 setName( s );
169 memberList->append( this ); 175 memberList->append( this );
170*/ 176*/
171 177
172 d = new KMainWindowPrivate; 178 d = new KMainWindowPrivate;
173//US d->showHelpMenu = true; 179//US d->showHelpMenu = true;
174 d->settingsDirty = false; 180 d->settingsDirty = false;
175 d->autoSaveSettings = false; 181 d->autoSaveSettings = false;
176 d->autoSaveWindowSize = true; // for compatibility 182 d->autoSaveWindowSize = true; // for compatibility
177//US d->kaccel = actionCollection()->kaccel(); 183//US d->kaccel = actionCollection()->kaccel();
178 d->toolBarHandler = 0; 184 d->toolBarHandler = 0;
179 d->settingsTimer = 0; 185 d->settingsTimer = 0;
180 d->showStatusBarAction = NULL; 186 d->showStatusBarAction = NULL;
181/*US 187/*US
182 if ((d->care_about_geometry == beeing_first)) { 188 if ((d->care_about_geometry == beeing_first)) {
183 beeing_first = false; 189 beeing_first = false;
184 if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater 190 if ( kapp->geometryArgument().isNull() ) // if there is no geometry, it doesn't mater
185 d->care_about_geometry = false; 191 d->care_about_geometry = false;
186 else 192 else
187 parseGeometry(false); 193 parseGeometry(false);
188 } 194 }
189*/ 195*/
190 d->care_about_geometry = false; 196 d->care_about_geometry = false;
191 197
192//US setCaption( kapp->caption() ); 198//US setCaption( kapp->caption() );
193 // attach dcop interface 199 // attach dcop interface
194//US d->m_interface = new KMainWindowInterface(this); 200//US d->m_interface = new KMainWindowInterface(this);
195 201
196//US if (!kapp->authorize("movable_toolbars")) 202//US if (!kapp->authorize("movable_toolbars"))
197//US setDockWindowsMovable(false); 203//US setDockWindowsMovable(false);
198} 204}
199 205
200KAction *KMainWindow::toolBarMenuAction() 206KAction *KMainWindow::toolBarMenuAction()
201{ 207{
202 if ( !d->toolBarHandler ) 208 if ( !d->toolBarHandler )
203 return 0; 209 return 0;
204 210
205 return d->toolBarHandler->toolBarMenuAction(); 211 return d->toolBarHandler->toolBarMenuAction();
206} 212}
207 213
208bool KMainWindow::canBeRestored( int number ) 214bool KMainWindow::canBeRestored( int number )
209{ 215{
210/*US we do not have and want to save sessioninformation. Use info from the default 216/*US we do not have and want to save sessioninformation. Use info from the default
211application config. 217application config.
212*/ 218*/
213//US if ( !kapp->isRestored() ) 219//US if ( !kapp->isRestored() )
214//US return FALSE; 220//US return FALSE;
215//US KConfig *config = kapp->sessionConfig(); 221//US KConfig *config = kapp->sessionConfig();
216 KConfig *config = KGlobal::config(); 222 KConfig *config = KGlobal::config();
217 if ( !config ) 223 if ( !config )
218 return FALSE; 224 return FALSE;
219 config->setGroup( QString::fromLatin1("Number") ); 225 config->setGroup( QString::fromLatin1("Number") );
220 int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 ); 226 int n = config->readNumEntry( QString::fromLatin1("NumberOfWindows") , 1 );
221 return number >= 1 && number <= n; 227 return number >= 1 && number <= n;
222 228
223} 229}
224 230
225const QString KMainWindow::classNameOfToplevel( int number ) 231const QString KMainWindow::classNameOfToplevel( int number )
226{ 232{
227/*US we do not have and want to save sessioninformation. Use info from the default 233/*US we do not have and want to save sessioninformation. Use info from the default
228application config. 234application config.
229*/ 235*/
230//US if ( !kapp->isRestored() ) 236//US if ( !kapp->isRestored() )
231//US return QString::null; 237//US return QString::null;
232//US KConfig *config = kapp->sessionConfig(); 238//US KConfig *config = kapp->sessionConfig();
233 KConfig *config = KGlobal::config(); 239 KConfig *config = KGlobal::config();
234 if ( !config ) 240 if ( !config )
235 return QString::null; 241 return QString::null;
236 QString s; 242 QString s;
237 s.setNum( number ); 243 s.setNum( number );
238 s.prepend( QString::fromLatin1("WindowProperties") ); 244 s.prepend( QString::fromLatin1("WindowProperties") );
239 config->setGroup( s ); 245 config->setGroup( s );
240 if ( !config->hasKey( QString::fromLatin1("ClassName") ) ) 246 if ( !config->hasKey( QString::fromLatin1("ClassName") ) )
241 return QString::null; 247 return QString::null;
242 else 248 else
243 return config->readEntry( QString::fromLatin1("ClassName") ); 249 return config->readEntry( QString::fromLatin1("ClassName") );
244} 250}
245 251
246bool KMainWindow::restore( int number, bool show ) 252bool KMainWindow::restore( int number, bool show )
247{ 253{
248/*US we do not have and want to save sessioninformation. Use info from the default 254/*US we do not have and want to save sessioninformation. Use info from the default
249application config. 255application config.
250*/ 256*/
251 if ( !canBeRestored( number ) ) 257 if ( !canBeRestored( number ) )
252 return FALSE; 258 return FALSE;
253//US KConfig *config = kapp->sessionConfig(); 259//US KConfig *config = kapp->sessionConfig();
254 KConfig *config = KGlobal::config(); 260 KConfig *config = KGlobal::config();
255 261
256 if ( readPropertiesInternal( config, number ) ){ 262 if ( readPropertiesInternal( config, number ) ){
257 if ( show ) 263 if ( show )
258 KMainWindow::show(); 264 KMainWindow::show();
259 return FALSE; 265 return FALSE;
260 } 266 }
261 return FALSE; 267 return FALSE;
262 268
263} 269}
264 270
265void KMainWindow::setCaption( const QString &caption ) 271void KMainWindow::setCaption( const QString &caption )
266{ 272{
267//US setPlainCaption( kapp->makeStdCaption(caption) ); 273//US setPlainCaption( kapp->makeStdCaption(caption) );
268 setPlainCaption( caption ); 274 setPlainCaption( caption );
269} 275}
270 276
271void KMainWindow::setCaption( const QString &caption, bool modified ) 277void KMainWindow::setCaption( const QString &caption, bool modified )
272{ 278{
273//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) ); 279//US setPlainCaption( kapp->makeStdCaption(caption, true, modified) );
274 setPlainCaption( caption + "modified:" ); 280 setPlainCaption( caption + "modified:" );
275} 281}
276 282
277void KMainWindow::setPlainCaption( const QString &caption ) 283void KMainWindow::setPlainCaption( const QString &caption )
278{ 284{
279 QMainWindow::setCaption( caption ); 285 Q3MainWindow::setCaption( caption );
280#ifndef Q_WS_QWS 286#ifndef Q_WS_QWS
281//US the following is disabled for the embedded version 287//US the following is disabled for the embedded version
282//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 ); 288//US NETWinInfo info( qt_xdisplay(), winId(), qt_xrootwin(), 0 );
283//US info.setName( caption.utf8().data() ); 289//US info.setName( caption.utf8().data() );
284#endif 290#endif
285} 291}
286 292
287void KMainWindow::slotStateChanged(const QString &newstate) 293void KMainWindow::slotStateChanged(const QString &newstate)
288{ 294{
289 stateChanged(newstate, KXMLGUIClient::StateNoReverse); 295 stateChanged(newstate, KXMLGUIClient::StateNoReverse);
290} 296}
291 297
292/* 298/*
293 * Get rid of this for KDE 4.0 299 * Get rid of this for KDE 4.0
294 */ 300 */
295void KMainWindow::slotStateChanged(const QString &newstate, 301void KMainWindow::slotStateChanged(const QString &newstate,
296 KXMLGUIClient::ReverseStateChange reverse) 302 KXMLGUIClient::ReverseStateChange reverse)
297{ 303{
298 stateChanged(newstate, reverse); 304 stateChanged(newstate, reverse);
299} 305}
300 306
301void KMainWindow::closeEvent ( QCloseEvent *e ) 307void KMainWindow::closeEvent ( QCloseEvent *e )
302{ 308{
303 //qDebug("MainWindow::closeEvent "); 309 //qDebug("MainWindow::closeEvent ");
304 // Save settings if auto-save is enabled, and settings have changed 310 // Save settings if auto-save is enabled, and settings have changed
305 if (d->settingsDirty && d->autoSaveSettings) 311 if (d->settingsDirty && d->autoSaveSettings)
306 saveAutoSaveSettings(); 312 saveAutoSaveSettings();
307 313
308 if (queryClose()) { 314 if (queryClose()) {
309 e->accept(); 315 e->accept();
310 316
311 int not_withdrawn = 0; 317 int not_withdrawn = 0;
312/*US 318/*US
313 QPtrListIterator<KMainWindow> it(*KMainWindow::memberList); 319 QPtrListIterator<KMainWindow> it(*KMainWindow::memberList);
314 for (it.toFirst(); it.current(); ++it){ 320 for (it.toFirst(); it.current(); ++it){
315 if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this ) 321 if ( !it.current()->isHidden() && it.current()->isTopLevel() && it.current() != this )
316 not_withdrawn++; 322 not_withdrawn++;
317 } 323 }
318*/ 324*/
319 if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted? 325 if ( !no_query_exit && not_withdrawn <= 0 ) { // last window close accepted?
320/*US 326/*US
321 if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app? 327 if ( queryExit() && !kapp->sessionSaving()) { // Yes, Quit app?
322 // don't call queryExit() twice 328 // don't call queryExit() twice
323 disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 329 disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
324 kapp->deref(); // ...and quit aplication. 330 kapp->deref(); // ...and quit aplication.
325 } else { 331 } else {
326 // cancel closing, it's stupid to end up with no windows at all.... 332 // cancel closing, it's stupid to end up with no windows at all....
327 e->ignore(); 333 e->ignore();
328 } 334 }
329*/ 335*/
330//US we have no sessionmanagement. Simply close app. 336//US we have no sessionmanagement. Simply close app.
331 if ( queryExit() ) { // Yes, Quit app? 337 if ( queryExit() ) { // Yes, Quit app?
332 qDebug("KMainWindow::closeEvent: Exit application ???"); 338 qDebug("KMainWindow::closeEvent: Exit application ???");
333 // don't call queryExit() twice 339 // don't call queryExit() twice
334//US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown())); 340//US disconnect(kapp, SIGNAL(shutDown()), this, SLOT(shuttingDown()));
335 } 341 }
336 342
337 } 343 }
338 } 344 }
339} 345}
340 346
341bool KMainWindow::queryExit() 347bool KMainWindow::queryExit()
342{ 348{
343 return TRUE; 349 return TRUE;
344} 350}
345 351
346bool KMainWindow::queryClose() 352bool KMainWindow::queryClose()
347{ 353{
348 return TRUE; 354 return TRUE;
349} 355}
350 356
351void KMainWindow::saveGlobalProperties( KConfig* ) 357void KMainWindow::saveGlobalProperties( KConfig* )
352{ 358{
353} 359}
354 360
355void KMainWindow::readGlobalProperties( KConfig* ) 361void KMainWindow::readGlobalProperties( KConfig* )
356{ 362{
357} 363}
358 364
359void KMainWindow::savePropertiesInternal( KConfig *config, int number ) 365void KMainWindow::savePropertiesInternal( KConfig *config, int number )
360{ 366{
361 bool oldASWS = d->autoSaveWindowSize; 367 bool oldASWS = d->autoSaveWindowSize;
362 d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size 368 d->autoSaveWindowSize = true; // make saveMainWindowSettings save the window size
363 369
364 QString s; 370 QString s;
365 s.setNum(number); 371 s.setNum(number);
366 s.prepend(QString::fromLatin1("WindowProperties")); 372 s.prepend(QString::fromLatin1("WindowProperties"));
367 config->setGroup(s); 373 config->setGroup(s);
368 374
369 // store objectName, className, Width and Height for later restoring 375 // store objectName, className, Width and Height for later restoring
370 // (Only useful for session management) 376 // (Only useful for session management)
371 config->writeEntry(QString::fromLatin1("ObjectName"), name()); 377 config->writeEntry(QString::fromLatin1("ObjectName"), name());
372 config->writeEntry(QString::fromLatin1("ClassName"), className()); 378 config->writeEntry(QString::fromLatin1("ClassName"), className());
373 379
374 saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings. 380 saveMainWindowSettings(config); // Menubar, statusbar and Toolbar settings.
375 381
376 s.setNum(number); 382 s.setNum(number);
377 config->setGroup(s); 383 config->setGroup(s);
378 saveProperties(config); 384 saveProperties(config);
379 385
380 d->autoSaveWindowSize = oldASWS; 386 d->autoSaveWindowSize = oldASWS;
381} 387}
382 388
383void KMainWindow::setStandardToolBarMenuEnabled( bool enable ) 389void KMainWindow::setStandardToolBarMenuEnabled( bool enable )
384{ 390{
385 if ( enable ) 391 if ( enable )
386 { 392 {
387 if ( d->toolBarHandler ) 393 if ( d->toolBarHandler )
388 return; 394 return;
389 395
390 d->toolBarHandler = new KDEPrivate::ToolBarHandler( this ); 396 d->toolBarHandler = new KDEPrivate::ToolBarHandler( this );
391 397
392/*US if ( factory() ) 398/*US if ( factory() )
393 factory()->addClient( d->toolBarHandler ); 399 factory()->addClient( d->toolBarHandler );
394*/ 400*/
395 } 401 }
396 else 402 else
397 { 403 {
398 if ( !d->toolBarHandler ) 404 if ( !d->toolBarHandler )
399 return; 405 return;
400/*US 406/*US
401 if ( factory() ) 407 if ( factory() )
402 factory()->removeClient( d->toolBarHandler ); 408 factory()->removeClient( d->toolBarHandler );
403*/ 409*/
404 delete d->toolBarHandler; 410 delete d->toolBarHandler;
405 d->toolBarHandler = 0; 411 d->toolBarHandler = 0;
406 } 412 }
407 413
408} 414}
409 415
410bool KMainWindow::isStandardToolBarMenuEnabled() const 416bool KMainWindow::isStandardToolBarMenuEnabled() const
411{ 417{
412 return ( d->toolBarHandler != 0 ); 418 return ( d->toolBarHandler != 0 );
413} 419}
414 420
415void KMainWindow::createStandardStatusBarAction(){ 421void KMainWindow::createStandardStatusBarAction(){
416 if(!d->showStatusBarAction){ 422 if(!d->showStatusBarAction){
417 d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection()); 423 d->showStatusBarAction = KStdAction::showStatusbar(this, SLOT(setSettingsDirty()), actionCollection());
418 connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool))); 424 connect(d->showStatusBarAction, SIGNAL(toggled(bool)), statusBar(), SLOT(setShown(bool)));
419 if(internalStatusBar()) 425 if(internalStatusBar())
420 d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden()); 426 d->showStatusBarAction->setChecked(!internalStatusBar()->isHidden());
421 } 427 }
422} 428}
423 429
424QToolBar *KMainWindow::tBar( ) 430Q3ToolBar *KMainWindow::tBar( )
425{ 431{
426 if ( ! mQToolBar ) 432 if ( ! mQToolBar )
427 mQToolBar = new QToolBar( this ); 433 mQToolBar = new Q3ToolBar( this );
428 return mQToolBar; 434 return mQToolBar;
429} 435}
430 436
431KToolBar *KMainWindow::toolBar( const char * name ) 437KToolBar *KMainWindow::toolBar( const char * name )
432{ 438{
433 439
434 if (!name) 440 if (!name)
435 name = "mainToolBar"; 441 name = "mainToolBar";
436 KToolBar *tb = (KToolBar*)child( name, "KToolBar" ); 442 KToolBar *tb = (KToolBar*)child( name, "KToolBar" );
437 if ( tb ) 443 if ( tb )
438 return tb; 444 return tb;
439 bool honor_mode = (name == "mainToolBar"); 445 bool honor_mode = (name == "mainToolBar");
440 446
441/*US 447/*US
442 if ( builderClient() ) 448 if ( builderClient() )
443 return new KToolBar(this, name, honor_mode); // XMLGUI constructor 449 return new KToolBar(this, name, honor_mode); // XMLGUI constructor
444 else 450 else
445*/ 451*/
446 return new KToolBar(this, Top, false, name, honor_mode ); // non-XMLGUI 452 return new KToolBar(this, Qt::Top, false, name, honor_mode ); // non-XMLGUI
447} 453}
448 454
449QPtrListIterator<KToolBar> KMainWindow::toolBarIterator() 455Q3PtrListIterator<KToolBar> KMainWindow::toolBarIterator()
450{ 456{
451 toolbarList.clear(); 457 toolbarList.clear();
452 QPtrList<QToolBar> lst; 458 QList<Q3ToolBar*> lst;
453 for ( int i = (int)QMainWindow::Unmanaged; i <= (int)Minimized; ++i ) { 459 for ( int i = (int)Qt::Unmanaged; i <= (int)Qt::Minimized; ++i ) {
454 lst = toolBars( (ToolBarDock)i ); 460 lst = toolBars( (Qt::ToolBarDock)i );
455 for ( QToolBar *tb = lst.first(); tb; tb = lst.next() ) { 461 for(QList<Q3ToolBar*>::iterator i=lst.begin();i!=lst.end();++i) {
462 Q3ToolBar *tb = *i;
456 if ( !tb->inherits( "KToolBar" ) ) 463 if ( !tb->inherits( "KToolBar" ) )
457 continue; 464 continue;
458 toolbarList.append( (KToolBar*)tb ); 465 toolbarList.append( (KToolBar*)tb );
459 } 466 }
460 } 467 }
461 return QPtrListIterator<KToolBar>( toolbarList ); 468 return Q3PtrListIterator<KToolBar>( toolbarList );
462} 469}
463 470
464void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize ) 471void KMainWindow::setAutoSaveSettings( const QString & groupName, bool saveWindowSize )
465{ 472{
466 d->autoSaveSettings = true; 473 d->autoSaveSettings = true;
467 d->autoSaveGroup = groupName; 474 d->autoSaveGroup = groupName;
468 d->autoSaveWindowSize = saveWindowSize; 475 d->autoSaveWindowSize = saveWindowSize;
469 // Get notified when the user moves a toolbar around 476 // Get notified when the user moves a toolbar around
470//US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ), 477//US connect( this, SIGNAL( dockWindowPositionChanged( QDockWindow * ) ),
471//US this, SLOT( setSettingsDirty() ) ); 478//US this, SLOT( setSettingsDirty() ) );
472 connect( this, SIGNAL( toolBarPositionChanged(QToolBar *) ), 479 connect( this, SIGNAL( toolBarPositionChanged(Q3ToolBar *) ),
473 this, SLOT( setSettingsDirty() ) ); 480 this, SLOT( setSettingsDirty() ) );
474 481
475 482
476 // Get default values 483 // Get default values
477//US int scnum = QApplication::desktop()->screenNumber(parentWidget()); 484//US int scnum = QApplication::desktop()->screenNumber(parentWidget());
478//US QRect desk = QApplication::desktop()->screenGeometry(scnum); 485//US QRect desk = QApplication::desktop()->screenGeometry(scnum);
479 QRect desk = KGlobalSettings::desktopGeometry(0); 486 QRect desk = KGlobalSettings::desktopGeometry(0);
480 487
481 d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height()); 488 d->defaultWindowSize = QRect(desk.width(), width(), desk.height(), height());
482 // Now read the previously saved settings 489 // Now read the previously saved settings
483 applyMainWindowSettings( KGlobal::config(), groupName ); 490 applyMainWindowSettings( KGlobal::config(), groupName );
484} 491}
485 492
486 493
487void KMainWindow::resetAutoSaveSettings() 494void KMainWindow::resetAutoSaveSettings()
488{ 495{
489 d->autoSaveSettings = false; 496 d->autoSaveSettings = false;
490 if ( d->settingsTimer ) 497 if ( d->settingsTimer )
491 d->settingsTimer->stop(); 498 d->settingsTimer->stop();
492} 499}
493 500
494bool KMainWindow::autoSaveSettings() const 501bool KMainWindow::autoSaveSettings() const
495{ 502{
496 return d->autoSaveSettings; 503 return d->autoSaveSettings;
497} 504}
498 505
499QString KMainWindow::autoSaveGroup() const 506QString KMainWindow::autoSaveGroup() const
500{ 507{
501 return d->autoSaveGroup; 508 return d->autoSaveGroup;
502} 509}
503 510
504void KMainWindow::saveAutoSaveSettings() 511void KMainWindow::saveAutoSaveSettings()
505{ 512{
506 ASSERT( d->autoSaveSettings ); 513 Q_ASSERT( d->autoSaveSettings );
507 //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl; 514 //kdDebug(200) << "KMainWindow::saveAutoSaveSettings -> saving settings" << endl;
508 saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup ); 515 saveMainWindowSettings( KGlobal::config(), d->autoSaveGroup );
509 KGlobal::config()->sync(); 516 KGlobal::config()->sync();
510 d->settingsDirty = false; 517 d->settingsDirty = false;
511 if ( d->settingsTimer ) 518 if ( d->settingsTimer )
512 d->settingsTimer->stop(); 519 d->settingsTimer->stop();
513} 520}
514 521
515void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory ) 522void KMainWindow::createGUI( const QString &xmlfile, bool _conserveMemory )
516{ 523{
517 // disabling the updates prevents unnecessary redraws 524 // disabling the updates prevents unnecessary redraws
518 setUpdatesEnabled( false ); 525 setUpdatesEnabled( false );
519 526
520 // just in case we are rebuilding, let's remove our old client 527 // just in case we are rebuilding, let's remove our old client
521//US guiFactory()->removeClient( this ); 528//US guiFactory()->removeClient( this );
522 529
523 // make sure to have an empty GUI 530 // make sure to have an empty GUI
524 QMenuBar* mb = internalMenuBar(); 531 QMenuBar* mb = internalMenuBar();
525 if ( mb ) 532 if ( mb )
526 mb->clear(); 533 mb->clear();
527 534
528 (void)toolBarIterator(); // make sure toolbarList is most-up-to-date 535 (void)toolBarIterator(); // make sure toolbarList is most-up-to-date
529 toolbarList.setAutoDelete( true ); 536 toolbarList.setAutoDelete( true );
530 toolbarList.clear(); 537 toolbarList.clear();
531 toolbarList.setAutoDelete( false ); 538 toolbarList.setAutoDelete( false );
532/*US 539/*US
533 // don't build a help menu unless the user ask for it 540 // don't build a help menu unless the user ask for it
534 if (d->showHelpMenu) { 541 if (d->showHelpMenu) {
535 // we always want a help menu 542 // we always want a help menu
536 if (helpMenu2 == 0) 543 if (helpMenu2 == 0)
537 helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true, 544 helpMenu2 = new KHelpMenu(this, instance()->aboutData(), true,
538 actionCollection()); 545 actionCollection());
539 } 546 }
540 547
541 // we always want to load in our global standards file 548 // we always want to load in our global standards file
542 setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) ); 549 setXMLFile( locate( "config", "ui/ui_standards.rc", instance() ) );
543 550
544 // now, merge in our local xml file. if this is null, then that 551 // now, merge in our local xml file. if this is null, then that
545 // means that we will be only using the global file 552 // means that we will be only using the global file
546 if ( !xmlfile.isNull() ) { 553 if ( !xmlfile.isNull() ) {
547 setXMLFile( xmlfile, true ); 554 setXMLFile( xmlfile, true );
548 } else { 555 } else {
549 QString auto_file(instance()->instanceName() + "ui.rc"); 556 QString auto_file(instance()->instanceName() + "ui.rc");
550 setXMLFile( auto_file, true ); 557 setXMLFile( auto_file, true );
551 } 558 }
552 559
553 // make sure we don't have any state saved already 560 // make sure we don't have any state saved already
554 setXMLGUIBuildDocument( QDomDocument() ); 561 setXMLGUIBuildDocument( QDomDocument() );
555 562
556 // do the actual GUI building 563 // do the actual GUI building
557 guiFactory()->addClient( this ); 564 guiFactory()->addClient( this );
558 565
559 // try and get back *some* of our memory 566 // try and get back *some* of our memory
560 if ( _conserveMemory ) 567 if ( _conserveMemory )
561 { 568 {
562 // before freeing the memory allocated by the DOM document we also 569 // before freeing the memory allocated by the DOM document we also
563 // free all memory allocated internally in the KXMLGUIFactory for 570 // free all memory allocated internally in the KXMLGUIFactory for
564 // the menubar and the toolbars . This however implies that we 571 // the menubar and the toolbars . This however implies that we
565 // have to take care of deleting those widgets ourselves. For 572 // have to take care of deleting those widgets ourselves. For
566 // destruction this is no problem, but when rebuilding we have 573 // destruction this is no problem, but when rebuilding we have
567 // to take care of that (and we want to rebuild the GUI when 574 // to take care of that (and we want to rebuild the GUI when
568 // using stuff like the toolbar editor ). 575 // using stuff like the toolbar editor ).
569 // In addition we have to take care of not removing containers 576 // In addition we have to take care of not removing containers
570 // like popupmenus, defined in the XML document. 577 // like popupmenus, defined in the XML document.
571 // this code should probably go into a separate method in KMainWindow. 578 // this code should probably go into a separate method in KMainWindow.
572 // there's just one problem: I'm bad in finding names ;-) , so 579 // there's just one problem: I'm bad in finding names ;-) , so
573 // I skipped this ;-) 580 // I skipped this ;-)
574 581
575 QDomDocument doc = domDocument(); 582 QDomDocument doc = domDocument();
576 583
577 QDomElement e = doc.documentElement().firstChild().toElement(); 584 QDomElement e = doc.documentElement().firstChild().toElement();
578 for (; !e.isNull(); e = e.nextSibling().toElement() ) { 585 for (; !e.isNull(); e = e.nextSibling().toElement() ) {
579 if ( e.tagName().lower() == "toolbar" ) 586 if ( e.tagName().lower() == "toolbar" )
580 factory_->resetContainer( e.attribute( "name" ) ); 587 factory_->resetContainer( e.attribute( "name" ) );
581 else if ( e.tagName().lower() == "menubar" ) 588 else if ( e.tagName().lower() == "menubar" )
582 factory_->resetContainer( e.tagName(), true ); 589 factory_->resetContainer( e.tagName(), true );
583 } 590 }
584 591
585 conserveMemory(); 592 conserveMemory();
586 } 593 }
587*/ 594*/
588 setUpdatesEnabled( true ); 595 setUpdatesEnabled( true );
589 updateGeometry(); 596 updateGeometry();
590} 597}
591 598
592void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup) 599void KMainWindow::saveMainWindowSettings(KConfig *config, const QString &configGroup)
593{ 600{
594 kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl; 601 kdDebug(200) << "KMainWindow::saveMainWindowSettings " << configGroup << endl;
595//US QStrList entryList; 602//US QStrList entryList;
596 QStringList entryList; 603 QStringList entryList;
597 QString oldGroup; 604 QString oldGroup;
598 605
599 if (!configGroup.isEmpty()) 606 if (!configGroup.isEmpty())
600 { 607 {
601 oldGroup = config->group(); 608 oldGroup = config->group();
602 config->setGroup(configGroup); 609 config->setGroup(configGroup);
603 } 610 }
604 611
605 // Called by session management - or if we want to save the window size anyway 612 // Called by session management - or if we want to save the window size anyway
606 if ( d->autoSaveWindowSize ) 613 if ( d->autoSaveWindowSize )
607 saveWindowSize( config ); 614 saveWindowSize( config );
608 615
609 QStatusBar* sb = internalStatusBar(); 616 QStatusBar* sb = internalStatusBar();
610 if (sb) { 617 if (sb) {
611 entryList.clear(); 618 entryList.clear();
612 if ( sb->isHidden() ) 619 if ( sb->isHidden() )
613 entryList.append("Disabled"); 620 entryList.append("Disabled");
614 else 621 else
615 entryList.append("Enabled"); 622 entryList.append("Enabled");
616 623
617 if(sb->isHidden()) 624 if(sb->isHidden())
618 //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';'); 625 //US config->writeEntry(QString::fromLatin1("StatusBar"), entryList, ';');
619 config->writeEntry(QString::fromLatin1("StatusBar"), entryList); 626 config->writeEntry(QString::fromLatin1("StatusBar"), entryList);
620 else 627 else
621 config->deleteEntry(QString::fromLatin1("StatusBar")); 628 config->deleteEntry(QString::fromLatin1("StatusBar"));
622 } 629 }
623 630
624 QMenuBar* mb = internalMenuBar(); 631 QMenuBar* mb = internalMenuBar();
625 if (mb) { 632 if (mb) {
626 entryList.clear(); 633 entryList.clear();
627 if ( mb->isHidden() ) 634 if ( mb->isHidden() )
628 entryList.append("Disabled"); 635 entryList.append("Disabled");
629 else 636 else
630 entryList.append("Enabled"); 637 entryList.append("Enabled");
631 638
632 // By default we don't hide. 639 // By default we don't hide.
633 if(mb->isHidden()) 640 if(mb->isHidden())
634 //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';'); 641 //US config->writeEntry(QString::fromLatin1("MenuBar"), entryList, ';');
635 config->writeEntry(QString::fromLatin1("MenuBar"), entryList); 642 config->writeEntry(QString::fromLatin1("MenuBar"), entryList);
636 else 643 else
637 config->deleteEntry(QString::fromLatin1("MenuBar")); 644 config->deleteEntry(QString::fromLatin1("MenuBar"));
638 } 645 }
639 646
640 int n = 1; // Toolbar counter. toolbars are counted from 1, 647 int n = 1; // Toolbar counter. toolbars are counted from 1,
641 KToolBar *toolbar = 0; 648 KToolBar *toolbar = 0;
642 QPtrListIterator<KToolBar> it( toolBarIterator() ); 649 Q3PtrListIterator<KToolBar> it( toolBarIterator() );
643 while ( ( toolbar = it.current() ) ) { 650 while ( ( toolbar = it.current() ) ) {
644 ++it; 651 ++it;
645 QString group; 652 QString group;
646 if (!configGroup.isEmpty()) 653 if (!configGroup.isEmpty())
647 { 654 {
648 // Give a number to the toolbar, but prefer a name if there is one, 655 // Give a number to the toolbar, but prefer a name if there is one,
649 // because there's no real guarantee on the ordering of toolbars 656 // because there's no real guarantee on the ordering of toolbars
650 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); 657 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name());
651 group.prepend(" Toolbar"); 658 group.prepend(" Toolbar");
652 group.prepend(configGroup); 659 group.prepend(configGroup);
653 } 660 }
654 toolbar->saveSettings(config, group); 661 toolbar->saveSettings(config, group);
655 n++; 662 n++;
656 } 663 }
657 if (!configGroup.isEmpty()) 664 if (!configGroup.isEmpty())
658 config->setGroup(oldGroup); 665 config->setGroup(oldGroup);
659} 666}
660 667
661bool KMainWindow::readPropertiesInternal( KConfig *config, int number ) 668bool KMainWindow::readPropertiesInternal( KConfig *config, int number )
662{ 669{
663 if ( number == 1 ) 670 if ( number == 1 )
664 readGlobalProperties( config ); 671 readGlobalProperties( config );
665 672
666 // in order they are in toolbar list 673 // in order they are in toolbar list
667 QString s; 674 QString s;
668 s.setNum(number); 675 s.setNum(number);
669 s.prepend(QString::fromLatin1("WindowProperties")); 676 s.prepend(QString::fromLatin1("WindowProperties"));
670 677
671 config->setGroup(s); 678 config->setGroup(s);
672 679
673 // restore the object name (window role) 680 // restore the object name (window role)
674 if ( config->hasKey(QString::fromLatin1("ObjectName" )) ) 681 if ( config->hasKey(QString::fromLatin1("ObjectName" )) )
675 setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here 682 setName( config->readEntry(QString::fromLatin1("ObjectName")).latin1()); // latin1 is right here
676 683
677 applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings. 684 applyMainWindowSettings(config); // Menubar, statusbar and toolbar settings.
678 685
679 s.setNum(number); 686 s.setNum(number);
680 config->setGroup(s); 687 config->setGroup(s);
681 readProperties(config); 688 readProperties(config);
682 return true; 689 return true;
683} 690}
684 691
685void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup) 692void KMainWindow::applyMainWindowSettings(KConfig *config, const QString &configGroup)
686{ 693{
687 kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl; 694 kdDebug(200) << "KMainWindow::applyMainWindowSettings" << endl;
688 QString entry; 695 QString entry;
689//US QStrList entryList; 696//US QStrList entryList;
690 QStringList entryList; 697 QStringList entryList;
691 int i = 0; // Number of entries in list 698 int i = 0; // Number of entries in list
692 699
693 if (!configGroup.isEmpty()) 700 if (!configGroup.isEmpty())
694 config->setGroup(configGroup); 701 config->setGroup(configGroup);
695 702
696 restoreWindowSize(config); 703 restoreWindowSize(config);
697 704
698 QStatusBar* sb = internalStatusBar(); 705 QStatusBar* sb = internalStatusBar();
699 if (sb) { 706 if (sb) {
700 entryList.clear(); 707 entryList.clear();
701//US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';'); 708//US i = config->readListEntry (QString::fromLatin1("StatusBar"), entryList, ';');
702 entryList = config->readListEntry (QString::fromLatin1("StatusBar")); 709 entryList = config->readListEntry (QString::fromLatin1("StatusBar"));
703 entry = entryList.first(); 710 entry = entryList.first();
704 if (entry == QString::fromLatin1("Disabled")) 711 if (entry == QString::fromLatin1("Disabled"))
705 sb->hide(); 712 sb->hide();
706 else 713 else
707 sb->show(); 714 sb->show();
708 if(d->showStatusBarAction) 715 if(d->showStatusBarAction)
709 d->showStatusBarAction->setChecked(!sb->isHidden()); 716 d->showStatusBarAction->setChecked(!sb->isHidden());
710 } 717 }
711 718
712 QMenuBar* mb = internalMenuBar(); 719 QMenuBar* mb = internalMenuBar();
713 if (mb) { 720 if (mb) {
714 entryList.clear(); 721 entryList.clear();
715//US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';'); 722//US i = config->readListEntry (QString::fromLatin1("MenuBar"), entryList, ';');
716 entryList = config->readListEntry (QString::fromLatin1("MenuBar")); 723 entryList = config->readListEntry (QString::fromLatin1("MenuBar"));
717 entry = entryList.first(); 724 if(!entryList.empty()) {
718 if (entry==QString::fromLatin1("Disabled")) 725 entry = entryList.first();
719 { 726 if (entry==QString::fromLatin1("Disabled"))
720 mb->hide(); 727 {
721 } else 728 mb->hide();
722 { 729 } else
723 mb->show(); 730 {
724 } 731 mb->show();
732 }
733 }
725 } 734 }
726 735
727 int n = 1; // Toolbar counter. toolbars are counted from 1, 736 int n = 1; // Toolbar counter. toolbars are counted from 1,
728 KToolBar *toolbar; 737 KToolBar *toolbar;
729 QPtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator 738 Q3PtrListIterator<KToolBar> it( toolBarIterator() ); // must use own iterator
730 739
731 for ( ; it.current(); ++it) { 740 for ( ; it.current(); ++it) {
732 toolbar= it.current(); 741 toolbar= it.current();
733 QString group; 742 QString group;
734 if (!configGroup.isEmpty()) 743 if (!configGroup.isEmpty())
735 { 744 {
736 // Give a number to the toolbar, but prefer a name if there is one, 745 // Give a number to the toolbar, but prefer a name if there is one,
737 // because there's no real guarantee on the ordering of toolbars 746 // because there's no real guarantee on the ordering of toolbars
738 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name()); 747 group = (!::qstrcmp(toolbar->name(), "unnamed") ? QString::number(n) : QString(" ")+toolbar->name());
739 group.prepend(" Toolbar"); 748 group.prepend(" Toolbar");
740 group.prepend(configGroup); 749 group.prepend(configGroup);
741 } 750 }
742 toolbar->applySettings(config, group); 751 toolbar->applySettings(config, group);
743 n++; 752 n++;
744 } 753 }
745 754
746 finalizeGUI( true ); 755 finalizeGUI( true );
747 } 756 }
748 757
749void KMainWindow::finalizeGUI( bool force ) 758void KMainWindow::finalizeGUI( bool force )
750{ 759{
751 //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl; 760 //kdDebug(200) << "KMainWindow::finalizeGUI force=" << force << endl;
752 // The whole reason for this is that moveToolBar relies on the indexes 761 // The whole reason for this is that moveToolBar relies on the indexes
753 // of the other toolbars, so in theory it should be called only once per 762 // of the other toolbars, so in theory it should be called only once per
754 // toolbar, but in increasing order of indexes. 763 // toolbar, but in increasing order of indexes.
755 // Since we can't do that immediately, we move them, and _then_ 764 // Since we can't do that immediately, we move them, and _then_
756 // we call positionYourself again for each of them, but this time 765 // we call positionYourself again for each of them, but this time
757 // the toolbariterator should give them in the proper order. 766 // the toolbariterator should give them in the proper order.
758 // Both the XMLGUI and applySettings call this, hence "force" for the latter. 767 // Both the XMLGUI and applySettings call this, hence "force" for the latter.
759 QPtrListIterator<KToolBar> it( toolBarIterator() ); 768 Q3PtrListIterator<KToolBar> it( toolBarIterator() );
760 for ( ; it.current() ; ++ it ) 769 for ( ; it.current() ; ++ it )
761 it.current()->positionYourself( force ); 770 it.current()->positionYourself( force );
762 771
763 d->settingsDirty = false; 772 d->settingsDirty = false;
764} 773}
765 774
766void KMainWindow::saveWindowSize( KConfig * config ) const 775void KMainWindow::saveWindowSize( KConfig * config ) const
767{ 776{
768/*US 777/*US
769 int scnum = QApplication::desktop()->screenNumber(parentWidget()); 778 int scnum = QApplication::desktop()->screenNumber(parentWidget());
770 QRect desk = QApplication::desktop()->screenGeometry(scnum); 779 QRect desk = QApplication::desktop()->screenGeometry(scnum);
771*/ 780*/
772 QRect desk = KGlobalSettings::desktopGeometry(0); 781 QRect desk = KGlobalSettings::desktopGeometry(0);
773 782
774 QRect size( desk.width(), width(), desk.height(), height() ); 783 QRect size( desk.width(), width(), desk.height(), height() );
775 if(size != d->defaultWindowSize){ 784 if(size != d->defaultWindowSize){
776 config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() ); 785 config->writeEntry(QString::fromLatin1("Width %1").arg(desk.width()), width() );
777 config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() ); 786 config->writeEntry(QString::fromLatin1("Height %1").arg(desk.height()), height() );
778 } 787 }
779 else{ 788 else{
780 config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width())); 789 config->deleteEntry(QString::fromLatin1("Width %1").arg(desk.width()));
781 config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height())); 790 config->deleteEntry(QString::fromLatin1("Height %1").arg(desk.height()));
782 } 791 }
783} 792}
784 793
785void KMainWindow::restoreWindowSize( KConfig * config ) 794void KMainWindow::restoreWindowSize( KConfig * config )
786{ 795{
787 if (d->care_about_geometry) { 796 if (d->care_about_geometry) {
788 parseGeometry(true); 797 parseGeometry(true);
789 } else { 798 } else {
790 // restore the size 799 // restore the size
791/*US int scnum = QApplication::desktop()->screenNumber(parentWidget()); 800/*US int scnum = QApplication::desktop()->screenNumber(parentWidget());
792 QRect desk = QApplication::desktop()->screenGeometry(scnum); 801 QRect desk = QApplication::desktop()->screenGeometry(scnum);
793*/ 802*/
794 QRect desk = KGlobalSettings::desktopGeometry(0); 803 QRect desk = KGlobalSettings::desktopGeometry(0);
795 804
796 QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ), 805 QSize size( config->readNumEntry( QString::fromLatin1("Width %1").arg(desk.width()), 0 ),
797 config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) ); 806 config->readNumEntry( QString::fromLatin1("Height %1").arg(desk.height()), 0 ) );
798 if (size.isEmpty()) { 807 if (size.isEmpty()) {
799 // try the KDE 2.0 way 808 // try the KDE 2.0 way
800 size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ), 809 size = QSize( config->readNumEntry( QString::fromLatin1("Width"), 0 ),
801 config->readNumEntry( QString::fromLatin1("Height"), 0 ) ); 810 config->readNumEntry( QString::fromLatin1("Height"), 0 ) );
802 if (!size.isEmpty()) { 811 if (!size.isEmpty()) {
803 // make sure the other resolutions don't get old settings 812 // make sure the other resolutions don't get old settings
804 config->writeEntry( QString::fromLatin1("Width"), 0 ); 813 config->writeEntry( QString::fromLatin1("Width"), 0 );
805 config->writeEntry( QString::fromLatin1("Height"), 0 ); 814 config->writeEntry( QString::fromLatin1("Height"), 0 );
806 } 815 }
807 } 816 }
808 if ( !size.isEmpty() ) 817 if ( !size.isEmpty() )
809 resize( size ); 818 resize( size );
810 } 819 }
811} 820}
812 821
813bool KMainWindow::initialGeometrySet() const 822bool KMainWindow::initialGeometrySet() const
814{ 823{
815 return d->care_about_geometry; 824 return d->care_about_geometry;
816} 825}
817 826
818void KMainWindow::ignoreInitialGeometry() 827void KMainWindow::ignoreInitialGeometry()
819{ 828{
820 d->care_about_geometry = false; 829 d->care_about_geometry = false;
821} 830}
822 831
823void KMainWindow::setSettingsDirty() 832void KMainWindow::setSettingsDirty()
824{ 833{
825 //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl; 834 //kdDebug(200) << "KMainWindow::setSettingsDirty" << endl;
826 d->settingsDirty = true; 835 d->settingsDirty = true;
827 if ( d->autoSaveSettings ) 836 if ( d->autoSaveSettings )
828 { 837 {
829 // Use a timer to save "immediately" user-wise, but not too immediately 838 // Use a timer to save "immediately" user-wise, but not too immediately
830 // (to compress calls and save only once, in case of multiple changes) 839 // (to compress calls and save only once, in case of multiple changes)
831 if ( !d->settingsTimer ) 840 if ( !d->settingsTimer )
832 { 841 {
833 d->settingsTimer = new QTimer( this ); 842 d->settingsTimer = new QTimer( this );
834 connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) ); 843 connect( d->settingsTimer, SIGNAL( timeout() ), SLOT( saveAutoSaveSettings() ) );
835 } 844 }
836 d->settingsTimer->start( 500, true ); 845 d->settingsTimer->start( 500, true );
837 } 846 }
838} 847}
839 848
840bool KMainWindow::settingsDirty() const 849bool KMainWindow::settingsDirty() const
841{ 850{
842 return d->settingsDirty; 851 return d->settingsDirty;
843} 852}
844 853
845QString KMainWindow::settingsGroup() const 854QString KMainWindow::settingsGroup() const
846{ 855{
847 return d->autoSaveGroup; 856 return d->autoSaveGroup;
848} 857}
849 858
850void KMainWindow::resizeEvent( QResizeEvent * e) 859void KMainWindow::resizeEvent( QResizeEvent * e)
851{ 860{
852 if ( d->autoSaveWindowSize ) 861 if ( d->autoSaveWindowSize )
853 setSettingsDirty(); 862 setSettingsDirty();
854 QMainWindow::resizeEvent( e ); 863 Q3MainWindow::resizeEvent( e );
855} 864}
856 865
857bool KMainWindow::hasMenuBar() 866bool KMainWindow::hasMenuBar()
858{ 867{
859 return (internalMenuBar()); 868 return (internalMenuBar());
860} 869}
861 870
862//US KMenuBar *KMainWindow::menuBar() 871//US KMenuBar *KMainWindow::menuBar()
863QMenuBar *KMainWindow::menuBar() 872QMenuBar *KMainWindow::menuBar()
864{ 873{
865//US KMenuBar * mb = internalMenuBar(); 874//US KMenuBar * mb = internalMenuBar();
866 QMenuBar * mb = internalMenuBar(); 875 QMenuBar * mb = internalMenuBar();
867 if ( !mb ) { 876 if ( !mb ) {
868//US mb = new KMenuBar( this ); 877//US mb = new KMenuBar( this );
869 mb = new QMenuBar( this ); 878 mb = new QMenuBar( this );
870 // trigger a re-layout and trigger a call to the private 879 // trigger a re-layout and trigger a call to the private
871 // setMenuBar method. 880 // setMenuBar method.
872 QMainWindow::menuBar(); 881 Q3MainWindow::menuBar();
873 } 882 }
874 return mb; 883 return mb;
875} 884}
876 885
877//US KStatusBar *KMainWindow::statusBar() 886//US KStatusBar *KMainWindow::statusBar()
878QStatusBar *KMainWindow::statusBar() 887QStatusBar *KMainWindow::statusBar()
879{ 888{
880//US KStatusBar * sb = internalStatusBar(); 889//US KStatusBar * sb = internalStatusBar();
881 QStatusBar * sb = internalStatusBar(); 890 QStatusBar * sb = internalStatusBar();
882 if ( !sb ) { 891 if ( !sb ) {
883//US sb = new KStatusBar( this ); 892//US sb = new KStatusBar( this );
884 sb = new QStatusBar( this ); 893 sb = new QStatusBar( this );
885 // trigger a re-layout and trigger a call to the private 894 // trigger a re-layout and trigger a call to the private
886 // setStatusBar method. 895 // setStatusBar method.
887 QMainWindow::statusBar(); 896 Q3MainWindow::statusBar();
888 } 897 }
889 return sb; 898 return sb;
890} 899}
891 900
892void KMainWindow::shuttingDown() 901void KMainWindow::shuttingDown()
893{ 902{
894 // Needed for Qt <= 3.0.3 at least to prevent reentrancy 903 // Needed for Qt <= 3.0.3 at least to prevent reentrancy
895 // when queryExit() shows a dialog. Check before removing! 904 // when queryExit() shows a dialog. Check before removing!
896 static bool reentrancy_protection = false; 905 static bool reentrancy_protection = false;
897 if (!reentrancy_protection) 906 if (!reentrancy_protection)
898 { 907 {
899 reentrancy_protection = true; 908 reentrancy_protection = true;
900 // call the virtual queryExit 909 // call the virtual queryExit
901 queryExit(); 910 queryExit();
902 reentrancy_protection = false; 911 reentrancy_protection = false;
903 } 912 }
904 913
905} 914}
906 915
907//US KMenuBar *KMainWindow::internalMenuBar() 916//US KMenuBar *KMainWindow::internalMenuBar()
908QMenuBar *KMainWindow::internalMenuBar() 917QMenuBar *KMainWindow::internalMenuBar()
909{ 918{
910//US QObjectList *l = queryList( "KMenuBar", 0, false, false ); 919//US QObjectList *l = queryList( "KMenuBar", 0, false, false );
911 QObjectList *l = queryList( "QMenuBar", 0, false, false ); 920 QObjectList l = queryList( "QMenuBar", 0, false, false );
912 if ( !l || !l->first() ) { 921 if(l.empty())
913 delete l; 922 return 0;
914 return 0; 923 return (QMenuBar*)l.front();
915 }
916
917//US KMenuBar *m = (KMenuBar*)l->first();
918 QMenuBar *m = (QMenuBar*)l->first();
919 delete l;
920 return m;
921} 924}
922 925
923//US KStatusBar *KMainWindow::internalStatusBar() 926//US KStatusBar *KMainWindow::internalStatusBar()
924QStatusBar *KMainWindow::internalStatusBar() 927QStatusBar *KMainWindow::internalStatusBar()
925{ 928{
926//US QObjectList *l = queryList( "KStatusBar", 0, false, false ); 929//US QObjectList *l = queryList( "KStatusBar", 0, false, false );
927 QObjectList *l = queryList( "QStatusBar", 0, false, false ); 930 QObjectList l = queryList( "QStatusBar", 0, false, false );
928 if ( !l || !l->first() ) { 931 if(l.empty())
929 delete l; 932 return 0;
930 return 0; 933 return (QStatusBar*)l.front();
931 }
932
933//US KStatusBar *s = (KStatusBar*)l->first();
934 QStatusBar *s = (QStatusBar*)l->first();
935 delete l;
936 return s;
937} 934}
938 935
939void KMainWindow::childEvent( QChildEvent* e) 936void KMainWindow::childEvent( QChildEvent* e)
940{ 937{
941 QMainWindow::childEvent( e ); 938 Q3MainWindow::childEvent( e );
942} 939}
943 940
944void KMainWindow::paintEvent( QPaintEvent * e) 941void KMainWindow::paintEvent( QPaintEvent * e)
945{ 942{
946 QMainWindow::paintEvent( e ); 943 Q3MainWindow::paintEvent( e );
947} 944}
948 945
949QSize KMainWindow::sizeForCentralWidgetSize(QSize size) 946QSize KMainWindow::sizeForCentralWidgetSize(QSize size)
950{ 947{
951 KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" ); 948 KToolBar *tb = (KToolBar*)child( "mainToolBar", "KToolBar" );
952 if (tb && !tb->isHidden()) { 949 if (tb && !tb->isHidden()) {
953 switch( tb->barPos() ) 950 switch( tb->barPos() )
954 { 951 {
955 case KToolBar::Top: 952 case KToolBar::Top:
956 case KToolBar::Bottom: 953 case KToolBar::Bottom:
957 size += QSize(0, tb->sizeHint().height()); 954 size += QSize(0, tb->sizeHint().height());
958 break; 955 break;
959 956
960 case KToolBar::Left: 957 case KToolBar::Left:
961 case KToolBar::Right: 958 case KToolBar::Right:
962 size += QSize(toolBar()->sizeHint().width(), 0); 959 size += QSize(toolBar()->sizeHint().width(), 0);
963 break; 960 break;
964 961
965 case KToolBar::Flat: 962 case KToolBar::Flat:
966//US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 963//US size += QSize(0, 3+kapp->style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
967 size += QSize(0, tb->sizeHint().height()); 964 size += QSize(0, tb->sizeHint().height());
968 break; 965 break;
969 966
970 default: 967 default:
971 break; 968 break;
972 } 969 }
973 } 970 }
974//US KMenuBar *mb = menuBar(); 971//US KMenuBar *mb = menuBar();
975 QMenuBar *mb = menuBar(); 972 QMenuBar *mb = menuBar();
976 if (!mb->isHidden()) { 973 if (!mb->isHidden()) {
977 size += QSize(0,mb->heightForWidth(size.width())); 974 size += QSize(0,mb->heightForWidth(size.width()));
978/*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this)) 975/*US if (style().styleHint(QStyle::SH_MainWindow_SpaceBelowMenuBar, this))
979 size += QSize( 0, dockWindowsMovable() ? 1 : 2); 976 size += QSize( 0, dockWindowsMovable() ? 1 : 2);
980*/ 977*/
981 size += QSize( 0, 2); 978 size += QSize( 0, 2);
982 } 979 }
983 QStatusBar *sb = internalStatusBar(); 980 QStatusBar *sb = internalStatusBar();
984 if( sb && !sb->isHidden() ) 981 if( sb && !sb->isHidden() )
985 size += QSize(0, sb->sizeHint().height()); 982 size += QSize(0, sb->sizeHint().height());
986 983
987 return size; 984 return size;
988} 985}
989 986
990// why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; 987// why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI;
991void KMainWindow::finalizeGUI( KXMLGUIClient *client ) 988void KMainWindow::finalizeGUI( KXMLGUIClient *client )
992{ /*US KXMLGUIBuilder::finalizeGUI( client );*/ } 989{ /*US KXMLGUIBuilder::finalizeGUI( client );*/ }
993 990
994void KMainWindow::virtual_hook( int id, void* data ) 991void KMainWindow::virtual_hook( int id, void* data )
995{ /*US KXMLGUIBuilder::virtual_hook( id, data );*/ 992{ /*US KXMLGUIBuilder::virtual_hook( id, data );*/
996 KXMLGUIClient::virtual_hook( id, data ); } 993 KXMLGUIClient::virtual_hook( id, data ); }
diff --git a/microkde/kdeui/kmainwindow.h b/microkde/kdeui/kmainwindow.h
index 2dc8033..a3ac82f 100644
--- a/microkde/kdeui/kmainwindow.h
+++ b/microkde/kdeui/kmainwindow.h
@@ -1,777 +1,782 @@
1//Added by qt3to4:
2#include <QResizeEvent>
3#include <QChildEvent>
4#include <QCloseEvent>
5#include <QPaintEvent>
1/* 6/*
2 This file is part of the KDE libraries 7 This file is part of the KDE libraries
3 8
4 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 11 License version 2 as published by the Free Software Foundation.
7 12
8 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 16 Library General Public License for more details.
12 17
13 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
17 22
18 $Id$ 23 $Id$
19 24
20*/ 25*/
21 26
22 27
23 28
24#ifndef KMAINWINDOW_H 29#ifndef KMAINWINDOW_H
25#define KMAINWINDOW_H 30#define KMAINWINDOW_H
26 31
27/*US 32/*US
28#include "kxmlguifactory.h" 33#include "kxmlguifactory.h"
29#include "kxmlguiclient.h" 34#include "kxmlguiclient.h"
30#include "kxmlguibuilder.h" 35#include "kxmlguibuilder.h"
31#include <qmetaobject.h> 36#include <qmetaobject.h>
32 37
33class KPopupMenu; 38class KPopupMenu;
34class KXMLGUIFactory; 39class KXMLGUIFactory;
35class KConfig; 40class KConfig;
36class KHelpMenu; 41class KHelpMenu;
37class KStatusBar; 42class KStatusBar;
38class QStatusBar; 43class QStatusBar;
39class KMenuBar; 44class KMenuBar;
40class KMWSessionManaged; 45class KMWSessionManaged;
41class KAccel; 46class KAccel;
42class KToolBarMenuAction; 47class KToolBarMenuAction;
43*/ 48*/
44 49
45class QMenuBar; 50class QMenuBar;
46class QStatusBar; 51class QStatusBar;
47class KMainWindowPrivate; 52class KMainWindowPrivate;
48class KAction; 53class KAction;
49 54
50#include <ktoolbar.h> 55#include <ktoolbar.h>
51#include <ktoolbarhandler.h> 56#include <ktoolbarhandler.h>
52#include <kxmlguiclient.h> 57#include <kxmlguiclient.h>
53#include <qmainwindow.h> 58#include <q3mainwindow.h>
54#include <qptrlist.h> 59#include <q3ptrlist.h>
55 60
56class KActionCollection; 61class KActionCollection;
57 62
58class KMainWindow : public QMainWindow, virtual public KXMLGUIClient 63class KMainWindow : public Q3MainWindow, virtual public KXMLGUIClient
59{ 64{
60 Q_OBJECT 65 Q_OBJECT
61 66
62private: 67private:
63//US create private defaultconstructor 68//US create private defaultconstructor
64 KMainWindow() {;}; 69 KMainWindow() {;};
65 70
66 71
67public: 72public:
68 /** 73 /**
69 * Construct a main window. 74 * Construct a main window.
70 * 75 *
71 * @param parent The widget parent. This is usually 0 but it may also be the window 76 * @param parent The widget parent. This is usually 0 but it may also be the window
72 * group leader. In that case, the KMainWindow becomes sort of a 77 * group leader. In that case, the KMainWindow becomes sort of a
73 * secondary window. 78 * secondary window.
74 * 79 *
75 * @param name The object name. For session management and window management to work 80 * @param name The object name. For session management and window management to work
76 * properly, all main windows in the application should have a 81 * properly, all main windows in the application should have a
77 * different name. When passing 0 (the default), KMainWindow will create 82 * different name. When passing 0 (the default), KMainWindow will create
78 * a unique name, but it's recommended to explicitly pass a window name that will 83 * a unique name, but it's recommended to explicitly pass a window name that will
79 * also describe the type of the window. If there can be several windows of the same 84 * also describe the type of the window. If there can be several windows of the same
80 * type, append '#' (hash) to the name, and KMainWindow will append numbers to make 85 * type, append '#' (hash) to the name, and KMainWindow will append numbers to make
81 * the names unique. For example, for a mail client which has one main window showing 86 * the names unique. For example, for a mail client which has one main window showing
82 * the mails and folders, and which can also have one or more windows for composing 87 * the mails and folders, and which can also have one or more windows for composing
83 * mails, the name for the folders window should be e.g. "mainwindow" and 88 * mails, the name for the folders window should be e.g. "mainwindow" and
84 * for the composer windows "composer#". 89 * for the composer windows "composer#".
85 * 90 *
86 * @param f Specify the widget flags. The default is 91 * @param f Specify the widget flags. The default is
87 * WType_TopLevel and WDestructiveClose. TopLevel indicates that a 92 * WType_TopLevel and WDestructiveClose. TopLevel indicates that a
88 * main window is a toplevel window, regardless of whether it has a 93 * main window is a toplevel window, regardless of whether it has a
89 * parent or not. DestructiveClose indicates that a main window is 94 * parent or not. DestructiveClose indicates that a main window is
90 * automatically destroyed when its window is closed. Pass 0 if 95 * automatically destroyed when its window is closed. Pass 0 if
91 * you do not want this behavior. 96 * you do not want this behavior.
92 * 97 *
93 * KMainWindows must be created on the heap with 'new', like: 98 * KMainWindows must be created on the heap with 'new', like:
94 * <pre> KMainWindow *kmw = new KMainWindow (...</pre> 99 * <pre> KMainWindow *kmw = new KMainWindow (...</pre>
95 **/ 100 **/
96 //LR remove WDestructiveClose 101 //LR remove WDestructiveClose
97 KMainWindow( QWidget* parent = 0, const char *name = 0 ); //, WFlags f = WType_TopLevel /*| WDestructiveClose*/ ; 102 KMainWindow( QWidget* parent = 0, const char *name = 0 ); //, WFlags f = WType_TopLevel /*| WDestructiveClose*/ ;
98 103
99 104
100 /** 105 /**
101 * Destructor. 106 * Destructor.
102 * 107 *
103 * Will also destroy the toolbars, and menubar if 108 * Will also destroy the toolbars, and menubar if
104 * needed. 109 * needed.
105 */ 110 */
106 virtual ~KMainWindow(); 111 virtual ~KMainWindow();
107 112
108 /** 113 /**
109 * Retrieve the standard help menu. 114 * Retrieve the standard help menu.
110 * 115 *
111 * It contains entires for the 116 * It contains entires for the
112 * help system (activated by F1), an optional "What's This?" entry 117 * help system (activated by F1), an optional "What's This?" entry
113 * (activated by Shift F1), an application specific dialog box, 118 * (activated by Shift F1), an application specific dialog box,
114 * and an "About KDE" dialog box. 119 * and an "About KDE" dialog box.
115 * 120 *
116 * Example (adding a standard help menu to your application): 121 * Example (adding a standard help menu to your application):
117 * <pre> 122 * <pre>
118 * KPopupMenu *help = helpMenu( <myTextString> ); 123 * KPopupMenu *help = helpMenu( <myTextString> );
119 * menuBar()->insertItem( i18n("&Help"), help ); 124 * menuBar()->insertItem( i18n("&Help"), help );
120 * </pre> 125 * </pre>
121 * 126 *
122 * @param aboutAppText The string that is used in the application 127 * @param aboutAppText The string that is used in the application
123 * specific dialog box. If you leave this string empty the 128 * specific dialog box. If you leave this string empty the
124 * information in the global @ref KAboutData of the 129 * information in the global @ref KAboutData of the
125 * application will be used to make a standard dialog box. 130 * application will be used to make a standard dialog box.
126 * 131 *
127 * @param showWhatsThis Set this to false if you do not want to include 132 * @param showWhatsThis Set this to false if you do not want to include
128 * the "What's This" menu entry. 133 * the "What's This" menu entry.
129 * 134 *
130 * @return A standard help menu. 135 * @return A standard help menu.
131 */ 136 */
132//US KPopupMenu* helpMenu( const QString &aboutAppText = QString::null, 137//US KPopupMenu* helpMenu( const QString &aboutAppText = QString::null,
133//US bool showWhatsThis = TRUE ); 138//US bool showWhatsThis = TRUE );
134 139
135 /** 140 /**
136 * Returns the help menu. Creates a standard help menu if none exists yet. 141 * Returns the help menu. Creates a standard help menu if none exists yet.
137 * 142 *
138 * It contains entries for the 143 * It contains entries for the
139 * help system (activated by F1), an optional "What's This?" entry 144 * help system (activated by F1), an optional "What's This?" entry
140 * (activated by Shift F1), an application specific dialog box, 145 * (activated by Shift F1), an application specific dialog box,
141 * and an "About KDE" dialog box. You must create the application 146 * and an "About KDE" dialog box. You must create the application
142 * specific dialog box yourself. When the "About application" 147 * specific dialog box yourself. When the "About application"
143 * menu entry is activated, a signal will trigger the 148 * menu entry is activated, a signal will trigger the
144 * @ref showAboutApplication slot. See @ref showAboutApplication for more 149 * @ref showAboutApplication slot. See @ref showAboutApplication for more
145 * information. 150 * information.
146 * 151 *
147 * Example (adding a help menu to your application): 152 * Example (adding a help menu to your application):
148 * <pre> 153 * <pre>
149 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); 154 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() );
150 * </pre> 155 * </pre>
151 * 156 *
152 * @param showWhatsThis Set this to @p false if you do not want to include 157 * @param showWhatsThis Set this to @p false if you do not want to include
153 * the "What's This" menu entry. 158 * the "What's This" menu entry.
154 * 159 *
155 * @return A standard help menu. 160 * @return A standard help menu.
156 */ 161 */
157//US KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE ); 162//US KPopupMenu* customHelpMenu( bool showWhatsThis = TRUE );
158 163
159 /** 164 /**
160 * @sect Session Management 165 * @sect Session Management
161 * 166 *
162 * Try to restore the toplevel widget as defined by the number (1..X). 167 * Try to restore the toplevel widget as defined by the number (1..X).
163 * 168 *
164 * If the session did not contain so high a number, the configuration 169 * If the session did not contain so high a number, the configuration
165 * is not changed and @p false returned. 170 * is not changed and @p false returned.
166 * 171 *
167 * That means clients could simply do the following: 172 * That means clients could simply do the following:
168 * <pre> 173 * <pre>
169 * if (kapp->isRestored()){ 174 * if (kapp->isRestored()){
170 * int n = 1; 175 * int n = 1;
171 * while (KMainWindow::canBeRestored(n)){ 176 * while (KMainWindow::canBeRestored(n)){
172 * (new childMW)->restore(n); 177 * (new childMW)->restore(n);
173 * n++; 178 * n++;
174 * } 179 * }
175 * } else { 180 * } else {
176 * // create default application as usual 181 * // create default application as usual
177 * } 182 * }
178 * </pre> 183 * </pre>
179 * Note that @ref QWidget::show() is called implicitly in restore. 184 * Note that @ref QWidget::show() is called implicitly in restore.
180 * 185 *
181 * With this you can easily restore all toplevel windows of your 186 * With this you can easily restore all toplevel windows of your
182 * application. 187 * application.
183 * 188 *
184 * If your application uses different kinds of toplevel 189 * If your application uses different kinds of toplevel
185 * windows, then you can use @ref KMainWindow::classNameOfToplevel(n) 190 * windows, then you can use @ref KMainWindow::classNameOfToplevel(n)
186 * to determine the exact type before calling the childMW 191 * to determine the exact type before calling the childMW
187 * constructor in the example from above. 192 * constructor in the example from above.
188 * 193 *
189 * If your client has only one kind of toplevel widgets (which 194 * If your client has only one kind of toplevel widgets (which
190 * should be pretty usual) then you should use the RESTORE-macro 195 * should be pretty usual) then you should use the RESTORE-macro
191 * for backwards compatibility with 3.1 and 3.0 branches: 196 * for backwards compatibility with 3.1 and 3.0 branches:
192 * 197 *
193 * <pre> 198 * <pre>
194 * if (kapp->isRestored()) 199 * if (kapp->isRestored())
195 * RESTORE(childMW) 200 * RESTORE(childMW)
196 * else { 201 * else {
197 * // create default application as usual 202 * // create default application as usual
198 * } 203 * }
199 * </pre> 204 * </pre>
200 * 205 *
201 * The macro expands to the term above but is easier to use and 206 * The macro expands to the term above but is easier to use and
202 * less code to write. 207 * less code to write.
203 * 208 *
204 * For new code or if you have more than one kind of toplevel 209 * For new code or if you have more than one kind of toplevel
205 * widget (each derived from @ref KMainWindow, of course), you can 210 * widget (each derived from @ref KMainWindow, of course), you can
206 * use the templated @ref kRestoreMainWindows global functions: 211 * use the templated @ref kRestoreMainWindows global functions:
207 * 212 *
208 * <pre> 213 * <pre>
209 * if (kapp->isRestored()) 214 * if (kapp->isRestored())
210 * kRestoreMainWindows< childMW1, childMW2, childMW3 >(); 215 * kRestoreMainWindows< childMW1, childMW2, childMW3 >();
211 * else { 216 * else {
212 * // create default application as usual 217 * // create default application as usual
213 * } 218 * }
214 * </pre> 219 * </pre>
215 * 220 *
216 * Currently, these functions are provided for up to three 221 * Currently, these functions are provided for up to three
217 * template arguments. If you need more, tell us. To help you in 222 * template arguments. If you need more, tell us. To help you in
218 * deciding whether or not you can use @ref kRestoreMainWindows, a 223 * deciding whether or not you can use @ref kRestoreMainWindows, a
219 * define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided. 224 * define KDE_RESTORE_MAIN_WINDOWS_NUM_TEMPLATE_ARGS is provided.
220 * 225 *
221 * @see restore() 226 * @see restore()
222 * @see classNameOfToplevel() 227 * @see classNameOfToplevel()
223 * 228 *
224 **/ 229 **/
225 static bool canBeRestored( int number ); 230 static bool canBeRestored( int number );
226 231
227 /** 232 /**
228 * Returns the @ref className() of the @p number of the toplevel window which 233 * Returns the @ref className() of the @p number of the toplevel window which
229 * should be restored. 234 * should be restored.
230 * 235 *
231 * This is only useful if your application uses 236 * This is only useful if your application uses
232 * different kinds of toplevel windows. 237 * different kinds of toplevel windows.
233 */ 238 */
234 static const QString classNameOfToplevel( int number ); 239 static const QString classNameOfToplevel( int number );
235 240
236 /** 241 /**
237 * Restore the session specified by @p number. 242 * Restore the session specified by @p number.
238 * 243 *
239 * Returns @p false if this 244 * Returns @p false if this
240 * fails, otherwise returns @p true and shows the window. 245 * fails, otherwise returns @p true and shows the window.
241 * You should call @ref canBeRestored() first. 246 * You should call @ref canBeRestored() first.
242 * If @p show is true (default), this widget will be shown automatically. 247 * If @p show is true (default), this widget will be shown automatically.
243 */ 248 */
244 bool restore( int number, bool show = TRUE ); 249 bool restore( int number, bool show = TRUE );
245 250
246//US virtual KXMLGUIFactory *guiFactory(); 251//US virtual KXMLGUIFactory *guiFactory();
247 252
248 /** 253 /**
249 * Create a GUI given a local XML file. 254 * Create a GUI given a local XML file.
250 * 255 *
251 * If @p xmlfile is NULL, 256 * If @p xmlfile is NULL,
252 * then it will try to construct a local XML filename like 257 * then it will try to construct a local XML filename like
253 * appnameui.rc where 'appname' is your app's name. If that file 258 * appnameui.rc where 'appname' is your app's name. If that file
254 * does not exist, then the XML UI code will only use the global 259 * does not exist, then the XML UI code will only use the global
255 * (standard) XML file for the layout purposes. 260 * (standard) XML file for the layout purposes.
256 * 261 *
257 * Note that when passing true for the conserveMemory argument subsequent 262 * Note that when passing true for the conserveMemory argument subsequent
258 * calls to guiFactory()->addClient/removeClient may not work as expected. 263 * calls to guiFactory()->addClient/removeClient may not work as expected.
259 * Also retrieving references to containers like popup menus or toolbars using 264 * Also retrieving references to containers like popup menus or toolbars using
260 * the container method will not work. 265 * the container method will not work.
261 * 266 *
262 * @param xmlfile The local xmlfile (relative or absolute) 267 * @param xmlfile The local xmlfile (relative or absolute)
263 * @param _conserveMemory Specify whether createGUI() should call 268 * @param _conserveMemory Specify whether createGUI() should call
264 * @ref KXMLGuiClient::conserveMemory() to free all memory 269 * @ref KXMLGuiClient::conserveMemory() to free all memory
265 * allocated by the @ref QDomDocument and by the KXMLGUIFactory. 270 * allocated by the @ref QDomDocument and by the KXMLGUIFactory.
266 */ 271 */
267 void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE ); 272 void createGUI( const QString &xmlfile = QString::null, bool _conserveMemory = TRUE );
268 273
269 /** 274 /**
270 * Enables the build of a standard help menu when calling createGUI(). 275 * Enables the build of a standard help menu when calling createGUI().
271 * 276 *
272 * The default behavior is to build one, you must call this function 277 * The default behavior is to build one, you must call this function
273 * to disable it 278 * to disable it
274 */ 279 */
275 void setHelpMenuEnabled(bool showHelpMenu = true); 280 void setHelpMenuEnabled(bool showHelpMenu = true);
276 281
277 /** 282 /**
278 * Return @p true when the help menu is enabled 283 * Return @p true when the help menu is enabled
279 */ 284 */
280 bool isHelpMenuEnabled(); 285 bool isHelpMenuEnabled();
281 286
282 287
283 /** 288 /**
284 * Returns true, if there is a menubar 289 * Returns true, if there is a menubar
285 * @since 3.1 290 * @since 3.1
286 */ 291 */
287 bool hasMenuBar(); 292 bool hasMenuBar();
288 293
289 /** 294 /**
290 * Returns a pointer to the menu bar. 295 * Returns a pointer to the menu bar.
291 * 296 *
292 * If there is no menu bar yet one will be created. 297 * If there is no menu bar yet one will be created.
293 **/ 298 **/
294//US KMenuBar *menuBar(); 299//US KMenuBar *menuBar();
295 QMenuBar *menuBar(); 300 QMenuBar *menuBar();
296 301
297 /** 302 /**
298 * Returns a pointer to the status bar. 303 * Returns a pointer to the status bar.
299 * 304 *
300 * If there is no 305 * If there is no
301 * status bar yet one will be created. 306 * status bar yet one will be created.
302 */ 307 */
303//US KStatusBar *statusBar(); 308//US KStatusBar *statusBar();
304 QStatusBar *statusBar(); 309 QStatusBar *statusBar();
305 310
306 /** 311 /**
307 * List of members of KMainWindow class. 312 * List of members of KMainWindow class.
308 */ 313 */
309//US static QPtrList<KMainWindow>* memberList; 314//US static QPtrList<KMainWindow>* memberList;
310 315
311 /** 316 /**
312 * Returns a pointer to the toolbar with the specified name. 317 * Returns a pointer to the toolbar with the specified name.
313 * This refers to toolbars created dynamically from the XML UI 318 * This refers to toolbars created dynamically from the XML UI
314 * framework. If the toolbar does not exist one will be created. 319 * framework. If the toolbar does not exist one will be created.
315 * 320 *
316 * @param name The internal name of the toolbar. If no name is 321 * @param name The internal name of the toolbar. If no name is
317 * specified "mainToolBar" is assumed. 322 * specified "mainToolBar" is assumed.
318 * 323 *
319 * @return A pointer to the toolbar 324 * @return A pointer to the toolbar
320 **/ 325 **/
321 KToolBar *toolBar( const char *name=0 ); 326 KToolBar *toolBar( const char *name=0 );
322 // method for getting rid of KDE-Crap 327 // method for getting rid of KDE-Crap
323 QToolBar *tBar( ); 328 Q3ToolBar *tBar( );
324 329
325 /** 330 /**
326 * @return An iterator over the list of all toolbars for this window. 331 * @return An iterator over the list of all toolbars for this window.
327 */ 332 */
328 QPtrListIterator<KToolBar> toolBarIterator(); 333 Q3PtrListIterator<KToolBar> toolBarIterator();
329 334
330 /** 335 /**
331 * @return A KAccel instance bound to this mainwindow. Used automatically 336 * @return A KAccel instance bound to this mainwindow. Used automatically
332 * by KAction to make keybindings work in all cases. 337 * by KAction to make keybindings work in all cases.
333 */ 338 */
334 KAccel *accel(); 339 KAccel *accel();
335 340
336 void setFrameBorderWidth( int ) {} 341 void setFrameBorderWidth( int ) {}
337 342
338 /** 343 /**
339 * Call this to enable "auto-save" of toolbar/menubar/statusbar settings 344 * Call this to enable "auto-save" of toolbar/menubar/statusbar settings
340 * (and optionally window size). 345 * (and optionally window size).
341 * If the *bars were moved around/shown/hidden when the window is closed, 346 * If the *bars were moved around/shown/hidden when the window is closed,
342 * saveMainWindowSettings( KGlobal::config(), groupName ) will be called. 347 * saveMainWindowSettings( KGlobal::config(), groupName ) will be called.
343 * 348 *
344 * @param groupName a name that identifies this "type of window". 349 * @param groupName a name that identifies this "type of window".
345 * You can have several types of window in the same application. 350 * You can have several types of window in the same application.
346 * 351 *
347 * @param saveWindowSize set it to true to include the window size 352 * @param saveWindowSize set it to true to include the window size
348 * when saving. 353 * when saving.
349 * 354 *
350 * Typically, you will call setAutoSaveSettings() in your 355 * Typically, you will call setAutoSaveSettings() in your
351 * KMainWindow-inherited class constructor, and it will take care 356 * KMainWindow-inherited class constructor, and it will take care
352 * of restoring and saving automatically. Make sure you call this 357 * of restoring and saving automatically. Make sure you call this
353 * _after all_ your *bars have been created. 358 * _after all_ your *bars have been created.
354 */ 359 */
355 void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"), 360 void setAutoSaveSettings( const QString & groupName = QString::fromLatin1("MainWindow"),
356 bool saveWindowSize = true ); 361 bool saveWindowSize = true );
357 362
358 /** 363 /**
359 * Disable the auto-save-settings feature. 364 * Disable the auto-save-settings feature.
360 * You don't normally need to call this, ever. 365 * You don't normally need to call this, ever.
361 */ 366 */
362 void resetAutoSaveSettings(); 367 void resetAutoSaveSettings();
363 368
364 /** 369 /**
365 * @return the current autosave setting, i.e. true if setAutoSaveSettings() was called, 370 * @return the current autosave setting, i.e. true if setAutoSaveSettings() was called,
366 * false by default or if resetAutoSaveSettings() was called. 371 * false by default or if resetAutoSaveSettings() was called.
367 * @since 3.1 372 * @since 3.1
368 */ 373 */
369 bool autoSaveSettings() const; 374 bool autoSaveSettings() const;
370 375
371 /** 376 /**
372 * @return the group used for setting-autosaving. 377 * @return the group used for setting-autosaving.
373 * Only meaningful if setAutoSaveSettings() was called. 378 * Only meaningful if setAutoSaveSettings() was called.
374 * This can be useful for forcing a save or an apply, e.g. before and after 379 * This can be useful for forcing a save or an apply, e.g. before and after
375 * using KEditToolbar. 380 * using KEditToolbar.
376 * @since 3.1 381 * @since 3.1
377 */ 382 */
378 QString autoSaveGroup() const; 383 QString autoSaveGroup() const;
379 384
380 /** 385 /**
381 * Read settings for statusbar, menubar and toolbar from their respective 386 * Read settings for statusbar, menubar and toolbar from their respective
382 * groups in the config file and apply them. 387 * groups in the config file and apply them.
383 * 388 *
384 * @param config Config file to read the settings from. 389 * @param config Config file to read the settings from.
385 * @param groupName Group name to use. If not specified, the last used 390 * @param groupName Group name to use. If not specified, the last used
386 * group name is used. 391 * group name is used.
387 */ 392 */
388 void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null); 393 void applyMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
389 394
390 /** 395 /**
391 * Save settings for statusbar, menubar and toolbar to their respective 396 * Save settings for statusbar, menubar and toolbar to their respective
392 * groups in the config file @p config. 397 * groups in the config file @p config.
393 * 398 *
394 * @param config Config file to save the settings to. 399 * @param config Config file to save the settings to.
395 * @param groupName Group name to use. If not specified, the last used 400 * @param groupName Group name to use. If not specified, the last used
396 * group name is used 401 * group name is used
397 */ 402 */
398 void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null); 403 void saveMainWindowSettings(KConfig *config, const QString &groupName = QString::null);
399 404
400 /** 405 /**
401 * Sets whether KMainWindow should provide a menu that allows showing/hiding 406 * Sets whether KMainWindow should provide a menu that allows showing/hiding
402 * the available toolbars ( using @ref KToggleToolBarAction ) . In case there 407 * the available toolbars ( using @ref KToggleToolBarAction ) . In case there
403 * is only one toolbar configured a simple 'Show <toolbar name here>' menu item 408 * is only one toolbar configured a simple 'Show <toolbar name here>' menu item
404 * is shown. 409 * is shown.
405 * 410 *
406 * The menu / menu item is implemented using xmlgui. It will be inserted in your 411 * The menu / menu item is implemented using xmlgui. It will be inserted in your
407 * menu structure in the 'Settings' menu. 412 * menu structure in the 'Settings' menu.
408 * 413 *
409 * If your application uses a non-standard xmlgui resource file then you can 414 * If your application uses a non-standard xmlgui resource file then you can
410 * specify the exact position of the menu / menu item by adding a 415 * specify the exact position of the menu / menu item by adding a
411 * &lt;Merge name="StandardToolBarMenuHandler" /&gt; 416 * &lt;Merge name="StandardToolBarMenuHandler" /&gt;
412 * line to the settings menu section of your resource file ( usually appname.rc ). 417 * line to the settings menu section of your resource file ( usually appname.rc ).
413 * 418 *
414 * Note that you should enable this feature before calling createGUI() ( or similar ) . 419 * Note that you should enable this feature before calling createGUI() ( or similar ) .
415 * You enable/disable it anytime if you pass false to the conserveMemory argument of createGUI. 420 * You enable/disable it anytime if you pass false to the conserveMemory argument of createGUI.
416 * @since 3.1 421 * @since 3.1
417 */ 422 */
418 void setStandardToolBarMenuEnabled( bool enable ); 423 void setStandardToolBarMenuEnabled( bool enable );
419 /// @since 3.1 424 /// @since 3.1
420 bool isStandardToolBarMenuEnabled() const; 425 bool isStandardToolBarMenuEnabled() const;
421 426
422 427
423 /** 428 /**
424 * Sets whether KMainWindow should provide a menu that allows showing/hiding 429 * Sets whether KMainWindow should provide a menu that allows showing/hiding
425 * of the statusbar ( using @ref KToggleStatusBarAction ). 430 * of the statusbar ( using @ref KToggleStatusBarAction ).
426 * 431 *
427 * The menu / menu item is implemented using xmlgui. It will be inserted 432 * The menu / menu item is implemented using xmlgui. It will be inserted
428 * in your menu structure in the 'Settings' menu. 433 * in your menu structure in the 'Settings' menu.
429 * 434 *
430 * Note that you should enable this feature before calling createGUI() 435 * Note that you should enable this feature before calling createGUI()
431 * ( or similar ). 436 * ( or similar ).
432 * 437 *
433 * If an application maintains the action on its own (i.e. never calls 438 * If an application maintains the action on its own (i.e. never calls
434 * this function) a connection needs to be made to let KMainWindow 439 * this function) a connection needs to be made to let KMainWindow
435 * know when that status (hidden/shown) of the statusbar has changed. 440 * know when that status (hidden/shown) of the statusbar has changed.
436 * For example: 441 * For example:
437 * connect(action, SIGNAL(activated()), 442 * connect(action, SIGNAL(activated()),
438 * kmainwindow, SLOT(setSettingsDirty())); 443 * kmainwindow, SLOT(setSettingsDirty()));
439 * Otherwise the status (hidden/show) of the statusbar might not be saved 444 * Otherwise the status (hidden/show) of the statusbar might not be saved
440 * by KMainWindow. 445 * by KMainWindow.
441 * @since 3.2 446 * @since 3.2
442 */ 447 */
443 void createStandardStatusBarAction(); 448 void createStandardStatusBarAction();
444 449
445 450
446 /** 451 /**
447 * Returns a pointer to the mainwindows action responsible for the toolbars menu 452 * Returns a pointer to the mainwindows action responsible for the toolbars menu
448 * @since 3.1 453 * @since 3.1
449 */ 454 */
450 KAction *toolBarMenuAction(); 455 KAction *toolBarMenuAction();
451 456
452 // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI; 457 // why do we support old gcc versions? using KXMLGUIBuilder::finalizeGUI;
453 /// @since 3.1 458 /// @since 3.1
454 virtual void finalizeGUI( KXMLGUIClient *client ); 459 virtual void finalizeGUI( KXMLGUIClient *client );
455 460
456 /** 461 /**
457 * @internal 462 * @internal
458 */ 463 */
459 void finalizeGUI( bool force ); 464 void finalizeGUI( bool force );
460 465
461 /** 466 /**
462 * @return true if a -geometry argument was given on the command line, 467 * @return true if a -geometry argument was given on the command line,
463 * and this is the first window created (the one on which this option applies) 468 * and this is the first window created (the one on which this option applies)
464 */ 469 */
465 bool initialGeometrySet() const; 470 bool initialGeometrySet() const;
466 471
467 /** 472 /**
468 * @internal 473 * @internal
469 * Used from Konqueror when reusing the main window. 474 * Used from Konqueror when reusing the main window.
470 */ 475 */
471 void ignoreInitialGeometry(); 476 void ignoreInitialGeometry();
472 477
473 /** 478 /**
474 * @return the size the mainwindow should have so that the central 479 * @return the size the mainwindow should have so that the central
475 * widget will be of @p size. 480 * widget will be of @p size.
476 */ 481 */
477 QSize sizeForCentralWidgetSize(QSize size); 482 QSize sizeForCentralWidgetSize(QSize size);
478 483
479public slots: 484public slots:
480 /** 485 /**
481 * Makes a KDE compliant caption. 486 * Makes a KDE compliant caption.
482 * 487 *
483 * @param caption Your caption. @em Do @em not include the application name 488 * @param caption Your caption. @em Do @em not include the application name
484 * in this string. It will be added automatically according to the KDE 489 * in this string. It will be added automatically according to the KDE
485 * standard. 490 * standard.
486 */ 491 */
487 virtual void setCaption( const QString &caption ); 492 virtual void setCaption( const QString &caption );
488 /** 493 /**
489 * Makes a KDE compliant caption. 494 * Makes a KDE compliant caption.
490 * 495 *
491 * @param caption Your caption. @em Do @em not include the application name 496 * @param caption Your caption. @em Do @em not include the application name
492 * in this string. It will be added automatically according to the KDE 497 * in this string. It will be added automatically according to the KDE
493 * standard. 498 * standard.
494 * @param modified Specify whether the document is modified. This displays 499 * @param modified Specify whether the document is modified. This displays
495 * an additional sign in the title bar, usually "**". 500 * an additional sign in the title bar, usually "**".
496 */ 501 */
497 virtual void setCaption( const QString &caption, bool modified ); 502 virtual void setCaption( const QString &caption, bool modified );
498 503
499 /** 504 /**
500 * Make a plain caption without any modifications. 505 * Make a plain caption without any modifications.
501 * 506 *
502 * @param caption Your caption. This is the string that will be 507 * @param caption Your caption. This is the string that will be
503 * displayed in the window title. 508 * displayed in the window title.
504 */ 509 */
505 virtual void setPlainCaption( const QString &caption ); 510 virtual void setPlainCaption( const QString &caption );
506 511
507 /** 512 /**
508 * Open the help page for the application. 513 * Open the help page for the application.
509 * 514 *
510 * The application name is 515 * The application name is
511 * used as a key to determine what to display and the system will attempt 516 * used as a key to determine what to display and the system will attempt
512 * to open <appName>/index.html. 517 * to open <appName>/index.html.
513 * 518 *
514 * This method is intended for use by a help button in the toolbar or 519 * This method is intended for use by a help button in the toolbar or
515 * components outside the regular help menu. Use @ref helpMenu() when you 520 * components outside the regular help menu. Use @ref helpMenu() when you
516 * want to provide access to the help system from the help menu. 521 * want to provide access to the help system from the help menu.
517 * 522 *
518 * Example (adding a help button to the first toolbar): 523 * Example (adding a help button to the first toolbar):
519 * 524 *
520 * <pre> 525 * <pre>
521 * KIconLoader &loader = *KGlobal::iconLoader(); 526 * KIconLoader &loader = *KGlobal::iconLoader();
522 * QPixmap pixmap = loader.loadIcon( "help" ); 527 * QPixmap pixmap = loader.loadIcon( "help" );
523 * toolBar(0)->insertButton( pixmap, 0, SIGNAL(clicked()), 528 * toolBar(0)->insertButton( pixmap, 0, SIGNAL(clicked()),
524 * this, SLOT(appHelpActivated()), true, i18n("Help") ); 529 * this, SLOT(appHelpActivated()), true, i18n("Help") );
525 * </pre> 530 * </pre>
526 * 531 *
527 */ 532 */
528//US void appHelpActivated( void ); 533//US void appHelpActivated( void );
529 534
530 /** 535 /**
531 * Apply a state change 536 * Apply a state change
532 * 537 *
533 * Enable and disable actions as defined in the XML rc file 538 * Enable and disable actions as defined in the XML rc file
534 * @since 3.1 539 * @since 3.1
535 */ 540 */
536 virtual void slotStateChanged(const QString &newstate); 541 virtual void slotStateChanged(const QString &newstate);
537 542
538 /** 543 /**
539 * Apply a state change 544 * Apply a state change
540 * 545 *
541 * Enable and disable actions as defined in the XML rc file, 546 * Enable and disable actions as defined in the XML rc file,
542 * can "reverse" the state (disable the actions which should be 547 * can "reverse" the state (disable the actions which should be
543 * enabled, and vice-versa) if specified. 548 * enabled, and vice-versa) if specified.
544 * @since 3.1 549 * @since 3.1
545 */ 550 */
546 void slotStateChanged(const QString &newstate, 551 void slotStateChanged(const QString &newstate,
547 KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this 552 KXMLGUIClient::ReverseStateChange); // KDE 4.0: remove this
548 553
549 554
550 /** 555 /**
551 * Apply a state change 556 * Apply a state change
552 * 557 *
553 * Enable and disable actions as defined in the XML rc file, 558 * Enable and disable actions as defined in the XML rc file,
554 * can "reverse" the state (disable the actions which should be 559 * can "reverse" the state (disable the actions which should be
555 * enabled, and vice-versa) if specified. 560 * enabled, and vice-versa) if specified.
556 */ 561 */
557// void slotStateChanged(const QString &newstate, 562// void slotStateChanged(const QString &newstate,
558// bool reverse); // KDE 4.0: enable this 563// bool reverse); // KDE 4.0: enable this
559 564
560 /** 565 /**
561 * Tell the main window that it should save its settings when being closed. 566 * Tell the main window that it should save its settings when being closed.
562 * This is part of the auto-save-settings feature. 567 * This is part of the auto-save-settings feature.
563 * For everything related to toolbars this happens automatically, 568 * For everything related to toolbars this happens automatically,
564 * but you have to call setSettingsDirty() in the slot that toggles 569 * but you have to call setSettingsDirty() in the slot that toggles
565 * the visibility of the statusbar. 570 * the visibility of the statusbar.
566 */ 571 */
567 void setSettingsDirty(); 572 void setSettingsDirty();
568 573
569protected: 574protected:
570 void paintEvent( QPaintEvent* e ); 575 void paintEvent( QPaintEvent* e );
571 void childEvent( QChildEvent* e); 576 void childEvent( QChildEvent* e);
572 void resizeEvent( QResizeEvent* e); 577 void resizeEvent( QResizeEvent* e);
573 /** 578 /**
574 * Reimplemented to call the queryClose() and queryExit() handlers. 579 * Reimplemented to call the queryClose() and queryExit() handlers.
575 * 580 *
576 * We recommend that you reimplement the handlers rather than @ref closeEvent(). 581 * We recommend that you reimplement the handlers rather than @ref closeEvent().
577 * If you do it anyway, ensure to call the base implementation to keep 582 * If you do it anyway, ensure to call the base implementation to keep
578 * @ref queryExit() running. 583 * @ref queryExit() running.
579 */ 584 */
580 virtual void closeEvent ( QCloseEvent *); 585 virtual void closeEvent ( QCloseEvent *);
581 586
582 // KDE4 This seems to be flawed to me. Either the app has only one 587 // KDE4 This seems to be flawed to me. Either the app has only one
583 // mainwindow, so queryClose() is enough, or if it can have more of them, 588 // mainwindow, so queryClose() is enough, or if it can have more of them,
584 // then the windows should take care of themselves, and queryExit() 589 // then the windows should take care of themselves, and queryExit()
585 // would be useful only for the annoying 'really quit' dialog, which 590 // would be useful only for the annoying 'really quit' dialog, which
586 // also doesn't make sense in apps with multiple mainwindows. 591 // also doesn't make sense in apps with multiple mainwindows.
587 // And saving configuration in something called queryExit()? IMHO 592 // And saving configuration in something called queryExit()? IMHO
588 // one can e.g. use KApplication::shutDown(), which if nothing else 593 // one can e.g. use KApplication::shutDown(), which if nothing else
589 // has at least better fitting name. 594 // has at least better fitting name.
590 // See also KApplication::sessionSaving(). 595 // See also KApplication::sessionSaving().
591 // This stuff should get changed somehow, so that it at least doesn't 596 // This stuff should get changed somehow, so that it at least doesn't
592 // mess with session management. 597 // mess with session management.
593 /** 598 /**
594 Called before the very last window is closed, either by the 599 Called before the very last window is closed, either by the
595 user or indirectly by the session manager. 600 user or indirectly by the session manager.
596 601
597 It is not recommended to do any user interaction in this 602 It is not recommended to do any user interaction in this
598 function other than indicating severe errors. Better ask the 603 function other than indicating severe errors. Better ask the
599 user on @ref queryClose() (see below). 604 user on @ref queryClose() (see below).
600 605
601 A typical usage of @ref queryExit() is to write configuration data back. 606 A typical usage of @ref queryExit() is to write configuration data back.
602 Note that the application may continue to run after @ref queryExit() 607 Note that the application may continue to run after @ref queryExit()
603 (the user may have cancelled a shutdown), so you should not do any cleanups 608 (the user may have cancelled a shutdown), so you should not do any cleanups
604 here. The purpose of @ref queryExit() is purely to prepare the application 609 here. The purpose of @ref queryExit() is purely to prepare the application
605 (with possible user interaction) so it can safely be closed later (without 610 (with possible user interaction) so it can safely be closed later (without
606 user interaction). 611 user interaction).
607 612
608 If you need to do serious things on exit (like shutting a 613 If you need to do serious things on exit (like shutting a
609 dial-up connection down), connect to the signal 614 dial-up connection down), connect to the signal
610 @ref KApplication::shutDown(). 615 @ref KApplication::shutDown().
611 616
612 Default implementation returns @p true. Returning @p false will 617 Default implementation returns @p true. Returning @p false will
613 cancel the exiting. In the latter case, the last window will 618 cancel the exiting. In the latter case, the last window will
614 remain visible. If KApplication::sessionSaving() is true, refusing 619 remain visible. If KApplication::sessionSaving() is true, refusing
615 the exit will also cancel KDE logout. 620 the exit will also cancel KDE logout.
616 621
617 @see queryClose() 622 @see queryClose()
618 @see KApplication::sessionSaving() 623 @see KApplication::sessionSaving()
619 */ 624 */
620 virtual bool queryExit(); 625 virtual bool queryExit();
621 626
622 /** 627 /**
623 Called before the window is closed, either by the user or indirectly by 628 Called before the window is closed, either by the user or indirectly by
624 the session manager. 629 the session manager.
625 630
626 The purpose of this function is to prepare the window in a way that it is 631 The purpose of this function is to prepare the window in a way that it is
627 safe to close it, i.e. without the user losing some data. 632 safe to close it, i.e. without the user losing some data.
628 633
629 Default implementation returns true. Returning @p false will cancel 634 Default implementation returns true. Returning @p false will cancel
630 the closing, and, if KApplication::sessionSaving() is true, it will also 635 the closing, and, if KApplication::sessionSaving() is true, it will also
631 cancel KDE logout. 636 cancel KDE logout.
632 637
633 Reimplement this function to prevent the user from losing data. 638 Reimplement this function to prevent the user from losing data.
634 Example: 639 Example:
635 <pre> 640 <pre>
636 641
637 switch ( KMessageBox::warningYesNoCancel( this, 642 switch ( KMessageBox::warningYesNoCancel( this,
638 i18n("Save changes to document foo?")) ) { 643 i18n("Save changes to document foo?")) ) {
639 case KMessageBox::Yes : 644 case KMessageBox::Yes :
640 // save document here. If saving fails, return FALSE; 645 // save document here. If saving fails, return FALSE;
641 return TRUE; 646 return TRUE;
642 case KMessageBox::No : 647 case KMessageBox::No :
643 return TRUE; 648 return TRUE;
644 default: // cancel 649 default: // cancel
645 return FALSE; 650 return FALSE;
646 651
647 </pre> 652 </pre>
648 653
649 @see queryExit() 654 @see queryExit()
650 @see KApplication::sessionSaving() 655 @see KApplication::sessionSaving()
651 656
652 */ 657 */
653 virtual bool queryClose(); 658 virtual bool queryClose();
654 /** 659 /**
655 * Save your instance-specific properties. The function is 660 * Save your instance-specific properties. The function is
656 * invoked when the session manager requests your application 661 * invoked when the session manager requests your application
657 * to save its state. 662 * to save its state.
658 * 663 *
659 * You @em must @em not change the group of the @p kconfig object, since 664 * You @em must @em not change the group of the @p kconfig object, since
660 * KMainWindow uses one group for each window. Please 665 * KMainWindow uses one group for each window. Please
661 * reimplement these function in childclasses. 666 * reimplement these function in childclasses.
662 * 667 *
663 * Note: No user interaction is allowed 668 * Note: No user interaction is allowed
664 * in this function! 669 * in this function!
665 * 670 *
666 */ 671 */
667 virtual void saveProperties( KConfig* ) {} 672 virtual void saveProperties( KConfig* ) {}
668 673
669 /** 674 /**
670 * Read your instance-specific properties. 675 * Read your instance-specific properties.
671 */ 676 */
672 virtual void readProperties( KConfig* ) {} 677 virtual void readProperties( KConfig* ) {}
673 678
674 /** 679 /**
675 * Save your application-wide properties. The function is 680 * Save your application-wide properties. The function is
676 * invoked when the session manager requests your application 681 * invoked when the session manager requests your application
677 * to save its state. 682 * to save its state.
678 * 683 *
679 * This function is similar to @ref saveProperties() but is only called for 684 * This function is similar to @ref saveProperties() but is only called for
680 * the very first main window, regardless how many main window are open. 685 * the very first main window, regardless how many main window are open.
681 686
682 * Override it if you need to save other data about your documents on 687 * Override it if you need to save other data about your documents on
683 * session end. sessionConfig is a config to which that data should be 688 * session end. sessionConfig is a config to which that data should be
684 * saved. Normally, you don't need this function. But if you want to save 689 * saved. Normally, you don't need this function. But if you want to save
685 * data about your documents that are not in opened windows you might need 690 * data about your documents that are not in opened windows you might need
686 * it. 691 * it.
687 * 692 *
688 * Default implementation does nothing. 693 * Default implementation does nothing.
689 */ 694 */
690 virtual void saveGlobalProperties( KConfig* sessionConfig ); 695 virtual void saveGlobalProperties( KConfig* sessionConfig );
691 696
692 /** 697 /**
693 * The counterpart of @ref saveGlobalProperties(). 698 * The counterpart of @ref saveGlobalProperties().
694 * 699 *
695 * Read the application-specific properties in again. 700 * Read the application-specific properties in again.
696 */ 701 */
697 virtual void readGlobalProperties( KConfig* sessionConfig ); 702 virtual void readGlobalProperties( KConfig* sessionConfig );
698 void savePropertiesInternal( KConfig*, int ); 703 void savePropertiesInternal( KConfig*, int );
699 bool readPropertiesInternal( KConfig*, int ); 704 bool readPropertiesInternal( KConfig*, int );
700 705
701 /** 706 /**
702 * For inherited classes 707 * For inherited classes
703 */ 708 */
704 bool settingsDirty() const; 709 bool settingsDirty() const;
705 /** 710 /**
706 * For inherited classes 711 * For inherited classes
707 */ 712 */
708 QString settingsGroup() const; 713 QString settingsGroup() const;
709 /** 714 /**
710 * For inherited classes 715 * For inherited classes
711 * Note that the group must be set before calling 716 * Note that the group must be set before calling
712 */ 717 */
713 void saveWindowSize( KConfig * config ) const; 718 void saveWindowSize( KConfig * config ) const;
714 /** 719 /**
715 * For inherited classes 720 * For inherited classes
716 * Note that the group must be set before calling, and that 721 * Note that the group must be set before calling, and that
717 * a -geometry on the command line has priority. 722 * a -geometry on the command line has priority.
718 */ 723 */
719 void restoreWindowSize( KConfig * config ); 724 void restoreWindowSize( KConfig * config );
720 725
721 /// parse the geometry from the geometry command line argument 726 /// parse the geometry from the geometry command line argument
722 void parseGeometry(bool parsewidth); 727 void parseGeometry(bool parsewidth);
723 728
724protected slots: 729protected slots:
725 730
726 /** 731 /**
727 * This slot does nothing. 732 * This slot does nothing.
728 * 733 *
729 * It must be reimplemented if you want 734 * It must be reimplemented if you want
730 * to use a custom About Application dialog box. This slot is 735 * to use a custom About Application dialog box. This slot is
731 * connected to the About Application entry in the menu returned 736 * connected to the About Application entry in the menu returned
732 * by @ref customHelpMenu. 737 * by @ref customHelpMenu.
733 * 738 *
734 * Example: 739 * Example:
735 * <pre> 740 * <pre>
736 * 741 *
737 * void MyMainLevel::setupInterface() 742 * void MyMainLevel::setupInterface()
738 * { 743 * {
739 * .. 744 * ..
740 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() ); 745 * menuBar()->insertItem( i18n("&Help"), customHelpMenu() );
741 * .. 746 * ..
742 * } 747 * }
743 * 748 *
744 * void MyMainLevel::showAboutApplication() 749 * void MyMainLevel::showAboutApplication()
745 * { 750 * {
746 * <activate your custom dialog> 751 * <activate your custom dialog>
747 * } 752 * }
748 * </pre> 753 * </pre>
749 */ 754 */
750//US virtual void showAboutApplication(); 755//US virtual void showAboutApplication();
751 756
752private slots: 757private slots:
753 /** 758 /**
754 * Called when the app is shutting down. 759 * Called when the app is shutting down.
755 */ 760 */
756 void shuttingDown(); 761 void shuttingDown();
757 762
758 void saveAutoSaveSettings(); 763 void saveAutoSaveSettings();
759 764
760private: 765private:
761 QToolBar * mQToolBar; 766 Q3ToolBar * mQToolBar;
762//US KMenuBar *internalMenuBar(); 767//US KMenuBar *internalMenuBar();
763 QMenuBar *internalMenuBar(); 768 QMenuBar *internalMenuBar();
764//US KStatusBar *internalStatusBar(); 769//US KStatusBar *internalStatusBar();
765 QStatusBar *internalStatusBar(); 770 QStatusBar *internalStatusBar();
766 771
767 KMainWindowPrivate *d; 772 KMainWindowPrivate *d;
768 void initKMainWindow(const char *name); 773 void initKMainWindow(const char *name);
769 774
770 QPtrList<KToolBar> toolbarList; 775 Q3PtrList<KToolBar> toolbarList;
771 776
772protected: 777protected:
773 virtual void virtual_hook( int id, void* data ); 778 virtual void virtual_hook( int id, void* data );
774 779
775}; 780};
776 781
777#endif 782#endif
diff --git a/microkde/kdeui/knuminput.cpp b/microkde/kdeui/knuminput.cpp
index 335d6f4..da01a20 100644
--- a/microkde/kdeui/knuminput.cpp
+++ b/microkde/kdeui/knuminput.cpp
@@ -1,1095 +1,1098 @@
1// -*- c-basic-offset: 4 -*- 1// -*- c-basic-offset: 4 -*-
2/* 2/*
3 * knuminput.cpp 3 * knuminput.cpp
4 * 4 *
5 * Initial implementation: 5 * Initial implementation:
6 * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca> 6 * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
7 * Rewritten and maintained by: 7 * Rewritten and maintained by:
8 * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org> 8 * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org>
9 * KDoubleSpinBox: 9 * KDoubleSpinBox:
10 * Copyright (c) 2002 Marc Mutz <mutz@kde.org> 10 * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
11 * 11 *
12 * Requires the Qt widget libraries, available at no cost at 12 * Requires the Qt widget libraries, available at no cost at
13 * http://www.troll.no/ 13 * http://www.troll.no/
14 * 14 *
15 * This library is free software; you can redistribute it and/or 15 * This library is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Library General Public 16 * modify it under the terms of the GNU Library General Public
17 * License as published by the Free Software Foundation; either 17 * License as published by the Free Software Foundation; either
18 * version 2 of the License, or (at your option) any later version. 18 * version 2 of the License, or (at your option) any later version.
19 * 19 *
20 * This library is distributed in the hope that it will be useful, 20 * This library is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of 21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Library General Public License for more details. 23 * Library General Public License for more details.
24 * 24 *
25 * You should have received a copy of the GNU Library General Public License 25 * You should have received a copy of the GNU Library General Public License
26 * along with this library; see the file COPYING.LIB. If not, write to 26 * along with this library; see the file COPYING.LIB. If not, write to
27 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 27 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
28 * Boston, MA 02111-1307, USA. 28 * Boston, MA 02111-1307, USA.
29 */ 29 */
30 30
31//US #include <config.h> 31//US #include <config.h>
32#ifdef HAVE_LIMITS_H 32#ifdef HAVE_LIMITS_H
33#include <limits.h> 33#include <limits.h>
34#endif 34#endif
35#include <assert.h> 35#include <assert.h>
36#include <math.h> 36#include <math.h>
37#include <algorithm> 37#include <algorithm>
38 38
39#include <qlabel.h> 39#include <qlabel.h>
40#include <qlineedit.h> 40#include <qlineedit.h>
41#include <qsize.h> 41#include <qsize.h>
42#include <qslider.h> 42#include <qslider.h>
43#include <qspinbox.h> 43#include <qspinbox.h>
44#include <qstyle.h> 44#include <qstyle.h>
45//Added by qt3to4:
46#include <QResizeEvent>
47#include <QEvent>
45 48
46#include <kglobal.h> 49#include <kglobal.h>
47#include <klocale.h> 50#include <klocale.h>
48#include <kdebug.h> 51#include <kdebug.h>
49 52
50#include "knumvalidator.h" 53#include "knumvalidator.h"
51#include "knuminput.h" 54#include "knuminput.h"
52 55
53static inline int calcDiffByTen( int x, int y ) { 56static inline int calcDiffByTen( int x, int y ) {
54 // calculate ( x - y ) / 10 without overflowing ints: 57 // calculate ( x - y ) / 10 without overflowing ints:
55 return ( x / 10 ) - ( y / 10 ) + ( x % 10 - y % 10 ) / 10; 58 return ( x / 10 ) - ( y / 10 ) + ( x % 10 - y % 10 ) / 10;
56} 59}
57 60
58// ---------------------------------------------------------------------------- 61// ----------------------------------------------------------------------------
59 62
60KNumInput::KNumInput(QWidget* parent, const char* name) 63KNumInput::KNumInput(QWidget* parent, const char* name)
61 : QWidget(parent, name) 64 : QWidget(parent, name)
62{ 65{
63 init(); 66 init();
64} 67}
65 68
66KNumInput::KNumInput(KNumInput* below, QWidget* parent, const char* name) 69KNumInput::KNumInput(KNumInput* below, QWidget* parent, const char* name)
67 : QWidget(parent, name) 70 : QWidget(parent, name)
68{ 71{
69 init(); 72 init();
70 73
71 if(below) { 74 if(below) {
72 m_next = below->m_next; 75 m_next = below->m_next;
73 m_prev = below; 76 m_prev = below;
74 below->m_next = this; 77 below->m_next = this;
75 if(m_next) 78 if(m_next)
76 m_next->m_prev = this; 79 m_next->m_prev = this;
77 } 80 }
78} 81}
79 82
80void KNumInput::init() 83void KNumInput::init()
81{ 84{
82 m_prev = m_next = 0; 85 m_prev = m_next = 0;
83 m_colw1 = m_colw2 = 0; 86 m_colw1 = m_colw2 = 0;
84 87
85 m_label = 0; 88 m_label = 0;
86 m_slider = 0; 89 m_slider = 0;
87 m_alignment = 0; 90 m_alignment = 0;
88} 91}
89 92
90KNumInput::~KNumInput() 93KNumInput::~KNumInput()
91{ 94{
92 if(m_prev) 95 if(m_prev)
93 m_prev->m_next = m_next; 96 m_prev->m_next = m_next;
94 97
95 if(m_next) 98 if(m_next)
96 m_next->m_prev = m_prev; 99 m_next->m_prev = m_prev;
97} 100}
98 101
99void KNumInput::setLabel(const QString & label, int a) 102void KNumInput::setLabel(const QString & label, int a)
100{ 103{
101 if(label.isEmpty()) { 104 if(label.isEmpty()) {
102 delete m_label; 105 delete m_label;
103 m_label = 0; 106 m_label = 0;
104 m_alignment = 0; 107 m_alignment = 0;
105 } 108 }
106 else { 109 else {
107 if (m_label) m_label->setText(label); 110 if (m_label) m_label->setText(label);
108 else m_label = new QLabel(label, this, "KNumInput::QLabel"); 111 else m_label = new QLabel(label, this, "KNumInput::QLabel");
109 m_label->setAlignment((a & (~(AlignTop|AlignBottom|AlignVCenter))) 112 m_label->setAlignment((a & (~(Qt::AlignTop|Qt::AlignBottom|Qt::AlignVCenter)))
110 | AlignVCenter); 113 | Qt::AlignVCenter);
111 // if no vertical alignment set, use Top alignment 114 // if no vertical alignment set, use Top alignment
112 if(!(a & (AlignTop|AlignBottom|AlignVCenter))) 115 if(!(a & (Qt::AlignTop|Qt::AlignBottom|Qt::AlignVCenter)))
113 a |= AlignTop; 116 a |= Qt::AlignTop;
114 m_alignment = a; 117 m_alignment = a;
115 } 118 }
116 119
117 layout(true); 120 layout(true);
118} 121}
119 122
120QString KNumInput::label() const 123QString KNumInput::label() const
121{ 124{
122 if (m_label) return m_label->text(); 125 if (m_label) return m_label->text();
123 return QString::null; 126 return QString::null;
124} 127}
125 128
126void KNumInput::layout(bool deep) 129void KNumInput::layout(bool deep)
127{ 130{
128 int w1 = m_colw1; 131 int w1 = m_colw1;
129 int w2 = m_colw2; 132 int w2 = m_colw2;
130 133
131 // label sizeHint 134 // label sizeHint
132 m_sizeLabel = (m_label ? m_label->sizeHint() : QSize(0,0)); 135 m_sizeLabel = (m_label ? m_label->sizeHint() : QSize(0,0));
133 136
134 if(m_label && (m_alignment & AlignVCenter)) 137 if(m_label && (m_alignment & Qt::AlignVCenter))
135 m_colw1 = m_sizeLabel.width() + 4; 138 m_colw1 = m_sizeLabel.width() + 4;
136 else 139 else
137 m_colw1 = 0; 140 m_colw1 = 0;
138 141
139 // slider sizeHint 142 // slider sizeHint
140 m_sizeSlider = (m_slider ? m_slider->sizeHint() : QSize(0, 0)); 143 m_sizeSlider = (m_slider ? m_slider->sizeHint() : QSize(0, 0));
141 144
142 doLayout(); 145 doLayout();
143 146
144 if(!deep) { 147 if(!deep) {
145 m_colw1 = w1; 148 m_colw1 = w1;
146 m_colw2 = w2; 149 m_colw2 = w2;
147 return; 150 return;
148 } 151 }
149 152
150 KNumInput* p = this; 153 KNumInput* p = this;
151 while(p) { 154 while(p) {
152 p->doLayout(); 155 p->doLayout();
153 w1 = QMAX(w1, p->m_colw1); 156 w1 = QMAX(w1, p->m_colw1);
154 w2 = QMAX(w2, p->m_colw2); 157 w2 = QMAX(w2, p->m_colw2);
155 p = p->m_prev; 158 p = p->m_prev;
156 } 159 }
157 160
158 p = m_next; 161 p = m_next;
159 while(p) { 162 while(p) {
160 p->doLayout(); 163 p->doLayout();
161 w1 = QMAX(w1, p->m_colw1); 164 w1 = QMAX(w1, p->m_colw1);
162 w2 = QMAX(w2, p->m_colw2); 165 w2 = QMAX(w2, p->m_colw2);
163 p = p->m_next; 166 p = p->m_next;
164 } 167 }
165 168
166 p = this; 169 p = this;
167 while(p) { 170 while(p) {
168 p->m_colw1 = w1; 171 p->m_colw1 = w1;
169 p->m_colw2 = w2; 172 p->m_colw2 = w2;
170 p = p->m_prev; 173 p = p->m_prev;
171 } 174 }
172 175
173 p = m_next; 176 p = m_next;
174 while(p) { 177 while(p) {
175 p->m_colw1 = w1; 178 p->m_colw1 = w1;
176 p->m_colw2 = w2; 179 p->m_colw2 = w2;
177 p = p->m_next; 180 p = p->m_next;
178 } 181 }
179 182
180// kdDebug() << "w1 " << w1 << " w2 " << w2 << endl; 183// kdDebug() << "w1 " << w1 << " w2 " << w2 << endl;
181} 184}
182 185
183QSizePolicy KNumInput::sizePolicy() const 186QSizePolicy KNumInput::sizePolicy() const
184{ 187{
185 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); 188 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
186} 189}
187 190
188QSize KNumInput::sizeHint() const 191QSize KNumInput::sizeHint() const
189{ 192{
190 return minimumSizeHint(); 193 return minimumSizeHint();
191} 194}
192 195
193void KNumInput::setSteps(int minor, int major) 196void KNumInput::setSteps(int minor, int major)
194{ 197{
195 if(m_slider) 198 if(m_slider)
196 m_slider->setSteps( minor, major ); 199 m_slider->setSteps( minor, major );
197} 200}
198 201
199 202
200// ---------------------------------------------------------------------------- 203// ----------------------------------------------------------------------------
201 204
202KIntSpinBox::KIntSpinBox(QWidget *parent, const char *name) 205KIntSpinBox::KIntSpinBox(QWidget *parent, const char *name)
203 : QSpinBox(0, 99, 1, parent, name) 206 : QSpinBox(0, 99, 1, parent, name)
204{ 207{
205 editor()->setAlignment(AlignRight); 208 setAlignment(Qt::AlignRight);
206 val_base = 10; 209 val_base = 10;
207 setValue(0); 210 setValue(0);
208} 211}
209 212
210KIntSpinBox::~KIntSpinBox() 213KIntSpinBox::~KIntSpinBox()
211{ 214{
212} 215}
213 216
214KIntSpinBox::KIntSpinBox(int lower, int upper, int step, int value, int base, 217KIntSpinBox::KIntSpinBox(int lower, int upper, int step, int value, int base,
215 QWidget* parent, const char* name) 218 QWidget* parent, const char* name)
216 : QSpinBox(lower, upper, step, parent, name) 219 : QSpinBox(lower, upper, step, parent, name)
217{ 220{
218 editor()->setAlignment(AlignRight); 221 setAlignment(Qt::AlignRight);
219 val_base = base; 222 val_base = base;
220 setValue(value); 223 setValue(value);
221} 224}
222 225
223void KIntSpinBox::setBase(int base) 226void KIntSpinBox::setBase(int base)
224{ 227{
225 val_base = base; 228 val_base = base;
226} 229}
227 230
228 231
229int KIntSpinBox::base() const 232int KIntSpinBox::base() const
230{ 233{
231 return val_base; 234 return val_base;
232} 235}
233 236
234QString KIntSpinBox::mapValueToText(int v) 237QString KIntSpinBox::mapValueToText(int v)
235{ 238{
236 return QString::number(v, val_base); 239 return QString::number(v, val_base);
237} 240}
238 241
239int KIntSpinBox::mapTextToValue(bool* ok) 242int KIntSpinBox::mapTextToValue(bool* ok)
240{ 243{
241 return cleanText().toInt(ok, val_base); 244 return cleanText().toInt(ok, val_base);
242} 245}
243 246
244void KIntSpinBox::setEditFocus(bool mark) 247void KIntSpinBox::setEditFocus(bool mark)
245{ 248{
246 editor()->setFocus(); 249 setFocus();
247 if(mark) 250 if(mark)
248 editor()->selectAll(); 251 selectAll();
249} 252}
250 253
251 254
252// ---------------------------------------------------------------------------- 255// ----------------------------------------------------------------------------
253 256
254class KIntNumInput::KIntNumInputPrivate { 257class KIntNumInput::KIntNumInputPrivate {
255public: 258public:
256 int referencePoint; 259 int referencePoint;
257 short blockRelative; 260 short blockRelative;
258 KIntNumInputPrivate( int r ) 261 KIntNumInputPrivate( int r )
259 : referencePoint( r ), 262 : referencePoint( r ),
260 blockRelative( 0 ) {} 263 blockRelative( 0 ) {}
261}; 264};
262 265
263 266
264KIntNumInput::KIntNumInput(KNumInput* below, int val, QWidget* parent, 267KIntNumInput::KIntNumInput(KNumInput* below, int val, QWidget* parent,
265 int _base, const char* name) 268 int _base, const char* name)
266 : KNumInput(below, parent, name) 269 : KNumInput(below, parent, name)
267{ 270{
268 init(val, _base); 271 init(val, _base);
269} 272}
270 273
271KIntNumInput::KIntNumInput(QWidget *parent, const char *name) 274KIntNumInput::KIntNumInput(QWidget *parent, const char *name)
272 : KNumInput(parent, name) 275 : KNumInput(parent, name)
273{ 276{
274 init(0, 10); 277 init(0, 10);
275} 278}
276 279
277KIntNumInput::KIntNumInput(int val, QWidget *parent, int _base, const char *name) 280KIntNumInput::KIntNumInput(int val, QWidget *parent, int _base, const char *name)
278 : KNumInput(parent, name) 281 : KNumInput(parent, name)
279{ 282{
280 init(val, _base); 283 init(val, _base);
281 284
282} 285}
283 286
284void KIntNumInput::init(int val, int _base) 287void KIntNumInput::init(int val, int _base)
285{ 288{
286 d = new KIntNumInputPrivate( val ); 289 d = new KIntNumInputPrivate( val );
287 m_spin = new KIntSpinBox(INT_MIN, INT_MAX, 1, val, _base, this, "KIntNumInput::KIntSpinBox"); 290 m_spin = new KIntSpinBox(INT_MIN, INT_MAX, 1, val, _base, this, "KIntNumInput::KIntSpinBox");
288 m_spin->setValidator(new KIntValidator(this, _base, "KNumInput::KIntValidtr")); 291 m_spin->setValidator(new KIntValidator(this, _base, "KNumInput::KIntValidtr"));
289 connect(m_spin, SIGNAL(valueChanged(int)), SLOT(spinValueChanged(int))); 292 connect(m_spin, SIGNAL(valueChanged(int)), SLOT(spinValueChanged(int)));
290 connect(this, SIGNAL(valueChanged(int)), 293 connect(this, SIGNAL(valueChanged(int)),
291 SLOT(slotEmitRelativeValueChanged(int))); 294 SLOT(slotEmitRelativeValueChanged(int)));
292 295
293 setFocusProxy(m_spin); 296 setFocusProxy(m_spin);
294 layout(true); 297 layout(true);
295} 298}
296 299
297void KIntNumInput::setReferencePoint( int ref ) { 300void KIntNumInput::setReferencePoint( int ref ) {
298 // clip to valid range: 301 // clip to valid range:
299 ref = kMin( maxValue(), kMax( minValue(), ref ) ); 302 ref = kMin( maxValue(), kMax( minValue(), ref ) );
300 d->referencePoint = ref; 303 d->referencePoint = ref;
301} 304}
302 305
303int KIntNumInput::referencePoint() const { 306int KIntNumInput::referencePoint() const {
304 return d->referencePoint; 307 return d->referencePoint;
305} 308}
306 309
307void KIntNumInput::spinValueChanged(int val) 310void KIntNumInput::spinValueChanged(int val)
308{ 311{
309 if(m_slider) 312 if(m_slider)
310 m_slider->setValue(val); 313 m_slider->setValue(val);
311 314
312 emit valueChanged(val); 315 emit valueChanged(val);
313} 316}
314 317
315void KIntNumInput::slotEmitRelativeValueChanged( int value ) { 318void KIntNumInput::slotEmitRelativeValueChanged( int value ) {
316 if ( d->blockRelative || !d->referencePoint ) return; 319 if ( d->blockRelative || !d->referencePoint ) return;
317 emit relativeValueChanged( double( value ) / double( d->referencePoint ) ); 320 emit relativeValueChanged( double( value ) / double( d->referencePoint ) );
318} 321}
319 322
320void KIntNumInput::setRange(int lower, int upper, int step, bool slider) 323void KIntNumInput::setRange(int lower, int upper, int step, bool slider)
321{ 324{
322 upper = kMax(upper, lower); 325 upper = kMax(upper, lower);
323 lower = kMin(upper, lower); 326 lower = kMin(upper, lower);
324 m_spin->setMinValue(lower); 327 m_spin->setMinValue(lower);
325 m_spin->setMaxValue(upper); 328 m_spin->setMaxValue(upper);
326 m_spin->setLineStep(step); 329 m_spin->setLineStep(step);
327 330
328 step = m_spin->lineStep(); // maybe QRangeControl didn't like out lineStep? 331 step = m_spin->singleStep(); // maybe QRangeControl didn't like out lineStep?
329 332
330 if(slider) { 333 if(slider) {
331 if (m_slider) 334 if (m_slider)
332 m_slider->setRange(lower, upper); 335 m_slider->setRange(lower, upper);
333 else { 336 else {
334 m_slider = new QSlider(lower, upper, step, m_spin->value(), 337 m_slider = new QSlider(lower, upper, step, m_spin->value(),
335 QSlider::Horizontal, this); 338 Qt::Horizontal, this);
336 m_slider->setTickmarks(QSlider::Below); 339 m_slider->setTickmarks(QSlider::Below);
337 connect(m_slider, SIGNAL(valueChanged(int)), 340 connect(m_slider, SIGNAL(valueChanged(int)),
338 m_spin, SLOT(setValue(int))); 341 m_spin, SLOT(setValue(int)));
339 } 342 }
340 343
341 // calculate (upper-lower)/10 without overflowing int's: 344 // calculate (upper-lower)/10 without overflowing int's:
342 int major = calcDiffByTen( upper, lower ); 345 int major = calcDiffByTen( upper, lower );
343 if ( major==0 ) major = step; // #### workaround Qt bug in 2.1-beta4 346 if ( major==0 ) major = step; // #### workaround Qt bug in 2.1-beta4
344 347
345 m_slider->setSteps(step, major); 348 m_slider->setSteps(step, major);
346 m_slider->setTickInterval(major); 349 m_slider->setTickInterval(major);
347 } 350 }
348 else { 351 else {
349 delete m_slider; 352 delete m_slider;
350 m_slider = 0; 353 m_slider = 0;
351 } 354 }
352 355
353 // check that reference point is still inside valid range: 356 // check that reference point is still inside valid range:
354 setReferencePoint( referencePoint() ); 357 setReferencePoint( referencePoint() );
355 358
356 layout(true); 359 layout(true);
357} 360}
358 361
359void KIntNumInput::setMinValue(int min) 362void KIntNumInput::setMinValue(int min)
360{ 363{
361 setRange(min, m_spin->maxValue(), m_spin->lineStep(), m_slider); 364 setRange(min, m_spin->maxValue(), m_spin->singleStep(), m_slider);
362} 365}
363 366
364int KIntNumInput::minValue() const 367int KIntNumInput::minValue() const
365{ 368{
366 return m_spin->minValue(); 369 return m_spin->minValue();
367} 370}
368 371
369void KIntNumInput::setMaxValue(int max) 372void KIntNumInput::setMaxValue(int max)
370{ 373{
371 setRange(m_spin->minValue(), max, m_spin->lineStep(), m_slider); 374 setRange(m_spin->minValue(), max, m_spin->singleStep(), m_slider);
372} 375}
373 376
374int KIntNumInput::maxValue() const 377int KIntNumInput::maxValue() const
375{ 378{
376 return m_spin->maxValue(); 379 return m_spin->maxValue();
377} 380}
378 381
379void KIntNumInput::setSuffix(const QString &suffix) 382void KIntNumInput::setSuffix(const QString &suffix)
380{ 383{
381 m_spin->setSuffix(suffix); 384 m_spin->setSuffix(suffix);
382 385
383 layout(true); 386 layout(true);
384} 387}
385 388
386QString KIntNumInput::suffix() const 389QString KIntNumInput::suffix() const
387{ 390{
388 return m_spin->suffix(); 391 return m_spin->suffix();
389} 392}
390 393
391void KIntNumInput::setPrefix(const QString &prefix) 394void KIntNumInput::setPrefix(const QString &prefix)
392{ 395{
393 m_spin->setPrefix(prefix); 396 m_spin->setPrefix(prefix);
394 397
395 layout(true); 398 layout(true);
396} 399}
397 400
398QString KIntNumInput::prefix() const 401QString KIntNumInput::prefix() const
399{ 402{
400 return m_spin->prefix(); 403 return m_spin->prefix();
401} 404}
402 405
403void KIntNumInput::setEditFocus(bool mark) 406void KIntNumInput::setEditFocus(bool mark)
404{ 407{
405 m_spin->setEditFocus(mark); 408 m_spin->setEditFocus(mark);
406} 409}
407 410
408QSize KIntNumInput::minimumSizeHint() const 411QSize KIntNumInput::minimumSizeHint() const
409{ 412{
410 constPolish(); 413 constPolish();
411 414
412 int w; 415 int w;
413 int h; 416 int h;
414 417
415 h = 2 + QMAX(m_sizeSpin.height(), m_sizeSlider.height()); 418 h = 2 + QMAX(m_sizeSpin.height(), m_sizeSlider.height());
416 419
417 // if in extra row, then count it here 420 // if in extra row, then count it here
418 if(m_label && (m_alignment & (AlignBottom|AlignTop))) 421 if(m_label && (m_alignment & (Qt::AlignBottom|Qt::AlignTop)))
419 h += 4 + m_sizeLabel.height(); 422 h += 4 + m_sizeLabel.height();
420 else 423 else
421 // label is in the same row as the other widgets 424 // label is in the same row as the other widgets
422 h = QMAX(h, m_sizeLabel.height() + 2); 425 h = QMAX(h, m_sizeLabel.height() + 2);
423 426
424 w = m_slider ? m_slider->sizeHint().width() + 8 : 0; 427 w = m_slider ? m_slider->sizeHint().width() + 8 : 0;
425 w += m_colw1 + m_colw2; 428 w += m_colw1 + m_colw2;
426 429
427 if(m_alignment & (AlignTop|AlignBottom)) 430 if(m_alignment & (Qt::AlignTop|Qt::AlignBottom))
428 w = QMAX(w, m_sizeLabel.width() + 4); 431 w = QMAX(w, m_sizeLabel.width() + 4);
429 432
430 return QSize(w, h); 433 return QSize(w, h);
431} 434}
432 435
433void KIntNumInput::doLayout() 436void KIntNumInput::doLayout()
434{ 437{
435 m_sizeSpin = m_spin->sizeHint(); 438 m_sizeSpin = m_spin->sizeHint();
436 m_colw2 = m_sizeSpin.width(); 439 m_colw2 = m_sizeSpin.width();
437 440
438 if (m_label) 441 if (m_label)
439 m_label->setBuddy(m_spin); 442 m_label->setBuddy(m_spin);
440} 443}
441 444
442void KIntNumInput::resizeEvent(QResizeEvent* e) 445void KIntNumInput::resizeEvent(QResizeEvent* e)
443{ 446{
444 int w = m_colw1; 447 int w = m_colw1;
445 int h = 0; 448 int h = 0;
446 449
447 if(m_label && (m_alignment & AlignTop)) { 450 if(m_label && (m_alignment & Qt::AlignTop)) {
448 m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height()); 451 m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height());
449 h += m_sizeLabel.height() + 4; 452 h += m_sizeLabel.height() + 4;
450 } 453 }
451 454
452 if(m_label && (m_alignment & AlignVCenter)) 455 if(m_label && (m_alignment & Qt::AlignVCenter))
453 m_label->setGeometry(0, 0, w, m_sizeSpin.height()); 456 m_label->setGeometry(0, 0, w, m_sizeSpin.height());
454 457
455 m_spin->setGeometry(w, h, m_slider ? m_colw2 : QMAX(m_colw2, e->size().width() - w), m_sizeSpin.height()); 458 m_spin->setGeometry(w, h, m_slider ? m_colw2 : QMAX(m_colw2, e->size().width() - w), m_sizeSpin.height());
456 w += m_colw2 + 8; 459 w += m_colw2 + 8;
457 460
458 if(m_slider) 461 if(m_slider)
459 m_slider->setGeometry(w, h, e->size().width() - w, m_sizeSpin.height()); 462 m_slider->setGeometry(w, h, e->size().width() - w, m_sizeSpin.height());
460 463
461 h += m_sizeSpin.height() + 2; 464 h += m_sizeSpin.height() + 2;
462 465
463 if(m_label && (m_alignment & AlignBottom)) 466 if(m_label && (m_alignment & Qt::AlignBottom))
464 m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height()); 467 m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height());
465} 468}
466 469
467KIntNumInput::~KIntNumInput() 470KIntNumInput::~KIntNumInput()
468{ 471{
469 delete d; 472 delete d;
470} 473}
471 474
472void KIntNumInput::setValue(int val) 475void KIntNumInput::setValue(int val)
473{ 476{
474 m_spin->setValue(val); 477 m_spin->setValue(val);
475 // slider value is changed by spinValueChanged 478 // slider value is changed by spinValueChanged
476} 479}
477 480
478void KIntNumInput::setRelativeValue( double r ) { 481void KIntNumInput::setRelativeValue( double r ) {
479 if ( !d->referencePoint ) return; 482 if ( !d->referencePoint ) return;
480 ++d->blockRelative; 483 ++d->blockRelative;
481 setValue( int( d->referencePoint * r + 0.5 ) ); 484 setValue( int( d->referencePoint * r + 0.5 ) );
482 --d->blockRelative; 485 --d->blockRelative;
483} 486}
484 487
485double KIntNumInput::relativeValue() const { 488double KIntNumInput::relativeValue() const {
486 if ( !d->referencePoint ) return 0; 489 if ( !d->referencePoint ) return 0;
487 return double( value() ) / double ( d->referencePoint ); 490 return double( value() ) / double ( d->referencePoint );
488} 491}
489 492
490int KIntNumInput::value() const 493int KIntNumInput::value() const
491{ 494{
492 return m_spin->value(); 495 return m_spin->value();
493} 496}
494 497
495void KIntNumInput::setSpecialValueText(const QString& text) 498void KIntNumInput::setSpecialValueText(const QString& text)
496{ 499{
497 m_spin->setSpecialValueText(text); 500 m_spin->setSpecialValueText(text);
498 layout(true); 501 layout(true);
499} 502}
500 503
501QString KIntNumInput::specialValueText() const 504QString KIntNumInput::specialValueText() const
502{ 505{
503 return m_spin->specialValueText(); 506 return m_spin->specialValueText();
504} 507}
505 508
506void KIntNumInput::setLabel(const QString & label, int a) 509void KIntNumInput::setLabel(const QString & label, int a)
507{ 510{
508 KNumInput::setLabel(label, a); 511 KNumInput::setLabel(label, a);
509 512
510 if(m_label) 513 if(m_label)
511 m_label->setBuddy(m_spin); 514 m_label->setBuddy(m_spin);
512} 515}
513 516
514// ---------------------------------------------------------------------------- 517// ----------------------------------------------------------------------------
515 518
516class KDoubleNumInput::KDoubleNumInputPrivate { 519class KDoubleNumInput::KDoubleNumInputPrivate {
517public: 520public:
518 KDoubleNumInputPrivate( double r ) 521 KDoubleNumInputPrivate( double r )
519 : spin( 0 ), 522 : spin( 0 ),
520 referencePoint( r ), 523 referencePoint( r ),
521 blockRelative ( 0 ) {} 524 blockRelative ( 0 ) {}
522 KDoubleSpinBox * spin; 525 KDoubleSpinBox * spin;
523 double referencePoint; 526 double referencePoint;
524 short blockRelative; 527 short blockRelative;
525}; 528};
526 529
527KDoubleNumInput::KDoubleNumInput(QWidget *parent, const char *name) 530KDoubleNumInput::KDoubleNumInput(QWidget *parent, const char *name)
528 : KNumInput(parent, name) 531 : KNumInput(parent, name)
529{ 532{
530 init(0.0, 0.0, 9999.0, 0.01, 2); 533 init(0.0, 0.0, 9999.0, 0.01, 2);
531} 534}
532 535
533KDoubleNumInput::KDoubleNumInput(double lower, double upper, double value, 536KDoubleNumInput::KDoubleNumInput(double lower, double upper, double value,
534 double step, int precision, QWidget* parent, 537 double step, int precision, QWidget* parent,
535 const char *name) 538 const char *name)
536 : KNumInput(parent, name) 539 : KNumInput(parent, name)
537{ 540{
538 init(value, lower, upper, step, precision); 541 init(value, lower, upper, step, precision);
539} 542}
540 543
541KDoubleNumInput::KDoubleNumInput(KNumInput *below, 544KDoubleNumInput::KDoubleNumInput(KNumInput *below,
542 double lower, double upper, double value, 545 double lower, double upper, double value,
543 double step, int precision, QWidget* parent, 546 double step, int precision, QWidget* parent,
544 const char *name) 547 const char *name)
545 : KNumInput(below, parent, name) 548 : KNumInput(below, parent, name)
546{ 549{
547 init(value, lower, upper, step, precision); 550 init(value, lower, upper, step, precision);
548} 551}
549 552
550KDoubleNumInput::KDoubleNumInput(double value, QWidget *parent, const char *name) 553KDoubleNumInput::KDoubleNumInput(double value, QWidget *parent, const char *name)
551 : KNumInput(parent, name) 554 : KNumInput(parent, name)
552{ 555{
553 init(value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 ); 556 init(value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 );
554} 557}
555 558
556KDoubleNumInput::KDoubleNumInput(KNumInput* below, double value, QWidget* parent, 559KDoubleNumInput::KDoubleNumInput(KNumInput* below, double value, QWidget* parent,
557 const char* name) 560 const char* name)
558 : KNumInput(below, parent, name) 561 : KNumInput(below, parent, name)
559{ 562{
560 init( value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 ); 563 init( value, kMin(0.0, value), kMax(0.0, value), 0.01, 2 );
561} 564}
562 565
563KDoubleNumInput::~KDoubleNumInput() 566KDoubleNumInput::~KDoubleNumInput()
564{ 567{
565 delete d; 568 delete d;
566} 569}
567 570
568// ### remove when BIC changes are allowed again: 571// ### remove when BIC changes are allowed again:
569 572
570bool KDoubleNumInput::eventFilter( QObject * o, QEvent * e ) { 573bool KDoubleNumInput::eventFilter( QObject * o, QEvent * e ) {
571 return KNumInput::eventFilter( o, e ); 574 return KNumInput::eventFilter( o, e );
572} 575}
573 576
574void KDoubleNumInput::resetEditBox() { 577void KDoubleNumInput::resetEditBox() {
575 578
576} 579}
577 580
578// ### end stuff to remove when BIC changes are allowed again 581// ### end stuff to remove when BIC changes are allowed again
579 582
580 583
581 584
582void KDoubleNumInput::init(double value, double lower, double upper, 585void KDoubleNumInput::init(double value, double lower, double upper,
583 double step, int precision ) 586 double step, int precision )
584{ 587{
585 // ### init no longer used members: 588 // ### init no longer used members:
586 edit = 0; 589 edit = 0;
587 m_range = true; 590 m_range = true;
588 m_value = 0.0; 591 m_value = 0.0;
589 m_precision = 2; 592 m_precision = 2;
590 // ### end 593 // ### end
591 594
592 d = new KDoubleNumInputPrivate( value ); 595 d = new KDoubleNumInputPrivate( value );
593 596
594 d->spin = new KDoubleSpinBox( lower, upper, step, value, precision, 597 d->spin = new KDoubleSpinBox( lower, upper, step, value, precision,
595 this, "KDoubleNumInput::d->spin" ); 598 this, "KDoubleNumInput::d->spin" );
596 setFocusProxy(d->spin); 599 setFocusProxy(d->spin);
597 connect( d->spin, SIGNAL(valueChanged(double)), 600 connect( d->spin, SIGNAL(valueChanged(double)),
598 this, SIGNAL(valueChanged(double)) ); 601 this, SIGNAL(valueChanged(double)) );
599 connect( this, SIGNAL(valueChanged(double)), 602 connect( this, SIGNAL(valueChanged(double)),
600 this, SLOT(slotEmitRelativeValueChanged(double)) ); 603 this, SLOT(slotEmitRelativeValueChanged(double)) );
601 604
602 updateLegacyMembers(); 605 updateLegacyMembers();
603 606
604 layout(true); 607 layout(true);
605} 608}
606 609
607void KDoubleNumInput::updateLegacyMembers() { 610void KDoubleNumInput::updateLegacyMembers() {
608 // ### update legacy members that are either not private or for 611 // ### update legacy members that are either not private or for
609 // which an inlined getter exists: 612 // which an inlined getter exists:
610 m_lower = minValue(); 613 m_lower = minValue();
611 m_upper = maxValue(); 614 m_upper = maxValue();
612 m_step = d->spin->lineStep(); 615 m_step = d->spin->lineStep();
613 m_specialvalue = specialValueText(); 616 m_specialvalue = specialValueText();
614} 617}
615 618
616 619
617double KDoubleNumInput::mapSliderToSpin( int val ) const 620double KDoubleNumInput::mapSliderToSpin( int val ) const
618{ 621{
619 // map [slidemin,slidemax] to [spinmin,spinmax] 622 // map [slidemin,slidemax] to [spinmin,spinmax]
620 double spinmin = d->spin->minValue(); 623 double spinmin = d->spin->minValue();
621 double spinmax = d->spin->maxValue(); 624 double spinmax = d->spin->maxValue();
622 double slidemin = m_slider->minValue(); // cast int to double to avoid 625 double slidemin = m_slider->minValue(); // cast int to double to avoid
623 double slidemax = m_slider->maxValue(); // overflow in rel denominator 626 double slidemax = m_slider->maxValue(); // overflow in rel denominator
624 double rel = ( double(val) - slidemin ) / ( slidemax - slidemin ); 627 double rel = ( double(val) - slidemin ) / ( slidemax - slidemin );
625 return spinmin + rel * ( spinmax - spinmin ); 628 return spinmin + rel * ( spinmax - spinmin );
626} 629}
627 630
628void KDoubleNumInput::sliderMoved(int val) 631void KDoubleNumInput::sliderMoved(int val)
629{ 632{
630 d->spin->setValue( mapSliderToSpin( val ) ); 633 d->spin->setValue( mapSliderToSpin( val ) );
631} 634}
632 635
633void KDoubleNumInput::slotEmitRelativeValueChanged( double value ) 636void KDoubleNumInput::slotEmitRelativeValueChanged( double value )
634{ 637{
635 if ( !d->referencePoint ) return; 638 if ( !d->referencePoint ) return;
636 emit relativeValueChanged( value / d->referencePoint ); 639 emit relativeValueChanged( value / d->referencePoint );
637} 640}
638 641
639QSize KDoubleNumInput::minimumSizeHint() const 642QSize KDoubleNumInput::minimumSizeHint() const
640{ 643{
641 constPolish(); 644 constPolish();
642 645
643 int w; 646 int w;
644 int h; 647 int h;
645 648
646 h = 2 + QMAX(m_sizeEdit.height(), m_sizeSlider.height()); 649 h = 2 + QMAX(m_sizeEdit.height(), m_sizeSlider.height());
647 650
648 // if in extra row, then count it here 651 // if in extra row, then count it here
649 if(m_label && (m_alignment & (AlignBottom|AlignTop))) 652 if(m_label && (m_alignment & (Qt::AlignBottom|Qt::AlignTop)))
650 h += 4 + m_sizeLabel.height(); 653 h += 4 + m_sizeLabel.height();
651 else 654 else
652 // label is in the same row as the other widgets 655 // label is in the same row as the other widgets
653 h = QMAX(h, m_sizeLabel.height() + 2); 656 h = QMAX(h, m_sizeLabel.height() + 2);
654 657
655 w = m_slider ? m_slider->sizeHint().width() + 8 : 0; 658 w = m_slider ? m_slider->sizeHint().width() + 8 : 0;
656 w += m_colw1 + m_colw2; 659 w += m_colw1 + m_colw2;
657 660
658 if(m_alignment & (AlignTop|AlignBottom)) 661 if(m_alignment & (Qt::AlignTop|Qt::AlignBottom))
659 w = QMAX(w, m_sizeLabel.width() + 4); 662 w = QMAX(w, m_sizeLabel.width() + 4);
660 663
661 return QSize(w, h); 664 return QSize(w, h);
662} 665}
663 666
664void KDoubleNumInput::resizeEvent(QResizeEvent* e) 667void KDoubleNumInput::resizeEvent(QResizeEvent* e)
665{ 668{
666 int w = m_colw1; 669 int w = m_colw1;
667 int h = 0; 670 int h = 0;
668 671
669 if(m_label && (m_alignment & AlignTop)) { 672 if(m_label && (m_alignment & Qt::AlignTop)) {
670 m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height()); 673 m_label->setGeometry(0, 0, e->size().width(), m_sizeLabel.height());
671 h += m_sizeLabel.height() + 4; 674 h += m_sizeLabel.height() + 4;
672 } 675 }
673 676
674 if(m_label && (m_alignment & AlignVCenter)) 677 if(m_label && (m_alignment & Qt::AlignVCenter))
675 m_label->setGeometry(0, 0, w, m_sizeEdit.height()); 678 m_label->setGeometry(0, 0, w, m_sizeEdit.height());
676 679
677 d->spin->setGeometry(w, h, m_slider ? m_colw2 680 d->spin->setGeometry(w, h, m_slider ? m_colw2
678 : e->size().width() - w, m_sizeEdit.height()); 681 : e->size().width() - w, m_sizeEdit.height());
679 w += m_colw2 + 8; 682 w += m_colw2 + 8;
680 683
681 if(m_slider) 684 if(m_slider)
682 m_slider->setGeometry(w, h, e->size().width() - w, m_sizeEdit.height()); 685 m_slider->setGeometry(w, h, e->size().width() - w, m_sizeEdit.height());
683 686
684 h += m_sizeEdit.height() + 2; 687 h += m_sizeEdit.height() + 2;
685 688
686 if(m_label && (m_alignment & AlignBottom)) 689 if(m_label && (m_alignment & Qt::AlignBottom))
687 m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height()); 690 m_label->setGeometry(0, h, m_sizeLabel.width(), m_sizeLabel.height());
688} 691}
689 692
690void KDoubleNumInput::doLayout() 693void KDoubleNumInput::doLayout()
691{ 694{
692 m_sizeEdit = d->spin->sizeHint(); 695 m_sizeEdit = d->spin->sizeHint();
693 m_colw2 = m_sizeEdit.width(); 696 m_colw2 = m_sizeEdit.width();
694} 697}
695 698
696void KDoubleNumInput::setValue(double val) 699void KDoubleNumInput::setValue(double val)
697{ 700{
698 d->spin->setValue( val ); 701 d->spin->setValue( val );
699} 702}
700 703
701void KDoubleNumInput::setRelativeValue( double r ) 704void KDoubleNumInput::setRelativeValue( double r )
702{ 705{
703 if ( !d->referencePoint ) return; 706 if ( !d->referencePoint ) return;
704 ++d->blockRelative; 707 ++d->blockRelative;
705 setValue( r * d->referencePoint ); 708 setValue( r * d->referencePoint );
706 --d->blockRelative; 709 --d->blockRelative;
707} 710}
708 711
709void KDoubleNumInput::setReferencePoint( double ref ) 712void KDoubleNumInput::setReferencePoint( double ref )
710{ 713{
711 // clip to valid range: 714 // clip to valid range:
712 ref = kMin( maxValue(), kMax( minValue(), ref ) ); 715 ref = kMin( maxValue(), kMax( minValue(), ref ) );
713 d->referencePoint = ref; 716 d->referencePoint = ref;
714} 717}
715 718
716void KDoubleNumInput::setRange(double lower, double upper, double step, 719void KDoubleNumInput::setRange(double lower, double upper, double step,
717 bool slider) 720 bool slider)
718{ 721{
719 if( m_slider ) { 722 if( m_slider ) {
720 // don't update the slider to avoid an endless recursion 723 // don't update the slider to avoid an endless recursion
721 QSpinBox * spin = d->spin; 724 QSpinBox * spin = d->spin;
722 disconnect(spin, SIGNAL(valueChanged(int)), 725 disconnect(spin, SIGNAL(valueChanged(int)),
723 m_slider, SLOT(setValue(int)) ); 726 m_slider, SLOT(setValue(int)) );
724 } 727 }
725 d->spin->setRange( lower, upper, step, d->spin->precision() ); 728 d->spin->setRange( lower, upper, step, d->spin->precision() );
726 729
727 if(slider) { 730 if(slider) {
728 // upcast to base type to get the min/maxValue in int form: 731 // upcast to base type to get the min/maxValue in int form:
729 QSpinBox * spin = d->spin; 732 QSpinBox * spin = d->spin;
730 int slmax = spin->maxValue(); 733 int slmax = spin->maxValue();
731 int slmin = spin->minValue(); 734 int slmin = spin->minValue();
732 int slvalue = spin->value(); 735 int slvalue = spin->value();
733 int slstep = spin->lineStep(); 736 int slstep = spin->singleStep();
734 if (m_slider) { 737 if (m_slider) {
735 m_slider->setRange(slmin, slmax); 738 m_slider->setRange(slmin, slmax);
736 m_slider->setLineStep(slstep); 739 m_slider->setLineStep(slstep);
737 m_slider->setValue(slvalue); 740 m_slider->setValue(slvalue);
738 } else { 741 } else {
739 m_slider = new QSlider(slmin, slmax, slstep, slvalue, 742 m_slider = new QSlider(slmin, slmax, slstep, slvalue,
740 QSlider::Horizontal, this); 743 Qt::Horizontal, this);
741 m_slider->setTickmarks(QSlider::Below); 744 m_slider->setTickmarks(QSlider::Below);
742 // feedback line: when one moves, the other moves, too: 745 // feedback line: when one moves, the other moves, too:
743 connect(m_slider, SIGNAL(valueChanged(int)), 746 connect(m_slider, SIGNAL(valueChanged(int)),
744 SLOT(sliderMoved(int)) ); 747 SLOT(sliderMoved(int)) );
745 } 748 }
746 connect(spin, SIGNAL(valueChanged(int)), 749 connect(spin, SIGNAL(valueChanged(int)),
747 m_slider, SLOT(setValue(int)) ); 750 m_slider, SLOT(setValue(int)) );
748 // calculate ( slmax - slmin ) / 10 without overflowing ints: 751 // calculate ( slmax - slmin ) / 10 without overflowing ints:
749 int major = calcDiffByTen( slmax, slmin ); 752 int major = calcDiffByTen( slmax, slmin );
750 if ( !major ) major = slstep; // ### needed? 753 if ( !major ) major = slstep; // ### needed?
751 m_slider->setTickInterval(major); 754 m_slider->setTickInterval(major);
752 } else { 755 } else {
753 delete m_slider; 756 delete m_slider;
754 m_slider = 0; 757 m_slider = 0;
755 } 758 }
756 759
757 setReferencePoint( referencePoint() ); 760 setReferencePoint( referencePoint() );
758 761
759 layout(true); 762 layout(true);
760 updateLegacyMembers(); 763 updateLegacyMembers();
761} 764}
762 765
763void KDoubleNumInput::setMinValue(double min) 766void KDoubleNumInput::setMinValue(double min)
764{ 767{
765 setRange(min, maxValue(), d->spin->lineStep(), m_slider); 768 setRange(min, maxValue(), d->spin->lineStep(), m_slider);
766} 769}
767 770
768double KDoubleNumInput::minValue() const 771double KDoubleNumInput::minValue() const
769{ 772{
770 return d->spin->minValue(); 773 return d->spin->minValue();
771} 774}
772 775
773void KDoubleNumInput::setMaxValue(double max) 776void KDoubleNumInput::setMaxValue(double max)
774{ 777{
775 setRange(minValue(), max, d->spin->lineStep(), m_slider); 778 setRange(minValue(), max, d->spin->lineStep(), m_slider);
776} 779}
777 780
778double KDoubleNumInput::maxValue() const 781double KDoubleNumInput::maxValue() const
779{ 782{
780 return d->spin->maxValue(); 783 return d->spin->maxValue();
781} 784}
782 785
783double KDoubleNumInput::value() const 786double KDoubleNumInput::value() const
784{ 787{
785 return d->spin->value(); 788 return d->spin->value();
786} 789}
787 790
788double KDoubleNumInput::relativeValue() const 791double KDoubleNumInput::relativeValue() const
789{ 792{
790 if ( !d->referencePoint ) return 0; 793 if ( !d->referencePoint ) return 0;
791 return value() / d->referencePoint; 794 return value() / d->referencePoint;
792} 795}
793 796
794double KDoubleNumInput::referencePoint() const 797double KDoubleNumInput::referencePoint() const
795{ 798{
796 return d->referencePoint; 799 return d->referencePoint;
797} 800}
798 801
799QString KDoubleNumInput::suffix() const 802QString KDoubleNumInput::suffix() const
800{ 803{
801 return d->spin->suffix(); 804 return d->spin->suffix();
802} 805}
803 806
804QString KDoubleNumInput::prefix() const 807QString KDoubleNumInput::prefix() const
805{ 808{
806 return d->spin->prefix(); 809 return d->spin->prefix();
807} 810}
808 811
809void KDoubleNumInput::setSuffix(const QString &suffix) 812void KDoubleNumInput::setSuffix(const QString &suffix)
810{ 813{
811 d->spin->setSuffix( suffix ); 814 d->spin->setSuffix( suffix );
812 815
813 layout(true); 816 layout(true);
814} 817}
815 818
816void KDoubleNumInput::setPrefix(const QString &prefix) 819void KDoubleNumInput::setPrefix(const QString &prefix)
817{ 820{
818 d->spin->setPrefix( prefix ); 821 d->spin->setPrefix( prefix );
819 822
820 layout(true); 823 layout(true);
821} 824}
822 825
823void KDoubleNumInput::setPrecision(int precision) 826void KDoubleNumInput::setPrecision(int precision)
824{ 827{
825 d->spin->setPrecision( precision ); 828 d->spin->setPrecision( precision );
826 829
827 layout(true); 830 layout(true);
828} 831}
829 832
830int KDoubleNumInput::precision() const 833int KDoubleNumInput::precision() const
831{ 834{
832 return d->spin->precision(); 835 return d->spin->precision();
833} 836}
834 837
835void KDoubleNumInput::setSpecialValueText(const QString& text) 838void KDoubleNumInput::setSpecialValueText(const QString& text)
836{ 839{
837 d->spin->setSpecialValueText( text ); 840 d->spin->setSpecialValueText( text );
838 841
839 layout(true); 842 layout(true);
840 updateLegacyMembers(); 843 updateLegacyMembers();
841} 844}
842 845
843void KDoubleNumInput::setLabel(const QString & label, int a) 846void KDoubleNumInput::setLabel(const QString & label, int a)
844{ 847{
845 KNumInput::setLabel(label, a); 848 KNumInput::setLabel(label, a);
846 849
847 if(m_label) 850 if(m_label)
848 m_label->setBuddy(d->spin); 851 m_label->setBuddy(d->spin);
849 852
850} 853}
851 854
852// ---------------------------------------------------------------------------- 855// ----------------------------------------------------------------------------
853 856
854 857
855// We use a kind of fixed-point arithmetic to represent the range of 858// We use a kind of fixed-point arithmetic to represent the range of
856// doubles [mLower,mUpper] in steps of 10^(-mPrecision). Thus, the 859// doubles [mLower,mUpper] in steps of 10^(-mPrecision). Thus, the
857// following relations hold: 860// following relations hold:
858// 861//
859// 1. factor = 10^mPrecision 862// 1. factor = 10^mPrecision
860// 2. basicStep = 1/factor = 10^(-mPrecision); 863// 2. basicStep = 1/factor = 10^(-mPrecision);
861// 3. lowerInt = lower * factor; 864// 3. lowerInt = lower * factor;
862// 4. upperInt = upper * factor; 865// 4. upperInt = upper * factor;
863// 5. lower = lowerInt * basicStep; 866// 5. lower = lowerInt * basicStep;
864// 6. upper = upperInt * basicStep; 867// 6. upper = upperInt * basicStep;
865class KDoubleSpinBox::Private { 868class KDoubleSpinBox::Private {
866public: 869public:
867 Private( int precision=1 ) 870 Private( int precision=1 )
868 : mPrecision( precision ), 871 : mPrecision( precision ),
869 mValidator( 0 ) 872 mValidator( 0 )
870 { 873 {
871 } 874 }
872 875
873 int factor() const { 876 int factor() const {
874 int f = 1; 877 int f = 1;
875 for ( int i = 0 ; i < mPrecision ; ++i ) f *= 10; 878 for ( int i = 0 ; i < mPrecision ; ++i ) f *= 10;
876 return f; 879 return f;
877 } 880 }
878 881
879 double basicStep() const { 882 double basicStep() const {
880 return 1.0/double(factor()); 883 return 1.0/double(factor());
881 } 884 }
882 885
883 int mapToInt( double value, bool * ok ) const { 886 int mapToInt( double value, bool * ok ) const {
884 assert( ok ); 887 assert( ok );
885 const double f = factor(); 888 const double f = factor();
886 if ( value > double(INT_MAX) / f ) { 889 if ( value > double(INT_MAX) / f ) {
887 kdWarning() << "KDoubleSpinBox: can't represent value " << value 890 kdWarning() << "KDoubleSpinBox: can't represent value " << value
888 << "in terms of fixed-point numbers with precision " 891 << "in terms of fixed-point numbers with precision "
889 << mPrecision << endl; 892 << mPrecision << endl;
890 *ok = false; 893 *ok = false;
891 return INT_MAX; 894 return INT_MAX;
892 } else if ( value < double(INT_MIN) / f ) { 895 } else if ( value < double(INT_MIN) / f ) {
893 kdWarning() << "KDoubleSpinBox: can't represent value " << value 896 kdWarning() << "KDoubleSpinBox: can't represent value " << value
894 << "in terms of fixed-point numbers with precision " 897 << "in terms of fixed-point numbers with precision "
895 << mPrecision << endl; 898 << mPrecision << endl;
896 *ok = false; 899 *ok = false;
897 return INT_MIN; 900 return INT_MIN;
898 } else { 901 } else {
899 *ok = true; 902 *ok = true;
900 return int( value * f + ( value < 0 ? -0.5 : 0.5 ) ); 903 return int( value * f + ( value < 0 ? -0.5 : 0.5 ) );
901 } 904 }
902 } 905 }
903 906
904 double mapToDouble( int value ) const { 907 double mapToDouble( int value ) const {
905 return double(value) * basicStep(); 908 return double(value) * basicStep();
906 } 909 }
907 910
908 int mPrecision; 911 int mPrecision;
909 KDoubleValidator * mValidator; 912 KDoubleValidator * mValidator;
910}; 913};
911 914
912KDoubleSpinBox::KDoubleSpinBox( QWidget * parent, const char * name ) 915KDoubleSpinBox::KDoubleSpinBox( QWidget * parent, const char * name )
913 : QSpinBox( parent, name ) 916 : QSpinBox( parent, name )
914{ 917{
915 editor()->setAlignment( Qt::AlignRight ); 918 setAlignment( Qt::AlignRight );
916 d = new Private(); 919 d = new Private();
917 updateValidator(); 920 updateValidator();
918} 921}
919 922
920KDoubleSpinBox::KDoubleSpinBox( double lower, double upper, double step, 923KDoubleSpinBox::KDoubleSpinBox( double lower, double upper, double step,
921 double value, int precision, 924 double value, int precision,
922 QWidget * parent, const char * name ) 925 QWidget * parent, const char * name )
923 : QSpinBox( parent, name ) 926 : QSpinBox( parent, name )
924{ 927{
925 editor()->setAlignment( Qt::AlignRight ); 928 setAlignment( Qt::AlignRight );
926 d = new Private(); 929 d = new Private();
927 setRange( lower, upper, step, precision ); 930 setRange( lower, upper, step, precision );
928 setValue( value ); 931 setValue( value );
929 connect( this, SIGNAL(valueChanged(int)), SLOT(slotValueChanged(int)) ); 932 connect( this, SIGNAL(valueChanged(int)), SLOT(slotValueChanged(int)) );
930} 933}
931 934
932KDoubleSpinBox::~KDoubleSpinBox() { 935KDoubleSpinBox::~KDoubleSpinBox() {
933 delete d; d = 0; 936 delete d; d = 0;
934} 937}
935 938
936bool KDoubleSpinBox::acceptLocalizedNumbers() const { 939bool KDoubleSpinBox::acceptLocalizedNumbers() const {
937 if ( !d->mValidator ) return true; // we'll set one that does; 940 if ( !d->mValidator ) return true; // we'll set one that does;
938 // can't do it now, since we're const 941 // can't do it now, since we're const
939 return d->mValidator->acceptLocalizedNumbers(); 942 return d->mValidator->acceptLocalizedNumbers();
940} 943}
941 944
942void KDoubleSpinBox::setAcceptLocalizedNumbers( bool accept ) { 945void KDoubleSpinBox::setAcceptLocalizedNumbers( bool accept ) {
943 if ( !d->mValidator ) updateValidator(); 946 if ( !d->mValidator ) updateValidator();
944 d->mValidator->setAcceptLocalizedNumbers( accept ); 947 d->mValidator->setAcceptLocalizedNumbers( accept );
945} 948}
946 949
947void KDoubleSpinBox::setRange( double lower, double upper, double step, 950void KDoubleSpinBox::setRange( double lower, double upper, double step,
948 int precision ) { 951 int precision ) {
949 lower = kMin(upper, lower); 952 lower = kMin(upper, lower);
950 upper = kMax(upper, lower); 953 upper = kMax(upper, lower);
951 setPrecision( precision, true ); // disable bounds checking, since 954 setPrecision( precision, true ); // disable bounds checking, since
952 setMinValue( lower ); // it's done in set{Min,Max}Value 955 setMinValue( lower ); // it's done in set{Min,Max}Value
953 setMaxValue( upper ); // anyway and we want lower, upper 956 setMaxValue( upper ); // anyway and we want lower, upper
954 setLineStep( step ); // and step to have the right precision 957 setLineStep( step ); // and step to have the right precision
955} 958}
956 959
957int KDoubleSpinBox::precision() const { 960int KDoubleSpinBox::precision() const {
958 return d->mPrecision; 961 return d->mPrecision;
959} 962}
960 963
961void KDoubleSpinBox::setPrecision( int precision ) { 964void KDoubleSpinBox::setPrecision( int precision ) {
962 setPrecision( precision, false ); 965 setPrecision( precision, false );
963} 966}
964 967
965void KDoubleSpinBox::setPrecision( int precision, bool force ) { 968void KDoubleSpinBox::setPrecision( int precision, bool force ) {
966 if ( precision < 1 ) return; 969 if ( precision < 1 ) return;
967 if ( !force ) { 970 if ( !force ) {
968 int maxPrec = maxPrecision(); 971 int maxPrec = maxPrecision();
969 if ( precision > maxPrec ) 972 if ( precision > maxPrec )
970 precision = maxPrec; 973 precision = maxPrec;
971 } 974 }
972 d->mPrecision = precision; 975 d->mPrecision = precision;
973 updateValidator(); 976 updateValidator();
974} 977}
975 978
976int KDoubleSpinBox::maxPrecision() const { 979int KDoubleSpinBox::maxPrecision() const {
977 // INT_MAX must be > maxAbsValue * 10^precision 980 // INT_MAX must be > maxAbsValue * 10^precision
978 // ==> 10^precision < INT_MAX / maxAbsValue 981 // ==> 10^precision < INT_MAX / maxAbsValue
979 // ==> precision < log10 ( INT_MAX / maxAbsValue ) 982 // ==> precision < log10 ( INT_MAX / maxAbsValue )
980 // ==> maxPrecision = floor( log10 ( INT_MAX / maxAbsValue ) ); 983 // ==> maxPrecision = floor( log10 ( INT_MAX / maxAbsValue ) );
981 double maxAbsValue = kMax( fabs(minValue()), fabs(maxValue()) ); 984 double maxAbsValue = kMax( fabs(minValue()), fabs(maxValue()) );
982 if ( maxAbsValue == 0 ) return 6; // return arbitrary value to avoid dbz... 985 if ( maxAbsValue == 0 ) return 6; // return arbitrary value to avoid dbz...
983 986
984 return int( floor( log10( double(INT_MAX) / maxAbsValue ) ) ); 987 return int( floor( log10( double(INT_MAX) / maxAbsValue ) ) );
985} 988}
986 989
987double KDoubleSpinBox::value() const { 990double KDoubleSpinBox::value() const {
988 return d->mapToDouble( base::value() ); 991 return d->mapToDouble( base::value() );
989} 992}
990 993
991void KDoubleSpinBox::setValue( double value ) { 994void KDoubleSpinBox::setValue( double value ) {
992 if ( value == this->value() ) return; 995 if ( value == this->value() ) return;
993 if ( value < minValue() ) 996 if ( value < minValue() )
994 base::setValue( base::minValue() ); 997 base::setValue( base::minValue() );
995 else if ( value > maxValue() ) 998 else if ( value > maxValue() )
996 base::setValue( base::maxValue() ); 999 base::setValue( base::maxValue() );
997 else { 1000 else {
998 bool ok = false; 1001 bool ok = false;
999 base::setValue( d->mapToInt( value, &ok ) ); 1002 base::setValue( d->mapToInt( value, &ok ) );
1000 assert( ok ); 1003 assert( ok );
1001 } 1004 }
1002} 1005}
1003 1006
1004double KDoubleSpinBox::minValue() const { 1007double KDoubleSpinBox::minValue() const {
1005 return d->mapToDouble( base::minValue() ); 1008 return d->mapToDouble( base::minValue() );
1006} 1009}
1007 1010
1008void KDoubleSpinBox::setMinValue( double value ) { 1011void KDoubleSpinBox::setMinValue( double value ) {
1009 bool ok = false; 1012 bool ok = false;
1010 int min = d->mapToInt( value, &ok ); 1013 int min = d->mapToInt( value, &ok );
1011 if ( !ok ) return; 1014 if ( !ok ) return;
1012 base::setMinValue( min ); 1015 base::setMinValue( min );
1013 updateValidator(); 1016 updateValidator();
1014} 1017}
1015 1018
1016 1019
1017double KDoubleSpinBox::maxValue() const { 1020double KDoubleSpinBox::maxValue() const {
1018 return d->mapToDouble( base::maxValue() ); 1021 return d->mapToDouble( base::maxValue() );
1019} 1022}
1020 1023
1021void KDoubleSpinBox::setMaxValue( double value ) { 1024void KDoubleSpinBox::setMaxValue( double value ) {
1022 bool ok = false; 1025 bool ok = false;
1023 int max = d->mapToInt( value, &ok ); 1026 int max = d->mapToInt( value, &ok );
1024 if ( !ok ) return; 1027 if ( !ok ) return;
1025 base::setMaxValue( max ); 1028 base::setMaxValue( max );
1026 updateValidator(); 1029 updateValidator();
1027} 1030}
1028 1031
1029double KDoubleSpinBox::lineStep() const { 1032double KDoubleSpinBox::lineStep() const {
1030 return d->mapToDouble( base::lineStep() ); 1033 return d->mapToDouble( base::singleStep() );
1031} 1034}
1032 1035
1033void KDoubleSpinBox::setLineStep( double step ) { 1036void KDoubleSpinBox::setLineStep( double step ) {
1034 bool ok = false; 1037 bool ok = false;
1035 if ( step > maxValue() - minValue() ) 1038 if ( step > maxValue() - minValue() )
1036 base::setLineStep( 1 ); 1039 base::setLineStep( 1 );
1037 else 1040 else
1038 base::setLineStep( kMax( d->mapToInt( step, &ok ), 1 ) ); 1041 base::setLineStep( kMax( d->mapToInt( step, &ok ), 1 ) );
1039} 1042}
1040 1043
1041QString KDoubleSpinBox::mapValueToText( int value ) { 1044QString KDoubleSpinBox::mapValueToText( int value ) {
1042 if ( acceptLocalizedNumbers() ) 1045 if ( acceptLocalizedNumbers() )
1043 return KGlobal::locale() 1046 return KGlobal::locale()
1044 ->formatNumber( d->mapToDouble( value ), d->mPrecision ); 1047 ->formatNumber( d->mapToDouble( value ), d->mPrecision );
1045 else 1048 else
1046 return QString().setNum( d->mapToDouble( value ), 'f', d->mPrecision ); 1049 return QString().setNum( d->mapToDouble( value ), 'f', d->mPrecision );
1047} 1050}
1048 1051
1049int KDoubleSpinBox::mapTextToValue( bool * ok ) { 1052int KDoubleSpinBox::mapTextToValue( bool * ok ) {
1050 double value; 1053 double value;
1051 if ( acceptLocalizedNumbers() ) 1054 if ( acceptLocalizedNumbers() )
1052 value = KGlobal::locale()->readNumber( cleanText(), ok ); 1055 value = KGlobal::locale()->readNumber( cleanText(), ok );
1053 else 1056 else
1054 value = cleanText().toDouble( ok ); 1057 value = cleanText().toDouble( ok );
1055 if ( !*ok ) return 0; 1058 if ( !*ok ) return 0;
1056 if ( value > maxValue() ) 1059 if ( value > maxValue() )
1057 value = maxValue(); 1060 value = maxValue();
1058 else if ( value < minValue() ) 1061 else if ( value < minValue() )
1059 value = minValue(); 1062 value = minValue();
1060 return d->mapToInt( value, ok ); 1063 return d->mapToInt( value, ok );
1061} 1064}
1062 1065
1063void KDoubleSpinBox::setValidator( const QValidator * ) { 1066void KDoubleSpinBox::setValidator( const QValidator * ) {
1064 // silently discard the new validator. We don't want another one ;-) 1067 // silently discard the new validator. We don't want another one ;-)
1065} 1068}
1066 1069
1067void KDoubleSpinBox::slotValueChanged( int value ) { 1070void KDoubleSpinBox::slotValueChanged( int value ) {
1068 emit valueChanged( d->mapToDouble( value ) ); 1071 emit valueChanged( d->mapToDouble( value ) );
1069} 1072}
1070 1073
1071void KDoubleSpinBox::updateValidator() { 1074void KDoubleSpinBox::updateValidator() {
1072 if ( !d->mValidator ) { 1075 if ( !d->mValidator ) {
1073 d->mValidator = new KDoubleValidator( minValue(), maxValue(), precision(), 1076 d->mValidator = new KDoubleValidator( minValue(), maxValue(), precision(),
1074 this, "d->mValidator" ); 1077 this, "d->mValidator" );
1075 base::setValidator( d->mValidator ); 1078 lineEdit()->setValidator( d->mValidator );
1076 } else 1079 } else
1077 d->mValidator->setRange( minValue(), maxValue(), precision() ); 1080 d->mValidator->setRange( minValue(), maxValue(), precision() );
1078} 1081}
1079 1082
1080void KNumInput::virtual_hook( int, void* ) 1083void KNumInput::virtual_hook( int, void* )
1081{ /*BASE::virtual_hook( id, data );*/ } 1084{ /*BASE::virtual_hook( id, data );*/ }
1082 1085
1083void KIntNumInput::virtual_hook( int id, void* data ) 1086void KIntNumInput::virtual_hook( int id, void* data )
1084{ KNumInput::virtual_hook( id, data ); } 1087{ KNumInput::virtual_hook( id, data ); }
1085 1088
1086void KDoubleNumInput::virtual_hook( int id, void* data ) 1089void KDoubleNumInput::virtual_hook( int id, void* data )
1087{ KNumInput::virtual_hook( id, data ); } 1090{ KNumInput::virtual_hook( id, data ); }
1088 1091
1089void KIntSpinBox::virtual_hook( int, void* ) 1092void KIntSpinBox::virtual_hook( int, void* )
1090{ /*BASE::virtual_hook( id, data );*/ } 1093{ /*BASE::virtual_hook( id, data );*/ }
1091 1094
1092void KDoubleSpinBox::virtual_hook( int, void* ) 1095void KDoubleSpinBox::virtual_hook( int, void* )
1093{ /*BASE::virtual_hook( id, data );*/ } 1096{ /*BASE::virtual_hook( id, data );*/ }
1094 1097
1095//US #include "knuminput.moc" 1098//US #include "knuminput.moc"
diff --git a/microkde/kdeui/knuminput.h b/microkde/kdeui/knuminput.h
index 123fefa..9f9e200 100644
--- a/microkde/kdeui/knuminput.h
+++ b/microkde/kdeui/knuminput.h
@@ -1,948 +1,957 @@
1/* 1/*
2 * knuminput.h 2 * knuminput.h
3 * 3 *
4 * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca> 4 * Copyright (c) 1997 Patrick Dowler <dowler@morgul.fsh.uvic.ca>
5 * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org> 5 * Copyright (c) 2000 Dirk A. Mueller <mueller@kde.org>
6 * Copyright (c) 2002 Marc Mutz <mutz@kde.org> 6 * Copyright (c) 2002 Marc Mutz <mutz@kde.org>
7 * 7 *
8 * Requires the Qt widget libraries, available at no cost at 8 * Requires the Qt widget libraries, available at no cost at
9 * http://www.troll.no/ 9 * http://www.troll.no/
10 * 10 *
11 * This library is free software; you can redistribute it and/or 11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Library General Public 12 * modify it under the terms of the GNU Library General Public
13 * License as published by the Free Software Foundation; either 13 * License as published by the Free Software Foundation; either
14 * version 2 of the License, or (at your option) any later version. 14 * version 2 of the License, or (at your option) any later version.
15 * 15 *
16 * This library is distributed in the hope that it will be useful, 16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Library General Public License for more details. 19 * Library General Public License for more details.
20 * 20 *
21 * You should have received a copy of the GNU Library General Public License 21 * You should have received a copy of the GNU Library General Public License
22 * along with this library; see the file COPYING.LIB. If not, write to 22 * along with this library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 23 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 * Boston, MA 02111-1307, USA. 24 * Boston, MA 02111-1307, USA.
25 */ 25 */
26 26
27#ifndef K_NUMINPUT_H 27#ifndef K_NUMINPUT_H
28#define K_NUMINPUT_H 28#define K_NUMINPUT_H
29 29
30#include <qwidget.h> 30#include <qwidget.h>
31#include <qspinbox.h> 31#include <qspinbox.h>
32#include <QLineEdit>
33//Added by qt3to4:
34#include <QResizeEvent>
35#include <QLabel>
36#include <QEvent>
32 37
33class QLabel; 38class QLabel;
34class QSlider; 39class QSlider;
35class QLineEdit; 40class QLineEdit;
36class QLayout; 41class QLayout;
37class QValidator; 42class QValidator;
38 43
39class KIntSpinBox; 44class KIntSpinBox;
40 45
41/* ------------------------------------------------------------------------ */ 46/* ------------------------------------------------------------------------ */
42 47
43/** 48/**
44 * You need to inherit from this class if you want to implement K*NumInput 49 * You need to inherit from this class if you want to implement K*NumInput
45 * for a different variable type 50 * for a different variable type
46 * 51 *
47 */ 52 */
48class KNumInput : public QWidget 53class KNumInput : public QWidget
49{ 54{
50 Q_OBJECT 55 Q_OBJECT
51 Q_PROPERTY( QString label READ label WRITE setLabel ) 56 Q_PROPERTY( QString label READ label WRITE setLabel )
52public: 57public:
53 /** 58 /**
54 * Default constructor 59 * Default constructor
55 * 60 *
56 */ 61 */
57 KNumInput(QWidget* parent=0, const char* name=0); 62 KNumInput(QWidget* parent=0, const char* name=0);
58 63
59 /** 64 /**
60 * @param below A pointer to another KNumInput. 65 * @param below A pointer to another KNumInput.
61 * 66 *
62 */ 67 */
63 KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0); 68 KNumInput(KNumInput* below, QWidget* parent=0, const char* name=0);
64 ~KNumInput(); 69 ~KNumInput();
65 70
66 /** 71 /**
67 * Sets the text and alignment of the main description label. 72 * Sets the text and alignment of the main description label.
68 * 73 *
69 * @param label The text of the label. 74 * @param label The text of the label.
70 * Use QString::null to remove an existing one. 75 * Use QString::null to remove an existing one.
71 * 76 *
72 * @param a one of @p AlignLeft, @p AlignHCenter, YAlignRight and 77 * @param a one of @p AlignLeft, @p AlignHCenter, YAlignRight and
73 * @p AlignTop, @p AlignVCenter, @p AlignBottom. 78 * @p AlignTop, @p AlignVCenter, @p AlignBottom.
74 * default is @p AlignLeft | @p AlignTop. 79 * default is @p AlignLeft | @p AlignTop.
75 * 80 *
76 * The vertical alignment flags have special meaning with this 81 * The vertical alignment flags have special meaning with this
77 * widget: 82 * widget:
78 * 83 *
79 * @li @p AlignTop The label is placed above the edit/slider 84 * @li @p AlignTop The label is placed above the edit/slider
80 * @li @p AlignVCenter The label is placed left beside the edit 85 * @li @p AlignVCenter The label is placed left beside the edit
81 * @li @p AlignBottom The label is placed below the edit/slider 86 * @li @p AlignBottom The label is placed below the edit/slider
82 * 87 *
83 */ 88 */
84 virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); 89 virtual void setLabel(const QString & label, int a = Qt::AlignLeft | Qt::AlignTop);
85 90
86 /** 91 /**
87 * @return the text of the label. 92 * @return the text of the label.
88 */ 93 */
89 QString label() const; 94 QString label() const;
90 95
91 /** 96 /**
92 * @return if the num input has a slider. 97 * @return if the num input has a slider.
93 * @since 3.1 98 * @since 3.1
94 */ 99 */
95 bool showSlider() const { return m_slider; } 100 bool showSlider() const { return m_slider; }
96 101
97 /** 102 /**
98 * Sets the spacing of tickmarks for the slider. 103 * Sets the spacing of tickmarks for the slider.
99 * 104 *
100 * @param minor Minor tickmark separation. 105 * @param minor Minor tickmark separation.
101 * @param major Major tickmark separation. 106 * @param major Major tickmark separation.
102 */ 107 */
103 void setSteps(int minor, int major); 108 void setSteps(int minor, int major);
104 109
105 /** 110 /**
106 * Specifies that this widget may stretch horizontally, but is 111 * Specifies that this widget may stretch horizontally, but is
107 * fixed vertically (like @ref QSpinBox itself). 112 * fixed vertically (like @ref QSpinBox itself).
108 */ 113 */
109 QSizePolicy sizePolicy() const; 114 QSizePolicy sizePolicy() const;
110 115
111 /** 116 /**
112 * Returns a size which fits the contents of the control. 117 * Returns a size which fits the contents of the control.
113 * 118 *
114 * @return the preferred size necessary to show the control 119 * @return the preferred size necessary to show the control
115 */ 120 */
116 virtual QSize sizeHint() const; 121 virtual QSize sizeHint() const;
117 122
118protected: 123protected:
119 /** 124 /**
120 * Call this function whenever you change something in the geometry 125 * Call this function whenever you change something in the geometry
121 * of your KNumInput child. 126 * of your KNumInput child.
122 * 127 *
123 */ 128 */
124 void layout(bool deep); 129 void layout(bool deep);
125 130
126 /** 131 /**
127 * You need to overwrite this method and implement your layout 132 * You need to overwrite this method and implement your layout
128 * calculations there. 133 * calculations there.
129 * 134 *
130 * See KIntNumInput::doLayout and KDoubleNumInput::doLayout implementation 135 * See KIntNumInput::doLayout and KDoubleNumInput::doLayout implementation
131 * for details. 136 * for details.
132 * 137 *
133 */ 138 */
134 virtual void doLayout() = 0; 139 virtual void doLayout() = 0;
135 140
136 KNumInput* m_prev, *m_next; 141 KNumInput* m_prev, *m_next;
137 int m_colw1, m_colw2; 142 int m_colw1, m_colw2;
138 143
139 QLabel* m_label; 144 QLabel* m_label;
140 QSlider* m_slider; 145 QSlider* m_slider;
141 QSize m_sizeSlider, m_sizeLabel; 146 QSize m_sizeSlider, m_sizeLabel;
142 147
143 int m_alignment; 148 int m_alignment;
144 149
145private: 150private:
146 void init(); 151 void init();
147 152
148protected: 153protected:
149 virtual void virtual_hook( int id, void* data ); 154 virtual void virtual_hook( int id, void* data );
150private: 155private:
151 class KNumInputPrivate; 156 class KNumInputPrivate;
152 KNumInputPrivate *d; 157 KNumInputPrivate *d;
153}; 158};
154 159
155/* ------------------------------------------------------------------------ */ 160/* ------------------------------------------------------------------------ */
156 161
157/** 162/**
158 * KIntNumInput combines a @ref QSpinBox and optionally a @ref QSlider 163 * KIntNumInput combines a @ref QSpinBox and optionally a @ref QSlider
159 * with a label to make an easy to use control for setting some integer 164 * with a label to make an easy to use control for setting some integer
160 * parameter. This is especially nice for configuration dialogs, 165 * parameter. This is especially nice for configuration dialogs,
161 * which can have many such combinated controls. 166 * which can have many such combinated controls.
162 * 167 *
163 * The slider is created only when the user specifies a range 168 * The slider is created only when the user specifies a range
164 * for the control using the setRange function with the slider 169 * for the control using the setRange function with the slider
165 * parameter set to "true". 170 * parameter set to "true".
166 * 171 *
167 * A special feature of KIntNumInput, designed specifically for 172 * A special feature of KIntNumInput, designed specifically for
168 * the situation when there are several KIntNumInputs in a column, 173 * the situation when there are several KIntNumInputs in a column,
169 * is that you can specify what portion of the control is taken by the 174 * is that you can specify what portion of the control is taken by the
170 * QSpinBox (the remaining portion is used by the slider). This makes 175 * QSpinBox (the remaining portion is used by the slider). This makes
171 * it very simple to have all the sliders in a column be the same size. 176 * it very simple to have all the sliders in a column be the same size.
172 * 177 *
173 * It uses @ref KIntValidator validator class. KIntNumInput enforces the 178 * It uses @ref KIntValidator validator class. KIntNumInput enforces the
174 * value to be in the given range, and can display it in any base 179 * value to be in the given range, and can display it in any base
175 * between 2 and 36. 180 * between 2 and 36.
176 * 181 *
177 * @short An input widget for integer numbers, consisting of a spinbox and a slider. 182 * @short An input widget for integer numbers, consisting of a spinbox and a slider.
178 * @version $Id$ 183 * @version $Id$
179 */ 184 */
180 185
181class KIntNumInput : public KNumInput 186class KIntNumInput : public KNumInput
182{ 187{
183 Q_OBJECT 188 Q_OBJECT
184 Q_PROPERTY( int value READ value WRITE setValue ) 189 Q_PROPERTY( int value READ value WRITE setValue )
185 Q_PROPERTY( int minValue READ minValue WRITE setMinValue ) 190 Q_PROPERTY( int minValue READ minValue WRITE setMinValue )
186 Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue ) 191 Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue )
187 Q_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint ) 192 Q_PROPERTY( int referencePoint READ referencePoint WRITE setReferencePoint )
188 Q_PROPERTY( QString suffix READ suffix WRITE setSuffix ) 193 Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
189 Q_PROPERTY( QString prefix READ prefix WRITE setPrefix ) 194 Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
190 Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText ) 195 Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
191 196
192public: 197public:
193 /** 198 /**
194 * Constructs an input control for integer values 199 * Constructs an input control for integer values
195 * with base 10 and initial value 0. 200 * with base 10 and initial value 0.
196 */ 201 */
197 KIntNumInput(QWidget *parent=0, const char *name=0); 202 KIntNumInput(QWidget *parent=0, const char *name=0);
198 /** 203 /**
199 * Constructor 204 * Constructor
200 * It constructs a QSpinBox that allows the input of integer numbers 205 * It constructs a QSpinBox that allows the input of integer numbers
201 * in the range of -INT_MAX to +INT_MAX. To set a descriptive label, 206 * in the range of -INT_MAX to +INT_MAX. To set a descriptive label,
202 * use setLabel(). To enforce the value being in a range and optionally to 207 * use setLabel(). To enforce the value being in a range and optionally to
203 * attach a slider to it, use setRange(). 208 * attach a slider to it, use setRange().
204 * 209 *
205 * @param value initial value for the control 210 * @param value initial value for the control
206 * @param base numeric base used for display 211 * @param base numeric base used for display
207 * @param parent parent QWidget 212 * @param parent parent QWidget
208 * @param name internal name for this widget 213 * @param name internal name for this widget
209 */ 214 */
210 KIntNumInput(int value, QWidget* parent=0, int base = 10, const char *name=0); 215 KIntNumInput(int value, QWidget* parent=0, int base = 10, const char *name=0);
211 216
212 /** 217 /**
213 * Constructor 218 * Constructor
214 * 219 *
215 * the difference to the one above is the "below" parameter. It tells 220 * the difference to the one above is the "below" parameter. It tells
216 * this instance that it is visually put below some other KNumInput widget. 221 * this instance that it is visually put below some other KNumInput widget.
217 * Note that these two KNumInput's need not to have the same parent widget 222 * Note that these two KNumInput's need not to have the same parent widget
218 * or be in the same layout group. 223 * or be in the same layout group.
219 * The effect is that it'll adjust it's layout in correspondence 224 * The effect is that it'll adjust it's layout in correspondence
220 * with the layout of the other KNumInput's (you can build an arbitary long 225 * with the layout of the other KNumInput's (you can build an arbitary long
221 * chain). 226 * chain).
222 * 227 *
223 * @param below append KIntNumInput to the KNumInput chain 228 * @param below append KIntNumInput to the KNumInput chain
224 * @param value initial value for the control 229 * @param value initial value for the control
225 * @param base numeric base used for display 230 * @param base numeric base used for display
226 * @param parent parent QWidget 231 * @param parent parent QWidget
227 * @param name internal name for this widget 232 * @param name internal name for this widget
228 */ 233 */
229 KIntNumInput(KNumInput* below, int value, QWidget* parent=0, int base = 10, const char *name=0); 234 KIntNumInput(KNumInput* below, int value, QWidget* parent=0, int base = 10, const char *name=0);
230 235
231 /** 236 /**
232 * Destructor 237 * Destructor
233 * 238 *
234 * 239 *
235 */ 240 */
236 virtual ~KIntNumInput(); 241 virtual ~KIntNumInput();
237 242
238 /** 243 /**
239 * @return the current value. 244 * @return the current value.
240 */ 245 */
241 int value() const; 246 int value() const;
242 247
243 /** 248 /**
244 * @return the curent value in units of the @ref referencePoint. 249 * @return the curent value in units of the @ref referencePoint.
245 * @since 3.1 250 * @since 3.1
246 */ 251 */
247 double relativeValue() const; 252 double relativeValue() const;
248 253
249 /** 254 /**
250 * @return the current reference point 255 * @return the current reference point
251 * @since 3.1 256 * @since 3.1
252 */ 257 */
253 int referencePoint() const; 258 int referencePoint() const;
254 259
255 /** 260 /**
256 * @return the suffix displayed behind the value. 261 * @return the suffix displayed behind the value.
257 * @see #setSuffix() 262 * @see #setSuffix()
258 */ 263 */
259 QString suffix() const; 264 QString suffix() const;
260 /** 265 /**
261 * @return the prefix displayed in front of the value. 266 * @return the prefix displayed in front of the value.
262 * @see #setPrefix() 267 * @see #setPrefix()
263 */ 268 */
264 QString prefix() const; 269 QString prefix() const;
265 /** 270 /**
266 * @return the string displayed for a special value. 271 * @return the string displayed for a special value.
267 * @see #setSpecialValueText() 272 * @see #setSpecialValueText()
268 */ 273 */
269 QString specialValueText() const; 274 QString specialValueText() const;
270 275
271 /** 276 /**
272 * @param min minimum value 277 * @param min minimum value
273 * @param max maximum value 278 * @param max maximum value
274 * @param step step size for the QSlider 279 * @param step step size for the QSlider
275 */ 280 */
276 void setRange(int min, int max, int step=1, bool slider=true); 281 void setRange(int min, int max, int step=1, bool slider=true);
277 /** 282 /**
278 * Sets the minimum value. 283 * Sets the minimum value.
279 */ 284 */
280 void setMinValue(int min); 285 void setMinValue(int min);
281 /** 286 /**
282 * @return the minimum value. 287 * @return the minimum value.
283 */ 288 */
284 int minValue() const; 289 int minValue() const;
285 /** 290 /**
286 * Sets the maximum value. 291 * Sets the maximum value.
287 */ 292 */
288 void setMaxValue(int max); 293 void setMaxValue(int max);
289 /** 294 /**
290 * @return the maximum value. 295 * @return the maximum value.
291 */ 296 */
292 int maxValue() const; 297 int maxValue() const;
293 298
294 /** 299 /**
295 * Sets the special value text. If set, the SpinBox will display 300 * Sets the special value text. If set, the SpinBox will display
296 * this text instead of the numeric value whenever the current 301 * this text instead of the numeric value whenever the current
297 * value is equal to minVal(). Typically this is used for indicating 302 * value is equal to minVal(). Typically this is used for indicating
298 * that the choice has a special (default) meaning. 303 * that the choice has a special (default) meaning.
299 */ 304 */
300 void setSpecialValueText(const QString& text); 305 void setSpecialValueText(const QString& text);
301 306
302 /** 307 /**
303 * @reimplemented 308 * @reimplemented
304 */ 309 */
305 virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); 310 virtual void setLabel(const QString & label, int a = Qt::AlignLeft | Qt::AlignTop);
306 311
307 /** 312 /**
308 * This method returns the minimum size necessary to display the 313 * This method returns the minimum size necessary to display the
309 * control. The minimum size is enough to show all the labels 314 * control. The minimum size is enough to show all the labels
310 * in the current font (font change may invalidate the return value). 315 * in the current font (font change may invalidate the return value).
311 * 316 *
312 * @return the minimum size necessary to show the control 317 * @return the minimum size necessary to show the control
313 */ 318 */
314 virtual QSize minimumSizeHint() const; 319 virtual QSize minimumSizeHint() const;
315 320
316public slots: 321public slots:
317 /** 322 /**
318 * Sets the value of the control. 323 * Sets the value of the control.
319 */ 324 */
320 void setValue(int); 325 void setValue(int);
321 326
322 /** 327 /**
323 * Sets the value in units of the @ref referencePoint 328 * Sets the value in units of the @ref referencePoint
324 * @since 3.1 329 * @since 3.1
325 */ 330 */
326 void setRelativeValue(double); 331 void setRelativeValue(double);
327 332
328 /** 333 /**
329 * Sets the reference point for @ref relativeValue. 334 * Sets the reference point for @ref relativeValue.
330 * @since 3.1 335 * @since 3.1
331 */ 336 */
332 void setReferencePoint(int); 337 void setReferencePoint(int);
333 338
334 /** 339 /**
335 * Sets the suffix to @p suffix. 340 * Sets the suffix to @p suffix.
336 * Use QString::null to disable this feature. 341 * Use QString::null to disable this feature.
337 * Formatting has to be provided (e.g. a space separator between the 342 * Formatting has to be provided (e.g. a space separator between the
338 * prepended @p value and the suffix's text has to be provided 343 * prepended @p value and the suffix's text has to be provided
339 * as the first character in the suffix). 344 * as the first character in the suffix).
340 * 345 *
341 * @see QSpinBox::setSuffix(), #setPrefix() 346 * @see QSpinBox::setSuffix(), #setPrefix()
342 */ 347 */
343 void setSuffix(const QString &suffix); 348 void setSuffix(const QString &suffix);
344 349
345 /** 350 /**
346 * Sets the prefix to @p prefix. 351 * Sets the prefix to @p prefix.
347 * Use QString::null to disable this feature. 352 * Use QString::null to disable this feature.
348 * Formatting has to be provided (see above). 353 * Formatting has to be provided (see above).
349 * 354 *
350 * @see QSpinBox::setPrefix(), #setSuffix() 355 * @see QSpinBox::setPrefix(), #setSuffix()
351 */ 356 */
352 void setPrefix(const QString &prefix); 357 void setPrefix(const QString &prefix);
353 358
354 /** 359 /**
355 * sets focus to the edit widget and marks all text in if mark == true 360 * sets focus to the edit widget and marks all text in if mark == true
356 * 361 *
357 */ 362 */
358 void setEditFocus( bool mark = true ); 363 void setEditFocus( bool mark = true );
359 364
360signals: 365signals:
361 /** 366 /**
362 * Emitted every time the value changes (by calling @ref setValue() or 367 * Emitted every time the value changes (by calling @ref setValue() or
363 * by user interaction). 368 * by user interaction).
364 */ 369 */
365 void valueChanged(int); 370 void valueChanged(int);
366 371
367 /** 372 /**
368 * Emitted whenever @ref #valueChanged is. Contains the change 373 * Emitted whenever @ref #valueChanged is. Contains the change
369 * relative to the @ref referencePoint. 374 * relative to the @ref referencePoint.
370 * @since 3.1 375 * @since 3.1
371 */ 376 */
372 void relativeValueChanged(double); 377 void relativeValueChanged(double);
373 378
374private slots: 379private slots:
375 void spinValueChanged(int); 380 void spinValueChanged(int);
376 void slotEmitRelativeValueChanged(int); 381 void slotEmitRelativeValueChanged(int);
377 382
378protected: 383protected:
379 /** 384 /**
380 * @reimplemented 385 * @reimplemented
381 */ 386 */
382 virtual void doLayout(); 387 virtual void doLayout();
383 /** 388 /**
384 * @reimplemented 389 * @reimplemented
385 */ 390 */
386 void resizeEvent ( QResizeEvent * ); 391 void resizeEvent ( QResizeEvent * );
387 392
388 KIntSpinBox* m_spin; 393 KIntSpinBox* m_spin;
389 QSize m_sizeSpin; 394 QSize m_sizeSpin;
390 395
391private: 396private:
392 void init(int value, int _base); 397 void init(int value, int _base);
393 398
394protected: 399protected:
395 virtual void virtual_hook( int id, void* data ); 400 virtual void virtual_hook( int id, void* data );
396private: 401private:
397 class KIntNumInputPrivate; 402 class KIntNumInputPrivate;
398 KIntNumInputPrivate *d; 403 KIntNumInputPrivate *d;
399}; 404};
400 405
401 406
402/* ------------------------------------------------------------------------ */ 407/* ------------------------------------------------------------------------ */
403 408
404class KDoubleLine; 409class KDoubleLine;
405 410
406/** 411/**
407 * KDoubleNumInput combines a @ref QSpinBox and optionally a @ref QSlider 412 * KDoubleNumInput combines a @ref QSpinBox and optionally a @ref QSlider
408 * with a label to make an easy to use control for setting some float 413 * with a label to make an easy to use control for setting some float
409 * parameter. This is especially nice for configuration dialogs, 414 * parameter. This is especially nice for configuration dialogs,
410 * which can have many such combinated controls. 415 * which can have many such combinated controls.
411 * 416 *
412 * The slider is created only when the user specifies a range 417 * The slider is created only when the user specifies a range
413 * for the control using the setRange function with the slider 418 * for the control using the setRange function with the slider
414 * parameter set to "true". 419 * parameter set to "true".
415 * 420 *
416 * A special feature of KDoubleNumInput, designed specifically for 421 * A special feature of KDoubleNumInput, designed specifically for
417 * the situation when there are several instances in a column, 422 * the situation when there are several instances in a column,
418 * is that you can specify what portion of the control is taken by the 423 * is that you can specify what portion of the control is taken by the
419 * QSpinBox (the remaining portion is used by the slider). This makes 424 * QSpinBox (the remaining portion is used by the slider). This makes
420 * it very simple to have all the sliders in a column be the same size. 425 * it very simple to have all the sliders in a column be the same size.
421 * 426 *
422 * It uses the @ref KDoubleValidator validator class. KDoubleNumInput 427 * It uses the @ref KDoubleValidator validator class. KDoubleNumInput
423 * enforces the value to be in the given range, but see the class 428 * enforces the value to be in the given range, but see the class
424 * documentation of @ref KDoubleSpinBox for the tricky 429 * documentation of @ref KDoubleSpinBox for the tricky
425 * interrelationship of precision and values. All of what is said 430 * interrelationship of precision and values. All of what is said
426 * there applies here, too. 431 * there applies here, too.
427 * 432 *
428 * @see KIntNumInput, KDoubleSpinBox 433 * @see KIntNumInput, KDoubleSpinBox
429 * @short An input control for real numbers, consisting of a spinbox and a slider. 434 * @short An input control for real numbers, consisting of a spinbox and a slider.
430 */ 435 */
431 436
432class KDoubleNumInput : public KNumInput 437class KDoubleNumInput : public KNumInput
433{ 438{
434 Q_OBJECT 439 Q_OBJECT
435 Q_PROPERTY( double value READ value WRITE setValue ) 440 Q_PROPERTY( double value READ value WRITE setValue )
436 Q_PROPERTY( double minValue READ minValue WRITE setMinValue ) 441 Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
437 Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue ) 442 Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
438 Q_PROPERTY( QString suffix READ suffix WRITE setSuffix ) 443 Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
439 Q_PROPERTY( QString prefix READ prefix WRITE setPrefix ) 444 Q_PROPERTY( QString prefix READ prefix WRITE setPrefix )
440 Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText ) 445 Q_PROPERTY( QString specialValueText READ specialValueText WRITE setSpecialValueText )
441 Q_PROPERTY( int precision READ precision WRITE setPrecision ) 446 Q_PROPERTY( int precision READ precision WRITE setPrecision )
442 447
443public: 448public:
444 /** 449 /**
445 * Constructs an input control for double values 450 * Constructs an input control for double values
446 * with initial value 0.00. 451 * with initial value 0.00.
447 */ 452 */
448 KDoubleNumInput(QWidget *parent=0, const char *name=0); 453 KDoubleNumInput(QWidget *parent=0, const char *name=0);
449 454
450 /** 455 /**
451 * @deprecated (value is rounded to a multiple of 1/100) 456 * @deprecated (value is rounded to a multiple of 1/100)
452 * Constructor 457 * Constructor
453 * 458 *
454 * @param value initial value for the control 459 * @param value initial value for the control
455 * @param parent parent QWidget 460 * @param parent parent QWidget
456 * @param name internal name for this widget 461 * @param name internal name for this widget
457 */ 462 */
458 KDoubleNumInput(double value, QWidget *parent=0, const char *name=0); 463 KDoubleNumInput(double value, QWidget *parent=0, const char *name=0);
459 464
460 /** 465 /**
461 * Constructor 466 * Constructor
462 * 467 *
463 * @param lower lower boundary value 468 * @param lower lower boundary value
464 * @param upper upper boundary value 469 * @param upper upper boundary value
465 * @param value initial value for the control 470 * @param value initial value for the control
466 * @param step step size to use for up/down arrow clicks 471 * @param step step size to use for up/down arrow clicks
467 * @param precision number of digits after the decimal point 472 * @param precision number of digits after the decimal point
468 * @param parent parent QWidget 473 * @param parent parent QWidget
469 * @param name internal name for this widget 474 * @param name internal name for this widget
470 * @since 3.1 475 * @since 3.1
471 */ 476 */
472 KDoubleNumInput(double lower, double upper, double value, double step=0.01, 477 KDoubleNumInput(double lower, double upper, double value, double step=0.01,
473 int precision=2, QWidget *parent=0, const char *name=0); 478 int precision=2, QWidget *parent=0, const char *name=0);
474 479
475 /** 480 /**
476 * destructor 481 * destructor
477 */ 482 */
478 virtual ~KDoubleNumInput(); 483 virtual ~KDoubleNumInput();
479 484
480 /** 485 /**
481 * @deprecated (rounds @p value to a mulitple of 1/100) 486 * @deprecated (rounds @p value to a mulitple of 1/100)
482 * Constructor 487 * Constructor
483 * 488 *
484 * puts it below other KNumInput 489 * puts it below other KNumInput
485 * 490 *
486 * @param below 491 * @param below
487 * @param value initial value for the control 492 * @param value initial value for the control
488 * @param parent parent QWidget 493 * @param parent parent QWidget
489 * @param name internal name for this widget 494 * @param name internal name for this widget
490 **/ 495 **/
491 KDoubleNumInput(KNumInput* below, double value, QWidget* parent=0, const char* name=0); 496 KDoubleNumInput(KNumInput* below, double value, QWidget* parent=0, const char* name=0);
492 497
493 /** 498 /**
494 * Constructor 499 * Constructor
495 * 500 *
496 * puts it below other KNumInput 501 * puts it below other KNumInput
497 * 502 *
498 * @param lower lower boundary value 503 * @param lower lower boundary value
499 * @param upper upper boundary value 504 * @param upper upper boundary value
500 * @param value initial value for the control 505 * @param value initial value for the control
501 * @param step step size to use for up/down arrow clicks 506 * @param step step size to use for up/down arrow clicks
502 * @param precision number of digits after the decimal point 507 * @param precision number of digits after the decimal point
503 * @param parent parent QWidget 508 * @param parent parent QWidget
504 * @param name internal name for this widget 509 * @param name internal name for this widget
505 * @since 3.1 510 * @since 3.1
506 */ 511 */
507 KDoubleNumInput(KNumInput* below, 512 KDoubleNumInput(KNumInput* below,
508 double lower, double upper, double value, double step=0.02, 513 double lower, double upper, double value, double step=0.02,
509 int precision=2, QWidget *parent=0, const char *name=0); 514 int precision=2, QWidget *parent=0, const char *name=0);
510 515
511 /** 516 /**
512 * @return the current value. 517 * @return the current value.
513 */ 518 */
514 double value() const; 519 double value() const;
515 520
516 /** 521 /**
517 * @return the suffix. 522 * @return the suffix.
518 * @see #setSuffix() 523 * @see #setSuffix()
519 */ 524 */
520 QString suffix() const; 525 QString suffix() const;
521 526
522 /** 527 /**
523 * @return the prefix. 528 * @return the prefix.
524 * @see #setPrefix() 529 * @see #setPrefix()
525 */ 530 */
526 QString prefix() const; 531 QString prefix() const;
527 532
528 /** 533 /**
529 * @return the precision. 534 * @return the precision.
530 * @see #setPrecision() 535 * @see #setPrecision()
531 */ 536 */
532 int precision() const; 537 int precision() const;
533 538
534 /** 539 /**
535 * @return the string displayed for a special value. 540 * @return the string displayed for a special value.
536 * @see #setSpecialValueText() 541 * @see #setSpecialValueText()
537 */ 542 */
538 QString specialValueText() const { return m_specialvalue; } 543 QString specialValueText() const { return m_specialvalue; }
539 544
540 /** 545 /**
541 * @param min minimum value 546 * @param min minimum value
542 * @param max maximum value 547 * @param max maximum value
543 * @param step step size for the QSlider 548 * @param step step size for the QSlider
544 */ 549 */
545 void setRange(double min, double max, double step=1, bool slider=true); 550 void setRange(double min, double max, double step=1, bool slider=true);
546 /** 551 /**
547 * Sets the minimum value. 552 * Sets the minimum value.
548 */ 553 */
549 void setMinValue(double min); 554 void setMinValue(double min);
550 /** 555 /**
551 * @return the minimum value. 556 * @return the minimum value.
552 */ 557 */
553 double minValue() const; 558 double minValue() const;
554 /** 559 /**
555 * Sets the maximum value. 560 * Sets the maximum value.
556 */ 561 */
557 void setMaxValue(double max); 562 void setMaxValue(double max);
558 /** 563 /**
559 * @return the maximum value. 564 * @return the maximum value.
560 */ 565 */
561 double maxValue() const; 566 double maxValue() const;
562 567
563 /** 568 /**
564 * Specifies the number of digits to use. 569 * Specifies the number of digits to use.
565 */ 570 */
566 void setPrecision(int precision); 571 void setPrecision(int precision);
567 572
568 /** 573 /**
569 * @return the reference point for @ref #relativeValue calculation 574 * @return the reference point for @ref #relativeValue calculation
570 * @since 3.1 575 * @since 3.1
571 */ 576 */
572 double referencePoint() const; 577 double referencePoint() const;
573 578
574 /** 579 /**
575 * @return the current value in units of @ref #referencePoint. 580 * @return the current value in units of @ref #referencePoint.
576 * @since 3.1 581 * @since 3.1
577 */ 582 */
578 double relativeValue() const; 583 double relativeValue() const;
579 584
580 /** 585 /**
581 * Sets the special value text. If set, the spin box will display 586 * Sets the special value text. If set, the spin box will display
582 * this text instead of the numeric value whenever the current 587 * this text instead of the numeric value whenever the current
583 * value is equal to @ref #minVal(). Typically this is used for indicating 588 * value is equal to @ref #minVal(). Typically this is used for indicating
584 * that the choice has a special (default) meaning. 589 * that the choice has a special (default) meaning.
585 */ 590 */
586 void setSpecialValueText(const QString& text); 591 void setSpecialValueText(const QString& text);
587 592
588 /** 593 /**
589 * @reimplemented 594 * @reimplemented
590 */ 595 */
591 virtual void setLabel(const QString & label, int a = AlignLeft | AlignTop); 596 virtual void setLabel(const QString & label, int a = Qt::AlignLeft | Qt::AlignTop);
592 /** 597 /**
593 * @reimplemented 598 * @reimplemented
594 */ 599 */
595 virtual QSize minimumSizeHint() const; 600 virtual QSize minimumSizeHint() const;
596 /** 601 /**
597 * @reimplemented 602 * @reimplemented
598 */ 603 */
599 virtual bool eventFilter(QObject*, QEvent*); 604 virtual bool eventFilter(QObject*, QEvent*);
600 605
601public slots: 606public slots:
602 /** 607 /**
603 * Sets the value of the control. 608 * Sets the value of the control.
604 */ 609 */
605 void setValue(double); 610 void setValue(double);
606 611
607 /** 612 /**
608 * Sets the value in units of @ref #referencePoint. 613 * Sets the value in units of @ref #referencePoint.
609 * @since 3.1 614 * @since 3.1
610 */ 615 */
611 void setRelativeValue(double); 616 void setRelativeValue(double);
612 617
613 /** 618 /**
614 * Sets the reference Point to @p ref. It @p ref == 0, emitting of 619 * Sets the reference Point to @p ref. It @p ref == 0, emitting of
615 * @ref #relativeValueChanged is blocked and @ref #relativeValue 620 * @ref #relativeValueChanged is blocked and @ref #relativeValue
616 * just returns 0. 621 * just returns 0.
617 * @since 3.1 622 * @since 3.1
618 */ 623 */
619 void setReferencePoint(double ref); 624 void setReferencePoint(double ref);
620 625
621 /** 626 /**
622 * Sets the suffix to be displayed to @p suffix. Use QString::null to disable 627 * Sets the suffix to be displayed to @p suffix. Use QString::null to disable
623 * this feature. Note that the suffix is attached to the value without any 628 * this feature. Note that the suffix is attached to the value without any
624 * spacing. So if you prefer to display a space separator, set suffix 629 * spacing. So if you prefer to display a space separator, set suffix
625 * to something like " cm". 630 * to something like " cm".
626 * @see #setSuffix() 631 * @see #setSuffix()
627 */ 632 */
628 void setSuffix(const QString &suffix); 633 void setSuffix(const QString &suffix);
629 634
630 /** 635 /**
631 * Sets the prefix to be displayed to @p prefix. Use QString::null to disable 636 * Sets the prefix to be displayed to @p prefix. Use QString::null to disable
632 * this feature. Note that the prefix is attached to the value without any 637 * this feature. Note that the prefix is attached to the value without any
633 * spacing. 638 * spacing.
634 * @see #setPrefix() 639 * @see #setPrefix()
635 */ 640 */
636 void setPrefix(const QString &prefix); 641 void setPrefix(const QString &prefix);
637 642
638signals: 643signals:
639 /** 644 /**
640 * Emitted every time the value changes (by calling @ref setValue() or 645 * Emitted every time the value changes (by calling @ref setValue() or
641 * by user interaction). 646 * by user interaction).
642 */ 647 */
643 void valueChanged(double); 648 void valueChanged(double);
644 /** 649 /**
645 * This is an overloaded member function, provided for 650 * This is an overloaded member function, provided for
646 * convenience. It essentially behaves like the above function. 651 * convenience. It essentially behaves like the above function.
647 * 652 *
648 * Contains the value in units of @ref #referencePoint. 653 * Contains the value in units of @ref #referencePoint.
649 * @since 3.1 654 * @since 3.1
650 */ 655 */
651 void relativeValueChanged(double); 656 void relativeValueChanged(double);
652 657
653private slots: 658private slots:
654 void sliderMoved(int); 659 void sliderMoved(int);
655 void slotEmitRelativeValueChanged(double); 660 void slotEmitRelativeValueChanged(double);
656 661
657protected: 662protected:
658 663
659 /** 664 /**
660 * @reimplemented 665 * @reimplemented
661 */ 666 */
662 virtual void doLayout(); 667 virtual void doLayout();
663 /** 668 /**
664 * @reimplemented 669 * @reimplemented
665 */ 670 */
666 void resizeEvent ( QResizeEvent * ); 671 void resizeEvent ( QResizeEvent * );
667 virtual void resetEditBox(); 672 virtual void resetEditBox();
668 673
669 // ### no longer used, remove when BIC allowed 674 // ### no longer used, remove when BIC allowed
670 KDoubleLine* edit; 675 KDoubleLine* edit;
671 676
672 bool m_range; 677 bool m_range;
673 double m_lower, m_upper, m_step; 678 double m_lower, m_upper, m_step;
674 // ### end no longer used 679 // ### end no longer used
675 680
676 QSize m_sizeEdit; 681 QSize m_sizeEdit;
677 682
678 friend class KDoubleLine; 683 friend class KDoubleLine;
679private: 684private:
680 void init(double value, double lower, double upper, 685 void init(double value, double lower, double upper,
681 double step, int precision); 686 double step, int precision);
682 double mapSliderToSpin(int) const; 687 double mapSliderToSpin(int) const;
683 void updateLegacyMembers(); 688 void updateLegacyMembers();
684 // ### no longer used, remove when BIC allowed: 689 // ### no longer used, remove when BIC allowed:
685 QString m_specialvalue, m_prefix, m_suffix; 690 QString m_specialvalue, m_prefix, m_suffix;
686 double m_value; 691 double m_value;
687 short m_precision; 692 short m_precision;
688 // ### end remove when BIC allowed 693 // ### end remove when BIC allowed
689 694
690protected: 695protected:
691 virtual void virtual_hook( int id, void* data ); 696 virtual void virtual_hook( int id, void* data );
692private: 697private:
693 class KDoubleNumInputPrivate; 698 class KDoubleNumInputPrivate;
694 KDoubleNumInputPrivate *d; 699 KDoubleNumInputPrivate *d;
695}; 700};
696 701
697 702
698/* ------------------------------------------------------------------------ */ 703/* ------------------------------------------------------------------------ */
699 704
700/** 705/**
701 * A @ref QSpinBox with support for arbitrary base numbers 706 * A @ref QSpinBox with support for arbitrary base numbers
702 * (e.g. hexadecimal). 707 * (e.g. hexadecimal).
703 * 708 *
704 * The class provides an easy interface to use other 709 * The class provides an easy interface to use other
705 * numeric systems than the decimal. 710 * numeric systems than the decimal.
706 * 711 *
707 * @short A @ref QSpinBox with support for arbitrary base numbers. 712 * @short A @ref QSpinBox with support for arbitrary base numbers.
708 */ 713 */
709class KIntSpinBox : public QSpinBox 714class KIntSpinBox : public QSpinBox
710{ 715{
711 Q_OBJECT 716 Q_OBJECT
712 Q_PROPERTY( int base READ base WRITE setBase ) 717 Q_PROPERTY( int base READ base WRITE setBase )
713 718
714public: 719public:
715 720
716 /** 721 /**
717 * Constructor. 722 * Constructor.
718 * 723 *
719 * Constructs a widget with an integer inputline with a little scrollbar 724 * Constructs a widget with an integer inputline with a little scrollbar
720 * and a slider, with minimal value 0, maximal value 99, step 1, base 10 725 * and a slider, with minimal value 0, maximal value 99, step 1, base 10
721 * and initial value 0. 726 * and initial value 0.
722 */ 727 */
723 KIntSpinBox( QWidget *parent=0, const char *name=0); 728 KIntSpinBox( QWidget *parent=0, const char *name=0);
724 729
725 /** 730 /**
726 * Constructor. 731 * Constructor.
727 * 732 *
728 * Constructs a widget with an integer inputline with a little scrollbar 733 * Constructs a widget with an integer inputline with a little scrollbar
729 * and a slider. 734 * and a slider.
730 * 735 *
731 * @param lower The lowest valid value. 736 * @param lower The lowest valid value.
732 * @param upper The greatest valid value. 737 * @param upper The greatest valid value.
733 * @param step The step size of the scrollbar. 738 * @param step The step size of the scrollbar.
734 * @param value The actual value. 739 * @param value The actual value.
735 * @param base The base of the used number system. 740 * @param base The base of the used number system.
736 * @param parent The parent of the widget. 741 * @param parent The parent of the widget.
737 * @param name The Name of the widget. 742 * @param name The Name of the widget.
738 */ 743 */
739 KIntSpinBox(int lower, int upper, int step, int value, int base = 10, 744 KIntSpinBox(int lower, int upper, int step, int value, int base = 10,
740 QWidget* parent = 0, const char* name = 0); 745 QWidget* parent = 0, const char* name = 0);
741 746
742 /** 747 /**
743 * Destructor. 748 * Destructor.
744 */ 749 */
745 virtual ~KIntSpinBox(); 750 virtual ~KIntSpinBox();
746 751
747 /** 752 /**
748 * Sets the base in which the numbers in the spin box are represented. 753 * Sets the base in which the numbers in the spin box are represented.
749 */ 754 */
750 void setBase(int base); 755 void setBase(int base);
751 /** 756 /**
752 * @return the base in which numbers in the spin box are represented. 757 * @return the base in which numbers in the spin box are represented.
753 */ 758 */
754 int base() const; 759 int base() const;
755 /** 760 /**
756 * sets focus and optionally marks all text 761 * sets focus and optionally marks all text
757 * 762 *
758 */ 763 */
759 void setEditFocus(bool mark); 764 void setEditFocus(bool mark);
760 765
766 void setValidator(const QValidator *v) {
767 lineEdit()->setValidator(v);
768 }
769
761protected: 770protected:
762 771
763 /** 772 /**
764 * Overloaded the method in QSpinBox 773 * Overloaded the method in QSpinBox
765 * to make use of the base given in the constructor. 774 * to make use of the base given in the constructor.
766 */ 775 */
767 virtual QString mapValueToText(int); 776 virtual QString mapValueToText(int);
768 777
769 /** 778 /**
770 * Overloaded the method in QSpinBox 779 * Overloaded the method in QSpinBox
771 * to make use of the base given in the constructor. 780 * to make use of the base given in the constructor.
772 */ 781 */
773 virtual int mapTextToValue(bool*); 782 virtual int mapTextToValue(bool*);
774 783
775private: 784private:
776 int val_base; 785 int val_base;
777protected: 786protected:
778 virtual void virtual_hook( int id, void* data ); 787 virtual void virtual_hook( int id, void* data );
779private: 788private:
780 class KIntSpinBoxPrivate; 789 class KIntSpinBoxPrivate;
781 KIntSpinBoxPrivate *d; 790 KIntSpinBoxPrivate *d;
782}; 791};
783 792
784 793
785/* --------------------------------------------------------------------------- */ 794/* --------------------------------------------------------------------------- */
786 795
787/** 796/**
788 This class provides a spin box for fractional numbers. 797 This class provides a spin box for fractional numbers.
789 798
790 @sect Parameters 799 @sect Parameters
791 800
792 There are a number of interdependent parameters whose relation to 801 There are a number of interdependent parameters whose relation to
793 each other you need to understand in order to make successful use 802 each other you need to understand in order to make successful use
794 of the spin box. 803 of the spin box.
795 804
796 @li precision: The number of decimals after the decimal point. 805 @li precision: The number of decimals after the decimal point.
797 @li maxValue/minValue: upper and lower bound of the valid range 806 @li maxValue/minValue: upper and lower bound of the valid range
798 @li lineStep: the size of the step that is taken when the user hits 807 @li lineStep: the size of the step that is taken when the user hits
799 the up or down buttons 808 the up or down buttons
800 809
801 Since we work with fixed-point numbers internally, the maximum 810 Since we work with fixed-point numbers internally, the maximum
802 precision is a function of the valid range and vice versa. More 811 precision is a function of the valid range and vice versa. More
803 precisely, the following relations hold: 812 precisely, the following relations hold:
804 <pre> 813 <pre>
805 max( abs(minValue()), abs(maxValue() ) <= INT_MAX/10^precision 814 max( abs(minValue()), abs(maxValue() ) <= INT_MAX/10^precision
806 maxPrecision = floor( log10( INT_MAX/max(abs(minValue()),abs(maxValue())) ) ) 815 maxPrecision = floor( log10( INT_MAX/max(abs(minValue()),abs(maxValue())) ) )
807 </pre> 816 </pre>
808 817
809 Since the value, bounds and step are rounded to the current 818 Since the value, bounds and step are rounded to the current
810 precision, you may experience that the order of setting above 819 precision, you may experience that the order of setting above
811 parameters matters. E.g. the following are @em not equivalent (try 820 parameters matters. E.g. the following are @em not equivalent (try
812 it!): 821 it!):
813 822
814 <pre> 823 <pre>
815 // sets precision, 824 // sets precision,
816 // then min/max value (rounded to precison and clipped to obtainable range if needed) 825 // then min/max value (rounded to precison and clipped to obtainable range if needed)
817 // then value and lineStep 826 // then value and lineStep
818 KDoubleSpinBox * spin = new KDoubleSpinBox( 0, 9.999, 0.001, 4.321, 3, this ); 827 KDoubleSpinBox * spin = new KDoubleSpinBox( 0, 9.999, 0.001, 4.321, 3, this );
819 828
820 // sets minValue to 0; maxValue to 10.00(!); value to 4.32(!) and only then 829 // sets minValue to 0; maxValue to 10.00(!); value to 4.32(!) and only then
821 // increases the precision - too late, since e.g. value has already been rounded... 830 // increases the precision - too late, since e.g. value has already been rounded...
822 KDpubleSpinBox * spin = new KDoubleSpinBox( this ); 831 KDpubleSpinBox * spin = new KDoubleSpinBox( this );
823 spin->setMinValue( 0 ); 832 spin->setMinValue( 0 );
824 spin->setMaxValue( 9.999 ); 833 spin->setMaxValue( 9.999 );
825 spin->setValue( 4.321 ); 834 spin->setValue( 4.321 );
826 spin->setPrecision( 3 ); 835 spin->setPrecision( 3 );
827 </pre> 836 </pre>
828 837
829 @short A spin box for fractional numbers. 838 @short A spin box for fractional numbers.
830 @author Marc Mutz <mutz@kde.org> 839 @author Marc Mutz <mutz@kde.org>
831 @version $Id$ 840 @version $Id$
832 @since 3.1 841 @since 3.1
833**/ 842**/
834 843
835class KDoubleSpinBox : public QSpinBox { 844class KDoubleSpinBox : public QSpinBox {
836 Q_OBJECT 845 Q_OBJECT
837 Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers ) 846 Q_PROPERTY( bool acceptLocalizedNumbers READ acceptLocalizedNumbers WRITE setAcceptLocalizedNumbers )
838 Q_OVERRIDE( double maxValue READ maxValue WRITE setMaxValue ) 847 Q_OVERRIDE( double maxValue READ maxValue WRITE setMaxValue )
839 Q_OVERRIDE( double minValue READ minValue WRITE setMinValue ) 848 Q_OVERRIDE( double minValue READ minValue WRITE setMinValue )
840 Q_OVERRIDE( double lineStep READ lineStep WRITE setLineStep ) 849 Q_OVERRIDE( double lineStep READ lineStep WRITE setLineStep )
841 Q_OVERRIDE( double value READ value WRITE setValue ) 850 Q_OVERRIDE( double value READ value WRITE setValue )
842 Q_PROPERTY( int precision READ precision WRITE setPrecision ) 851 Q_PROPERTY( int precision READ precision WRITE setPrecision )
843 852
844public: 853public:
845 /** Constructs a @ref KDoubleSpinBox with parent @p parent and 854 /** Constructs a @ref KDoubleSpinBox with parent @p parent and
846 default values for range and value (whatever @ref QRangeControl 855 default values for range and value (whatever @ref QRangeControl
847 uses) and precision (2). */ 856 uses) and precision (2). */
848 KDoubleSpinBox( QWidget * parent=0, const char * name=0 ); 857 KDoubleSpinBox( QWidget * parent=0, const char * name=0 );
849 /** Constructs a @ref KDoubleSpinBox with parent @p parent, range 858 /** Constructs a @ref KDoubleSpinBox with parent @p parent, range
850 [@p lower,@p upper], @ref lineStep @p step, @ref precision @p 859 [@p lower,@p upper], @ref lineStep @p step, @ref precision @p
851 precision and initial value @p value. */ 860 precision and initial value @p value. */
852 KDoubleSpinBox( double lower, double upper, double step, double value, 861 KDoubleSpinBox( double lower, double upper, double step, double value,
853 int precision=2, QWidget * parent=0, const char * name=0 ); 862 int precision=2, QWidget * parent=0, const char * name=0 );
854 863
855 virtual ~KDoubleSpinBox(); 864 virtual ~KDoubleSpinBox();
856 865
857 /** @return whether the spinbox uses localized numbers */ 866 /** @return whether the spinbox uses localized numbers */
858 bool acceptLocalizedNumbers() const; 867 bool acceptLocalizedNumbers() const;
859 /** Sets whether to use and accept localized numbers as returned by 868 /** Sets whether to use and accept localized numbers as returned by
860 @ref KLocale::formatNumber() */ 869 @ref KLocale::formatNumber() */
861 virtual void setAcceptLocalizedNumbers( bool accept ); 870 virtual void setAcceptLocalizedNumbers( bool accept );
862 871
863 /** Sets a new range for the spin box values. Note that @p lower, @p 872 /** Sets a new range for the spin box values. Note that @p lower, @p
864 upper and @p step are rounded to @p precision decimal points 873 upper and @p step are rounded to @p precision decimal points
865 first. */ 874 first. */
866 void setRange( double lower, double upper, double step=0.01, int precision=2 ); 875 void setRange( double lower, double upper, double step=0.01, int precision=2 );
867 876
868 /** @return the current number of decimal points displayed. */ 877 /** @return the current number of decimal points displayed. */
869 int precision() const; 878 int precision() const;
870 /** Equivalent to @ref setPrecsion( @p precison, @p false ); Needed 879 /** Equivalent to @ref setPrecsion( @p precison, @p false ); Needed
871 since Qt's moc doesn't ignore trailing parameters with default 880 since Qt's moc doesn't ignore trailing parameters with default
872 args when searching for a property setter method. */ 881 args when searching for a property setter method. */
873 void setPrecision( int precision ); 882 void setPrecision( int precision );
874 /** Sets the number of decimal points to use. Note that there is a 883 /** Sets the number of decimal points to use. Note that there is a
875 tradeoff between the precision used and the available range of 884 tradeoff between the precision used and the available range of
876 values. See the class docs for more. 885 values. See the class docs for more.
877 @param precision the new number of decimal points to use 886 @param precision the new number of decimal points to use
878 887
879 @param force disables checking of bound violations that can 888 @param force disables checking of bound violations that can
880 arise if you increase the precision so much that the 889 arise if you increase the precision so much that the
881 minimum and maximum values can't be represented 890 minimum and maximum values can't be represented
882 anymore. Disabling is useful if you don't want to keep 891 anymore. Disabling is useful if you don't want to keep
883 the current min and max values anyway. This is what 892 the current min and max values anyway. This is what
884 e.g. @ref setRange() does. 893 e.g. @ref setRange() does.
885 **/ 894 **/
886 virtual void setPrecision( int precision, bool force ); 895 virtual void setPrecision( int precision, bool force );
887 896
888 /** @return the current value */ 897 /** @return the current value */
889 double value() const; 898 double value() const;
890 /** @return the current lower bound */ 899 /** @return the current lower bound */
891 double minValue() const; 900 double minValue() const;
892 /** Sets the lower bound of the range to @p value, subject to the 901 /** Sets the lower bound of the range to @p value, subject to the
893 contraints that @p value is first rounded to the current 902 contraints that @p value is first rounded to the current
894 precision and then clipped to the maximum representable 903 precision and then clipped to the maximum representable
895 interval. 904 interval.
896 @see maxValue, minValue, setMaxValue, setRange 905 @see maxValue, minValue, setMaxValue, setRange
897 */ 906 */
898 void setMinValue( double value ); 907 void setMinValue( double value );
899 /** @return the current upper bound */ 908 /** @return the current upper bound */
900 double maxValue() const; 909 double maxValue() const;
901 /** Sets the upper bound of the range to @p value, subject to the 910 /** Sets the upper bound of the range to @p value, subject to the
902 contraints that @p value is first rounded to the current 911 contraints that @p value is first rounded to the current
903 precision and then clipped to the maximum representable 912 precision and then clipped to the maximum representable
904 interval. 913 interval.
905 @see minValue, maxValue, setMinValue, setRange 914 @see minValue, maxValue, setMinValue, setRange
906 */ 915 */
907 void setMaxValue( double value ); 916 void setMaxValue( double value );
908 917
909 /** @return the current step size */ 918 /** @return the current step size */
910 double lineStep() const; 919 double lineStep() const;
911 /** Sets the step size for clicking the up/down buttons to @p step, 920 /** Sets the step size for clicking the up/down buttons to @p step,
912 subject to the constraints that @p step is first rounded to the 921 subject to the constraints that @p step is first rounded to the
913 current precision and then clipped to the meaningful interval 922 current precision and then clipped to the meaningful interval
914 [1, @p maxValue - @p minValue]. */ 923 [1, @p maxValue - @p minValue]. */
915 void setLineStep( double step ); 924 void setLineStep( double step );
916 925
917 /** Overridden to ignore any setValidator() calls. */ 926 /** Overridden to ignore any setValidator() calls. */
918 void setValidator( const QValidator * ); 927 void setValidator( const QValidator * );
919 928
920signals: 929signals:
921 /** Emitted whenever @ref QSpinBox::valueChanged( int ) is emitted. */ 930 /** Emitted whenever @ref QSpinBox::valueChanged( int ) is emitted. */
922 void valueChanged( double value ); 931 void valueChanged( double value );
923 932
924public slots: 933public slots:
925 /** Sets the current value to @p value, cubject to the constraints 934 /** Sets the current value to @p value, cubject to the constraints
926 that @p value is frist rounded to the current precision and then 935 that @p value is frist rounded to the current precision and then
927 clipped to the interval [@p minvalue(),@p maxValue()]. */ 936 clipped to the interval [@p minvalue(),@p maxValue()]. */
928 virtual void setValue( double value ); 937 virtual void setValue( double value );
929 938
930protected: 939protected:
931 virtual QString mapValueToText(int); 940 virtual QString mapValueToText(int);
932 virtual int mapTextToValue(bool*); 941 virtual int mapTextToValue(bool*);
933 942
934protected slots: 943protected slots:
935 void slotValueChanged( int value ); 944 void slotValueChanged( int value );
936 945
937protected: 946protected:
938 virtual void virtual_hook( int id, void* data ); 947 virtual void virtual_hook( int id, void* data );
939private: 948private:
940 typedef QSpinBox base; 949 typedef QSpinBox base;
941 void updateValidator(); 950 void updateValidator();
942 int maxPrecision() const; 951 int maxPrecision() const;
943 952
944 class Private; 953 class Private;
945 Private * d; 954 Private * d;
946}; 955};
947 956
948#endif // K_NUMINPUT_H 957#endif // K_NUMINPUT_H
diff --git a/microkde/kdeui/kpopupmenu.cpp b/microkde/kdeui/kpopupmenu.cpp
index 96d2a87..7e1503c 100644
--- a/microkde/kdeui/kpopupmenu.cpp
+++ b/microkde/kdeui/kpopupmenu.cpp
@@ -1,19 +1,22 @@
1 1
2#include <kpopupmenu.h> 2#include <kpopupmenu.h>
3#include <qtimer.h> 3#include <qtimer.h>
4//Added by qt3to4:
5#include <QFocusEvent>
6#include <Q3PopupMenu>
4 7
5 8
6KPopupMenu::KPopupMenu ( QWidget * parent, const char * name ) 9KPopupMenu::KPopupMenu ( QWidget * parent, const char * name )
7 : QPopupMenu ( parent, name ) {;} 10 : Q3PopupMenu ( parent, name ) {;}
8 11
9 12
10 13
11KMenuBar::KMenuBar ( QWidget * parent, const char * name ) 14KMenuBar::KMenuBar ( QWidget * parent, const char * name )
12 : QPEMenuBar ( parent, name ) {} 15 : QPEMenuBar ( parent, name ) {}
13 16
14void KMenuBar::focusOutEvent ( QFocusEvent * e) 17void KMenuBar::focusOutEvent ( QFocusEvent * e)
15{ 18{
16 QPEMenuBar::focusOutEvent( e ); 19 QPEMenuBar::focusOutEvent( e );
17 QTimer::singleShot( 100, this, SIGNAL ( lostFocus() ) ); 20 QTimer::singleShot( 100, this, SIGNAL ( lostFocus() ) );
18 21
19} 22}
diff --git a/microkde/kdeui/kpopupmenu.h b/microkde/kdeui/kpopupmenu.h
index fd00f36..1c903ad 100644
--- a/microkde/kdeui/kpopupmenu.h
+++ b/microkde/kdeui/kpopupmenu.h
@@ -1,32 +1,34 @@
1#ifndef KPOPUPMENU_H 1#ifndef KPOPUPMENU_H
2#define KPOPUPMENU_H 2#define KPOPUPMENU_H
3 3
4#include <qpopupmenu.h> 4#include <q3popupmenu.h>
5//Added by qt3to4:
6#include <QFocusEvent>
5#ifdef DESKTOP_VERSION 7#ifdef DESKTOP_VERSION
6#include <qmenubar.h> 8#include <qmenubar.h>
7#define QPEMenuBar QMenuBar 9#define QPEMenuBar QMenuBar
8#else 10#else
9#include <qpe/qpemenubar.h> 11#include <qpe/qpemenubar.h>
10#endif 12#endif
11 13
12class KPopupMenu : public QPopupMenu 14class KPopupMenu : public Q3PopupMenu
13{ 15{
14Q_OBJECT 16Q_OBJECT
15 public: 17 public:
16 KPopupMenu ( QWidget * parent=0, const char * name=0 ); 18 KPopupMenu ( QWidget * parent=0, const char * name=0 );
17 19
18}; 20};
19 21
20 22
21class KMenuBar : public QPEMenuBar 23class KMenuBar : public QPEMenuBar
22{ 24{
23Q_OBJECT 25Q_OBJECT
24 public: 26 public:
25 KMenuBar ( QWidget * parent=0, const char * name=0 ); 27 KMenuBar ( QWidget * parent=0, const char * name=0 );
26 signals: 28 signals:
27 void lostFocus(); 29 void lostFocus();
28 protected: 30 protected:
29 void focusOutEvent ( QFocusEvent * e); 31 void focusOutEvent ( QFocusEvent * e);
30}; 32};
31 33
32#endif 34#endif
diff --git a/microkde/kdeui/kseparator.cpp b/microkde/kdeui/kseparator.cpp
index d028420..66000f0 100644
--- a/microkde/kdeui/kseparator.cpp
+++ b/microkde/kdeui/kseparator.cpp
@@ -1,121 +1,123 @@
1/* 1/*
2 * Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> 2 * Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as published by 5 * it under the terms of the GNU Library General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or 6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. 7 * (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Library General Public License for more details. 12 * GNU Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * 17 *
18 */ 18 */
19 19
20#include <qstyle.h> 20#include <qstyle.h>
21//Added by qt3to4:
22#include <Q3Frame>
21 23
22#include <kdebug.h> 24#include <kdebug.h>
23//US #include <kapplication.h> 25//US #include <kapplication.h>
24 26
25//US #include "kseparator.moc" 27//US #include "kseparator.moc"
26 28
27#include "kseparator.h" 29#include "kseparator.h"
28 30
29KSeparator::KSeparator(QWidget* parent, const char* name, WFlags f) 31KSeparator::KSeparator(QWidget* parent, const char* name, Qt::WFlags f)
30 : QFrame(parent, name, f) 32 : Q3Frame(parent, name, f)
31{ 33{
32 setLineWidth(1); 34 setLineWidth(1);
33 setMidLineWidth(0); 35 setMidLineWidth(0);
34 setOrientation( HLine ); 36 setOrientation( HLine );
35} 37}
36 38
37 39
38 40
39KSeparator::KSeparator(int orientation, QWidget* parent, const char* name, WFlags f) 41KSeparator::KSeparator(int orientation, QWidget* parent, const char* name, Qt::WFlags f)
40 : QFrame(parent, name, f) 42 : Q3Frame(parent, name, f)
41{ 43{
42 setLineWidth(1); 44 setLineWidth(1);
43 setMidLineWidth(0); 45 setMidLineWidth(0);
44 setOrientation( orientation ); 46 setOrientation( orientation );
45} 47}
46 48
47 49
48 50
49void KSeparator::setOrientation(int orientation) 51void KSeparator::setOrientation(int orientation)
50{ 52{
51 switch(orientation) 53 switch(orientation)
52 { 54 {
53 case Vertical: 55 case Qt::Vertical:
54 case VLine: 56 case VLine:
55 setFrameStyle( QFrame::VLine | QFrame::Sunken ); 57 setFrameStyle( Q3Frame::VLine | Q3Frame::Sunken );
56 setMinimumSize(2, 0); 58 setMinimumSize(2, 0);
57 break; 59 break;
58 60
59 default: 61 default:
60 kdWarning() << "KSeparator::setOrientation(): invalid orientation, using default orientation HLine" << endl; 62 kdWarning() << "KSeparator::setOrientation(): invalid orientation, using default orientation HLine" << endl;
61 63
62 case Horizontal: 64 case Qt::Horizontal:
63 case HLine: 65 case HLine:
64 setFrameStyle( QFrame::HLine | QFrame::Sunken ); 66 setFrameStyle( Q3Frame::HLine | Q3Frame::Sunken );
65 setMinimumSize(0, 2); 67 setMinimumSize(0, 2);
66 break; 68 break;
67 } 69 }
68} 70}
69 71
70 72
71 73
72int KSeparator::orientation() const 74int KSeparator::orientation() const
73{ 75{
74 if ( frameStyle() & VLine ) 76 if ( frameStyle() & VLine )
75 return VLine; 77 return VLine;
76 78
77 if ( frameStyle() & HLine ) 79 if ( frameStyle() & HLine )
78 return HLine; 80 return HLine;
79 81
80 return 0; 82 return 0;
81} 83}
82 84
83void KSeparator::drawFrame(QPainter *p) 85void KSeparator::drawFrame(QPainter *p)
84{ 86{
85 QPointp1, p2; 87 QPointp1, p2;
86 QRectr = frameRect(); 88 QRectr = frameRect();
87 const QColorGroup & g = colorGroup(); 89 const QColorGroup & g = colorGroup();
88 90
89 if ( frameStyle() & HLine ) { 91 if ( frameStyle() & HLine ) {
90 p1 = QPoint( r.x(), r.height()/2 ); 92 p1 = QPoint( r.x(), r.height()/2 );
91 p2 = QPoint( r.x()+r.width(), p1.y() ); 93 p2 = QPoint( r.x()+r.width(), p1.y() );
92 } 94 }
93 else { 95 else {
94 p1 = QPoint( r.x()+r.width()/2, 0 ); 96 p1 = QPoint( r.x()+r.width()/2, 0 );
95 p2 = QPoint( p1.x(), r.height() ); 97 p2 = QPoint( p1.x(), r.height() );
96 } 98 }
97 99
98/*US 100/*US
99 QStyleOption opt( lineWidth(), midLineWidth() ); 101 QStyleOption opt( lineWidth(), midLineWidth() );
100 style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, 102 style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g,
101 QStyle::Style_Sunken, opt ); 103 QStyle::Style_Sunken, opt );
102*/ 104*/
103//LRstyle().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, lineWidth(), midLineWidth()); 105//LRstyle().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, lineWidth(), midLineWidth());
104 106
105} 107}
106 108
107 109
108QSize KSeparator::sizeHint() const 110QSize KSeparator::sizeHint() const
109{ 111{
110 if ( frameStyle() & VLine ) 112 if ( frameStyle() & VLine )
111 return QSize(2, 0); 113 return QSize(2, 0);
112 114
113 if ( frameStyle() & HLine ) 115 if ( frameStyle() & HLine )
114 return QSize(0, 2); 116 return QSize(0, 2);
115 117
116 return QSize(-1, -1); 118 return QSize(-1, -1);
117} 119}
118 120
119void KSeparator::virtual_hook( int, void* ) 121void KSeparator::virtual_hook( int, void* )
120{ /*BASE::virtual_hook( id, data );*/ } 122{ /*BASE::virtual_hook( id, data );*/ }
121 123
diff --git a/microkde/kdeui/kseparator.h b/microkde/kdeui/kseparator.h
index 6d2712a..c673475 100644
--- a/microkde/kdeui/kseparator.h
+++ b/microkde/kdeui/kseparator.h
@@ -1,77 +1,77 @@
1/* 1/*
2 * Copyright (C) 1997 Michael Roth <mroth@wirlweb.de> 2 * Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
3 * 3 *
4 * This program is free software; you can redistribute it and/or modify 4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Library General Public License as published by 5 * it under the terms of the GNU Library General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or 6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version. 7 * (at your option) any later version.
8 * 8 *
9 * This program is distributed in the hope that it will be useful, 9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Library General Public License for more details. 12 * GNU Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this program; if not, write to the Free Software 15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 * 17 *
18 */ 18 */
19 19
20#ifndef __KSEPARATOR_H__ 20#ifndef __KSEPARATOR_H__
21#define __KSEPARATOR_H__ 21#define __KSEPARATOR_H__
22 22
23#include <qframe.h> 23#include <q3frame.h>
24 24
25/** 25/**
26 * Standard horizontal or vertical separator. 26 * Standard horizontal or vertical separator.
27 * 27 *
28 * @author Michael Roth <mroth@wirlweb.de> 28 * @author Michael Roth <mroth@wirlweb.de>
29 * @version $Id$ 29 * @version $Id$
30*/ 30*/
31class KSeparator : public QFrame 31class KSeparator : public Q3Frame
32{ 32{
33 Q_OBJECT 33 Q_OBJECT
34 Q_PROPERTY( int orientation READ orientation WRITE setOrientation ) 34 Q_PROPERTY( int orientation READ orientation WRITE setOrientation )
35 public: 35 public:
36 /** 36 /**
37 * Constructor. 37 * Constructor.
38 **/ 38 **/
39 KSeparator(QWidget* parent=0, const char* name=0, WFlags f=0); 39 KSeparator(QWidget* parent=0, const char* name=0, Qt::WFlags f=0);
40 /** 40 /**
41 * Constructor. 41 * Constructor.
42 * 42 *
43 * @param orientation Set the orientation of the separator. 43 * @param orientation Set the orientation of the separator.
44 * Possible values are HLine or Horizontal and VLine or Vertical. 44 * Possible values are HLine or Horizontal and VLine or Vertical.
45 **/ 45 **/
46 KSeparator(int orientation, QWidget* parent=0, const char* name=0, 46 KSeparator(int orientation, QWidget* parent=0, const char* name=0,
47 WFlags f=0); 47 Qt::WFlags f=0);
48 48
49 /** 49 /**
50 * Returns the orientation of the separator. 50 * Returns the orientation of the separator.
51 * 51 *
52 * Possible values are VLine and HLine. 52 * Possible values are VLine and HLine.
53 **/ 53 **/
54 int orientation() const; 54 int orientation() const;
55 55
56 /** 56 /**
57 * Set the orientation of the separator to @p orient 57 * Set the orientation of the separator to @p orient
58 * 58 *
59 * Possible values are VLine and HLine. 59 * Possible values are VLine and HLine.
60 */ 60 */
61 void setOrientation(int orient); 61 void setOrientation(int orient);
62 62
63 /** 63 /**
64 * The recommended height (width) for a horizontal (vertical) separator. 64 * The recommended height (width) for a horizontal (vertical) separator.
65 **/ 65 **/
66 virtual QSize sizeHint() const; 66 virtual QSize sizeHint() const;
67 67
68protected: 68protected:
69 virtual void drawFrame( QPainter * ); 69 virtual void drawFrame( QPainter * );
70protected: 70protected:
71 virtual void virtual_hook( int id, void* data ); 71 virtual void virtual_hook( int id, void* data );
72private: 72private:
73 class KSeparatorPrivate* d; 73 class KSeparatorPrivate* d;
74}; 74};
75 75
76 76
77#endif // __KSEPARATOR_H__ 77#endif // __KSEPARATOR_H__
diff --git a/microkde/kdeui/ksqueezedtextlabel.cpp b/microkde/kdeui/ksqueezedtextlabel.cpp
index 37fa29a..e2c61fd 100644
--- a/microkde/kdeui/ksqueezedtextlabel.cpp
+++ b/microkde/kdeui/ksqueezedtextlabel.cpp
@@ -1,107 +1,110 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Ronny Standtke <Ronny.Standtke@gmx.de> 2 Copyright (C) 2000 Ronny Standtke <Ronny.Standtke@gmx.de>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19#include "ksqueezedtextlabel.h" 19#include "ksqueezedtextlabel.h"
20#include <qtooltip.h> 20#include <qtooltip.h>
21//Added by qt3to4:
22#include <QResizeEvent>
23#include <QLabel>
21 24
22KSqueezedTextLabel::KSqueezedTextLabel( const QString &text , QWidget *parent, const char *name ) 25KSqueezedTextLabel::KSqueezedTextLabel( const QString &text , QWidget *parent, const char *name )
23 : QLabel ( parent, name ) { 26 : QLabel ( parent, name ) {
24 setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed )); 27 setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ));
25 fullText = text; 28 fullText = text;
26 squeezeTextToLabel(); 29 squeezeTextToLabel();
27} 30}
28 31
29KSqueezedTextLabel::KSqueezedTextLabel( QWidget *parent, const char *name ) 32KSqueezedTextLabel::KSqueezedTextLabel( QWidget *parent, const char *name )
30 : QLabel ( parent, name ) { 33 : QLabel ( parent, name ) {
31 setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed )); 34 setSizePolicy(QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ));
32} 35}
33 36
34void KSqueezedTextLabel::resizeEvent( QResizeEvent * ) { 37void KSqueezedTextLabel::resizeEvent( QResizeEvent * ) {
35 squeezeTextToLabel(); 38 squeezeTextToLabel();
36} 39}
37 40
38QSize KSqueezedTextLabel::minimumSizeHint() const 41QSize KSqueezedTextLabel::minimumSizeHint() const
39{ 42{
40 QSize sh = QLabel::minimumSizeHint(); 43 QSize sh = QLabel::minimumSizeHint();
41 sh.setWidth(-1); 44 sh.setWidth(-1);
42 return sh; 45 return sh;
43} 46}
44 47
45void KSqueezedTextLabel::setText( const QString &text ) { 48void KSqueezedTextLabel::setText( const QString &text ) {
46 fullText = text; 49 fullText = text;
47 squeezeTextToLabel(); 50 squeezeTextToLabel();
48} 51}
49 52
50void KSqueezedTextLabel::squeezeTextToLabel() { 53void KSqueezedTextLabel::squeezeTextToLabel() {
51 QFontMetrics fm(fontMetrics()); 54 QFontMetrics fm(fontMetrics());
52 int labelWidth = size().width(); 55 int labelWidth = size().width();
53 int textWidth = fm.width(fullText); 56 int textWidth = fm.width(fullText);
54 if (textWidth > labelWidth) { 57 if (textWidth > labelWidth) {
55 // start with the dots only 58 // start with the dots only
56 QString squeezedText = "..."; 59 QString squeezedText = "...";
57 int squeezedWidth = fm.width(squeezedText); 60 int squeezedWidth = fm.width(squeezedText);
58 61
59 // estimate how many letters we can add to the dots on both sides 62 // estimate how many letters we can add to the dots on both sides
60 int letters = fullText.length() * (labelWidth - squeezedWidth) / textWidth / 2; 63 int letters = fullText.length() * (labelWidth - squeezedWidth) / textWidth / 2;
61 if (labelWidth < squeezedWidth) letters=1; 64 if (labelWidth < squeezedWidth) letters=1;
62 squeezedText = fullText.left(letters) + "..." + fullText.right(letters); 65 squeezedText = fullText.left(letters) + "..." + fullText.right(letters);
63 squeezedWidth = fm.width(squeezedText); 66 squeezedWidth = fm.width(squeezedText);
64 67
65 if (squeezedWidth < labelWidth) { 68 if (squeezedWidth < labelWidth) {
66 // we estimated too short 69 // we estimated too short
67 // add letters while text < label 70 // add letters while text < label
68 do { 71 do {
69 letters++; 72 letters++;
70 squeezedText = fullText.left(letters) + "..." + fullText.right(letters); 73 squeezedText = fullText.left(letters) + "..." + fullText.right(letters);
71 squeezedWidth = fm.width(squeezedText); 74 squeezedWidth = fm.width(squeezedText);
72 } while (squeezedWidth < labelWidth); 75 } while (squeezedWidth < labelWidth);
73 letters--; 76 letters--;
74 squeezedText = fullText.left(letters) + "..." + fullText.right(letters); 77 squeezedText = fullText.left(letters) + "..." + fullText.right(letters);
75 } else if (squeezedWidth > labelWidth) { 78 } else if (squeezedWidth > labelWidth) {
76 // we estimated too long 79 // we estimated too long
77 // remove letters while text > label 80 // remove letters while text > label
78 do { 81 do {
79 letters--; 82 letters--;
80 squeezedText = fullText.left(letters) + "..." + fullText.right(letters); 83 squeezedText = fullText.left(letters) + "..." + fullText.right(letters);
81 squeezedWidth = fm.width(squeezedText); 84 squeezedWidth = fm.width(squeezedText);
82 } while (letters && squeezedWidth > labelWidth); 85 } while (letters && squeezedWidth > labelWidth);
83 } 86 }
84 87
85 if (letters < 5) { 88 if (letters < 5) {
86 // too few letters added -> we give up squeezing 89 // too few letters added -> we give up squeezing
87 QLabel::setText(fullText); 90 QLabel::setText(fullText);
88 } else { 91 } else {
89 QLabel::setText(squeezedText); 92 QLabel::setText(squeezedText);
90 } 93 }
91 94
92//US QToolTip::remove( this ); 95//US QToolTip::remove( this );
93//US QToolTip::add( this, fullText ); 96//US QToolTip::add( this, fullText );
94 97
95 } else { 98 } else {
96 QLabel::setText(fullText); 99 QLabel::setText(fullText);
97 100
98//US QToolTip::remove( this ); 101//US QToolTip::remove( this );
99//US QToolTip::hide(); 102//US QToolTip::hide();
100 103
101 }; 104 };
102} 105}
103 106
104void KSqueezedTextLabel::virtual_hook( int, void* ) 107void KSqueezedTextLabel::virtual_hook( int, void* )
105{ /*BASE::virtual_hook( id, data );*/ } 108{ /*BASE::virtual_hook( id, data );*/ }
106 109
107//US #include "ksqueezedtextlabel.moc" 110//US #include "ksqueezedtextlabel.moc"
diff --git a/microkde/kdeui/ksqueezedtextlabel.h b/microkde/kdeui/ksqueezedtextlabel.h
index 1634adc..487d0b0 100644
--- a/microkde/kdeui/ksqueezedtextlabel.h
+++ b/microkde/kdeui/ksqueezedtextlabel.h
@@ -1,76 +1,78 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Ronny Standtke <Ronny.Standtke@gmx.de> 2 Copyright (C) 2000 Ronny Standtke <Ronny.Standtke@gmx.de>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19#ifndef KSQUEEZEDTEXTLABEL_H 19#ifndef KSQUEEZEDTEXTLABEL_H
20#define KSQUEEZEDTEXTLABEL_H 20#define KSQUEEZEDTEXTLABEL_H
21 21
22#include <qlabel.h> 22#include <qlabel.h>
23//Added by qt3to4:
24#include <QResizeEvent>
23 25
24/** 26/**
25 * A label class that squeezes its text into the label 27 * A label class that squeezes its text into the label
26 * 28 *
27 * If the text is too long to fit into the label it is divided into 29 * If the text is too long to fit into the label it is divided into
28 * remaining left and right parts which are separated by three dots. 30 * remaining left and right parts which are separated by three dots.
29 * 31 *
30 * Example: 32 * Example:
31 * http://www.kde.org/documentation/index.html could be squeezed to 33 * http://www.kde.org/documentation/index.html could be squeezed to
32 * http://www.kde...ion/index.html 34 * http://www.kde...ion/index.html
33 35
34 * @short A replacement for QLabel that squeezes its text 36 * @short A replacement for QLabel that squeezes its text
35 * @author Ronny Standtke <Ronny.Standtke@gmx.de> 37 * @author Ronny Standtke <Ronny.Standtke@gmx.de>
36 * @version $Id$ 38 * @version $Id$
37 * 39 *
38 */ 40 */
39 41
40/* 42/*
41 * @ref QLabel 43 * @ref QLabel
42 */ 44 */
43class KSqueezedTextLabel : public QLabel { 45class KSqueezedTextLabel : public QLabel {
44 Q_OBJECT 46 Q_OBJECT
45 47
46public: 48public:
47 /** 49 /**
48 * Default constructor. 50 * Default constructor.
49 */ 51 */
50 KSqueezedTextLabel( QWidget *parent, const char *name = 0 ); 52 KSqueezedTextLabel( QWidget *parent, const char *name = 0 );
51 KSqueezedTextLabel( const QString &text, QWidget *parent, const char *name = 0 ); 53 KSqueezedTextLabel( const QString &text, QWidget *parent, const char *name = 0 );
52 54
53 virtual QSize minimumSizeHint() const; 55 virtual QSize minimumSizeHint() const;
54 56
55public slots: 57public slots:
56 void setText( const QString & ); 58 void setText( const QString & );
57 59
58protected: 60protected:
59 /** 61 /**
60 * used when widget is resized 62 * used when widget is resized
61 */ 63 */
62 void resizeEvent( QResizeEvent * ); 64 void resizeEvent( QResizeEvent * );
63 /** 65 /**
64 * does the dirty work 66 * does the dirty work
65 */ 67 */
66 void squeezeTextToLabel(); 68 void squeezeTextToLabel();
67 QString fullText; 69 QString fullText;
68 70
69protected: 71protected:
70 virtual void virtual_hook( int id, void* data ); 72 virtual void virtual_hook( int id, void* data );
71private: 73private:
72 class KSqueezedTextLabelPrivate; 74 class KSqueezedTextLabelPrivate;
73 KSqueezedTextLabelPrivate *d; 75 KSqueezedTextLabelPrivate *d;
74}; 76};
75 77
76#endif // KSQUEEZEDTEXTLABEL_H 78#endif // KSQUEEZEDTEXTLABEL_H
diff --git a/microkde/kdeui/kstdaction.cpp b/microkde/kdeui/kstdaction.cpp
index cfd7b54..f0d162d 100644
--- a/microkde/kdeui/kstdaction.cpp
+++ b/microkde/kdeui/kstdaction.cpp
@@ -1,362 +1,362 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000 Kurt Granroth <granroth@kde.org> 2 Copyright (C) 1999,2000 Kurt Granroth <granroth@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19#include "kstdaction.h" 19#include "kstdaction.h"
20 20
21#include <qtoolbutton.h> 21#include <qtoolbutton.h>
22#include <qwhatsthis.h> 22#include <q3whatsthis.h>
23 23
24//US #include <kaboutdata.h> 24//US #include <kaboutdata.h>
25#include <kaction.h> 25#include <kaction.h>
26#include <kapplication.h> 26#include <kapplication.h>
27#include <kdebug.h> 27#include <kdebug.h>
28#include <kglobal.h> 28#include <kglobal.h>
29#include <kiconloader.h> 29#include <kiconloader.h>
30#include <klocale.h> 30#include <klocale.h>
31//US #include <kstdaccel.h> 31//US #include <kstdaccel.h>
32//US #include <kmainwindow.h> 32//US #include <kmainwindow.h>
33 33
34namespace KStdAction 34namespace KStdAction
35{ 35{
36 36
37struct KStdActionInfo 37struct KStdActionInfo
38{ 38{
39 StdAction id; 39 StdAction id;
40 /*USKStdAccel::StdAccel idAccel;*/ 40 /*USKStdAccel::StdAccel idAccel;*/
41 const char* psName; 41 const char* psName;
42 const char* psLabel; 42 const char* psLabel;
43 const char* psWhatsThis; 43 const char* psWhatsThis;
44 const char* psIconName; 44 const char* psIconName;
45}; 45};
46 46
47const KStdActionInfo g_rgActionInfo[] = 47const KStdActionInfo g_rgActionInfo[] =
48{ 48{
49 { New, /*USKStdAccel::New,*/ "file_new", I18N_NOOP("&New"), 0, "filenew" }, 49 { New, /*USKStdAccel::New,*/ "file_new", I18N_NOOP("&New"), 0, "filenew" },
50 { Open, /*USKStdAccel::Open,*/ "file_open", I18N_NOOP("&Open..."), 0, "fileopen" }, 50 { Open, /*USKStdAccel::Open,*/ "file_open", I18N_NOOP("&Open..."), 0, "fileopen" },
51 { OpenRecent, /*USKStdAccel::AccelNone,*/ "file_open_recent", I18N_NOOP("Open &Recent"), 0, 0 }, 51 { OpenRecent, /*USKStdAccel::AccelNone,*/ "file_open_recent", I18N_NOOP("Open &Recent"), 0, 0 },
52 { Save, /*USKStdAccel::Save,*/ "file_save", I18N_NOOP("&Save"), 0, "filesave" }, 52 { Save, /*USKStdAccel::Save,*/ "file_save", I18N_NOOP("&Save"), 0, "filesave" },
53 { SaveAs, /*USKStdAccel::AccelNone,*/ "file_save_as", I18N_NOOP("Save &As..."), 0, "filesaveas" }, 53 { SaveAs, /*USKStdAccel::AccelNone,*/ "file_save_as", I18N_NOOP("Save &As..."), 0, "filesaveas" },
54 { Revert, /*USKStdAccel::AccelNone,*/ "file_revert", I18N_NOOP("Re&vert"), 0, "revert" }, 54 { Revert, /*USKStdAccel::AccelNone,*/ "file_revert", I18N_NOOP("Re&vert"), 0, "revert" },
55 { Close, /*USKStdAccel::Close,*/ "file_close", I18N_NOOP("&Close"), 0, "fileclose" }, 55 { Close, /*USKStdAccel::Close,*/ "file_close", I18N_NOOP("&Close"), 0, "fileclose" },
56 { Print, /*USKStdAccel::Print,*/ "file_print", I18N_NOOP("&Print..."), 0, "fileprint" }, 56 { Print, /*USKStdAccel::Print,*/ "file_print", I18N_NOOP("&Print..."), 0, "fileprint" },
57 { PrintPreview, /*USKStdAccel::AccelNone,*/ "file_print_preview", I18N_NOOP("Print Previe&w..."), 0, "filequickprint" }, 57 { PrintPreview, /*USKStdAccel::AccelNone,*/ "file_print_preview", I18N_NOOP("Print Previe&w..."), 0, "filequickprint" },
58 { Mail, /*USKStdAccel::AccelNone,*/ "file_mail", I18N_NOOP("&Mail..."), 0, "mail_send" }, 58 { Mail, /*USKStdAccel::AccelNone,*/ "file_mail", I18N_NOOP("&Mail..."), 0, "mail_send" },
59 { Quit, /*USKStdAccel::Quit,*/ "file_quit", I18N_NOOP("&Exit"), 0, "exit" }, 59 { Quit, /*USKStdAccel::Quit,*/ "file_quit", I18N_NOOP("&Exit"), 0, "exit" },
60 60
61 { Undo, /*USKStdAccel::Undo,*/ "edit_undo", I18N_NOOP("&Undo"), 0, "undo" }, 61 { Undo, /*USKStdAccel::Undo,*/ "edit_undo", I18N_NOOP("&Undo"), 0, "undo" },
62 { Redo, /*USKStdAccel::Redo,*/ "edit_redo", I18N_NOOP("Re&do"), 0, "redo" }, 62 { Redo, /*USKStdAccel::Redo,*/ "edit_redo", I18N_NOOP("Re&do"), 0, "redo" },
63 { Cut, /*USKStdAccel::Cut,*/ "edit_cut", I18N_NOOP("Cu&t"), 0, "editcut" }, 63 { Cut, /*USKStdAccel::Cut,*/ "edit_cut", I18N_NOOP("Cu&t"), 0, "editcut" },
64 { Copy, /*USKStdAccel::Copy,*/ "edit_copy", I18N_NOOP("&Copy"), 0, "editcopy" }, 64 { Copy, /*USKStdAccel::Copy,*/ "edit_copy", I18N_NOOP("&Copy"), 0, "editcopy" },
65 { Paste, /*USKStdAccel::Paste,*/ "edit_paste", I18N_NOOP("&Paste"), 0, "editpaste" }, 65 { Paste, /*USKStdAccel::Paste,*/ "edit_paste", I18N_NOOP("&Paste"), 0, "editpaste" },
66 { SelectAll, /*USKStdAccel::SelectAll,*/ "edit_select_all", I18N_NOOP("Select &All"), 0, 0 }, 66 { SelectAll, /*USKStdAccel::SelectAll,*/ "edit_select_all", I18N_NOOP("Select &All"), 0, 0 },
67 { Deselect, /*USKStdAccel::Deselect,*/ "edit_deselect", I18N_NOOP("Dese&lect"), 0, 0 }, 67 { Deselect, /*USKStdAccel::Deselect,*/ "edit_deselect", I18N_NOOP("Dese&lect"), 0, 0 },
68 { Find, /*USKStdAccel::Find,*/ "edit_find", I18N_NOOP("&Find..."), 0, "find" }, 68 { Find, /*USKStdAccel::Find,*/ "edit_find", I18N_NOOP("&Find..."), 0, "find" },
69 { FindNext, /*USKStdAccel::FindNext,*/ "edit_find_next", I18N_NOOP("Find &Next"), 0, "next" }, 69 { FindNext, /*USKStdAccel::FindNext,*/ "edit_find_next", I18N_NOOP("Find &Next"), 0, "next" },
70 // FIXME: rename edit_find_last to edit_find_prev for KDE 4 70 // FIXME: rename edit_find_last to edit_find_prev for KDE 4
71 { FindPrev, /*USKStdAccel::FindPrev,*/ "edit_find_last", I18N_NOOP("Find Pre&vious"), 0, "previous" }, 71 { FindPrev, /*USKStdAccel::FindPrev,*/ "edit_find_last", I18N_NOOP("Find Pre&vious"), 0, "previous" },
72 { Replace, /*USKStdAccel::Replace,*/ "edit_replace", I18N_NOOP("&Replace..."), 0, 0 }, 72 { Replace, /*USKStdAccel::Replace,*/ "edit_replace", I18N_NOOP("&Replace..."), 0, 0 },
73 73
74 { ActualSize, /*USKStdAccel::AccelNone,*/ "view_actual_size", I18N_NOOP("&Actual Size"), 0, 0 }, 74 { ActualSize, /*USKStdAccel::AccelNone,*/ "view_actual_size", I18N_NOOP("&Actual Size"), 0, 0 },
75 { FitToPage, /*USKStdAccel::AccelNone,*/ "view_fit_to_page", I18N_NOOP("&Fit to Page"), 0, 0 }, 75 { FitToPage, /*USKStdAccel::AccelNone,*/ "view_fit_to_page", I18N_NOOP("&Fit to Page"), 0, 0 },
76 { FitToWidth, /*USKStdAccel::AccelNone,*/ "view_fit_to_width", I18N_NOOP("Fit to Page &Width"), 0, 0 }, 76 { FitToWidth, /*USKStdAccel::AccelNone,*/ "view_fit_to_width", I18N_NOOP("Fit to Page &Width"), 0, 0 },
77 { FitToHeight, /*USKStdAccel::AccelNone,*/ "view_fit_to_height", I18N_NOOP("Fit to Page &Height"), 0, 0 }, 77 { FitToHeight, /*USKStdAccel::AccelNone,*/ "view_fit_to_height", I18N_NOOP("Fit to Page &Height"), 0, 0 },
78 { ZoomIn, /*USKStdAccel::ZoomIn,*/ "view_zoom_in", I18N_NOOP("Zoom &In"), 0, "viewmag+" }, 78 { ZoomIn, /*USKStdAccel::ZoomIn,*/ "view_zoom_in", I18N_NOOP("Zoom &In"), 0, "viewmag+" },
79 { ZoomOut, /*USKStdAccel::ZoomOut,*/ "view_zoom_out", I18N_NOOP("Zoom &Out"), 0, "viewmag-" }, 79 { ZoomOut, /*USKStdAccel::ZoomOut,*/ "view_zoom_out", I18N_NOOP("Zoom &Out"), 0, "viewmag-" },
80 { Zoom, /*USKStdAccel::AccelNone,*/ "view_zoom", I18N_NOOP("&Zoom..."), 0, "viewmag" }, 80 { Zoom, /*USKStdAccel::AccelNone,*/ "view_zoom", I18N_NOOP("&Zoom..."), 0, "viewmag" },
81 { Redisplay, /*USKStdAccel::AccelNone,*/ "view_redisplay", I18N_NOOP("&Redisplay"), 0, "reload" }, 81 { Redisplay, /*USKStdAccel::AccelNone,*/ "view_redisplay", I18N_NOOP("&Redisplay"), 0, "reload" },
82 82
83 { Up, /*USKStdAccel::Up,*/ "go_up", I18N_NOOP("&Up"), 0, "up" }, 83 { Up, /*USKStdAccel::Up,*/ "go_up", I18N_NOOP("&Up"), 0, "up" },
84 // The following three have special i18n() needs for sLabel 84 // The following three have special i18n() needs for sLabel
85 { Back, /*USKStdAccel::Back,*/ "go_back", 0, 0, "back" }, 85 { Back, /*USKStdAccel::Back,*/ "go_back", 0, 0, "back" },
86 { Forward, /*USKStdAccel::Forward,*/ "go_forward", 0, 0, "forward" }, 86 { Forward, /*USKStdAccel::Forward,*/ "go_forward", 0, 0, "forward" },
87 { Home, /*USKStdAccel::Home,*/ "go_home", 0, 0, "gohome" }, 87 { Home, /*USKStdAccel::Home,*/ "go_home", 0, 0, "gohome" },
88 { Prior, /*USKStdAccel::Prior,*/ "go_previous", I18N_NOOP("&Previous Page"), 0, "previous" }, 88 { Prior, /*USKStdAccel::Prior,*/ "go_previous", I18N_NOOP("&Previous Page"), 0, "previous" },
89 { Next, /*USKStdAccel::Next,*/ "go_next", I18N_NOOP("&Next Page"), 0, "next" }, 89 { Next, /*USKStdAccel::Next,*/ "go_next", I18N_NOOP("&Next Page"), 0, "next" },
90 { Goto, /*USKStdAccel::AccelNone,*/ "go_goto", I18N_NOOP("&Go To..."), 0, 0 }, 90 { Goto, /*USKStdAccel::AccelNone,*/ "go_goto", I18N_NOOP("&Go To..."), 0, 0 },
91 { GotoPage, /*USKStdAccel::AccelNone,*/ "go_goto_page", I18N_NOOP("&Go to Page..."), 0, "goto" }, 91 { GotoPage, /*USKStdAccel::AccelNone,*/ "go_goto_page", I18N_NOOP("&Go to Page..."), 0, "goto" },
92 { GotoLine, /*USKStdAccel::GotoLine,*/ "go_goto_line", I18N_NOOP("&Go to Line..."), 0, 0 }, 92 { GotoLine, /*USKStdAccel::GotoLine,*/ "go_goto_line", I18N_NOOP("&Go to Line..."), 0, 0 },
93 { FirstPage, /*USKStdAccel::Home,*/ "go_first", I18N_NOOP("&First Page"), 0, "top" }, 93 { FirstPage, /*USKStdAccel::Home,*/ "go_first", I18N_NOOP("&First Page"), 0, "top" },
94 { LastPage, /*USKStdAccel::End,*/ "go_last", I18N_NOOP("&Last Page"), 0, "bottom" }, 94 { LastPage, /*USKStdAccel::End,*/ "go_last", I18N_NOOP("&Last Page"), 0, "bottom" },
95 95
96 { AddBookmark, /*USKStdAccel::AddBookmark,*/ "bookmark_add", I18N_NOOP("&Add Bookmark"), 0, "bookmark_add" }, 96 { AddBookmark, /*USKStdAccel::AddBookmark,*/ "bookmark_add", I18N_NOOP("&Add Bookmark"), 0, "bookmark_add" },
97 { EditBookmarks, /*USKStdAccel::AccelNone,*/ "bookmark_edit", I18N_NOOP("&Edit Bookmarks"), 0, "bookmark" }, 97 { EditBookmarks, /*USKStdAccel::AccelNone,*/ "bookmark_edit", I18N_NOOP("&Edit Bookmarks"), 0, "bookmark" },
98 98
99 { Spelling, /*USKStdAccel::AccelNone,*/ "tools_spelling", I18N_NOOP("&Spelling..."), 0, "spellcheck" }, 99 { Spelling, /*USKStdAccel::AccelNone,*/ "tools_spelling", I18N_NOOP("&Spelling..."), 0, "spellcheck" },
100 100
101 { ShowMenubar, /*USKStdAccel::ShowMenubar,*/ "options_show_menubar", I18N_NOOP("Show &Menubar"), 0, "showmenu" }, 101 { ShowMenubar, /*USKStdAccel::ShowMenubar,*/ "options_show_menubar", I18N_NOOP("Show &Menubar"), 0, "showmenu" },
102 { ShowToolbar, /*USKStdAccel::AccelNone,*/ "options_show_toolbar", I18N_NOOP("Show &Toolbar"), 0, 0 }, 102 { ShowToolbar, /*USKStdAccel::AccelNone,*/ "options_show_toolbar", I18N_NOOP("Show &Toolbar"), 0, 0 },
103 { ShowStatusbar, /*USKStdAccel::AccelNone,*/ "options_show_statusbar", I18N_NOOP("Show St&atusbar"), 0, 0 }, 103 { ShowStatusbar, /*USKStdAccel::AccelNone,*/ "options_show_statusbar", I18N_NOOP("Show St&atusbar"), 0, 0 },
104 { SaveOptions, /*USKStdAccel::AccelNone,*/ "options_save_options", I18N_NOOP("&Save Settings"), 0, 0 }, 104 { SaveOptions, /*USKStdAccel::AccelNone,*/ "options_save_options", I18N_NOOP("&Save Settings"), 0, 0 },
105 { KeyBindings, /*USKStdAccel::AccelNone,*/ "options_configure_keybinding", I18N_NOOP("Configure S&hortcuts..."), 0,"configure_shortcuts" }, 105 { KeyBindings, /*USKStdAccel::AccelNone,*/ "options_configure_keybinding", I18N_NOOP("Configure S&hortcuts..."), 0,"configure_shortcuts" },
106 { Preferences, /*USKStdAccel::AccelNone,*/ "options_configure", I18N_NOOP("&Configure %1..."), 0, "configure" }, 106 { Preferences, /*USKStdAccel::AccelNone,*/ "options_configure", I18N_NOOP("&Configure %1..."), 0, "configure" },
107 { ConfigureToolbars, /*USKStdAccel::AccelNone,*/ "options_configure_toolbars", I18N_NOOP("Configure Tool&bars..."), 0,"configure_toolbars" }, 107 { ConfigureToolbars, /*USKStdAccel::AccelNone,*/ "options_configure_toolbars", I18N_NOOP("Configure Tool&bars..."), 0,"configure_toolbars" },
108 { ConfigureNotifications, /*USKStdAccel::AccelNone,*/ "options_configure_notifications", I18N_NOOP("Configure &Notifications..."), 0, "knotify" }, 108 { ConfigureNotifications, /*USKStdAccel::AccelNone,*/ "options_configure_notifications", I18N_NOOP("Configure &Notifications..."), 0, "knotify" },
109 109
110 { Help, /*USKStdAccel::Help,*/ "help", 0, 0, "help" }, 110 { Help, /*USKStdAccel::Help,*/ "help", 0, 0, "help" },
111 { HelpContents, /*USKStdAccel::AccelNone,*/ "help_contents", I18N_NOOP("%1 &Handbook"), 0, "contents" }, 111 { HelpContents, /*USKStdAccel::AccelNone,*/ "help_contents", I18N_NOOP("%1 &Handbook"), 0, "contents" },
112 { WhatsThis, /*USKStdAccel::WhatsThis,*/ "help_whats_this", I18N_NOOP("What's &This?"), 0, "contexthelp" }, 112 { WhatsThis, /*USKStdAccel::WhatsThis,*/ "help_whats_this", I18N_NOOP("What's &This?"), 0, "contexthelp" },
113 { TipofDay, /*USKStdAccel::AccelNone,*/ "help_show_tip", I18N_NOOP("Tip of the &Day"), 0, "idea" }, 113 { TipofDay, /*USKStdAccel::AccelNone,*/ "help_show_tip", I18N_NOOP("Tip of the &Day"), 0, "idea" },
114 { ReportBug, /*USKStdAccel::AccelNone,*/ "help_report_bug", I18N_NOOP("&Report Bug..."), 0, 0 }, 114 { ReportBug, /*USKStdAccel::AccelNone,*/ "help_report_bug", I18N_NOOP("&Report Bug..."), 0, 0 },
115 { AboutApp, /*USKStdAccel::AccelNone,*/ "help_about_app", I18N_NOOP("&About %1"), 0, 0 }, 115 { AboutApp, /*USKStdAccel::AccelNone,*/ "help_about_app", I18N_NOOP("&About %1"), 0, 0 },
116 { AboutKDE, /*USKStdAccel::AccelNone,*/ "help_about_kde", I18N_NOOP("About &KDE"), 0,"about_kde" }, 116 { AboutKDE, /*USKStdAccel::AccelNone,*/ "help_about_kde", I18N_NOOP("About &KDE"), 0,"about_kde" },
117 { ActionNone, /*USKStdAccel::AccelNone,*/ 0, 0, 0, 0 } 117 { ActionNone, /*USKStdAccel::AccelNone,*/ 0, 0, 0, 0 }
118}; 118};
119 119
120static const KStdActionInfo* infoPtr( StdAction id ) 120static const KStdActionInfo* infoPtr( StdAction id )
121{ 121{
122 for( uint i = 0; g_rgActionInfo[i].id != ActionNone; i++ ) { 122 for( uint i = 0; g_rgActionInfo[i].id != ActionNone; i++ ) {
123 if( g_rgActionInfo[i].id == id ) 123 if( g_rgActionInfo[i].id == id )
124 return &g_rgActionInfo[i]; 124 return &g_rgActionInfo[i];
125 } 125 }
126 return 0; 126 return 0;
127} 127}
128 128
129QStringList stdNames() 129QStringList stdNames()
130{ 130{
131 QStringList result; 131 QStringList result;
132 132
133 for( uint i = 0; g_rgActionInfo[i].id != ActionNone; i++ ) 133 for( uint i = 0; g_rgActionInfo[i].id != ActionNone; i++ )
134 if (g_rgActionInfo[i].psLabel) 134 if (g_rgActionInfo[i].psLabel)
135 result.append(i18n(g_rgActionInfo[i].psLabel)); 135 result.append(i18n(g_rgActionInfo[i].psLabel));
136 return result; 136 return result;
137} 137}
138 138
139KAction* create( StdAction id, const char *name, const QObject *recvr, const char *slot, KActionCollection* parent ) 139KAction* create( StdAction id, const char *name, const QObject *recvr, const char *slot, KActionCollection* parent )
140{ 140{
141 KAction* pAction = 0; 141 KAction* pAction = 0;
142 const KStdActionInfo* pInfo = infoPtr( id ); 142 const KStdActionInfo* pInfo = infoPtr( id );
143 kdDebug(125) << "KStdAction::create( " << id << "=" << (pInfo ? pInfo->psName : (const char*)0) << ", " << parent << ", " << name << " )" << endl; // ellis 143 kdDebug(125) << "KStdAction::create( " << id << "=" << (pInfo ? pInfo->psName : (const char*)0) << ", " << parent << ", " << name << " )" << endl; // ellis
144 if( pInfo ) { 144 if( pInfo ) {
145 QString sLabel, iconName = pInfo->psIconName; 145 QString sLabel, iconName = pInfo->psIconName;
146 switch( id ) { 146 switch( id ) {
147 case Back: sLabel = i18n("go back", "&Back"); 147 case Back: sLabel = i18n("go back", "&Back");
148 //US if (QApplication::reverseLayout() ) 148 //US if (QApplication::reverseLayout() )
149 //US iconName = "forward"; 149 //US iconName = "forward";
150 break; 150 break;
151 151
152 case Forward: sLabel = i18n("go forward", "&Forward"); 152 case Forward: sLabel = i18n("go forward", "&Forward");
153 //US if (QApplication::reverseLayout() ) 153 //US if (QApplication::reverseLayout() )
154 //US iconName = "back"; 154 //US iconName = "back";
155 break; 155 break;
156 156
157 case Home: sLabel = i18n("beginning (of line)", "&Home"); break; 157 case Home: sLabel = i18n("beginning (of line)", "&Home"); break;
158 case Help: sLabel = i18n("show help", "&Help"); break; 158 case Help: sLabel = i18n("show help", "&Help"); break;
159 //US case AboutApp: iconName = kapp->miniIconName(); 159 //US case AboutApp: iconName = kapp->miniIconName();
160 case Preferences: 160 case Preferences:
161 case HelpContents: 161 case HelpContents:
162 { 162 {
163 //US const KAboutData *aboutData = KGlobal::instance()->aboutData(); 163 //US const KAboutData *aboutData = KGlobal::instance()->aboutData();
164 //US QString appName = (aboutData) ? aboutData->programName() : QString::fromLatin1(qApp->name()); 164 //US QString appName = (aboutData) ? aboutData->programName() : QString::fromLatin1(qApp->name());
165 QString appName = QString::fromLatin1(KGlobal::getAppName()); 165 QString appName = QString::fromLatin1(KGlobal::getAppName());
166 sLabel = i18n(pInfo->psLabel).arg(appName); 166 sLabel = i18n(pInfo->psLabel).arg(appName);
167 } 167 }
168 break; 168 break;
169 default: sLabel = i18n(pInfo->psLabel); 169 default: sLabel = i18n(pInfo->psLabel);
170 } 170 }
171 171
172 /*US if (QApplication::reverseLayout()){ 172 /*US if (QApplication::reverseLayout()){
173 if (id == Prior) iconName = "next"; 173 if (id == Prior) iconName = "next";
174 if (id == Next ) iconName = "previous"; 174 if (id == Next ) iconName = "previous";
175 } 175 }
176 */ 176 */
177 //US KShortcut cut = KStdAccel::shortcut(pInfo->idAccel); 177 //US KShortcut cut = KStdAccel::shortcut(pInfo->idAccel);
178 KShortcut cut; 178 KShortcut cut;
179 switch( id ) { 179 switch( id ) {
180 case OpenRecent: 180 case OpenRecent:
181 pAction = new KRecentFilesAction( sLabel, cut, 181 pAction = new KRecentFilesAction( sLabel, cut,
182 recvr, slot, 182 recvr, slot,
183 parent, (name) ? name : pInfo->psName ); 183 parent, (name) ? name : pInfo->psName );
184 break; 184 break;
185 case ShowMenubar: 185 case ShowMenubar:
186 case ShowToolbar: 186 case ShowToolbar:
187 case ShowStatusbar: 187 case ShowStatusbar:
188 KToggleAction *ret; 188 KToggleAction *ret;
189 ret = new KToggleAction( sLabel, pInfo->psIconName, cut, 189 ret = new KToggleAction( sLabel, pInfo->psIconName, cut,
190 recvr, slot, 190 recvr, slot,
191 parent, (name) ? name : pInfo->psName ); 191 parent, (name) ? name : pInfo->psName );
192 ret->setChecked( true ); 192 ret->setChecked( true );
193 pAction = ret; 193 pAction = ret;
194 break; 194 break;
195 default: 195 default:
196 pAction = new KAction( sLabel, iconName, cut, 196 pAction = new KAction( sLabel, iconName, cut,
197 recvr, slot, 197 recvr, slot,
198 parent, (name) ? name : pInfo->psName ); 198 parent, (name) ? name : pInfo->psName );
199 break; 199 break;
200 } 200 }
201 } 201 }
202 return pAction; 202 return pAction;
203} 203}
204 204
205const char* name( StdAction id ) 205const char* name( StdAction id )
206{ 206{
207 const KStdActionInfo* pInfo = infoPtr( id ); 207 const KStdActionInfo* pInfo = infoPtr( id );
208 return (pInfo) ? pInfo->psName : 0; 208 return (pInfo) ? pInfo->psName : 0;
209} 209}
210 210
211KAction *openNew( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 211KAction *openNew( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
212 { return KStdAction::create( New, name, recvr, slot, parent ); } 212 { return KStdAction::create( New, name, recvr, slot, parent ); }
213KAction *open( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 213KAction *open( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
214 { return KStdAction::create( Open, name, recvr, slot, parent ); } 214 { return KStdAction::create( Open, name, recvr, slot, parent ); }
215KRecentFilesAction *openRecent( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 215KRecentFilesAction *openRecent( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
216 { return (KRecentFilesAction*) KStdAction::create( OpenRecent, name, recvr, slot, parent ); } 216 { return (KRecentFilesAction*) KStdAction::create( OpenRecent, name, recvr, slot, parent ); }
217KAction *save( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 217KAction *save( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
218 { return KStdAction::create( Save, name, recvr, slot, parent ); } 218 { return KStdAction::create( Save, name, recvr, slot, parent ); }
219KAction *saveAs( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 219KAction *saveAs( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
220 { return KStdAction::create( SaveAs, name, recvr, slot, parent ); } 220 { return KStdAction::create( SaveAs, name, recvr, slot, parent ); }
221KAction *revert( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 221KAction *revert( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
222 { return KStdAction::create( Revert, name, recvr, slot, parent ); } 222 { return KStdAction::create( Revert, name, recvr, slot, parent ); }
223KAction *print( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 223KAction *print( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
224 { return KStdAction::create( Print, name, recvr, slot, parent ); } 224 { return KStdAction::create( Print, name, recvr, slot, parent ); }
225KAction *printPreview( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 225KAction *printPreview( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
226 { return KStdAction::create( PrintPreview, name, recvr, slot, parent ); } 226 { return KStdAction::create( PrintPreview, name, recvr, slot, parent ); }
227KAction *close( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 227KAction *close( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
228 { return KStdAction::create( Close, name, recvr, slot, parent ); } 228 { return KStdAction::create( Close, name, recvr, slot, parent ); }
229KAction *mail( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 229KAction *mail( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
230 { return KStdAction::create( Mail, name, recvr, slot, parent ); } 230 { return KStdAction::create( Mail, name, recvr, slot, parent ); }
231KAction *quit( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 231KAction *quit( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
232 { return KStdAction::create( Quit, name, recvr, slot, parent ); } 232 { return KStdAction::create( Quit, name, recvr, slot, parent ); }
233KAction *undo( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 233KAction *undo( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
234 { return KStdAction::create( Undo, name, recvr, slot, parent ); } 234 { return KStdAction::create( Undo, name, recvr, slot, parent ); }
235KAction *redo( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 235KAction *redo( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
236 { return KStdAction::create( Redo, name, recvr, slot, parent ); } 236 { return KStdAction::create( Redo, name, recvr, slot, parent ); }
237KAction *cut( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 237KAction *cut( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
238 { return KStdAction::create( Cut, name, recvr, slot, parent ); } 238 { return KStdAction::create( Cut, name, recvr, slot, parent ); }
239KAction *copy( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 239KAction *copy( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
240 { return KStdAction::create( Copy, name, recvr, slot, parent ); } 240 { return KStdAction::create( Copy, name, recvr, slot, parent ); }
241KAction *paste( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 241KAction *paste( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
242 { return KStdAction::create( Paste, name, recvr, slot, parent ); } 242 { return KStdAction::create( Paste, name, recvr, slot, parent ); }
243KAction *selectAll( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 243KAction *selectAll( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
244 { return KStdAction::create( SelectAll, name, recvr, slot, parent ); } 244 { return KStdAction::create( SelectAll, name, recvr, slot, parent ); }
245KAction *deselect( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 245KAction *deselect( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
246 { return KStdAction::create( Deselect, name, recvr, slot, parent ); } 246 { return KStdAction::create( Deselect, name, recvr, slot, parent ); }
247KAction *find( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 247KAction *find( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
248 { return KStdAction::create( Find, name, recvr, slot, parent ); } 248 { return KStdAction::create( Find, name, recvr, slot, parent ); }
249KAction *findNext( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 249KAction *findNext( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
250 { return KStdAction::create( FindNext, name, recvr, slot, parent ); } 250 { return KStdAction::create( FindNext, name, recvr, slot, parent ); }
251KAction *findPrev( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 251KAction *findPrev( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
252 { return KStdAction::create( FindPrev, name, recvr, slot, parent ); } 252 { return KStdAction::create( FindPrev, name, recvr, slot, parent ); }
253KAction *replace( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 253KAction *replace( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
254 { return KStdAction::create( Replace, name, recvr, slot, parent ); } 254 { return KStdAction::create( Replace, name, recvr, slot, parent ); }
255KAction *actualSize( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 255KAction *actualSize( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
256 { return KStdAction::create( ActualSize, name, recvr, slot, parent ); } 256 { return KStdAction::create( ActualSize, name, recvr, slot, parent ); }
257KAction *fitToPage( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 257KAction *fitToPage( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
258 { return KStdAction::create( FitToPage, name, recvr, slot, parent ); } 258 { return KStdAction::create( FitToPage, name, recvr, slot, parent ); }
259KAction *fitToWidth( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 259KAction *fitToWidth( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
260 { return KStdAction::create( FitToWidth, name, recvr, slot, parent ); } 260 { return KStdAction::create( FitToWidth, name, recvr, slot, parent ); }
261KAction *fitToHeight( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 261KAction *fitToHeight( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
262 { return KStdAction::create( FitToHeight, name, recvr, slot, parent ); } 262 { return KStdAction::create( FitToHeight, name, recvr, slot, parent ); }
263KAction *zoomIn( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 263KAction *zoomIn( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
264 { return KStdAction::create( ZoomIn, name, recvr, slot, parent ); } 264 { return KStdAction::create( ZoomIn, name, recvr, slot, parent ); }
265KAction *zoomOut( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 265KAction *zoomOut( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
266 { return KStdAction::create( ZoomOut, name, recvr, slot, parent ); } 266 { return KStdAction::create( ZoomOut, name, recvr, slot, parent ); }
267KAction *zoom( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 267KAction *zoom( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
268 { return KStdAction::create( Zoom, name, recvr, slot, parent ); } 268 { return KStdAction::create( Zoom, name, recvr, slot, parent ); }
269KAction *redisplay( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 269KAction *redisplay( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
270 { return KStdAction::create( Redisplay, name, recvr, slot, parent ); } 270 { return KStdAction::create( Redisplay, name, recvr, slot, parent ); }
271KAction *up( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 271KAction *up( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
272 { return KStdAction::create( Up, name, recvr, slot, parent ); } 272 { return KStdAction::create( Up, name, recvr, slot, parent ); }
273KAction *back( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 273KAction *back( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
274 { return KStdAction::create( Back, name, recvr, slot, parent ); } 274 { return KStdAction::create( Back, name, recvr, slot, parent ); }
275KAction *forward( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 275KAction *forward( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
276 { return KStdAction::create( Forward, name, recvr, slot, parent ); } 276 { return KStdAction::create( Forward, name, recvr, slot, parent ); }
277KAction *home( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 277KAction *home( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
278 { return KStdAction::create( Home, name, recvr, slot, parent ); } 278 { return KStdAction::create( Home, name, recvr, slot, parent ); }
279KAction *prior( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 279KAction *prior( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
280 { return KStdAction::create( Prior, name, recvr, slot, parent ); } 280 { return KStdAction::create( Prior, name, recvr, slot, parent ); }
281KAction *next( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 281KAction *next( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
282 { return KStdAction::create( Next, name, recvr, slot, parent ); } 282 { return KStdAction::create( Next, name, recvr, slot, parent ); }
283KAction *goTo( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 283KAction *goTo( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
284 { return KStdAction::create( Goto, name, recvr, slot, parent ); } 284 { return KStdAction::create( Goto, name, recvr, slot, parent ); }
285KAction *gotoPage( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 285KAction *gotoPage( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
286 { return KStdAction::create( GotoPage, name, recvr, slot, parent ); } 286 { return KStdAction::create( GotoPage, name, recvr, slot, parent ); }
287KAction *gotoLine( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 287KAction *gotoLine( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
288 { return KStdAction::create( GotoLine, name, recvr, slot, parent ); } 288 { return KStdAction::create( GotoLine, name, recvr, slot, parent ); }
289KAction *firstPage( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 289KAction *firstPage( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
290 { return KStdAction::create( FirstPage, name, recvr, slot, parent ); } 290 { return KStdAction::create( FirstPage, name, recvr, slot, parent ); }
291KAction *lastPage( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 291KAction *lastPage( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
292 { return KStdAction::create( LastPage, name, recvr, slot, parent ); } 292 { return KStdAction::create( LastPage, name, recvr, slot, parent ); }
293KAction *addBookmark( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 293KAction *addBookmark( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
294 { return KStdAction::create( AddBookmark, name, recvr, slot, parent ); } 294 { return KStdAction::create( AddBookmark, name, recvr, slot, parent ); }
295KAction *editBookmarks( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 295KAction *editBookmarks( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
296 { return KStdAction::create( EditBookmarks, name, recvr, slot, parent ); } 296 { return KStdAction::create( EditBookmarks, name, recvr, slot, parent ); }
297KAction *spelling( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 297KAction *spelling( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
298 { return KStdAction::create( Spelling, name, recvr, slot, parent ); } 298 { return KStdAction::create( Spelling, name, recvr, slot, parent ); }
299 299
300KToggleAction *showMenubar( const QObject *recvr, const char *slot, KActionCollection* parent, const char *_name ) 300KToggleAction *showMenubar( const QObject *recvr, const char *slot, KActionCollection* parent, const char *_name )
301{ 301{
302 KToggleAction *ret; 302 KToggleAction *ret;
303 ret = new KToggleAction(i18n("Show &Menubar"), "showmenu", /*US KStdAccel::shortcut(KStdAccel::ShowMenubar)*/0, recvr, slot, 303 ret = new KToggleAction(i18n("Show &Menubar"), "showmenu", /*US KStdAccel::shortcut(KStdAccel::ShowMenubar)*/0, recvr, slot,
304 parent, _name ? _name : name(ShowMenubar)); 304 parent, _name ? _name : name(ShowMenubar));
305 ret->setChecked(true); 305 ret->setChecked(true);
306 return ret; 306 return ret;
307} 307}
308 308
309KToggleAction *showToolbar( const QObject *recvr, const char *slot, KActionCollection* parent, const char *_name ) 309KToggleAction *showToolbar( const QObject *recvr, const char *slot, KActionCollection* parent, const char *_name )
310{ 310{
311 KToggleAction *ret; 311 KToggleAction *ret;
312 ret = new KToggleAction(i18n("Show &Toolbar"), 0, recvr, slot, parent, 312 ret = new KToggleAction(i18n("Show &Toolbar"), 0, recvr, slot, parent,
313 _name ? _name : name(ShowToolbar)); 313 _name ? _name : name(ShowToolbar));
314 ret->setChecked(true); 314 ret->setChecked(true);
315 return ret; 315 return ret;
316 316
317} 317}
318 318
319KToggleToolBarAction *showToolbar( const char* toolBarName, KActionCollection* parent, const char *_name ) 319KToggleToolBarAction *showToolbar( const char* toolBarName, KActionCollection* parent, const char *_name )
320{ 320{
321 KToggleToolBarAction *ret; 321 KToggleToolBarAction *ret;
322 ret = new KToggleToolBarAction(toolBarName, i18n("Show &Toolbar"), parent, 322 ret = new KToggleToolBarAction(toolBarName, i18n("Show &Toolbar"), parent,
323 _name ? _name : name(ShowToolbar)); 323 _name ? _name : name(ShowToolbar));
324 return ret; 324 return ret;
325} 325}
326 326
327KToggleAction *showStatusbar( const QObject *recvr, const char *slot, 327KToggleAction *showStatusbar( const QObject *recvr, const char *slot,
328 KActionCollection* parent, const char *_name ) 328 KActionCollection* parent, const char *_name )
329{ 329{
330 KToggleAction *ret; 330 KToggleAction *ret;
331 ret = new KToggleAction(i18n("Show St&atusbar"), 0, recvr, slot, parent, 331 ret = new KToggleAction(i18n("Show St&atusbar"), 0, recvr, slot, parent,
332 _name ? _name : name(ShowStatusbar)); 332 _name ? _name : name(ShowStatusbar));
333 ret->setChecked(true); 333 ret->setChecked(true);
334 return ret; 334 return ret;
335} 335}
336 336
337KAction *saveOptions( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 337KAction *saveOptions( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
338 { return KStdAction::create( SaveOptions, name, recvr, slot, parent ); } 338 { return KStdAction::create( SaveOptions, name, recvr, slot, parent ); }
339KAction *keyBindings( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 339KAction *keyBindings( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
340 { return KStdAction::create( KeyBindings, name, recvr, slot, parent ); } 340 { return KStdAction::create( KeyBindings, name, recvr, slot, parent ); }
341KAction *preferences( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 341KAction *preferences( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
342 { return KStdAction::create( Preferences, name, recvr, slot, parent ); } 342 { return KStdAction::create( Preferences, name, recvr, slot, parent ); }
343KAction *configureToolbars( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 343KAction *configureToolbars( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
344 { return KStdAction::create( ConfigureToolbars, name, recvr, slot, parent ); } 344 { return KStdAction::create( ConfigureToolbars, name, recvr, slot, parent ); }
345KAction *configureNotifications( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 345KAction *configureNotifications( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
346 { return KStdAction::create( ConfigureNotifications, name, recvr, slot, parent ); } 346 { return KStdAction::create( ConfigureNotifications, name, recvr, slot, parent ); }
347KAction *help( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 347KAction *help( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
348 { return KStdAction::create( Help, name, recvr, slot, parent ); } 348 { return KStdAction::create( Help, name, recvr, slot, parent ); }
349KAction *helpContents( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 349KAction *helpContents( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
350 { return KStdAction::create( HelpContents, name, recvr, slot, parent ); } 350 { return KStdAction::create( HelpContents, name, recvr, slot, parent ); }
351KAction *whatsThis( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 351KAction *whatsThis( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
352 { return KStdAction::create( WhatsThis, name, recvr, slot, parent ); } 352 { return KStdAction::create( WhatsThis, name, recvr, slot, parent ); }
353KAction *tipOfDay( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 353KAction *tipOfDay( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
354 { return KStdAction::create( TipofDay, name, recvr, slot, parent ); } 354 { return KStdAction::create( TipofDay, name, recvr, slot, parent ); }
355KAction *reportBug( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 355KAction *reportBug( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
356 { return KStdAction::create( ReportBug, name, recvr, slot, parent ); } 356 { return KStdAction::create( ReportBug, name, recvr, slot, parent ); }
357KAction *aboutApp( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 357KAction *aboutApp( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
358 { return KStdAction::create( AboutApp, name, recvr, slot, parent ); } 358 { return KStdAction::create( AboutApp, name, recvr, slot, parent ); }
359KAction *aboutKDE( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name ) 359KAction *aboutKDE( const QObject *recvr, const char *slot, KActionCollection* parent, const char *name )
360 { return KStdAction::create( AboutKDE, name, recvr, slot, parent ); } 360 { return KStdAction::create( AboutKDE, name, recvr, slot, parent ); }
361 361
362} 362}
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index 027e5e9..02db316 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -1,2278 +1,2289 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright 2 Copyright
3 (C) 2000 Reginald Stadlbauer (reggie@kde.org) 3 (C) 2000 Reginald Stadlbauer (reggie@kde.org)
4 (C) 1997, 1998 Stephan Kulow (coolo@kde.org) 4 (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) 5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
6 (C) 1997, 1998 Sven Radej (radej@kde.org) 6 (C) 1997, 1998 Sven Radej (radej@kde.org)
7 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) 7 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
8 (C) 1999 Chris Schlaeger (cs@kde.org) 8 (C) 1999 Chris Schlaeger (cs@kde.org)
9 (C) 1999 Kurt Granroth (granroth@kde.org) 9 (C) 1999 Kurt Granroth (granroth@kde.org)
10 10
11 This library is free software; you can redistribute it and/or 11 This library is free software; you can redistribute it and/or
12 modify it under the terms of the GNU Library General Public 12 modify it under the terms of the GNU Library General Public
13 License version 2 as published by the Free Software Foundation. 13 License version 2 as published by the Free Software Foundation.
14 14
15 This library is distributed in the hope that it will be useful, 15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of 16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Library General Public License for more details. 18 Library General Public License for more details.
19 19
20 You should have received a copy of the GNU Library General Public License 20 You should have received a copy of the GNU Library General Public License
21 along with this library; see the file COPYING.LIB. If not, write to 21 along with this library; see the file COPYING.LIB. If not, write to
22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 22 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. 23 Boston, MA 02111-1307, USA.
24*/ 24*/
25 25
26#ifdef KDE_USE_FINAL 26#ifdef KDE_USE_FINAL
27#undef Always 27#undef Always
28#include <qdockwindow.h> 28#include <q3dockwindow.h>
29#endif 29#endif
30 30//Added by qt3to4:
31#include <Q3ValueList>
32#include <Q3PtrList>
33#include <QPixmap>
34#include <Q3Frame>
35#include <QResizeEvent>
36#include <QMouseEvent>
37#include <QChildEvent>
38#include <QEvent>
39#include <QShowEvent>
40#include <QDesktopWidget>
41#include <QBoxLayout>
31 42
32 43
33#include "ktoolbar.h" 44#include "ktoolbar.h"
34#include "kmainwindow.h" 45#include "kmainwindow.h"
35 46
36#include <string.h> 47#include <string.h>
37 48
38#include <qpainter.h> 49#include <qpainter.h>
39#include <qtooltip.h> 50#include <qtooltip.h>
40#include <qdrawutil.h> 51#include <qdrawutil.h>
41#include <qstring.h> 52#include <qstring.h>
42#include <qrect.h> 53#include <qrect.h>
43#include <qobjectlist.h> 54#include <qobject.h>
44#include <qtimer.h> 55#include <qtimer.h>
45#include <qstyle.h> 56#include <qstyle.h>
46#include <qapplication.h> 57#include <qapplication.h>
47 58
48//US #include <config.h> 59//US #include <config.h>
49 60
50#include "klineedit.h" 61#include "klineedit.h"
51#include "kseparator.h" 62#include "kseparator.h"
52#include <klocale.h> 63#include <klocale.h>
53#include <kapplication.h> 64#include <kapplication.h>
54#include <kaction.h> 65#include <kaction.h>
55#include <kstdaction.h> 66#include <kstdaction.h>
56#include <kglobal.h> 67#include <kglobal.h>
57#include <kconfig.h> 68#include <kconfig.h>
58#include <kiconloader.h> 69#include <kiconloader.h>
59#include <kcombobox.h> 70#include <kcombobox.h>
60//US #include <kpopupmenu.h> 71//US #include <kpopupmenu.h>
61//US #include <kanimwidget.h> 72//US #include <kanimwidget.h>
62//US #include <kipc.h> 73//US #include <kipc.h>
63//US #include <kwin.h> 74//US #include <kwin.h>
64#include <kdebug.h> 75#include <kdebug.h>
65#include <qlayout.h> 76#include <qlayout.h>
66 77
67#include "ktoolbarbutton.h" 78#include "ktoolbarbutton.h"
68 79
69//US 80//US
70#include "kconfigbase.h" 81#include "kconfigbase.h"
71 82
72#include <qpopupmenu.h> 83#include <q3popupmenu.h>
73#include <qmainwindow.h> 84#include <q3mainwindow.h>
74 85
75enum { 86enum {
76 CONTEXT_TOP = 0, 87 CONTEXT_TOP = 0,
77 CONTEXT_LEFT = 1, 88 CONTEXT_LEFT = 1,
78 CONTEXT_RIGHT = 2, 89 CONTEXT_RIGHT = 2,
79 CONTEXT_BOTTOM = 3, 90 CONTEXT_BOTTOM = 3,
80 CONTEXT_FLOAT = 4, 91 CONTEXT_FLOAT = 4,
81 CONTEXT_FLAT = 5, 92 CONTEXT_FLAT = 5,
82 CONTEXT_ICONS = 6, 93 CONTEXT_ICONS = 6,
83 CONTEXT_TEXT = 7, 94 CONTEXT_TEXT = 7,
84 CONTEXT_TEXTRIGHT = 8, 95 CONTEXT_TEXTRIGHT = 8,
85 CONTEXT_TEXTUNDER = 9, 96 CONTEXT_TEXTUNDER = 9,
86 CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before 97 CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before
87}; 98};
88 99
89class KToolBarPrivate 100class KToolBarPrivate
90{ 101{
91public: 102public:
92 KToolBarPrivate() { 103 KToolBarPrivate() {
93 m_iconSize = 0; 104 m_iconSize = 0;
94 m_iconText = KToolBar::IconOnly; 105 m_iconText = KToolBar::IconOnly;
95 m_highlight = true; 106 m_highlight = true;
96 m_transparent = true; 107 m_transparent = true;
97 m_honorStyle = false; 108 m_honorStyle = false;
98 109
99 m_enableContext = true; 110 m_enableContext = true;
100 111
101 m_xmlguiClient = 0; 112 m_xmlguiClient = 0;
102 m_configurePlugged = false; 113 m_configurePlugged = false;
103 114
104//US oldPos = Qt::DockUnmanaged; 115//US oldPos = Qt::DockUnmanaged;
105 oldPos = QMainWindow::Unmanaged; 116 oldPos = Qt::Unmanaged;
106 117
107 modified = m_isHorizontal = positioned = FALSE; 118 modified = m_isHorizontal = positioned = FALSE;
108 119
109 HiddenDefault = false; 120 HiddenDefault = false;
110 IconSizeDefault = 0; 121 IconSizeDefault = 0;
111 IconTextDefault = "IconOnly"; 122 IconTextDefault = "IconOnly";
112 IndexDefault = -1; 123 IndexDefault = -1;
113 NewLineDefault = false; 124 NewLineDefault = false;
114 OffsetDefault = -1; 125 OffsetDefault = -1;
115 PositionDefault = "Top"; 126 PositionDefault = "Top";
116 idleButtons.setAutoDelete(true); 127 idleButtons.setAutoDelete(true);
117 } 128 }
118 129
119 int m_iconSize; 130 int m_iconSize;
120 KToolBar::IconText m_iconText; 131 KToolBar::IconText m_iconText;
121 bool m_highlight : 1; 132 bool m_highlight : 1;
122 bool m_transparent : 1; 133 bool m_transparent : 1;
123 bool m_honorStyle : 1; 134 bool m_honorStyle : 1;
124 bool m_isHorizontal : 1; 135 bool m_isHorizontal : 1;
125 bool m_enableContext : 1; 136 bool m_enableContext : 1;
126 bool m_configurePlugged : 1; 137 bool m_configurePlugged : 1;
127 bool modified : 1; 138 bool modified : 1;
128 bool positioned : 1; 139 bool positioned : 1;
129 140
130 QWidget *m_parent; 141 QWidget *m_parent;
131 142
132 QMainWindow::ToolBarDock oldPos; 143 Qt::ToolBarDock oldPos;
133 144
134 KXMLGUIClient *m_xmlguiClient; 145 KXMLGUIClient *m_xmlguiClient;
135 146
136 struct ToolBarInfo 147 struct ToolBarInfo
137 { 148 {
138//US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} 149//US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {}
139 ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {} 150 ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {}
140//US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} 151//US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {}
141 ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} 152 ToolBarInfo( Qt::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {}
142 int index, offset; 153 int index, offset;
143 bool newline; 154 bool newline;
144//US Qt::Dock dock; 155//US Qt::Dock dock;
145 QMainWindow::ToolBarDock dock; 156 Qt::ToolBarDock dock;
146 }; 157 };
147 158
148 ToolBarInfo toolBarInfo; 159 ToolBarInfo toolBarInfo;
149 QValueList<int> iconSizes; 160 Q3ValueList<int> iconSizes;
150 QTimer repaintTimer; 161 QTimer repaintTimer;
151 162
152 // Default Values. 163 // Default Values.
153 bool HiddenDefault; 164 bool HiddenDefault;
154 int IconSizeDefault; 165 int IconSizeDefault;
155 QString IconTextDefault; 166 QString IconTextDefault;
156 int IndexDefault; 167 int IndexDefault;
157 bool NewLineDefault; 168 bool NewLineDefault;
158 int OffsetDefault; 169 int OffsetDefault;
159 QString PositionDefault; 170 QString PositionDefault;
160 171
161 QPtrList<QWidget> idleButtons; 172 Q3PtrList<QWidget> idleButtons;
162}; 173};
163 174
164KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, 175KToolBarSeparator::KToolBarSeparator(Qt::Orientation o , bool l, Q3ToolBar *parent,
165 const char* name ) 176 const char* name )
166 :QFrame( parent, name ), line( l ) 177 :Q3Frame( parent, name ), line( l )
167{ 178{
168 connect( parent, SIGNAL(orientationChanged(Orientation)), 179 connect( parent, SIGNAL(orientationChanged(Qt::Orientation)),
169 this, SLOT(setOrientation(Orientation)) ); 180 this, SLOT(setOrientation(Qt::Orientation)) );
170 setOrientation( o ); 181 setOrientation( o );
171 setBackgroundMode( parent->backgroundMode() ); 182 setBackgroundMode( parent->backgroundMode() );
172 setBackgroundOrigin( ParentOrigin ); 183 setBackgroundOrigin( ParentOrigin );
173} 184}
174 185
175void KToolBarSeparator::setOrientation( Orientation o ) 186void KToolBarSeparator::setOrientation( Qt::Orientation o )
176{ 187{
177 orient = o; 188 orient = o;
178 if ( line ) { 189 if ( line ) {
179 if ( orientation() == Vertical ) 190 if ( orientation() == Qt::Vertical )
180 setFrameStyle( HLine + Sunken ); 191 setFrameStyle( HLine + Sunken );
181 else 192 else
182 setFrameStyle( VLine + Sunken ); 193 setFrameStyle( VLine + Sunken );
183 } else { 194 } else {
184 setFrameStyle( NoFrame ); 195 setFrameStyle( NoFrame );
185 } 196 }
186} 197}
187 198
188void KToolBarSeparator::styleChange( QStyle& ) 199void KToolBarSeparator::styleChange( QStyle& )
189{ 200{
190 setOrientation( orient ); 201 setOrientation( orient );
191} 202}
192 203
193QSize KToolBarSeparator::sizeHint() const 204QSize KToolBarSeparator::sizeHint() const
194{ 205{
195 return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); 206 return orientation() == Qt::Vertical ? QSize( 0, 6 ) : QSize( 6, 0 );
196} 207}
197 208
198QSizePolicy KToolBarSeparator::sizePolicy() const 209QSizePolicy KToolBarSeparator::sizePolicy() const
199{ 210{
200 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); 211 return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
201} 212}
202 213
203KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) 214KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig )
204#ifdef DESKTOP_VERSION 215#ifdef DESKTOP_VERSION
205 : QToolBar( QString::fromLatin1( name ), 216 : Q3ToolBar( QString::fromLatin1( name ),
206 parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, 217 parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0,
207 parent, FALSE, 218 parent, FALSE,
208 name ? name : "mainToolBar") 219 name ? name : "mainToolBar")
209#else 220#else
210 : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, 221 : QPEToolBar( parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0,
211 QString::fromLatin1( name )) 222 QString::fromLatin1( name ))
212 223
213 224
214#endif 225#endif
215{ 226{
216 init( readConfig, honorStyle ); 227 init( readConfig, honorStyle );
217} 228}
218 229
219KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) 230KToolBar::KToolBar( Q3MainWindow *parentWindow, Qt::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig )
220#ifdef DESKTOP_VERSION 231#ifdef DESKTOP_VERSION
221 : QToolBar( QString::fromLatin1( name ), 232 : Q3ToolBar( QString::fromLatin1( name ),
222 parentWindow, dock, newLine, 233 parentWindow, dock, newLine,
223 name ? name : "mainToolBar") 234 name ? name : "mainToolBar")
224#else 235#else
225 : QPEToolBar( parentWindow,QString::fromLatin1( name )) 236 : QPEToolBar( parentWindow,QString::fromLatin1( name ))
226 237
227 238
228#endif 239#endif
229 240
230{ 241{
231 init( readConfig, honorStyle ); 242 init( readConfig, honorStyle );
232} 243}
233 244
234KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) 245KToolBar::KToolBar( Q3MainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig )
235#ifdef DESKTOP_VERSION 246#ifdef DESKTOP_VERSION
236 : QToolBar( QString::fromLatin1( name ), 247 : Q3ToolBar( QString::fromLatin1( name ),
237 parentWindow, dock, newLine, 248 parentWindow, dock, newLine,
238 name ? name : "mainToolBar") 249 name ? name : "mainToolBar")
239#else 250#else
240 : QPEToolBar( parentWindow,QString::fromLatin1( name )) 251 : QPEToolBar( parentWindow,QString::fromLatin1( name ))
241 252
242 253
243#endif 254#endif
244 255
245{ 256{
246 init( readConfig, honorStyle ); 257 init( readConfig, honorStyle );
247} 258}
248 259
249KToolBar::~KToolBar() 260KToolBar::~KToolBar()
250{ 261{
251 inshutdownprocess = true; 262 inshutdownprocess = true;
252 emit toolbarDestroyed(); 263 emit toolbarDestroyed();
253 delete d; 264 delete d;
254} 265}
255 266
256void KToolBar::init( bool readConfig, bool honorStyle ) 267void KToolBar::init( bool readConfig, bool honorStyle )
257{ 268{
258 sizeHintW = 240; 269 sizeHintW = 240;
259 sizeHintH = 22; 270 sizeHintH = 22;
260 inshutdownprocess = false; 271 inshutdownprocess = false;
261 d = new KToolBarPrivate; 272 d = new KToolBarPrivate;
262 setFullSize( TRUE ); 273 setFullSize( TRUE );
263 d->m_honorStyle = honorStyle; 274 d->m_honorStyle = honorStyle;
264 context = 0; 275 context = 0;
265 layoutTimer = new QTimer( this ); 276 layoutTimer = new QTimer( this );
266 connect( layoutTimer, SIGNAL( timeout() ), 277 connect( layoutTimer, SIGNAL( timeout() ),
267 this, SLOT( rebuildLayout() ) ); 278 this, SLOT( rebuildLayout() ) );
268 connect( &(d->repaintTimer), SIGNAL( timeout() ), 279 connect( &(d->repaintTimer), SIGNAL( timeout() ),
269 this, SLOT( slotRepaint() ) ); 280 this, SLOT( slotRepaint() ) );
270/*US 281/*US
271 if ( kapp ) { // may be null when started inside designer 282 if ( kapp ) { // may be null when started inside designer
272 connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged())); 283 connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged()));
273 // request notification of changes in icon style 284 // request notification of changes in icon style
274 kapp->addKipcEventMask(KIPC::IconChanged); 285 kapp->addKipcEventMask(KIPC::IconChanged);
275 connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int))); 286 connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int)));
276 } 287 }
277*/ 288*/
278 // finally, read in our configurable settings 289 // finally, read in our configurable settings
279 if ( readConfig ) 290 if ( readConfig )
280 slotReadConfig(); 291 slotReadConfig();
281 292
282 if ( mainWindow() ) 293 if ( mainWindow() )
283 connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), 294 connect( mainWindow(), SIGNAL( toolBarPositionChanged( Q3ToolBar * ) ),
284 this, SLOT( toolBarPosChanged( QToolBar * ) ) ); 295 this, SLOT( toolBarPosChanged( Q3ToolBar * ) ) );
285 296
286 // Hack to make sure we recalculate our size when we dock. 297 // Hack to make sure we recalculate our size when we dock.
287//US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); 298//US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) );
288} 299}
289 300
290int KToolBar::insertButton(const QString& icon, int id, bool enabled, 301int KToolBar::insertButton(const QString& icon, int id, bool enabled,
291 const QString& text, int index/*US, KInstance *_instance*/ ) 302 const QString& text, int index/*US, KInstance *_instance*/ )
292{ 303{
293 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ ); 304 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ );
294 305
295 insertWidgetInternal( button, index, id ); 306 insertWidgetInternal( button, index, id );
296 button->setEnabled( enabled ); 307 button->setEnabled( enabled );
297 doConnections( button ); 308 doConnections( button );
298 return index; 309 return index;
299} 310}
300 311
301 312
302int KToolBar::insertButton(const QString& icon, int id, const char *signal, 313int KToolBar::insertButton(const QString& icon, int id, const char *signal,
303 const QObject *receiver, const char *slot, 314 const QObject *receiver, const char *slot,
304 bool enabled, const QString& text, int index/*US, KInstance *_instance*/ ) 315 bool enabled, const QString& text, int index/*US, KInstance *_instance*/ )
305{ 316{
306 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/); 317 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/);
307 insertWidgetInternal( button, index, id ); 318 insertWidgetInternal( button, index, id );
308 button->setEnabled( enabled ); 319 button->setEnabled( enabled );
309 connect( button, signal, receiver, slot ); 320 connect( button, signal, receiver, slot );
310 doConnections( button ); 321 doConnections( button );
311 return index; 322 return index;
312} 323}
313 324
314 325
315int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled, 326int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled,
316 const QString& text, int index ) 327 const QString& text, int index )
317{ 328{
318 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); 329 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text);
319 insertWidgetInternal( button, index, id ); 330 insertWidgetInternal( button, index, id );
320 button->setEnabled( enabled ); 331 button->setEnabled( enabled );
321 doConnections( button ); 332 doConnections( button );
322 return index; 333 return index;
323} 334}
324#if 0 335#if 0
325 bar->insertButton( icon, id_, SIGNAL( clicked() ), this, 336 bar->insertButton( icon, id_, SIGNAL( clicked() ), this,
326 SLOT( slotActivated() ), 337 SLOT( slotActivated() ),
327 d->isEnabled(), d->plainText(), index/*US, instance*/ ); 338 d->isEnabled(), d->plainText(), index/*US, instance*/ );
328#endif 339#endif
329 340
330int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, 341int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal,
331 const QObject *receiver, const char *slot, 342 const QObject *receiver, const char *slot,
332 bool enabled, const QString& text, 343 bool enabled, const QString& text,
333 int index ) 344 int index )
334{ 345{
335 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text); 346 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text);
336 insertWidgetInternal( button, index, id ); 347 insertWidgetInternal( button, index, id );
337 button->setEnabled( enabled ); 348 button->setEnabled( enabled );
338 connect( button, signal, receiver, slot ); 349 connect( button, signal, receiver, slot );
339 doConnections( button ); 350 doConnections( button );
340 return index; 351 return index;
341} 352}
342 353
343 354
344int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, 355int KToolBar::insertButton(const QString& icon, int id, Q3PopupMenu *popup,
345 bool enabled, const QString &text, int index ) 356 bool enabled, const QString &text, int index )
346{ 357{
347 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); 358 KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text );
348 insertWidgetInternal( button, index, id ); 359 insertWidgetInternal( button, index, id );
349 button->setEnabled( enabled ); 360 button->setEnabled( enabled );
350 button->setPopup( popup ); 361 button->setPopup( popup );
351 doConnections( button ); 362 doConnections( button );
352 return index; 363 return index;
353} 364}
354 365
355 366
356int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, 367int KToolBar::insertButton(const QPixmap& pixmap, int id, Q3PopupMenu *popup,
357 bool enabled, const QString &text, int index ) 368 bool enabled, const QString &text, int index )
358{ 369{
359 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); 370 KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text );
360 insertWidgetInternal( button, index, id ); 371 insertWidgetInternal( button, index, id );
361 button->setEnabled( enabled ); 372 button->setEnabled( enabled );
362 button->setPopup( popup ); 373 button->setPopup( popup );
363 doConnections( button ); 374 doConnections( button );
364 return index; 375 return index;
365} 376}
366 377
367 378
368int KToolBar::insertLined (const QString& text, int id, 379int KToolBar::insertLined (const QString& text, int id,
369 const char *signal, 380 const char *signal,
370 const QObject *receiver, const char *slot, 381 const QObject *receiver, const char *slot,
371 bool enabled , 382 bool enabled ,
372 const QString& toolTipText, 383 const QString& toolTipText,
373 int size, int index ) 384 int size, int index )
374{ 385{
375 KLineEdit *lined = new KLineEdit ( this, 0 ); 386 KLineEdit *lined = new KLineEdit ( this, 0 );
376 if ( !toolTipText.isEmpty() ) 387 if ( !toolTipText.isEmpty() )
377 QToolTip::add( lined, toolTipText ); 388 QToolTip::add( lined, toolTipText );
378 if ( size > 0 ) 389 if ( size > 0 )
379 lined->setMinimumWidth( size ); 390 lined->setMinimumWidth( size );
380 insertWidgetInternal( lined, index, id ); 391 insertWidgetInternal( lined, index, id );
381 connect( lined, signal, receiver, slot ); 392 connect( lined, signal, receiver, slot );
382 lined->setText(text); 393 lined->setText(text);
383 lined->setEnabled( enabled ); 394 lined->setEnabled( enabled );
384 return index; 395 return index;
385} 396}
386 397
387int KToolBar::insertCombo (const QStringList &list, int id, bool writable, 398int KToolBar::insertCombo (const QStringList &list, int id, bool writable,
388 const char *signal, const QObject *receiver, 399 const char *signal, const QObject *receiver,
389 const char *slot, bool enabled, 400 const char *slot, bool enabled,
390 const QString& tooltiptext, 401 const QString& tooltiptext,
391 int size, int index, 402 int size, int index,
392 QComboBox::Policy policy ) 403 QComboBox::Policy policy )
393{ 404{
394//US KComboBox *combo = new KComboBox ( writable, this ); 405//US KComboBox *combo = new KComboBox ( writable, this );
395 KComboBox *combo = new KComboBox ( this ); 406 KComboBox *combo = new KComboBox ( this );
396 combo->setEditable(writable); 407 combo->setEditable(writable);
397 408
398 insertWidgetInternal( combo, index, id ); 409 insertWidgetInternal( combo, index, id );
399 combo->insertStringList (list); 410 combo->insertStringList (list);
400 combo->setInsertionPolicy(policy); 411 combo->setInsertionPolicy(policy);
401 combo->setEnabled( enabled ); 412 combo->setEnabled( enabled );
402 if ( !tooltiptext.isEmpty() ) 413 if ( !tooltiptext.isEmpty() )
403 QToolTip::add( combo, tooltiptext ); 414 QToolTip::add( combo, tooltiptext );
404 if ( size > 0 ) 415 if ( size > 0 )
405 combo->setMinimumWidth( size ); 416 combo->setMinimumWidth( size );
406 if (!tooltiptext.isNull()) 417 if (!tooltiptext.isNull())
407 QToolTip::add( combo, tooltiptext ); 418 QToolTip::add( combo, tooltiptext );
408 419
409 if ( signal && receiver && slot ) 420 if ( signal && receiver && slot )
410 connect ( combo, signal, receiver, slot ); 421 connect ( combo, signal, receiver, slot );
411 return index; 422 return index;
412} 423}
413 424
414 425
415int KToolBar::insertCombo (const QString& text, int id, bool writable, 426int KToolBar::insertCombo (const QString& text, int id, bool writable,
416 const char *signal, QObject *receiver, 427 const char *signal, QObject *receiver,
417 const char *slot, bool enabled, 428 const char *slot, bool enabled,
418 const QString& tooltiptext, 429 const QString& tooltiptext,
419 int size, int index, 430 int size, int index,
420 QComboBox::Policy policy ) 431 QComboBox::Policy policy )
421{ 432{
422//US KComboBox *combo = new KComboBox ( writable, this ); 433//US KComboBox *combo = new KComboBox ( writable, this );
423 KComboBox *combo = new KComboBox ( this ); 434 KComboBox *combo = new KComboBox ( this );
424 combo->setEditable(writable); 435 combo->setEditable(writable);
425 436
426 insertWidgetInternal( combo, index, id ); 437 insertWidgetInternal( combo, index, id );
427 combo->insertItem (text); 438 combo->insertItem (text);
428 combo->setInsertionPolicy(policy); 439 combo->setInsertionPolicy(policy);
429 combo->setEnabled( enabled ); 440 combo->setEnabled( enabled );
430 if ( !tooltiptext.isEmpty() ) 441 if ( !tooltiptext.isEmpty() )
431 QToolTip::add( combo, tooltiptext ); 442 QToolTip::add( combo, tooltiptext );
432 if ( size > 0 ) 443 if ( size > 0 )
433 combo->setMinimumWidth( size ); 444 combo->setMinimumWidth( size );
434 if (!tooltiptext.isNull()) 445 if (!tooltiptext.isNull())
435 QToolTip::add( combo, tooltiptext ); 446 QToolTip::add( combo, tooltiptext );
436 connect (combo, signal, receiver, slot); 447 connect (combo, signal, receiver, slot);
437 return index; 448 return index;
438} 449}
439 450
440int KToolBar::insertSeparator(int index, int id) 451int KToolBar::insertSeparator(int index, int id)
441{ 452{
442 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); 453 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" );
443 insertWidgetInternal( w, index, id ); 454 insertWidgetInternal( w, index, id );
444 return index; 455 return index;
445} 456}
446 457
447int KToolBar::insertLineSeparator(int index, int id) 458int KToolBar::insertLineSeparator(int index, int id)
448{ 459{
449 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); 460 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" );
450 insertWidgetInternal( w, index, id ); 461 insertWidgetInternal( w, index, id );
451 return index; 462 return index;
452} 463}
453 464
454 465
455int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) 466int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index)
456{ 467{
457 // removeWidgetInternal( widget ); // in case we already have it ? 468 // removeWidgetInternal( widget ); // in case we already have it ?
458 insertWidgetInternal( widget, index, id ); 469 insertWidgetInternal( widget, index, id );
459 return index; 470 return index;
460} 471}
461/*US 472/*US
462int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, 473int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot,
463 const QString& icons, int index ) 474 const QString& icons, int index )
464{ 475{
465 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); 476 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this );
466 insertWidgetInternal( anim, index, id ); 477 insertWidgetInternal( anim, index, id );
467 478
468 if ( receiver ) 479 if ( receiver )
469 connect( anim, SIGNAL(clicked()), receiver, slot); 480 connect( anim, SIGNAL(clicked()), receiver, slot);
470 481
471 return index; 482 return index;
472} 483}
473 484
474KAnimWidget *KToolBar::animatedWidget( int id ) 485KAnimWidget *KToolBar::animatedWidget( int id )
475{ 486{
476 Id2WidgetMap::Iterator it = id2widget.find( id ); 487 Id2WidgetMap::Iterator it = id2widget.find( id );
477 if ( it == id2widget.end() ) 488 if ( it == id2widget.end() )
478 return 0; 489 return 0;
479 if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) 490 if ( (*it) && (*it)->inherits( "KAnimWidget" ) )
480 return (KAnimWidget*)(*it); 491 return (KAnimWidget*)(*it);
481 QObjectList *l = queryList( "KAnimWidget" ); 492 QObjectList *l = queryList( "KAnimWidget" );
482 if ( !l || !l->first() ) { 493 if ( !l || !l->first() ) {
483 delete l; 494 delete l;
484 return 0; 495 return 0;
485 } 496 }
486 497
487 for ( QObject *o = l->first(); o; o = l->next() ) { 498 for ( QObject *o = l->first(); o; o = l->next() ) {
488 if ( o->inherits( "KAnimWidget" ) ) 499 if ( o->inherits( "KAnimWidget" ) )
489 { 500 {
490 delete l; 501 delete l;
491 return (KAnimWidget*)o; 502 return (KAnimWidget*)o;
492 } 503 }
493 } 504 }
494 505
495 delete l; 506 delete l;
496 return 0; 507 return 0;
497} 508}
498*/ 509*/
499 510
500void KToolBar::addConnection (int id, const char *signal, 511void KToolBar::addConnection (int id, const char *signal,
501 const QObject *receiver, const char *slot) 512 const QObject *receiver, const char *slot)
502{ 513{
503 Id2WidgetMap::Iterator it = id2widget.find( id ); 514 Id2WidgetMap::Iterator it = id2widget.find( id );
504 if ( it == id2widget.end() ) 515 if ( it == id2widget.end() )
505 return; 516 return;
506 if ( (*it) ) 517 if ( (*it) )
507 connect( (*it), signal, receiver, slot ); 518 connect( (*it), signal, receiver, slot );
508} 519}
509 520
510void KToolBar::setItemEnabled( int id, bool enabled ) 521void KToolBar::setItemEnabled( int id, bool enabled )
511{ 522{
512 Id2WidgetMap::Iterator it = id2widget.find( id ); 523 Id2WidgetMap::Iterator it = id2widget.find( id );
513 if ( it == id2widget.end() ) 524 if ( it == id2widget.end() )
514 return; 525 return;
515 if ( (*it) ) 526 if ( (*it) )
516 (*it)->setEnabled( enabled ); 527 (*it)->setEnabled( enabled );
517} 528}
518 529
519 530
520void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) 531void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap )
521{ 532{
522 Id2WidgetMap::Iterator it = id2widget.find( id ); 533 Id2WidgetMap::Iterator it = id2widget.find( id );
523 if ( it == id2widget.end() ) 534 if ( it == id2widget.end() )
524 return; 535 return;
525//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 536//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
526 KToolBarButton * button = (KToolBarButton *)( *it ); 537 KToolBarButton * button = (KToolBarButton *)( *it );
527 if ( button ) 538 if ( button )
528 button->setPixmap( _pixmap ); 539 button->setPixmap( _pixmap );
529} 540}
530 541
531 542
532void KToolBar::setButtonIcon( int id, const QString& _icon ) 543void KToolBar::setButtonIcon( int id, const QString& _icon )
533{ 544{
534 Id2WidgetMap::Iterator it = id2widget.find( id ); 545 Id2WidgetMap::Iterator it = id2widget.find( id );
535 if ( it == id2widget.end() ) 546 if ( it == id2widget.end() )
536 return; 547 return;
537//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 548//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
538 KToolBarButton * button = (KToolBarButton *)( *it ); 549 KToolBarButton * button = (KToolBarButton *)( *it );
539 if ( button ) 550 if ( button )
540 button->setIcon( _icon ); 551 button->setIcon( _icon );
541} 552}
542 553
543void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) 554void KToolBar::setButtonIconSet( int id, const QIcon& iconset )
544{ 555{
545 Id2WidgetMap::Iterator it = id2widget.find( id ); 556 Id2WidgetMap::Iterator it = id2widget.find( id );
546 if ( it == id2widget.end() ) 557 if ( it == id2widget.end() )
547 return; 558 return;
548//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 559//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
549 KToolBarButton * button = (KToolBarButton *)( *it ); 560 KToolBarButton * button = (KToolBarButton *)( *it );
550 if ( button ) 561 if ( button )
551 button->setIconSet( iconset ); 562 button->setIconSet( iconset );
552} 563}
553 564
554 565
555void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) 566void KToolBar::setDelayedPopup (int id , Q3PopupMenu *_popup, bool toggle )
556{ 567{
557 Id2WidgetMap::Iterator it = id2widget.find( id ); 568 Id2WidgetMap::Iterator it = id2widget.find( id );
558 if ( it == id2widget.end() ) 569 if ( it == id2widget.end() )
559 return; 570 return;
560//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 571//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
561 KToolBarButton * button = (KToolBarButton *)( *it ); 572 KToolBarButton * button = (KToolBarButton *)( *it );
562 if ( button ) 573 if ( button )
563 button->setDelayedPopup( _popup, toggle ); 574 button->setDelayedPopup( _popup, toggle );
564} 575}
565 576
566 577
567void KToolBar::setAutoRepeat (int id, bool flag) 578void KToolBar::setAutoRepeat (int id, bool flag)
568{ 579{
569 Id2WidgetMap::Iterator it = id2widget.find( id ); 580 Id2WidgetMap::Iterator it = id2widget.find( id );
570 if ( it == id2widget.end() ) 581 if ( it == id2widget.end() )
571 return; 582 return;
572//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 583//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
573 KToolBarButton * button = (KToolBarButton *)( *it ); 584 KToolBarButton * button = (KToolBarButton *)( *it );
574 if ( button ) 585 if ( button )
575 button->setAutoRepeat( flag ); 586 button->setAutoRepeat( flag );
576} 587}
577 588
578 589
579void KToolBar::setToggle (int id, bool flag ) 590void KToolBar::setToggle (int id, bool flag )
580{ 591{
581 Id2WidgetMap::Iterator it = id2widget.find( id ); 592 Id2WidgetMap::Iterator it = id2widget.find( id );
582 if ( it == id2widget.end() ) 593 if ( it == id2widget.end() )
583 return; 594 return;
584//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 595//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
585 KToolBarButton * button = (KToolBarButton *)( *it ); 596 KToolBarButton * button = (KToolBarButton *)( *it );
586 if ( button ) 597 if ( button )
587 button->setToggle( flag ); 598 button->setToggle( flag );
588} 599}
589 600
590 601
591void KToolBar::toggleButton (int id) 602void KToolBar::toggleButton (int id)
592{ 603{
593 Id2WidgetMap::Iterator it = id2widget.find( id ); 604 Id2WidgetMap::Iterator it = id2widget.find( id );
594 if ( it == id2widget.end() ) 605 if ( it == id2widget.end() )
595 return; 606 return;
596//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 607//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
597 KToolBarButton * button = (KToolBarButton *)( *it ); 608 KToolBarButton * button = (KToolBarButton *)( *it );
598 if ( button ) 609 if ( button )
599 button->toggle(); 610 button->toggle();
600} 611}
601 612
602 613
603void KToolBar::setButton (int id, bool flag) 614void KToolBar::setButton (int id, bool flag)
604{ 615{
605 Id2WidgetMap::Iterator it = id2widget.find( id ); 616 Id2WidgetMap::Iterator it = id2widget.find( id );
606 if ( it == id2widget.end() ) 617 if ( it == id2widget.end() )
607 return; 618 return;
608//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 619//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
609 KToolBarButton * button = (KToolBarButton *)( *it ); 620 KToolBarButton * button = (KToolBarButton *)( *it );
610 if ( button ) 621 if ( button )
611 button->on( flag ); 622 button->on( flag );
612} 623}
613 624
614 625
615bool KToolBar::isButtonOn (int id) const 626bool KToolBar::isButtonOn (int id) const
616{ 627{
617 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 628 Id2WidgetMap::ConstIterator it = id2widget.find( id );
618 if ( it == id2widget.end() ) 629 if ( it == id2widget.end() )
619 return false; 630 return false;
620//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 631//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
621 KToolBarButton * button = (KToolBarButton *)( *it ); 632 KToolBarButton * button = (KToolBarButton *)( *it );
622 return button ? button->isOn() : false; 633 return button ? button->isOn() : false;
623} 634}
624 635
625 636
626void KToolBar::setLinedText (int id, const QString& text) 637void KToolBar::setLinedText (int id, const QString& text)
627{ 638{
628 Id2WidgetMap::Iterator it = id2widget.find( id ); 639 Id2WidgetMap::Iterator it = id2widget.find( id );
629 if ( it == id2widget.end() ) 640 if ( it == id2widget.end() )
630 return; 641 return;
631//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 642//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
632 QLineEdit * lineEdit = (QLineEdit *)( *it ); 643 QLineEdit * lineEdit = (QLineEdit *)( *it );
633 if ( lineEdit ) 644 if ( lineEdit )
634 lineEdit->setText( text ); 645 lineEdit->setText( text );
635} 646}
636 647
637 648
638QString KToolBar::getLinedText (int id) const 649QString KToolBar::getLinedText (int id) const
639{ 650{
640 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 651 Id2WidgetMap::ConstIterator it = id2widget.find( id );
641 if ( it == id2widget.end() ) 652 if ( it == id2widget.end() )
642 return QString::null; 653 return QString::null;
643//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 654//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
644 QLineEdit * lineEdit = (QLineEdit *)( *it ); 655 QLineEdit * lineEdit = (QLineEdit *)( *it );
645 return lineEdit ? lineEdit->text() : QString::null; 656 return lineEdit ? lineEdit->text() : QString::null;
646} 657}
647 658
648 659
649void KToolBar::insertComboItem (int id, const QString& text, int index) 660void KToolBar::insertComboItem (int id, const QString& text, int index)
650{ 661{
651 Id2WidgetMap::Iterator it = id2widget.find( id ); 662 Id2WidgetMap::Iterator it = id2widget.find( id );
652 if ( it == id2widget.end() ) 663 if ( it == id2widget.end() )
653 return; 664 return;
654//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 665//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
655 QComboBox * comboBox = (QComboBox *)( *it ); 666 QComboBox * comboBox = (QComboBox *)( *it );
656 if (comboBox) 667 if (comboBox)
657 comboBox->insertItem( text, index ); 668 comboBox->insertItem( text, index );
658} 669}
659 670
660void KToolBar::insertComboList (int id, const QStringList &list, int index) 671void KToolBar::insertComboList (int id, const QStringList &list, int index)
661{ 672{
662 Id2WidgetMap::Iterator it = id2widget.find( id ); 673 Id2WidgetMap::Iterator it = id2widget.find( id );
663 if ( it == id2widget.end() ) 674 if ( it == id2widget.end() )
664 return; 675 return;
665//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 676//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
666 QComboBox * comboBox = (QComboBox *)( *it ); 677 QComboBox * comboBox = (QComboBox *)( *it );
667 if (comboBox) 678 if (comboBox)
668 comboBox->insertStringList( list, index ); 679 comboBox->insertStringList( list, index );
669} 680}
670 681
671 682
672void KToolBar::removeComboItem (int id, int index) 683void KToolBar::removeComboItem (int id, int index)
673{ 684{
674 Id2WidgetMap::Iterator it = id2widget.find( id ); 685 Id2WidgetMap::Iterator it = id2widget.find( id );
675 if ( it == id2widget.end() ) 686 if ( it == id2widget.end() )
676 return; 687 return;
677//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 688//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
678 QComboBox * comboBox = (QComboBox *)( *it ); 689 QComboBox * comboBox = (QComboBox *)( *it );
679 if (comboBox) 690 if (comboBox)
680 comboBox->removeItem( index ); 691 comboBox->removeItem( index );
681} 692}
682 693
683 694
684void KToolBar::setCurrentComboItem (int id, int index) 695void KToolBar::setCurrentComboItem (int id, int index)
685{ 696{
686 Id2WidgetMap::Iterator it = id2widget.find( id ); 697 Id2WidgetMap::Iterator it = id2widget.find( id );
687 if ( it == id2widget.end() ) 698 if ( it == id2widget.end() )
688 return; 699 return;
689//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 700//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
690 QComboBox * comboBox = (QComboBox *)( *it ); 701 QComboBox * comboBox = (QComboBox *)( *it );
691 if (comboBox) 702 if (comboBox)
692 comboBox->setCurrentItem( index ); 703 comboBox->setCurrentItem( index );
693} 704}
694 705
695 706
696void KToolBar::changeComboItem (int id, const QString& text, int index) 707void KToolBar::changeComboItem (int id, const QString& text, int index)
697{ 708{
698 Id2WidgetMap::Iterator it = id2widget.find( id ); 709 Id2WidgetMap::Iterator it = id2widget.find( id );
699 if ( it == id2widget.end() ) 710 if ( it == id2widget.end() )
700 return; 711 return;
701//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 712//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
702 QComboBox * comboBox = (QComboBox *)( *it ); 713 QComboBox * comboBox = (QComboBox *)( *it );
703 if (comboBox) 714 if (comboBox)
704 comboBox->changeItem( text, index ); 715 comboBox->changeItem( text, index );
705} 716}
706 717
707 718
708void KToolBar::clearCombo (int id) 719void KToolBar::clearCombo (int id)
709{ 720{
710 Id2WidgetMap::Iterator it = id2widget.find( id ); 721 Id2WidgetMap::Iterator it = id2widget.find( id );
711 if ( it == id2widget.end() ) 722 if ( it == id2widget.end() )
712 return; 723 return;
713//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 724//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
714 QComboBox * comboBox = (QComboBox *)( *it ); 725 QComboBox * comboBox = (QComboBox *)( *it );
715 if (comboBox) 726 if (comboBox)
716 comboBox->clear(); 727 comboBox->clear();
717} 728}
718 729
719 730
720QString KToolBar::getComboItem (int id, int index) const 731QString KToolBar::getComboItem (int id, int index) const
721{ 732{
722 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 733 Id2WidgetMap::ConstIterator it = id2widget.find( id );
723 if ( it == id2widget.end() ) 734 if ( it == id2widget.end() )
724 return QString::null; 735 return QString::null;
725//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 736//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
726 QComboBox * comboBox = (QComboBox *)( *it ); 737 QComboBox * comboBox = (QComboBox *)( *it );
727 return comboBox ? comboBox->text( index ) : QString::null; 738 return comboBox ? comboBox->text( index ) : QString::null;
728} 739}
729 740
730 741
731KComboBox * KToolBar::getCombo(int id) 742KComboBox * KToolBar::getCombo(int id)
732{ 743{
733 Id2WidgetMap::Iterator it = id2widget.find( id ); 744 Id2WidgetMap::Iterator it = id2widget.find( id );
734 if ( it == id2widget.end() ) 745 if ( it == id2widget.end() )
735 return 0; 746 return 0;
736//US return dynamic_cast<KComboBox *>( *it ); 747//US return dynamic_cast<KComboBox *>( *it );
737 return (KComboBox *)( *it ); 748 return (KComboBox *)( *it );
738} 749}
739 750
740 751
741KLineEdit * KToolBar::getLined (int id) 752KLineEdit * KToolBar::getLined (int id)
742{ 753{
743 Id2WidgetMap::Iterator it = id2widget.find( id ); 754 Id2WidgetMap::Iterator it = id2widget.find( id );
744 if ( it == id2widget.end() ) 755 if ( it == id2widget.end() )
745 return 0; 756 return 0;
746//US return dynamic_cast<KLineEdit *>( *it ); 757//US return dynamic_cast<KLineEdit *>( *it );
747 return (KLineEdit *)( *it ); 758 return (KLineEdit *)( *it );
748} 759}
749 760
750 761
751KToolBarButton * KToolBar::getButton (int id) 762KToolBarButton * KToolBar::getButton (int id)
752{ 763{
753 Id2WidgetMap::Iterator it = id2widget.find( id ); 764 Id2WidgetMap::Iterator it = id2widget.find( id );
754 if ( it == id2widget.end() ) 765 if ( it == id2widget.end() )
755 return 0; 766 return 0;
756//US return dynamic_cast<KToolBarButton *>( *it ); 767//US return dynamic_cast<KToolBarButton *>( *it );
757 return (KToolBarButton *)( *it ); 768 return (KToolBarButton *)( *it );
758} 769}
759 770
760 771
761void KToolBar::alignItemRight (int id, bool right ) 772void KToolBar::alignItemRight (int id, bool right )
762{ 773{
763 Id2WidgetMap::Iterator it = id2widget.find( id ); 774 Id2WidgetMap::Iterator it = id2widget.find( id );
764 if ( it == id2widget.end() ) 775 if ( it == id2widget.end() )
765 return; 776 return;
766 if ( rightAligned && !right && (*it) == rightAligned ) 777 if ( rightAligned && !right && (*it) == rightAligned )
767 rightAligned = 0; 778 rightAligned = 0;
768 if ( (*it) && right ) 779 if ( (*it) && right )
769 rightAligned = (*it); 780 rightAligned = (*it);
770} 781}
771 782
772 783
773QWidget *KToolBar::getWidget (int id) 784QWidget *KToolBar::getWidget (int id)
774{ 785{
775 Id2WidgetMap::Iterator it = id2widget.find( id ); 786 Id2WidgetMap::Iterator it = id2widget.find( id );
776 return ( it == id2widget.end() ) ? 0 : (*it); 787 return ( it == id2widget.end() ) ? 0 : (*it);
777} 788}
778 789
779 790
780void KToolBar::setItemAutoSized (int id, bool yes ) 791void KToolBar::setItemAutoSized (int id, bool yes )
781{ 792{
782 QWidget *w = getWidget(id); 793 QWidget *w = getWidget(id);
783 if ( w && yes ) 794 if ( w && yes )
784 setStretchableWidget( w ); 795 setStretchableWidget( w );
785} 796}
786 797
787 798
788void KToolBar::clear () 799void KToolBar::clear ()
789{ 800{
790 QToolBar::clear(); 801 Q3ToolBar::clear();
791 widget2id.clear(); 802 widget2id.clear();
792 id2widget.clear(); 803 id2widget.clear();
793} 804}
794 805
795 806
796void KToolBar::removeItem(int id) 807void KToolBar::removeItem(int id)
797{ 808{
798 Id2WidgetMap::Iterator it = id2widget.find( id ); 809 Id2WidgetMap::Iterator it = id2widget.find( id );
799 if ( it == id2widget.end() ) 810 if ( it == id2widget.end() )
800 { 811 {
801 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 812 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
802 return; 813 return;
803 } 814 }
804 QWidget * w = (*it); 815 QWidget * w = (*it);
805 id2widget.remove( id ); 816 id2widget.remove( id );
806 widget2id.remove( w ); 817 widget2id.remove( w );
807 widgets.removeRef( w ); 818 widgets.removeRef( w );
808 delete w; 819 delete w;
809} 820}
810 821
811 822
812void KToolBar::removeItemDelayed(int id) 823void KToolBar::removeItemDelayed(int id)
813{ 824{
814 Id2WidgetMap::Iterator it = id2widget.find( id ); 825 Id2WidgetMap::Iterator it = id2widget.find( id );
815 if ( it == id2widget.end() ) 826 if ( it == id2widget.end() )
816 { 827 {
817 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 828 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
818 return; 829 return;
819 } 830 }
820 QWidget * w = (*it); 831 QWidget * w = (*it);
821 id2widget.remove( id ); 832 id2widget.remove( id );
822 widget2id.remove( w ); 833 widget2id.remove( w );
823 widgets.removeRef( w ); 834 widgets.removeRef( w );
824 835
825 w->blockSignals(true); 836 w->blockSignals(true);
826 d->idleButtons.append(w); 837 d->idleButtons.append(w);
827 layoutTimer->start( 50, TRUE ); 838 layoutTimer->start( 50, TRUE );
828} 839}
829 840
830 841
831void KToolBar::hideItem (int id) 842void KToolBar::hideItem (int id)
832{ 843{
833 QWidget *w = getWidget(id); 844 QWidget *w = getWidget(id);
834 if ( w ) 845 if ( w )
835 w->hide(); 846 w->hide();
836} 847}
837 848
838 849
839void KToolBar::showItem (int id) 850void KToolBar::showItem (int id)
840{ 851{
841 QWidget *w = getWidget(id); 852 QWidget *w = getWidget(id);
842 if ( w ) 853 if ( w )
843 w->show(); 854 w->show();
844} 855}
845 856
846 857
847int KToolBar::itemIndex (int id) 858int KToolBar::itemIndex (int id)
848{ 859{
849 QWidget *w = getWidget(id); 860 QWidget *w = getWidget(id);
850 return w ? widgets.findRef(w) : -1; 861 return w ? widgets.findRef(w) : -1;
851} 862}
852 863
853 864
854void KToolBar::setFullSize(bool flag ) 865void KToolBar::setFullSize(bool flag )
855{ 866{
856 setHorizontalStretchable( flag ); 867 setHorizontalStretchable( flag );
857 setVerticalStretchable( flag ); 868 setVerticalStretchable( flag );
858} 869}
859 870
860 871
861bool KToolBar::fullSize() const 872bool KToolBar::fullSize() const
862{ 873{
863 return isHorizontalStretchable() || isVerticalStretchable(); 874 return isHorizontalStretchable() || isVerticalStretchable();
864} 875}
865 876
866 877
867void KToolBar::enableMoving(bool flag ) 878void KToolBar::enableMoving(bool flag )
868{ 879{
869//US setMovingEnabled(flag); 880//US setMovingEnabled(flag);
870 this->mainWindow()->setToolBarsMovable(flag); 881 this->mainWindow()->setToolBarsMovable(flag);
871} 882}
872 883
873 884
874void KToolBar::setBarPos (BarPosition bpos) 885void KToolBar::setBarPos (BarPosition bpos)
875{ 886{
876 if ( !mainWindow() ) 887 if ( !mainWindow() )
877 return; 888 return;
878//US mainWindow()->moveDockWindow( this, (Dock)bpos ); 889//US mainWindow()->moveDockWindow( this, (Dock)bpos );
879 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); 890 mainWindow()->moveToolBar( this, (Qt::ToolBarDock)bpos );
880} 891}
881 892
882 893
883const KToolBar::BarPosition KToolBar::barPos() 894const KToolBar::BarPosition KToolBar::barPos()
884{ 895{
885 if ( !(QMainWindow*)mainWindow() ) 896 if ( !(Q3MainWindow*)mainWindow() )
886 return KToolBar::Top; 897 return KToolBar::Top;
887//US Dock dock; 898//US Dock dock;
888 QMainWindow::ToolBarDock dock; 899 Qt::ToolBarDock dock;
889 int dm1, dm2; 900 int dm1, dm2;
890 bool dm3; 901 bool dm3;
891 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); 902 ((Q3MainWindow*)mainWindow())->getLocation( (Q3ToolBar*)this, dock, dm1, dm3, dm2 );
892//US if ( dock == DockUnmanaged ) { 903//US if ( dock == DockUnmanaged ) {
893 if ( dock == QMainWindow::Unmanaged ) { 904 if ( dock == Qt::Unmanaged ) {
894 return (KToolBar::BarPosition)Top; 905 return (KToolBar::BarPosition)Top;
895 } 906 }
896 return (BarPosition)dock; 907 return (BarPosition)dock;
897} 908}
898 909
899 910
900bool KToolBar::enable(BarStatus stat) 911bool KToolBar::enable(BarStatus stat)
901{ 912{
902 bool mystat = isVisible(); 913 bool mystat = isVisible();
903 914
904 if ( (stat == Toggle && mystat) || stat == Hide ) 915 if ( (stat == Toggle && mystat) || stat == Hide )
905 hide(); 916 hide();
906 else 917 else
907 show(); 918 show();
908 919
909 return isVisible() == mystat; 920 return isVisible() == mystat;
910} 921}
911 922
912 923
913void KToolBar::setMaxHeight ( int h ) 924void KToolBar::setMaxHeight ( int h )
914{ 925{
915 setMaximumHeight( h ); 926 setMaximumHeight( h );
916} 927}
917 928
918int KToolBar::maxHeight() 929int KToolBar::maxHeight()
919{ 930{
920 return maximumHeight(); 931 return maximumHeight();
921} 932}
922 933
923 934
924void KToolBar::setMaxWidth (int dw) 935void KToolBar::setMaxWidth (int dw)
925{ 936{
926 setMaximumWidth( dw ); 937 setMaximumWidth( dw );
927} 938}
928 939
929 940
930int KToolBar::maxWidth() 941int KToolBar::maxWidth()
931{ 942{
932 return maximumWidth(); 943 return maximumWidth();
933} 944}
934 945
935 946
936void KToolBar::setTitle (const QString& _title) 947void KToolBar::setTitle (const QString& _title)
937{ 948{
938 setLabel( _title ); 949 setLabel( _title );
939} 950}
940 951
941 952
942void KToolBar::enableFloating (bool ) 953void KToolBar::enableFloating (bool )
943{ 954{
944} 955}
945 956
946 957
947void KToolBar::setIconText(IconText it) 958void KToolBar::setIconText(IconText it)
948{ 959{
949 setIconText( it, true ); 960 setIconText( it, true );
950} 961}
951 962
952 963
953void KToolBar::setIconText(IconText icontext, bool update) 964void KToolBar::setIconText(IconText icontext, bool update)
954{ 965{
955 bool doUpdate=false; 966 bool doUpdate=false;
956 967
957 if (icontext != d->m_iconText) { 968 if (icontext != d->m_iconText) {
958 d->m_iconText = icontext; 969 d->m_iconText = icontext;
959 doUpdate=true; 970 doUpdate=true;
960 } 971 }
961 972
962 if (update == false) 973 if (update == false)
963 return; 974 return;
964 975
965 if (doUpdate) 976 if (doUpdate)
966 emit modechange(); // tell buttons what happened 977 emit modechange(); // tell buttons what happened
967 978
968 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 979 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
969 if ( mainWindow() ) { 980 if ( mainWindow() ) {
970 QMainWindow *mw = mainWindow(); 981 Q3MainWindow *mw = mainWindow();
971 mw->setUpdatesEnabled( FALSE ); 982 mw->setUpdatesEnabled( FALSE );
972 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 983 mw->setToolBarsMovable( !mw->toolBarsMovable() );
973 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 984 mw->setToolBarsMovable( !mw->toolBarsMovable() );
974 mw->setUpdatesEnabled( TRUE ); 985 mw->setUpdatesEnabled( TRUE );
975 } 986 }
976} 987}
977 988
978 989
979KToolBar::IconText KToolBar::iconText() const 990KToolBar::IconText KToolBar::iconText() const
980{ 991{
981 return d->m_iconText; 992 return d->m_iconText;
982} 993}
983 994
984 995
985void KToolBar::setIconSize(int size) 996void KToolBar::setIconSize(int size)
986{ 997{
987 setIconSize( size, true ); 998 setIconSize( size, true );
988} 999}
989 1000
990void KToolBar::setIconSize(int size, bool update) 1001void KToolBar::setIconSize(int size, bool update)
991{ 1002{
992 bool doUpdate=false; 1003 bool doUpdate=false;
993 1004
994 if ( size != d->m_iconSize ) { 1005 if ( size != d->m_iconSize ) {
995 d->m_iconSize = size; 1006 d->m_iconSize = size;
996 doUpdate=true; 1007 doUpdate=true;
997 } 1008 }
998 1009
999 if (update == false) 1010 if (update == false)
1000 return; 1011 return;
1001 1012
1002 if (doUpdate) 1013 if (doUpdate)
1003 emit modechange(); // tell buttons what happened 1014 emit modechange(); // tell buttons what happened
1004 1015
1005 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 1016 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
1006 if ( mainWindow() ) { 1017 if ( mainWindow() ) {
1007 QMainWindow *mw = mainWindow(); 1018 Q3MainWindow *mw = mainWindow();
1008 mw->setUpdatesEnabled( FALSE ); 1019 mw->setUpdatesEnabled( FALSE );
1009 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1020 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1010 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1021 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1011 mw->setUpdatesEnabled( TRUE ); 1022 mw->setUpdatesEnabled( TRUE );
1012 } 1023 }
1013} 1024}
1014 1025
1015 1026
1016int KToolBar::iconSize() const 1027int KToolBar::iconSize() const
1017{ 1028{
1018/*US 1029/*US
1019 if ( !d->m_iconSize ) // default value? 1030 if ( !d->m_iconSize ) // default value?
1020 { 1031 {
1021 if (!::qstrcmp(QObject::name(), "mainToolBar")) 1032 if (!::qstrcmp(QObject::name(), "mainToolBar"))
1022 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); 1033 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar);
1023 else 1034 else
1024 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); 1035 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar);
1025 } 1036 }
1026 return d->m_iconSize; 1037 return d->m_iconSize;
1027*/ 1038*/
1028 int ret = 18; 1039 int ret = 18;
1029 if ( QApplication::desktop()->width() > 320 ) 1040 if ( QApplication::desktop()->width() > 320 )
1030 ret = 30; 1041 ret = 30;
1031 return ret; 1042 return ret;
1032} 1043}
1033 1044
1034 1045
1035void KToolBar::setEnableContextMenu(bool enable ) 1046void KToolBar::setEnableContextMenu(bool enable )
1036{ 1047{
1037 d->m_enableContext = enable; 1048 d->m_enableContext = enable;
1038} 1049}
1039 1050
1040 1051
1041bool KToolBar::contextMenuEnabled() const 1052bool KToolBar::contextMenuEnabled() const
1042{ 1053{
1043 return d->m_enableContext; 1054 return d->m_enableContext;
1044} 1055}
1045 1056
1046 1057
1047void KToolBar::setItemNoStyle(int id, bool no_style ) 1058void KToolBar::setItemNoStyle(int id, bool no_style )
1048{ 1059{
1049 Id2WidgetMap::Iterator it = id2widget.find( id ); 1060 Id2WidgetMap::Iterator it = id2widget.find( id );
1050 if ( it == id2widget.end() ) 1061 if ( it == id2widget.end() )
1051 return; 1062 return;
1052//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 1063//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
1053 KToolBarButton * button = (KToolBarButton *)( *it ); 1064 KToolBarButton * button = (KToolBarButton *)( *it );
1054 if (button) 1065 if (button)
1055 button->setNoStyle( no_style ); 1066 button->setNoStyle( no_style );
1056} 1067}
1057 1068
1058 1069
1059void KToolBar::setFlat (bool flag) 1070void KToolBar::setFlat (bool flag)
1060{ 1071{
1061 if ( !mainWindow() ) 1072 if ( !mainWindow() )
1062 return; 1073 return;
1063 if ( flag ) 1074 if ( flag )
1064//US mainWindow()->moveDockWindow( this, DockMinimized ); 1075//US mainWindow()->moveDockWindow( this, DockMinimized );
1065 mainWindow()->moveToolBar( this, QMainWindow::Minimized ); 1076 mainWindow()->moveToolBar( this, Qt::Minimized );
1066 else 1077 else
1067//US mainWindow()->moveDockWindow( this, DockTop ); 1078//US mainWindow()->moveDockWindow( this, DockTop );
1068 mainWindow()->moveToolBar( this, QMainWindow::Top ); 1079 mainWindow()->moveToolBar( this, Qt::Top );
1069 // And remember to save the new look later 1080 // And remember to save the new look later
1070/*US 1081/*US
1071 if ( mainWindow()->inherits( "KMainWindow" ) ) 1082 if ( mainWindow()->inherits( "KMainWindow" ) )
1072 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1083 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1073*/ 1084*/
1074} 1085}
1075 1086
1076 1087
1077int KToolBar::count() const 1088int KToolBar::count() const
1078{ 1089{
1079 return id2widget.count(); 1090 return id2widget.count();
1080} 1091}
1081 1092
1082 1093
1083void KToolBar::saveState() 1094void KToolBar::saveState()
1084{ 1095{
1085/*US 1096/*US
1086 // first, try to save to the xml file 1097 // first, try to save to the xml file
1087 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { 1098 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
1088 // go down one level to get to the right tags 1099 // go down one level to get to the right tags
1089 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); 1100 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement();
1090 elem = elem.firstChild().toElement(); 1101 elem = elem.firstChild().toElement();
1091 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); 1102 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
1092 QDomElement current; 1103 QDomElement current;
1093 // now try to find our toolbar 1104 // now try to find our toolbar
1094 d->modified = false; 1105 d->modified = false;
1095 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1106 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1096 current = elem; 1107 current = elem;
1097 1108
1098 if ( current.tagName().lower() != "toolbar" ) 1109 if ( current.tagName().lower() != "toolbar" )
1099 continue; 1110 continue;
1100 1111
1101 QString curname(current.attribute( "name" )); 1112 QString curname(current.attribute( "name" ));
1102 1113
1103 if ( curname == barname ) { 1114 if ( curname == barname ) {
1104 saveState( current ); 1115 saveState( current );
1105 break; 1116 break;
1106 } 1117 }
1107 } 1118 }
1108 // if we didn't make changes, then just return 1119 // if we didn't make changes, then just return
1109 if ( !d->modified ) 1120 if ( !d->modified )
1110 return; 1121 return;
1111 1122
1112 // now we load in the (non-merged) local file 1123 // now we load in the (non-merged) local file
1113 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); 1124 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
1114 QDomDocument local; 1125 QDomDocument local;
1115 local.setContent(local_xml); 1126 local.setContent(local_xml);
1116 1127
1117 // make sure we don't append if this toolbar already exists locally 1128 // make sure we don't append if this toolbar already exists locally
1118 bool just_append = true; 1129 bool just_append = true;
1119 elem = local.documentElement().toElement(); 1130 elem = local.documentElement().toElement();
1120 KXMLGUIFactory::removeDOMComments( elem ); 1131 KXMLGUIFactory::removeDOMComments( elem );
1121 elem = elem.firstChild().toElement(); 1132 elem = elem.firstChild().toElement();
1122 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1133 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1123 if ( elem.tagName().lower() != "toolbar" ) 1134 if ( elem.tagName().lower() != "toolbar" )
1124 continue; 1135 continue;
1125 1136
1126 QString curname(elem.attribute( "name" )); 1137 QString curname(elem.attribute( "name" ));
1127 1138
1128 if ( curname == barname ) { 1139 if ( curname == barname ) {
1129 just_append = false; 1140 just_append = false;
1130 local.documentElement().replaceChild( current, elem ); 1141 local.documentElement().replaceChild( current, elem );
1131 break; 1142 break;
1132 } 1143 }
1133 } 1144 }
1134 1145
1135 if (just_append) 1146 if (just_append)
1136 local.documentElement().appendChild( current ); 1147 local.documentElement().appendChild( current );
1137 1148
1138 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); 1149 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
1139 1150
1140 return; 1151 return;
1141 } 1152 }
1142*/ 1153*/
1143 // if that didn't work, we save to the config file 1154 // if that didn't work, we save to the config file
1144 KConfig *config = KGlobal::config(); 1155 KConfig *config = KGlobal::config();
1145 saveSettings(config, QString::null); 1156 saveSettings(config, QString::null);
1146 config->sync(); 1157 config->sync();
1147} 1158}
1148 1159
1149QString KToolBar::settingsGroup() 1160QString KToolBar::settingsGroup()
1150{ 1161{
1151 QString configGroup; 1162 QString configGroup;
1152 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) 1163 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
1153 configGroup = "Toolbar style"; 1164 configGroup = "Toolbar style";
1154 else 1165 else
1155 configGroup = QString(name()) + " Toolbar style"; 1166 configGroup = QString(name()) + " Toolbar style";
1156 if ( this->mainWindow() ) 1167 if ( this->mainWindow() )
1157 { 1168 {
1158 configGroup.prepend(" "); 1169 configGroup.prepend(" ");
1159 configGroup.prepend( this->mainWindow()->name() ); 1170 configGroup.prepend( this->mainWindow()->name() );
1160 } 1171 }
1161 return configGroup; 1172 return configGroup;
1162} 1173}
1163 1174
1164void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) 1175void KToolBar::saveSettings(KConfig *config, const QString &_configGroup)
1165{ 1176{
1166 return; 1177 return;
1167 QString configGroup = _configGroup; 1178 QString configGroup = _configGroup;
1168 if (configGroup.isEmpty()) 1179 if (configGroup.isEmpty())
1169 configGroup = settingsGroup(); 1180 configGroup = settingsGroup();
1170 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; 1181 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl;
1171 1182
1172 QString position, icontext; 1183 QString position, icontext;
1173 int index; 1184 int index;
1174 getAttributes( position, icontext, index ); 1185 getAttributes( position, icontext, index );
1175 1186
1176 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; 1187 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl;
1177 1188
1178 KConfigGroupSaver saver(config, configGroup); 1189 KConfigGroupSaver saver(config, configGroup);
1179 1190
1180 if ( position != d->PositionDefault ) 1191 if ( position != d->PositionDefault )
1181 config->writeEntry("Position", position); 1192 config->writeEntry("Position", position);
1182 else 1193 else
1183 config->deleteEntry("Position"); 1194 config->deleteEntry("Position");
1184 1195
1185 if ( icontext != d->IconTextDefault ) 1196 if ( icontext != d->IconTextDefault )
1186 config->writeEntry("IconText", icontext); 1197 config->writeEntry("IconText", icontext);
1187 else 1198 else
1188 config->deleteEntry("IconText"); 1199 config->deleteEntry("IconText");
1189 1200
1190 if ( iconSize() != d->IconSizeDefault ) 1201 if ( iconSize() != d->IconSizeDefault )
1191 config->writeEntry("IconSize", iconSize()); 1202 config->writeEntry("IconSize", iconSize());
1192 else 1203 else
1193 config->deleteEntry("IconSize"); 1204 config->deleteEntry("IconSize");
1194 1205
1195 if ( isHidden() != d->HiddenDefault ) 1206 if ( isHidden() != d->HiddenDefault )
1196 config->writeEntry("Hidden", isHidden()); 1207 config->writeEntry("Hidden", isHidden());
1197 else 1208 else
1198 config->deleteEntry("Hidden"); 1209 config->deleteEntry("Hidden");
1199 1210
1200 if ( index != d->IndexDefault ) 1211 if ( index != d->IndexDefault )
1201 config->writeEntry( "Index", index ); 1212 config->writeEntry( "Index", index );
1202 else 1213 else
1203 config->deleteEntry("Index"); 1214 config->deleteEntry("Index");
1204//US the older version of KDE (used on the Zaurus) has no Offset property 1215//US the older version of KDE (used on the Zaurus) has no Offset property
1205/* if ( offset() != d->OffsetDefault ) 1216/* if ( offset() != d->OffsetDefault )
1206 config->writeEntry( "Offset", offset() ); 1217 config->writeEntry( "Offset", offset() );
1207 else 1218 else
1208*/ 1219*/
1209 config->deleteEntry("Offset"); 1220 config->deleteEntry("Offset");
1210 1221
1211//US the older version of KDE (used on the Zaurus) has no NewLine property 1222//US the older version of KDE (used on the Zaurus) has no NewLine property
1212/* 1223/*
1213 if ( newLine() != d->NewLineDefault ) 1224 if ( newLine() != d->NewLineDefault )
1214 config->writeEntry( "NewLine", newLine() ); 1225 config->writeEntry( "NewLine", newLine() );
1215 else 1226 else
1216*/ 1227*/
1217 config->deleteEntry("NewLine"); 1228 config->deleteEntry("NewLine");
1218} 1229}
1219 1230
1220void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) 1231void KToolBar::setXMLGUIClient( KXMLGUIClient *client )
1221{ 1232{
1222 d->m_xmlguiClient = client; 1233 d->m_xmlguiClient = client;
1223} 1234}
1224 1235
1225void KToolBar::setText( const QString & txt ) 1236void KToolBar::setText( const QString & txt )
1226{ 1237{
1227//US setLabel( txt + " ( " + kapp->caption() + " ) " ); 1238//US setLabel( txt + " ( " + kapp->caption() + " ) " );
1228 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); 1239 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " );
1229} 1240}
1230 1241
1231 1242
1232QString KToolBar::text() const 1243QString KToolBar::text() const
1233{ 1244{
1234 return label(); 1245 return label();
1235} 1246}
1236 1247
1237 1248
1238void KToolBar::doConnections( KToolBarButton *button ) 1249void KToolBar::doConnections( KToolBarButton *button )
1239{ 1250{
1240 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); 1251 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
1241 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); 1252 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
1242 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); 1253 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
1243 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); 1254 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
1244 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); 1255 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
1245 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); 1256 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
1246} 1257}
1247 1258
1248void KToolBar::mousePressEvent ( QMouseEvent *m ) 1259void KToolBar::mousePressEvent ( QMouseEvent *m )
1249{ 1260{
1250 if ( !mainWindow() ) 1261 if ( !mainWindow() )
1251 return; 1262 return;
1252 QMainWindow *mw = mainWindow(); 1263 Q3MainWindow *mw = mainWindow();
1253 if ( mw->toolBarsMovable() && d->m_enableContext ) { 1264 if ( mw->toolBarsMovable() && d->m_enableContext ) {
1254 if ( m->button() == RightButton ) { 1265 if ( m->button() == Qt::RightButton ) {
1255 int i = contextMenu()->exec( m->globalPos(), 0 ); 1266 int i = contextMenu()->exec( m->globalPos(), 0 );
1256 switch ( i ) { 1267 switch ( i ) {
1257 case -1: 1268 case -1:
1258 return; // popup cancelled 1269 return; // popup cancelled
1259 case CONTEXT_LEFT: 1270 case CONTEXT_LEFT:
1260//US mw->moveDockWindow( this, DockLeft ); 1271//US mw->moveDockWindow( this, DockLeft );
1261 mw->moveToolBar( this, QMainWindow::Left ); 1272 mw->moveToolBar( this, Qt::Left );
1262 break; 1273 break;
1263 case CONTEXT_RIGHT: 1274 case CONTEXT_RIGHT:
1264//US mw->moveDockWindow( this, DockRight ); 1275//US mw->moveDockWindow( this, DockRight );
1265 mw->moveToolBar( this, QMainWindow::Right ); 1276 mw->moveToolBar( this, Qt::Right );
1266 break; 1277 break;
1267 case CONTEXT_TOP: 1278 case CONTEXT_TOP:
1268//US mw->moveDockWindow( this, DockTop ); 1279//US mw->moveDockWindow( this, DockTop );
1269 mw->moveToolBar( this, QMainWindow::Top ); 1280 mw->moveToolBar( this, Qt::Top );
1270 break; 1281 break;
1271 case CONTEXT_BOTTOM: 1282 case CONTEXT_BOTTOM:
1272//US mw->moveDockWindow( this, DockBottom ); 1283//US mw->moveDockWindow( this, DockBottom );
1273 mw->moveToolBar( this, QMainWindow::Bottom ); 1284 mw->moveToolBar( this, Qt::Bottom );
1274 break; 1285 break;
1275 case CONTEXT_FLOAT: 1286 case CONTEXT_FLOAT:
1276 break; 1287 break;
1277 case CONTEXT_FLAT: 1288 case CONTEXT_FLAT:
1278//US mw->moveDockWindow( this, DockMinimized ); 1289//US mw->moveDockWindow( this, DockMinimized );
1279 mw->moveToolBar( this, QMainWindow::Minimized ); 1290 mw->moveToolBar( this, Qt::Minimized );
1280 break; 1291 break;
1281 case CONTEXT_ICONS: 1292 case CONTEXT_ICONS:
1282 setIconText( IconOnly ); 1293 setIconText( IconOnly );
1283 break; 1294 break;
1284 case CONTEXT_TEXTRIGHT: 1295 case CONTEXT_TEXTRIGHT:
1285 setIconText( IconTextRight ); 1296 setIconText( IconTextRight );
1286 break; 1297 break;
1287 case CONTEXT_TEXT: 1298 case CONTEXT_TEXT:
1288 setIconText( TextOnly ); 1299 setIconText( TextOnly );
1289 break; 1300 break;
1290 case CONTEXT_TEXTUNDER: 1301 case CONTEXT_TEXTUNDER:
1291 setIconText( IconTextBottom ); 1302 setIconText( IconTextBottom );
1292 break; 1303 break;
1293 default: 1304 default:
1294 if ( i >= CONTEXT_ICONSIZES ) 1305 if ( i >= CONTEXT_ICONSIZES )
1295 setIconSize( i - CONTEXT_ICONSIZES ); 1306 setIconSize( i - CONTEXT_ICONSIZES );
1296 else 1307 else
1297 return; // assume this was an action handled elsewhere, no need for setSettingsDirty() 1308 return; // assume this was an action handled elsewhere, no need for setSettingsDirty()
1298 } 1309 }
1299/*US 1310/*US
1300 if ( mw->inherits("KMainWindow") ) 1311 if ( mw->inherits("KMainWindow") )
1301 static_cast<KMainWindow *>(mw)->setSettingsDirty(); 1312 static_cast<KMainWindow *>(mw)->setSettingsDirty();
1302*/ 1313*/
1303 } 1314 }
1304 } 1315 }
1305} 1316}
1306 1317
1307 1318
1308void KToolBar::rebuildLayout() 1319void KToolBar::rebuildLayout()
1309{ 1320{
1310 1321
1311 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) 1322 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
1312 w->blockSignals(false); 1323 w->blockSignals(false);
1313 d->idleButtons.clear(); 1324 d->idleButtons.clear();
1314 1325
1315 layoutTimer->stop(); 1326 layoutTimer->stop();
1316 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1327 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1317 QBoxLayout *l = boxLayout(); 1328 QBoxLayout *l = boxLayout();
1318 l->setMargin( 1 ); 1329 l->setMargin( 1 );
1319 // clear the old layout 1330 // clear the old layout
1320 QLayoutIterator it = l->iterator(); 1331 QLayoutIterator it = l->iterator();
1321 1332
1322 while ( it.current() ) { 1333 while ( it.current() ) {
1323 it.deleteCurrent(); 1334 it.deleteCurrent();
1324 } 1335 }
1325 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { 1336 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
1326 if ( w == rightAligned ) { 1337 if ( w == rightAligned ) {
1327 continue; 1338 continue;
1328 } 1339 }
1329 if ( w->inherits( "KToolBarSeparator" ) && 1340 if ( w->inherits( "KToolBarSeparator" ) &&
1330 !( (KToolBarSeparator*)w )->showLine() ) { 1341 !( (KToolBarSeparator*)w )->showLine() ) {
1331 l->addSpacing( 6 ); 1342 l->addSpacing( 6 );
1332 w->hide(); 1343 w->hide();
1333 continue; 1344 continue;
1334 } 1345 }
1335 if ( w->inherits( "QPopupMenu" ) ) 1346 if ( w->inherits( "Q3PopupMenu" ) )
1336 continue; 1347 continue;
1337 l->addWidget( w ); 1348 l->addWidget( w );
1338 w->show(); 1349 w->show();
1339 } 1350 }
1340 if ( rightAligned ) { 1351 if ( rightAligned ) {
1341 l->addStretch(); 1352 l->addStretch();
1342 l->addWidget( rightAligned ); 1353 l->addWidget( rightAligned );
1343 rightAligned->show(); 1354 rightAligned->show();
1344 } 1355 }
1345 1356
1346 if ( fullSize() ) { 1357 if ( fullSize() ) {
1347 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). 1358 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword).
1348 //if ( !stretchableWidget && widgets.last() && 1359 //if ( !stretchableWidget && widgets.last() &&
1349 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) 1360 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) )
1350 // setStretchableWidget( widgets.last() ); 1361 // setStretchableWidget( widgets.last() );
1351 if ( !rightAligned ) 1362 if ( !rightAligned )
1352 l->addStretch(); 1363 l->addStretch();
1353 if ( stretchableWidget ) 1364 if ( stretchableWidget )
1354 l->setStretchFactor( stretchableWidget, 10 ); 1365 l->setStretchFactor( stretchableWidget, 10 );
1355 } 1366 }
1356 l->invalidate(); 1367 l->invalidate();
1357 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); 1368 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) );
1358 //#endif //DESKTOP_VERSION 1369 //#endif //DESKTOP_VERSION
1359} 1370}
1360 1371
1361void KToolBar::childEvent( QChildEvent *e ) 1372void KToolBar::childEvent( QChildEvent *e )
1362{ 1373{
1363 1374
1364 if ( e->child()->isWidgetType() ) { 1375 if ( e->child()->isWidgetType() ) {
1365 QWidget * w = (QWidget*)e->child(); 1376 QWidget * w = (QWidget*)e->child();
1366 if ( e->type() == QEvent::ChildInserted ) { 1377 if ( e->type() == QEvent::ChildInserted ) {
1367 if ( !e->child()->inherits( "QPopupMenu" ) && 1378 if ( !e->child()->inherits( "Q3PopupMenu" ) &&
1368 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { 1379 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) {
1369 1380
1370 // prevent items that have been explicitly inserted by insert*() from 1381 // prevent items that have been explicitly inserted by insert*() from
1371 // being inserted again 1382 // being inserted again
1372 if ( !widget2id.contains( w ) ) 1383 if ( !widget2id.contains( w ) )
1373 { 1384 {
1374 int dummy = -1; 1385 int dummy = -1;
1375 insertWidgetInternal( w, dummy, -1 ); 1386 insertWidgetInternal( w, dummy, -1 );
1376 } 1387 }
1377 } 1388 }
1378 } else { 1389 } else if( e->type() == QEvent::ChildRemoved ) {
1379 removeWidgetInternal( w ); 1390 removeWidgetInternal( w );
1380 } 1391 }
1381 if ( isVisibleTo( 0 ) ) 1392 /* TODO:hacker: if ( isVisibleTo( 0 ) )
1382 { 1393 {
1383 QBoxLayout *l = boxLayout(); 1394 QBoxLayout *l = boxLayout();
1384 // QLayout *l = layout(); 1395 // QLayout *l = layout();
1385 1396
1386 // clear the old layout so that we don't get unnecassery layout 1397 // clear the old layout so that we don't get unnecassery layout
1387 // changes till we have rebuild the thing 1398 // changes till we have rebuild the thing
1388 QLayoutIterator it = l->iterator(); 1399 QLayoutIterator it = l->iterator();
1389 while ( it.current() ) { 1400 while ( it.current() ) {
1390 it.deleteCurrent(); 1401 it.deleteCurrent();
1391 } 1402 }
1392 layoutTimer->start( 50, TRUE ); 1403 layoutTimer->start( 50, TRUE );
1393 } 1404 } */
1394 } 1405 }
1395 QToolBar::childEvent( e ); 1406 Q3ToolBar::childEvent( e );
1396} 1407}
1397 1408
1398void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) 1409void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id )
1399{ 1410{
1400 // we can't have it in widgets, or something is really wrong 1411 // we can't have it in widgets, or something is really wrong
1401 //widgets.removeRef( w ); 1412 //widgets.removeRef( w );
1402 1413
1403 connect( w, SIGNAL( destroyed() ), 1414 connect( w, SIGNAL( destroyed() ),
1404 this, SLOT( widgetDestroyed() ) ); 1415 this, SLOT( widgetDestroyed() ) );
1405 if ( index == -1 || index > (int)widgets.count() ) { 1416 if ( index == -1 || index > (int)widgets.count() ) {
1406 widgets.append( w ); 1417 widgets.append( w );
1407 index = (int)widgets.count(); 1418 index = (int)widgets.count();
1408 } 1419 }
1409 else 1420 else
1410 widgets.insert( index, w ); 1421 widgets.insert( index, w );
1411 if ( id == -1 ) 1422 if ( id == -1 )
1412 id = id2widget.count(); 1423 id = id2widget.count();
1413 id2widget.insert( id, w ); 1424 id2widget.insert( id, w );
1414 widget2id.insert( w, id ); 1425 widget2id.insert( w, id );
1415} 1426}
1416void KToolBar::repaintMe() 1427void KToolBar::repaintMe()
1417{ 1428{
1418 setUpdatesEnabled( true ); 1429 setUpdatesEnabled( true );
1419 QToolBar::repaint( true ); 1430 Q3ToolBar::repaint( true );
1420 qDebug(" KToolBar::repaintMe() "); 1431 qDebug(" KToolBar::repaintMe() ");
1421} 1432}
1422 1433
1423void KToolBar::showEvent( QShowEvent *e ) 1434void KToolBar::showEvent( QShowEvent *e )
1424{ 1435{
1425 rebuildLayout(); 1436 rebuildLayout();
1426 QToolBar::showEvent( e ); 1437 Q3ToolBar::showEvent( e );
1427} 1438}
1428 1439
1429void KToolBar::setStretchableWidget( QWidget *w ) 1440void KToolBar::setStretchableWidget( QWidget *w )
1430{ 1441{
1431 QToolBar::setStretchableWidget( w ); 1442 Q3ToolBar::setStretchableWidget( w );
1432 stretchableWidget = w; 1443 stretchableWidget = w;
1433} 1444}
1434 1445
1435QSizePolicy KToolBar::sizePolicy() const 1446QSizePolicy KToolBar::sizePolicy() const
1436{ 1447{
1437 if ( orientation() == Horizontal ) 1448 if ( orientation() == Qt::Horizontal )
1438 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); 1449 return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
1439 else 1450 else
1440 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); 1451 return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
1441} 1452}
1442 1453
1443QSize KToolBar::sizeHint() const 1454QSize KToolBar::sizeHint() const
1444{ 1455{
1445 QSize sh = QToolBar::sizeHint(); 1456 QSize sh = Q3ToolBar::sizeHint();
1446 //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() ); 1457 //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() );
1447 if ( sh.height() <= 20 || sh.width() < 60 ) 1458 if ( sh.height() <= 20 || sh.width() < 60 )
1448 return QSize( sizeHintW, sizeHintH ); 1459 return QSize( sizeHintW, sizeHintH );
1449 KToolBar* ttt = (KToolBar*) this; 1460 KToolBar* ttt = (KToolBar*) this;
1450 ttt->sizeHintW = sh.width(); 1461 ttt->sizeHintW = sh.width();
1451 ttt->sizeHintH = sh.height(); 1462 ttt->sizeHintH = sh.height();
1452 return sh; 1463 return sh;
1453 //return QToolBar::sizeHint(); 1464 //return QToolBar::sizeHint();
1454#if 0 1465#if 0
1455 QWidget::polish(); 1466 QWidget::polish();
1456 static int iii = 0; 1467 static int iii = 0;
1457 ++iii; 1468 ++iii;
1458 qDebug("++++++++ KToolBar::sizeHint() %d ", iii ); 1469 qDebug("++++++++ KToolBar::sizeHint() %d ", iii );
1459 int margin = static_cast<QWidget*>(ncThis)->layout()->margin(); 1470 int margin = static_cast<QWidget*>(ncThis)->layout()->margin();
1460 switch( barPos() ) 1471 switch( barPos() )
1461 { 1472 {
1462 case KToolBar::Top: 1473 case KToolBar::Top:
1463 case KToolBar::Bottom: 1474 case KToolBar::Bottom:
1464 for ( QWidget *w = widgets.first(); w; w =widgets.next() ) 1475 for ( QWidget *w = widgets.first(); w; w =widgets.next() )
1465 { 1476 {
1466 if ( w->inherits( "KToolBarSeparator" ) && 1477 if ( w->inherits( "KToolBarSeparator" ) &&
1467 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1478 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1468 { 1479 {
1469 minSize += QSize(6, 0); 1480 minSize += QSize(6, 0);
1470 } 1481 }
1471 else 1482 else
1472 { 1483 {
1473 QSize sh = w->sizeHint(); 1484 QSize sh = w->sizeHint();
1474 if (!sh.isValid()) 1485 if (!sh.isValid())
1475 sh = w->minimumSize(); 1486 sh = w->minimumSize();
1476 minSize = minSize.expandedTo(QSize(0, sh.height())); 1487 minSize = minSize.expandedTo(QSize(0, sh.height()));
1477 minSize += QSize(sh.width()+1, 0); 1488 minSize += QSize(sh.width()+1, 0);
1478 } 1489 }
1479 } 1490 }
1480/*US 1491/*US
1481 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0); 1492 minSize += QSize(QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ), 0);
1482*/ 1493*/
1483 minSize += QSize(margin*2, margin*2); 1494 minSize += QSize(margin*2, margin*2);
1484 break; 1495 break;
1485 1496
1486 case KToolBar::Left: 1497 case KToolBar::Left:
1487 case KToolBar::Right: 1498 case KToolBar::Right:
1488 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) 1499 for ( QWidget *w = widgets.first(); w; w = widgets.next() )
1489 { 1500 {
1490 if ( w->inherits( "KToolBarSeparator" ) && 1501 if ( w->inherits( "KToolBarSeparator" ) &&
1491 !( static_cast<KToolBarSeparator*>(w)->showLine() ) ) 1502 !( static_cast<KToolBarSeparator*>(w)->showLine() ) )
1492 { 1503 {
1493 minSize += QSize(0, 6); 1504 minSize += QSize(0, 6);
1494 } 1505 }
1495 else 1506 else
1496 { 1507 {
1497 QSize sh = w->sizeHint(); 1508 QSize sh = w->sizeHint();
1498 if (!sh.isValid()) 1509 if (!sh.isValid())
1499 sh = w->minimumSize(); 1510 sh = w->minimumSize();
1500 minSize = minSize.expandedTo(QSize(sh.width(), 0)); 1511 minSize = minSize.expandedTo(QSize(sh.width(), 0));
1501 minSize += QSize(0, sh.height()+1); 1512 minSize += QSize(0, sh.height()+1);
1502 } 1513 }
1503 } 1514 }
1504/*US 1515/*US
1505 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent )); 1516 minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
1506*/ 1517*/
1507 minSize += QSize(margin*2, margin*2); 1518 minSize += QSize(margin*2, margin*2);
1508 break; 1519 break;
1509 1520
1510 default: 1521 default:
1511 minSize = QToolBar::sizeHint(); 1522 minSize = Q3ToolBar::sizeHint();
1512 break; 1523 break;
1513 } 1524 }
1514 return minSize; 1525 return minSize;
1515#endif 1526#endif
1516} 1527}
1517 1528
1518QSize KToolBar::minimumSize() const 1529QSize KToolBar::minimumSize() const
1519{ 1530{
1520 return minimumSizeHint(); 1531 return minimumSizeHint();
1521} 1532}
1522 1533
1523QSize KToolBar::minimumSizeHint() const 1534QSize KToolBar::minimumSizeHint() const
1524{ 1535{
1525 return sizeHint(); 1536 return sizeHint();
1526} 1537}
1527 1538
1528bool KToolBar::highlight() const 1539bool KToolBar::highlight() const
1529{ 1540{
1530 return d->m_highlight; 1541 return d->m_highlight;
1531} 1542}
1532 1543
1533void KToolBar::hide() 1544void KToolBar::hide()
1534{ 1545{
1535 QToolBar::hide(); 1546 Q3ToolBar::hide();
1536} 1547}
1537 1548
1538void KToolBar::show() 1549void KToolBar::show()
1539{ 1550{
1540 QToolBar::show(); 1551 Q3ToolBar::show();
1541} 1552}
1542 1553
1543void KToolBar::resizeEvent( QResizeEvent *e ) 1554void KToolBar::resizeEvent( QResizeEvent *e )
1544{ 1555{
1545 bool b = isUpdatesEnabled(); 1556 bool b = isUpdatesEnabled();
1546 setUpdatesEnabled( FALSE ); 1557 setUpdatesEnabled( FALSE );
1547 QToolBar::resizeEvent( e ); 1558 Q3ToolBar::resizeEvent( e );
1548 if (b) 1559 if (b)
1549 d->repaintTimer.start( 100, true ); 1560 d->repaintTimer.start( 100, true );
1550} 1561}
1551 1562
1552void KToolBar::slotIconChanged(int group) 1563void KToolBar::slotIconChanged(int group)
1553{ 1564{
1554 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar)) 1565 if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar))
1555 return; 1566 return;
1556 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar")) 1567 if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar"))
1557 return; 1568 return;
1558 1569
1559 emit modechange(); 1570 emit modechange();
1560 if (isVisible()) 1571 if (isVisible())
1561 updateGeometry(); 1572 updateGeometry();
1562} 1573}
1563 1574
1564void KToolBar::slotReadConfig() 1575void KToolBar::slotReadConfig()
1565{ 1576{
1566 //kdDebug(220) << "KToolBar::slotReadConfig" << endl; 1577 //kdDebug(220) << "KToolBar::slotReadConfig" << endl;
1567 // Read appearance settings (hmm, we used to do both here, 1578 // Read appearance settings (hmm, we used to do both here,
1568 // but a well behaved application will call applyMainWindowSettings 1579 // but a well behaved application will call applyMainWindowSettings
1569 // anyway, right ?) 1580 // anyway, right ?)
1570 applyAppearanceSettings(KGlobal::config(), QString::null ); 1581 applyAppearanceSettings(KGlobal::config(), QString::null );
1571} 1582}
1572 1583
1573void KToolBar::slotAppearanceChanged() 1584void KToolBar::slotAppearanceChanged()
1574{ 1585{
1575 // Read appearance settings from global file. 1586 // Read appearance settings from global file.
1576 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ ); 1587 applyAppearanceSettings(KGlobal::config(), QString::null, true /* lose local settings */ );
1577 // And remember to save the new look later 1588 // And remember to save the new look later
1578/*US 1589/*US
1579 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1590 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1580 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1591 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1581*/ 1592*/
1582} 1593}
1583 1594
1584//static 1595//static
1585bool KToolBar::highlightSetting() 1596bool KToolBar::highlightSetting()
1586{ 1597{
1587 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1598 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1588 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1599 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1589 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true); 1600 return KGlobal::config()->readBoolEntry(QString::fromLatin1("Highlighting"),true);
1590} 1601}
1591 1602
1592//static 1603//static
1593bool KToolBar::transparentSetting() 1604bool KToolBar::transparentSetting()
1594{ 1605{
1595 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1606 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1596 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1607 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1597 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true); 1608 return KGlobal::config()->readBoolEntry(QString::fromLatin1("TransparentMoving"),true);
1598} 1609}
1599 1610
1600//static 1611//static
1601KToolBar::IconText KToolBar::iconTextSetting() 1612KToolBar::IconText KToolBar::iconTextSetting()
1602{ 1613{
1603 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1614 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1604 KConfigGroupSaver saver(KGlobal::config(), grpToolbar); 1615 KConfigGroupSaver saver(KGlobal::config(), grpToolbar);
1605 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly")); 1616 QString icontext = KGlobal::config()->readEntry(QString::fromLatin1("IconText"),QString::fromLatin1("IconOnly"));
1606 if ( icontext == "IconTextRight" ) 1617 if ( icontext == "IconTextRight" )
1607 return IconTextRight; 1618 return IconTextRight;
1608 else if ( icontext == "IconTextBottom" ) 1619 else if ( icontext == "IconTextBottom" )
1609 return IconTextBottom; 1620 return IconTextBottom;
1610 else if ( icontext == "TextOnly" ) 1621 else if ( icontext == "TextOnly" )
1611 return TextOnly; 1622 return TextOnly;
1612 else 1623 else
1613 return IconOnly; 1624 return IconOnly;
1614} 1625}
1615 1626
1616void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal) 1627void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal)
1617{ 1628{
1618 return; 1629 return;
1619 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1630 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1620 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl; 1631 //kdDebug(220) << "KToolBar::applyAppearanceSettings: configGroup=" << configGroup << endl;
1621 // We have application-specific settings in the XML file, 1632 // We have application-specific settings in the XML file,
1622 // and nothing in the application's config file 1633 // and nothing in the application's config file
1623 // -> don't apply the global defaults, the XML ones are preferred 1634 // -> don't apply the global defaults, the XML ones are preferred
1624 // See applySettings for a full explanation 1635 // See applySettings for a full explanation
1625/*US :we do not support xml files 1636/*US :we do not support xml files
1626 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() && 1637 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() &&
1627 !config->hasGroup(configGroup) ) 1638 !config->hasGroup(configGroup) )
1628 { 1639 {
1629 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1640 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1630 return; 1641 return;
1631 } 1642 }
1632*/ 1643*/
1633 if ( !config->hasGroup(configGroup) ) 1644 if ( !config->hasGroup(configGroup) )
1634 { 1645 {
1635 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl; 1646 //kdDebug(220) << "skipping global defaults, using XML ones instead" << endl;
1636 return; 1647 return;
1637 } 1648 }
1638 1649
1639 1650
1640 KConfig *gconfig = KGlobal::config(); 1651 KConfig *gconfig = KGlobal::config();
1641/*US 1652/*US
1642 static const QString &attrIconText = KGlobal::staticQString("IconText"); 1653 static const QString &attrIconText = KGlobal::staticQString("IconText");
1643 static const QString &attrHighlight = KGlobal::staticQString("Highlighting"); 1654 static const QString &attrHighlight = KGlobal::staticQString("Highlighting");
1644 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving"); 1655 static const QString &attrTrans = KGlobal::staticQString("TransparentMoving");
1645 static const QString &attrSize = KGlobal::staticQString("IconSize"); 1656 static const QString &attrSize = KGlobal::staticQString("IconSize");
1646*/ 1657*/
1647 // we actually do this in two steps. 1658 // we actually do this in two steps.
1648 // First, we read in the global styles [Toolbar style] (from the KControl module). 1659 // First, we read in the global styles [Toolbar style] (from the KControl module).
1649 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style] 1660 // Then, if the toolbar is NOT 'mainToolBar', we will also try to read in [barname Toolbar style]
1650 bool highlight; 1661 bool highlight;
1651 int transparent; 1662 int transparent;
1652 QString icontext; 1663 QString icontext;
1653 int iconsize = 0; 1664 int iconsize = 0;
1654 1665
1655 // this is the first iteration 1666 // this is the first iteration
1656 QString grpToolbar(QString::fromLatin1("Toolbar style")); 1667 QString grpToolbar(QString::fromLatin1("Toolbar style"));
1657 { // start block for KConfigGroupSaver 1668 { // start block for KConfigGroupSaver
1658 KConfigGroupSaver saver(gconfig, grpToolbar); 1669 KConfigGroupSaver saver(gconfig, grpToolbar);
1659 1670
1660 // first, get the generic settings 1671 // first, get the generic settings
1661//US highlight = gconfig->readBoolEntry(attrHighlight, true); 1672//US highlight = gconfig->readBoolEntry(attrHighlight, true);
1662 highlight = gconfig->readBoolEntry("Highlighting", true); 1673 highlight = gconfig->readBoolEntry("Highlighting", true);
1663//US transparent = gconfig->readBoolEntry(attrTrans, true); 1674//US transparent = gconfig->readBoolEntry(attrTrans, true);
1664 transparent = gconfig->readBoolEntry("TransparentMoving", true); 1675 transparent = gconfig->readBoolEntry("TransparentMoving", true);
1665 1676
1666 // we read in the IconText property *only* if we intend on actually 1677 // we read in the IconText property *only* if we intend on actually
1667 // honoring it 1678 // honoring it
1668 if (d->m_honorStyle) 1679 if (d->m_honorStyle)
1669//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault); 1680//US d->IconTextDefault = gconfig->readEntry(attrIconText, d->IconTextDefault);
1670 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault); 1681 d->IconTextDefault = gconfig->readEntry("IconText", d->IconTextDefault);
1671 else 1682 else
1672 d->IconTextDefault = "IconOnly"; 1683 d->IconTextDefault = "IconOnly";
1673 1684
1674 // Use the default icon size for toolbar icons. 1685 // Use the default icon size for toolbar icons.
1675//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault); 1686//US d->IconSizeDefault = gconfig->readNumEntry(attrSize, d->IconSizeDefault);
1676 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault); 1687 d->IconSizeDefault = gconfig->readNumEntry("IconSize", d->IconSizeDefault);
1677 1688
1678 if ( !forceGlobal && config->hasGroup(configGroup) ) 1689 if ( !forceGlobal && config->hasGroup(configGroup) )
1679 { 1690 {
1680 config->setGroup(configGroup); 1691 config->setGroup(configGroup);
1681 1692
1682 // first, get the generic settings 1693 // first, get the generic settings
1683//US highlight = config->readBoolEntry(attrHighlight, highlight); 1694//US highlight = config->readBoolEntry(attrHighlight, highlight);
1684 highlight = config->readBoolEntry("Highlighting", highlight); 1695 highlight = config->readBoolEntry("Highlighting", highlight);
1685//US transparent = config->readBoolEntry(attrTrans, transparent); 1696//US transparent = config->readBoolEntry(attrTrans, transparent);
1686 transparent = config->readBoolEntry("TransparentMoving", transparent); 1697 transparent = config->readBoolEntry("TransparentMoving", transparent);
1687 // now we always read in the IconText property 1698 // now we always read in the IconText property
1688//US icontext = config->readEntry(attrIconText, d->IconTextDefault); 1699//US icontext = config->readEntry(attrIconText, d->IconTextDefault);
1689 icontext = config->readEntry("IconText", d->IconTextDefault); 1700 icontext = config->readEntry("IconText", d->IconTextDefault);
1690 1701
1691 // now get the size 1702 // now get the size
1692//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault); 1703//US iconsize = config->readNumEntry(attrSize, d->IconSizeDefault);
1693 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault); 1704 iconsize = config->readNumEntry("IconSize", d->IconSizeDefault);
1694 } 1705 }
1695 else 1706 else
1696 { 1707 {
1697 iconsize = d->IconSizeDefault; 1708 iconsize = d->IconSizeDefault;
1698 icontext = d->IconTextDefault; 1709 icontext = d->IconTextDefault;
1699 } 1710 }
1700 1711
1701 // revert back to the old group 1712 // revert back to the old group
1702 } // end block for KConfigGroupSaver 1713 } // end block for KConfigGroupSaver
1703 1714
1704 bool doUpdate = false; 1715 bool doUpdate = false;
1705 1716
1706 IconText icon_text; 1717 IconText icon_text;
1707 if ( icontext == "IconTextRight" ) 1718 if ( icontext == "IconTextRight" )
1708 icon_text = IconTextRight; 1719 icon_text = IconTextRight;
1709 else if ( icontext == "IconTextBottom" ) 1720 else if ( icontext == "IconTextBottom" )
1710 icon_text = IconTextBottom; 1721 icon_text = IconTextBottom;
1711 else if ( icontext == "TextOnly" ) 1722 else if ( icontext == "TextOnly" )
1712 icon_text = TextOnly; 1723 icon_text = TextOnly;
1713 else 1724 else
1714 icon_text = IconOnly; 1725 icon_text = IconOnly;
1715 1726
1716 // check if the icon/text has changed 1727 // check if the icon/text has changed
1717 if (icon_text != d->m_iconText) { 1728 if (icon_text != d->m_iconText) {
1718 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl; 1729 //kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl;
1719 setIconText(icon_text, false); 1730 setIconText(icon_text, false);
1720 doUpdate = true; 1731 doUpdate = true;
1721 } 1732 }
1722 1733
1723 // ...and check if the icon size has changed 1734 // ...and check if the icon size has changed
1724 if (iconsize != d->m_iconSize) { 1735 if (iconsize != d->m_iconSize) {
1725 setIconSize(iconsize, false); 1736 setIconSize(iconsize, false);
1726 doUpdate = true; 1737 doUpdate = true;
1727 } 1738 }
1728 1739
1729 QMainWindow *mw = mainWindow(); 1740 Q3MainWindow *mw = mainWindow();
1730 1741
1731 // ...and if we should highlight 1742 // ...and if we should highlight
1732 if ( highlight != d->m_highlight ) { 1743 if ( highlight != d->m_highlight ) {
1733 d->m_highlight = highlight; 1744 d->m_highlight = highlight;
1734 doUpdate = true; 1745 doUpdate = true;
1735 } 1746 }
1736 1747
1737 // ...and if we should move transparently 1748 // ...and if we should move transparently
1738 if ( mw && transparent != (!mw->opaqueMoving()) ) { 1749 if ( mw && transparent != (!mw->opaqueMoving()) ) {
1739 mw->setOpaqueMoving( !transparent ); 1750 mw->setOpaqueMoving( !transparent );
1740 } 1751 }
1741 1752
1742 if (doUpdate) 1753 if (doUpdate)
1743 emit modechange(); // tell buttons what happened 1754 emit modechange(); // tell buttons what happened
1744 if (isVisible ()) 1755 if (isVisible ())
1745 updateGeometry(); 1756 updateGeometry();
1746} 1757}
1747 1758
1748void KToolBar::applySettings(KConfig *config, const QString &_configGroup) 1759void KToolBar::applySettings(KConfig *config, const QString &_configGroup)
1749{ 1760{
1750 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl; 1761 //kdDebug(220) << "KToolBar::applySettings group=" << _configGroup << endl;
1751 1762
1752 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup; 1763 QString configGroup = _configGroup.isEmpty() ? settingsGroup() : _configGroup;
1753 1764
1754 /* 1765 /*
1755 Let's explain this a bit more in details. 1766 Let's explain this a bit more in details.
1756 The order in which we apply settings is : 1767 The order in which we apply settings is :
1757 Global config / <appnamerc> user settings if no XMLGUI is used 1768 Global config / <appnamerc> user settings if no XMLGUI is used
1758 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used 1769 Global config / App-XML attributes / <appnamerc> user settings if XMLGUI is used
1759 1770
1760 So in the first case, we simply read everything from KConfig as below, 1771 So in the first case, we simply read everything from KConfig as below,
1761 but in the second case we don't do anything here if there is no app-specific config, 1772 but in the second case we don't do anything here if there is no app-specific config,
1762 and the XMLGUI uses the static methods of this class to get the global defaults. 1773 and the XMLGUI uses the static methods of this class to get the global defaults.
1763 1774
1764 Global config doesn't include position (index, offset, newline and hidden/shown). 1775 Global config doesn't include position (index, offset, newline and hidden/shown).
1765 */ 1776 */
1766 1777
1767 // First the appearance stuff - the one which has a global config 1778 // First the appearance stuff - the one which has a global config
1768 applyAppearanceSettings( config, _configGroup ); 1779 applyAppearanceSettings( config, _configGroup );
1769 1780
1770 // ...and now the position stuff 1781 // ...and now the position stuff
1771 if ( config->hasGroup(configGroup) ) 1782 if ( config->hasGroup(configGroup) )
1772 { 1783 {
1773 KConfigGroupSaver cgs(config, configGroup); 1784 KConfigGroupSaver cgs(config, configGroup);
1774/*US 1785/*US
1775 static const QString &attrPosition = KGlobal::staticQString("Position"); 1786 static const QString &attrPosition = KGlobal::staticQString("Position");
1776 static const QString &attrIndex = KGlobal::staticQString("Index"); 1787 static const QString &attrIndex = KGlobal::staticQString("Index");
1777 static const QString &attrOffset = KGlobal::staticQString("Offset"); 1788 static const QString &attrOffset = KGlobal::staticQString("Offset");
1778 static const QString &attrNewLine = KGlobal::staticQString("NewLine"); 1789 static const QString &attrNewLine = KGlobal::staticQString("NewLine");
1779 static const QString &attrHidden = KGlobal::staticQString("Hidden"); 1790 static const QString &attrHidden = KGlobal::staticQString("Hidden");
1780 1791
1781 QString position = config->readEntry(attrPosition, d->PositionDefault); 1792 QString position = config->readEntry(attrPosition, d->PositionDefault);
1782 int index = config->readNumEntry(attrIndex, d->IndexDefault); 1793 int index = config->readNumEntry(attrIndex, d->IndexDefault);
1783 int offset = config->readNumEntry(attrOffset, d->OffsetDefault); 1794 int offset = config->readNumEntry(attrOffset, d->OffsetDefault);
1784 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault); 1795 bool newLine = config->readBoolEntry(attrNewLine, d->NewLineDefault);
1785 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault); 1796 bool hidden = config->readBoolEntry(attrHidden, d->HiddenDefault);
1786*/ 1797*/
1787 1798
1788 QString position = config->readEntry("Position", d->PositionDefault); 1799 QString position = config->readEntry("Position", d->PositionDefault);
1789 int index = config->readNumEntry("Index", d->IndexDefault); 1800 int index = config->readNumEntry("Index", d->IndexDefault);
1790 int offset = config->readNumEntry("Offset", d->OffsetDefault); 1801 int offset = config->readNumEntry("Offset", d->OffsetDefault);
1791 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault); 1802 bool newLine = config->readBoolEntry("NewLine", d->NewLineDefault);
1792 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault); 1803 bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault);
1793 1804
1794/*US Dock pos(DockTop); 1805/*US Dock pos(DockTop);
1795 if ( position == "Top" ) 1806 if ( position == "Top" )
1796 pos = DockTop; 1807 pos = DockTop;
1797 else if ( position == "Bottom" ) 1808 else if ( position == "Bottom" )
1798 pos = DockBottom; 1809 pos = DockBottom;
1799 else if ( position == "Left" ) 1810 else if ( position == "Left" )
1800 pos = DockLeft; 1811 pos = DockLeft;
1801 else if ( position == "Right" ) 1812 else if ( position == "Right" )
1802 pos = DockRight; 1813 pos = DockRight;
1803 else if ( position == "Floating" ) 1814 else if ( position == "Floating" )
1804 pos = DockTornOff; 1815 pos = DockTornOff;
1805 else if ( position == "Flat" ) 1816 else if ( position == "Flat" )
1806 pos = DockMinimized; 1817 pos = DockMinimized;
1807*/ 1818*/
1808 QMainWindow::ToolBarDock pos(QMainWindow::Top); 1819 Qt::ToolBarDock pos(Qt::DockTop);
1809 if ( position == "Top" ) 1820 if ( position == "Top" )
1810 pos = QMainWindow::Top; 1821 pos = Qt::Top;
1811 else if ( position == "Bottom" ) 1822 else if ( position == "Bottom" )
1812 pos = QMainWindow::Bottom; 1823 pos = Qt::Bottom;
1813 else if ( position == "Left" ) 1824 else if ( position == "Left" )
1814 pos = QMainWindow::Left; 1825 pos = Qt::Left;
1815 else if ( position == "Right" ) 1826 else if ( position == "Right" )
1816 pos = QMainWindow::Right; 1827 pos = Qt::Right;
1817 else if ( position == "Floating" ) 1828 else if ( position == "Floating" )
1818 pos = QMainWindow::TornOff; 1829 pos = Qt::TornOff;
1819 else if ( position == "Flat" ) 1830 else if ( position == "Flat" )
1820 pos = QMainWindow::Minimized; 1831 pos = Qt::Minimized;
1821 1832
1822 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; 1833 //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl;
1823 if (hidden) 1834 if (hidden)
1824 hide(); 1835 hide();
1825 else 1836 else
1826 show(); 1837 show();
1827 1838
1828 if ( mainWindow() ) 1839 if ( mainWindow() )
1829 { 1840 {
1830 QMainWindow *mw = mainWindow(); 1841 Q3MainWindow *mw = mainWindow();
1831 1842
1832 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; 1843 //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl;
1833 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); 1844 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset );
1834 1845
1835 // moveDockWindow calls QDockArea which does a reparent() on us with 1846 // moveDockWindow calls QDockArea which does a reparent() on us with
1836 // showIt = true, so we loose our visibility status 1847 // showIt = true, so we loose our visibility status
1837 bool doHide = isHidden(); 1848 bool doHide = isHidden();
1838 1849
1839//US mw->moveDockWindow( this, pos, newLine, index, offset ); 1850//US mw->moveDockWindow( this, pos, newLine, index, offset );
1840 mw->moveToolBar( this, pos, newLine, index, offset ); 1851 mw->moveToolBar( this, pos, newLine, index, offset );
1841 1852
1842 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl; 1853 //kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl;
1843 if ( doHide ) 1854 if ( doHide )
1844 hide(); 1855 hide();
1845 } 1856 }
1846 if (isVisible ()) 1857 if (isVisible ())
1847 updateGeometry(); 1858 updateGeometry();
1848 } 1859 }
1849} 1860}
1850 1861
1851bool KToolBar::event( QEvent *e ) 1862bool KToolBar::event( QEvent *e )
1852{ 1863{
1853 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() ) 1864 if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() )
1854 d->repaintTimer.start( 100, true ); 1865 d->repaintTimer.start( 100, true );
1855 1866
1856 if (e->type() == QEvent::ChildInserted ) 1867 if (e->type() == QEvent::ChildInserted )
1857 { 1868 {
1858 // By pass QToolBar::event, 1869 // By pass QToolBar::event,
1859 // it will show() the inserted child and we don't want to 1870 // it will show() the inserted child and we don't want to
1860 // do that until we have rebuild the layout. 1871 // do that until we have rebuild the layout.
1861 childEvent((QChildEvent *)e); 1872 childEvent((QChildEvent *)e);
1862 return true; 1873 return true;
1863 } 1874 }
1864 1875
1865 return QToolBar::event( e ); 1876 return Q3ToolBar::event( e );
1866} 1877}
1867 1878
1868void KToolBar::slotRepaint() 1879void KToolBar::slotRepaint()
1869{ 1880{
1870 setUpdatesEnabled( FALSE ); 1881 setUpdatesEnabled( FALSE );
1871 // Send a resizeEvent to update the "toolbar extension arrow" 1882 // Send a resizeEvent to update the "toolbar extension arrow"
1872 // (The button you get when your toolbar-items don't fit in 1883 // (The button you get when your toolbar-items don't fit in
1873 // the available space) 1884 // the available space)
1874 QResizeEvent ev(size(), size()); 1885 QResizeEvent ev(size(), size());
1875 resizeEvent(&ev); 1886 resizeEvent(&ev);
1876 //#ifdef DESKTOP_VERSION 1887 //#ifdef DESKTOP_VERSION
1877 QApplication::sendPostedEvents( this, QEvent::LayoutHint ); 1888 QApplication::sendPostedEvents( this, QEvent::LayoutHint );
1878 //#endif //DESKTOP_VERSION 1889 //#endif //DESKTOP_VERSION
1879 setUpdatesEnabled( TRUE ); 1890 setUpdatesEnabled( TRUE );
1880 repaint( TRUE ); 1891 repaint( TRUE );
1881} 1892}
1882 1893
1883void KToolBar::toolBarPosChanged( QToolBar *tb ) 1894void KToolBar::toolBarPosChanged( Q3ToolBar *tb )
1884{ 1895{
1885 if ( tb != this ) 1896 if ( tb != this )
1886 return; 1897 return;
1887//US if ( d->oldPos == DockMinimized ) 1898//US if ( d->oldPos == DockMinimized )
1888 if ( d->oldPos == QMainWindow::Minimized ) 1899 if ( d->oldPos == Qt::Minimized )
1889 rebuildLayout(); 1900 rebuildLayout();
1890 d->oldPos = (QMainWindow::ToolBarDock)barPos(); 1901 d->oldPos = (Qt::ToolBarDock)barPos();
1891/*US 1902/*US
1892 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 1903 if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
1893 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1904 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1894*/ 1905*/
1895} 1906}
1896 1907
1897/*US 1908/*US
1898void KToolBar::loadState( const QDomElement &element ) 1909void KToolBar::loadState( const QDomElement &element )
1899{ 1910{
1900 //kdDebug(220) << "KToolBar::loadState " << this << endl; 1911 //kdDebug(220) << "KToolBar::loadState " << this << endl;
1901 if ( !mainWindow() ) 1912 if ( !mainWindow() )
1902 return; 1913 return;
1903 1914
1904 { 1915 {
1905 QCString text = element.namedItem( "text" ).toElement().text().utf8(); 1916 QCString text = element.namedItem( "text" ).toElement().text().utf8();
1906 if ( text.isEmpty() ) 1917 if ( text.isEmpty() )
1907 text = element.namedItem( "Text" ).toElement().text().utf8(); 1918 text = element.namedItem( "Text" ).toElement().text().utf8();
1908 if ( !text.isEmpty() ) 1919 if ( !text.isEmpty() )
1909 setText( i18n( text ) ); 1920 setText( i18n( text ) );
1910 } 1921 }
1911 1922
1912 { 1923 {
1913 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1(); 1924 QCString attrFullWidth = element.attribute( "fullWidth" ).lower().latin1();
1914 if ( !attrFullWidth.isEmpty() ) 1925 if ( !attrFullWidth.isEmpty() )
1915 setFullSize( attrFullWidth == "true" ); 1926 setFullSize( attrFullWidth == "true" );
1916 } 1927 }
1917 1928
1918 Dock dock = DockTop; 1929 Dock dock = DockTop;
1919 { 1930 {
1920 QCString attrPosition = element.attribute( "position" ).lower().latin1(); 1931 QCString attrPosition = element.attribute( "position" ).lower().latin1();
1921 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl; 1932 //kdDebug(220) << "KToolBar::loadState attrPosition=" << attrPosition << endl;
1922 if ( !attrPosition.isEmpty() ) { 1933 if ( !attrPosition.isEmpty() ) {
1923 if ( attrPosition == "top" ) 1934 if ( attrPosition == "top" )
1924 dock = DockTop; 1935 dock = DockTop;
1925 else if ( attrPosition == "left" ) 1936 else if ( attrPosition == "left" )
1926 dock = DockLeft; 1937 dock = DockLeft;
1927 else if ( attrPosition == "right" ) 1938 else if ( attrPosition == "right" )
1928 dock = DockRight; 1939 dock = DockRight;
1929 else if ( attrPosition == "bottom" ) 1940 else if ( attrPosition == "bottom" )
1930 dock = DockBottom; 1941 dock = DockBottom;
1931 else if ( attrPosition == "floating" ) 1942 else if ( attrPosition == "floating" )
1932 dock = DockTornOff; 1943 dock = DockTornOff;
1933 else if ( attrPosition == "flat" ) 1944 else if ( attrPosition == "flat" )
1934 dock = DockMinimized; 1945 dock = DockMinimized;
1935 } 1946 }
1936 } 1947 }
1937 1948
1938 { 1949 {
1939 QCString attrIconText = element.attribute( "iconText" ).lower().latin1(); 1950 QCString attrIconText = element.attribute( "iconText" ).lower().latin1();
1940 if ( !attrIconText.isEmpty() ) { 1951 if ( !attrIconText.isEmpty() ) {
1941 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl; 1952 //kdDebug(220) << "KToolBar::loadState attrIconText=" << attrIconText << endl;
1942 if ( attrIconText == "icontextright" ) 1953 if ( attrIconText == "icontextright" )
1943 setIconText( KToolBar::IconTextRight ); 1954 setIconText( KToolBar::IconTextRight );
1944 else if ( attrIconText == "textonly" ) 1955 else if ( attrIconText == "textonly" )
1945 setIconText( KToolBar::TextOnly ); 1956 setIconText( KToolBar::TextOnly );
1946 else if ( attrIconText == "icontextbottom" ) 1957 else if ( attrIconText == "icontextbottom" )
1947 setIconText( KToolBar::IconTextBottom ); 1958 setIconText( KToolBar::IconTextBottom );
1948 else if ( attrIconText == "icononly" ) 1959 else if ( attrIconText == "icononly" )
1949 setIconText( KToolBar::IconOnly ); 1960 setIconText( KToolBar::IconOnly );
1950 } else 1961 } else
1951 // Use global setting 1962 // Use global setting
1952 setIconText( iconTextSetting() ); 1963 setIconText( iconTextSetting() );
1953 } 1964 }
1954 1965
1955 { 1966 {
1956 QString attrIconSize = element.attribute( "iconSize" ).lower(); 1967 QString attrIconSize = element.attribute( "iconSize" ).lower();
1957 if ( !attrIconSize.isEmpty() ) 1968 if ( !attrIconSize.isEmpty() )
1958 d->IconSizeDefault = attrIconSize.toInt(); 1969 d->IconSizeDefault = attrIconSize.toInt();
1959 setIconSize( d->IconSizeDefault ); 1970 setIconSize( d->IconSizeDefault );
1960 } 1971 }
1961 1972
1962 { 1973 {
1963 QString attrIndex = element.attribute( "index" ).lower(); 1974 QString attrIndex = element.attribute( "index" ).lower();
1964 if ( !attrIndex.isEmpty() ) 1975 if ( !attrIndex.isEmpty() )
1965 d->IndexDefault = attrIndex.toInt(); 1976 d->IndexDefault = attrIndex.toInt();
1966 } 1977 }
1967 1978
1968 { 1979 {
1969 QString attrOffset = element.attribute( "offset" ).lower(); 1980 QString attrOffset = element.attribute( "offset" ).lower();
1970 if ( !attrOffset.isEmpty() ) 1981 if ( !attrOffset.isEmpty() )
1971 d->OffsetDefault = attrOffset.toInt(); 1982 d->OffsetDefault = attrOffset.toInt();
1972 } 1983 }
1973 1984
1974 { 1985 {
1975 QString attrNewLine = element.attribute( "newline" ).lower(); 1986 QString attrNewLine = element.attribute( "newline" ).lower();
1976 if ( !attrNewLine.isEmpty() ) 1987 if ( !attrNewLine.isEmpty() )
1977 d->NewLineDefault = attrNewLine == "true"; 1988 d->NewLineDefault = attrNewLine == "true";
1978 } 1989 }
1979 1990
1980 { 1991 {
1981 QString attrHidden = element.attribute( "hidden" ).lower(); 1992 QString attrHidden = element.attribute( "hidden" ).lower();
1982 if ( !attrHidden.isEmpty() ) 1993 if ( !attrHidden.isEmpty() )
1983 d->HiddenDefault = attrHidden == "true"; 1994 d->HiddenDefault = attrHidden == "true";
1984 } 1995 }
1985 1996
1986 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault ); 1997 d->toolBarInfo = KToolBarPrivate::ToolBarInfo( dock, d->IndexDefault, d->NewLineDefault, d->OffsetDefault );
1987 mainWindow()->addDockWindow( this, dock, d->NewLineDefault ); 1998 mainWindow()->addDockWindow( this, dock, d->NewLineDefault );
1988//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 1999//US mainWindow()->moveDockWindow( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1989 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 2000 mainWindow()->moveToolBar( this, dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
1990 2001
1991 // Apply the highlight button setting 2002 // Apply the highlight button setting
1992 d->m_highlight = highlightSetting(); 2003 d->m_highlight = highlightSetting();
1993 2004
1994 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow, 2005 // Apply transparent-toolbar-moving setting (ok, this is global to the mainwindow,
1995 // but we do it only if there are toolbars...) 2006 // but we do it only if there are toolbars...)
1996 if ( transparentSetting() != !mainWindow()->opaqueMoving() ) 2007 if ( transparentSetting() != !mainWindow()->opaqueMoving() )
1997 mainWindow()->setOpaqueMoving( !transparentSetting() ); 2008 mainWindow()->setOpaqueMoving( !transparentSetting() );
1998 2009
1999 if ( d->HiddenDefault ) 2010 if ( d->HiddenDefault )
2000 hide(); 2011 hide();
2001 else 2012 else
2002 show(); 2013 show();
2003 2014
2004 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault ); 2015 getAttributes( d->PositionDefault, d->IconTextDefault, d->IndexDefault );
2005} 2016}
2006*/ 2017*/
2007 2018
2008void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) 2019void KToolBar::getAttributes( QString &position, QString &icontext, int &index )
2009{ 2020{
2010 // get all of the stuff to save 2021 // get all of the stuff to save
2011 switch ( barPos() ) { 2022 switch ( barPos() ) {
2012 case KToolBar::Flat: 2023 case KToolBar::Flat:
2013 position = "Flat"; 2024 position = "Flat";
2014 break; 2025 break;
2015 case KToolBar::Bottom: 2026 case KToolBar::Bottom:
2016 position = "Bottom"; 2027 position = "Bottom";
2017 break; 2028 break;
2018 case KToolBar::Left: 2029 case KToolBar::Left:
2019 position = "Left"; 2030 position = "Left";
2020 break; 2031 break;
2021 case KToolBar::Right: 2032 case KToolBar::Right:
2022 position = "Right"; 2033 position = "Right";
2023 break; 2034 break;
2024 case KToolBar::Floating: 2035 case KToolBar::Floating:
2025 position = "Floating"; 2036 position = "Floating";
2026 break; 2037 break;
2027 case KToolBar::Top: 2038 case KToolBar::Top:
2028 default: 2039 default:
2029 position = "Top"; 2040 position = "Top";
2030 break; 2041 break;
2031 } 2042 }
2032 2043
2033 if ( mainWindow() ) { 2044 if ( mainWindow() ) {
2034 QMainWindow::ToolBarDock dock; 2045 Qt::ToolBarDock dock;
2035 bool newLine; 2046 bool newLine;
2036 int offset; 2047 int offset;
2037 mainWindow()->getLocation( this, dock, index, newLine, offset ); 2048 mainWindow()->getLocation( this, dock, index, newLine, offset );
2038 } 2049 }
2039 2050
2040 switch (d->m_iconText) { 2051 switch (d->m_iconText) {
2041 case KToolBar::IconTextRight: 2052 case KToolBar::IconTextRight:
2042 icontext = "IconTextRight"; 2053 icontext = "IconTextRight";
2043 break; 2054 break;
2044 case KToolBar::IconTextBottom: 2055 case KToolBar::IconTextBottom:
2045 icontext = "IconTextBottom"; 2056 icontext = "IconTextBottom";
2046 break; 2057 break;
2047 case KToolBar::TextOnly: 2058 case KToolBar::TextOnly:
2048 icontext = "TextOnly"; 2059 icontext = "TextOnly";
2049 break; 2060 break;
2050 case KToolBar::IconOnly: 2061 case KToolBar::IconOnly:
2051 default: 2062 default:
2052 icontext = "IconOnly"; 2063 icontext = "IconOnly";
2053 break; 2064 break;
2054 } 2065 }
2055} 2066}
2056/*US 2067/*US
2057void KToolBar::saveState( QDomElement &current ) 2068void KToolBar::saveState( QDomElement &current )
2058{ 2069{
2059 QString position, icontext; 2070 QString position, icontext;
2060 int index = -1; 2071 int index = -1;
2061 getAttributes( position, icontext, index ); 2072 getAttributes( position, icontext, index );
2062 2073
2063 current.setAttribute( "noMerge", "1" ); 2074 current.setAttribute( "noMerge", "1" );
2064 current.setAttribute( "position", position ); 2075 current.setAttribute( "position", position );
2065 current.setAttribute( "iconText", icontext ); 2076 current.setAttribute( "iconText", icontext );
2066 current.setAttribute( "index", index ); 2077 current.setAttribute( "index", index );
2067 current.setAttribute( "offset", offset() ); 2078 current.setAttribute( "offset", offset() );
2068 current.setAttribute( "newline", newLine() ); 2079 current.setAttribute( "newline", newLine() );
2069 if ( isHidden() ) 2080 if ( isHidden() )
2070 current.setAttribute( "hidden", "true" ); 2081 current.setAttribute( "hidden", "true" );
2071 d->modified = true; 2082 d->modified = true;
2072} 2083}
2073*/ 2084*/
2074 2085
2075void KToolBar::positionYourself( bool force ) 2086void KToolBar::positionYourself( bool force )
2076{ 2087{
2077 if (force) 2088 if (force)
2078 d->positioned = false; 2089 d->positioned = false;
2079 2090
2080 if ( d->positioned || !mainWindow() ) 2091 if ( d->positioned || !mainWindow() )
2081 { 2092 {
2082 //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl; 2093 //kdDebug(220) << "KToolBar::positionYourself d->positioned=true ALREADY DONE" << endl;
2083 return; 2094 return;
2084 } 2095 }
2085 // we can't test for ForceHide after moveDockWindow because QDockArea 2096 // we can't test for ForceHide after moveDockWindow because QDockArea
2086 // does a reparent() with showIt == true 2097 // does a reparent() with showIt == true
2087 bool doHide = isHidden(); 2098 bool doHide = isHidden();
2088 //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl; 2099 //kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl;
2089/*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock, 2100/*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock,
2090 d->toolBarInfo.newline, 2101 d->toolBarInfo.newline,
2091 d->toolBarInfo.index, 2102 d->toolBarInfo.index,
2092 d->toolBarInfo.offset ); 2103 d->toolBarInfo.offset );
2093*/ 2104*/
2094 mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault ); 2105 mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
2095 2106
2096 if ( doHide ) 2107 if ( doHide )
2097 hide(); 2108 hide();
2098 // This method can only have an effect once - unless force is set 2109 // This method can only have an effect once - unless force is set
2099 d->positioned = TRUE; 2110 d->positioned = TRUE;
2100} 2111}
2101 2112
2102//US KPopupMenu *KToolBar::contextMenu() 2113//US KPopupMenu *KToolBar::contextMenu()
2103QPopupMenu *KToolBar::contextMenu() 2114Q3PopupMenu *KToolBar::contextMenu()
2104{ 2115{
2105 if ( context ) 2116 if ( context )
2106 return context; 2117 return context;
2107 2118
2108 // Construct our context popup menu. Name it qt_dockwidget_internal so it 2119 // Construct our context popup menu. Name it qt_dockwidget_internal so it
2109 // won't be deleted by QToolBar::clear(). 2120 // won't be deleted by QToolBar::clear().
2110//US context = new KPopupMenu( this, "qt_dockwidget_internal" ); 2121//US context = new KPopupMenu( this, "qt_dockwidget_internal" );
2111 context = new QPopupMenu( this, "qt_dockwidget_internal" ); 2122 context = new Q3PopupMenu( this, "qt_dockwidget_internal" );
2112//US context->insertTitle(i18n("Toolbar Menu")); 2123//US context->insertTitle(i18n("Toolbar Menu"));
2113 2124
2114//US KPopupMenu *orient = new KPopupMenu( context, "orient" ); 2125//US KPopupMenu *orient = new KPopupMenu( context, "orient" );
2115 QPopupMenu *orient = new QPopupMenu( context, "orient" ); 2126 Q3PopupMenu *orient = new Q3PopupMenu( context, "orient" );
2116 orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); 2127 orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP );
2117 orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); 2128 orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT );
2118 orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); 2129 orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT );
2119 orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM ); 2130 orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM );
2120 orient->insertSeparator(-1); 2131 orient->insertSeparator(-1);
2121 //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT ); 2132 //orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT );
2122 orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); 2133 orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT );
2123 2134
2124//US KPopupMenu *mode = new KPopupMenu( context, "mode" ); 2135//US KPopupMenu *mode = new KPopupMenu( context, "mode" );
2125 QPopupMenu *mode = new QPopupMenu( context, "mode" ); 2136 Q3PopupMenu *mode = new Q3PopupMenu( context, "mode" );
2126 mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); 2137 mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS );
2127 mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); 2138 mode->insertItem( i18n("Text Only"), CONTEXT_TEXT );
2128 mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); 2139 mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT );
2129 mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); 2140 mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER );
2130 2141
2131//US KPopupMenu *size = new KPopupMenu( context, "size" ); 2142//US KPopupMenu *size = new KPopupMenu( context, "size" );
2132 QPopupMenu *size = new QPopupMenu( context, "size" ); 2143 Q3PopupMenu *size = new Q3PopupMenu( context, "size" );
2133 size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); 2144 size->insertItem( i18n("Default"), CONTEXT_ICONSIZES );
2134 // Query the current theme for available sizes 2145 // Query the current theme for available sizes
2135 QValueList<int> avSizes; 2146 Q3ValueList<int> avSizes;
2136/*US 2147/*US
2137 KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); 2148 KIconTheme *theme = KGlobal::instance()->iconLoader()->theme();
2138 if (!::qstrcmp(QObject::name(), "mainToolBar")) 2149 if (!::qstrcmp(QObject::name(), "mainToolBar"))
2139 avSizes = theme->querySizes( KIcon::MainToolbar); 2150 avSizes = theme->querySizes( KIcon::MainToolbar);
2140 else 2151 else
2141 avSizes = theme->querySizes( KIcon::Toolbar); 2152 avSizes = theme->querySizes( KIcon::Toolbar);
2142*/ 2153*/
2143 avSizes << 16; 2154 avSizes << 16;
2144 avSizes << 32; 2155 avSizes << 32;
2145 2156
2146 d->iconSizes = avSizes; 2157 d->iconSizes = avSizes;
2147 2158
2148 QValueList<int>::Iterator it; 2159 Q3ValueList<int>::Iterator it;
2149 for (it=avSizes.begin(); it!=avSizes.end(); it++) { 2160 for (it=avSizes.begin(); it!=avSizes.end(); it++) {
2150 QString text; 2161 QString text;
2151 if ( *it < 19 ) 2162 if ( *it < 19 )
2152 text = i18n("Small (%1x%2)").arg(*it).arg(*it); 2163 text = i18n("Small (%1x%2)").arg(*it).arg(*it);
2153 else if (*it < 25) 2164 else if (*it < 25)
2154 text = i18n("Medium (%1x%2)").arg(*it).arg(*it); 2165 text = i18n("Medium (%1x%2)").arg(*it).arg(*it);
2155 else 2166 else
2156 text = i18n("Large (%1x%2)").arg(*it).arg(*it); 2167 text = i18n("Large (%1x%2)").arg(*it).arg(*it);
2157 //we use the size as an id, with an offset 2168 //we use the size as an id, with an offset
2158 size->insertItem( text, CONTEXT_ICONSIZES + *it ); 2169 size->insertItem( text, CONTEXT_ICONSIZES + *it );
2159 } 2170 }
2160 2171
2161 context->insertItem( i18n("Orientation"), orient ); 2172 context->insertItem( i18n("Orientation"), orient );
2162 orient->setItemChecked(CONTEXT_TOP, true); 2173 orient->setItemChecked(CONTEXT_TOP, true);
2163 context->insertItem( i18n("Text Position"), mode ); 2174 context->insertItem( i18n("Text Position"), mode );
2164 context->setItemChecked(CONTEXT_ICONS, true); 2175 context->setItemChecked(CONTEXT_ICONS, true);
2165 context->insertItem( i18n("Icon Size"), size ); 2176 context->insertItem( i18n("Icon Size"), size );
2166 2177
2167/*US 2178/*US
2168 if (mainWindow()->inherits("KMainWindow")) 2179 if (mainWindow()->inherits("KMainWindow"))
2169 { 2180 {
2170 if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) && 2181 if ( (static_cast<KMainWindow*>(mainWindow())->toolBarMenuAction()) &&
2171 (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) ) 2182 (static_cast<KMainWindow*>(mainWindow())->hasMenuBar()) )
2172 2183
2173 (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context); 2184 (static_cast<KMainWindow*>(mainWindow()))->toolBarMenuAction()->plug(context);
2174 } 2185 }
2175*/ 2186*/
2176 2187
2177 connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) ); 2188 connect( context, SIGNAL( aboutToShow() ), this, SLOT( slotContextAboutToShow() ) );
2178 return context; 2189 return context;
2179} 2190}
2180 2191
2181void KToolBar::slotContextAboutToShow() 2192void KToolBar::slotContextAboutToShow()
2182{ 2193{
2183 if (!d->m_configurePlugged) 2194 if (!d->m_configurePlugged)
2184 { 2195 {
2185 // try to find "configure toolbars" action 2196 // try to find "configure toolbars" action
2186 2197
2187 KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient; 2198 KXMLGUIClient *xmlGuiClient = d->m_xmlguiClient;
2188 if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) 2199 if ( !xmlGuiClient && mainWindow() && mainWindow()->inherits( "KMainWindow" ) )
2189 xmlGuiClient = (KXMLGUIClient *)mainWindow(); 2200 xmlGuiClient = (KXMLGUIClient *)mainWindow();
2190 if ( xmlGuiClient ) 2201 if ( xmlGuiClient )
2191 { 2202 {
2192 KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars)); 2203 KAction *configureAction = xmlGuiClient->actionCollection()->action(KStdAction::stdName(KStdAction::ConfigureToolbars));
2193 if ( configureAction ) 2204 if ( configureAction )
2194 { 2205 {
2195 configureAction->plug(context); 2206 configureAction->plug(context);
2196 d->m_configurePlugged = true; 2207 d->m_configurePlugged = true;
2197 } 2208 }
2198 } 2209 }
2199 } 2210 }
2200 2211
2201 for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i) 2212 for(int i = CONTEXT_ICONS; i <= CONTEXT_TEXTUNDER; ++i)
2202 context->setItemChecked(i, false); 2213 context->setItemChecked(i, false);
2203 2214
2204 switch( d->m_iconText ) 2215 switch( d->m_iconText )
2205 { 2216 {
2206 case IconOnly: 2217 case IconOnly:
2207 default: 2218 default:
2208 context->setItemChecked(CONTEXT_ICONS, true); 2219 context->setItemChecked(CONTEXT_ICONS, true);
2209 break; 2220 break;
2210 case IconTextRight: 2221 case IconTextRight:
2211 context->setItemChecked(CONTEXT_TEXTRIGHT, true); 2222 context->setItemChecked(CONTEXT_TEXTRIGHT, true);
2212 break; 2223 break;
2213 case TextOnly: 2224 case TextOnly:
2214 context->setItemChecked(CONTEXT_TEXT, true); 2225 context->setItemChecked(CONTEXT_TEXT, true);
2215 break; 2226 break;
2216 case IconTextBottom: 2227 case IconTextBottom:
2217 context->setItemChecked(CONTEXT_TEXTUNDER, true); 2228 context->setItemChecked(CONTEXT_TEXTUNDER, true);
2218 break; 2229 break;
2219 } 2230 }
2220 2231
2221 QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); 2232 Q3ValueList<int>::ConstIterator iIt = d->iconSizes.begin();
2222 QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); 2233 Q3ValueList<int>::ConstIterator iEnd = d->iconSizes.end();
2223 for (; iIt != iEnd; ++iIt ) 2234 for (; iIt != iEnd; ++iIt )
2224 context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); 2235 context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false );
2225 2236
2226 context->setItemChecked( CONTEXT_ICONSIZES, false ); 2237 context->setItemChecked( CONTEXT_ICONSIZES, false );
2227 2238
2228 context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true ); 2239 context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true );
2229 2240
2230 for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i ) 2241 for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i )
2231 context->setItemChecked( i, false ); 2242 context->setItemChecked( i, false );
2232 2243
2233 switch ( barPos() ) 2244 switch ( barPos() )
2234 { 2245 {
2235 case KToolBar::Flat: 2246 case KToolBar::Flat:
2236 context->setItemChecked( CONTEXT_FLAT, true ); 2247 context->setItemChecked( CONTEXT_FLAT, true );
2237 break; 2248 break;
2238 case KToolBar::Bottom: 2249 case KToolBar::Bottom:
2239 context->setItemChecked( CONTEXT_BOTTOM, true ); 2250 context->setItemChecked( CONTEXT_BOTTOM, true );
2240 break; 2251 break;
2241 case KToolBar::Left: 2252 case KToolBar::Left:
2242 context->setItemChecked( CONTEXT_LEFT, true ); 2253 context->setItemChecked( CONTEXT_LEFT, true );
2243 break; 2254 break;
2244 case KToolBar::Right: 2255 case KToolBar::Right:
2245 context->setItemChecked( CONTEXT_RIGHT, true ); 2256 context->setItemChecked( CONTEXT_RIGHT, true );
2246 break; 2257 break;
2247 case KToolBar::Floating: 2258 case KToolBar::Floating:
2248 context->setItemChecked( CONTEXT_FLOAT, true ); 2259 context->setItemChecked( CONTEXT_FLOAT, true );
2249 break; 2260 break;
2250 case KToolBar::Top: 2261 case KToolBar::Top:
2251 context->setItemChecked( CONTEXT_TOP, true ); 2262 context->setItemChecked( CONTEXT_TOP, true );
2252 break; 2263 break;
2253 default: break; 2264 default: break;
2254 } 2265 }
2255} 2266}
2256 2267
2257void KToolBar::widgetDestroyed() 2268void KToolBar::widgetDestroyed()
2258{ 2269{
2259 removeWidgetInternal( (QWidget*)sender() ); 2270 removeWidgetInternal( (QWidget*)sender() );
2260} 2271}
2261 2272
2262void KToolBar::removeWidgetInternal( QWidget * w ) 2273void KToolBar::removeWidgetInternal( QWidget * w )
2263{ 2274{
2264 if ( inshutdownprocess ) 2275 if ( inshutdownprocess )
2265 return; 2276 return;
2266 widgets.removeRef( w ); 2277 widgets.removeRef( w );
2267 QMap< QWidget*, int >::Iterator it = widget2id.find( w ); 2278 QMap< QWidget*, int >::Iterator it = widget2id.find( w );
2268 if ( it == widget2id.end() ) 2279 if ( it == widget2id.end() )
2269 return; 2280 return;
2270 id2widget.remove( *it ); 2281 id2widget.remove( *it );
2271 widget2id.remove( it ); 2282 widget2id.remove( it );
2272} 2283}
2273 2284
2274void KToolBar::virtual_hook( int, void* ) 2285void KToolBar::virtual_hook( int, void* )
2275{ /*BASE::virtual_hook( id, data );*/ } 2286{ /*BASE::virtual_hook( id, data );*/ }
2276 2287
2277//US #include "ktoolbar.moc" 2288//US #include "ktoolbar.moc"
2278 2289
diff --git a/microkde/kdeui/ktoolbar.h b/microkde/kdeui/ktoolbar.h
index 3319fa8..4e00abd 100644
--- a/microkde/kdeui/ktoolbar.h
+++ b/microkde/kdeui/ktoolbar.h
@@ -1,1110 +1,1118 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Reginald Stadlbauer (reggie@kde.org) 2 Copyright (C) 2000 Reginald Stadlbauer (reggie@kde.org)
3 (C) 1997, 1998 Stephan Kulow (coolo@kde.org) 3 (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
4 (C) 1997, 1998 Sven Radej (radej@kde.org) 4 (C) 1997, 1998 Sven Radej (radej@kde.org)
5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) 5 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
6 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) 6 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
7 (C) 1999, 2000 Kurt Granroth (granroth@kde.org) 7 (C) 1999, 2000 Kurt Granroth (granroth@kde.org)
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
11 License version 2 as published by the Free Software Foundation. 11 License version 2 as published by the Free Software Foundation.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22 */ 22 */
23 23
24#ifndef KTOOLBAR_H 24#ifndef KTOOLBAR_H
25#define KTOOLBAR_H 25#define KTOOLBAR_H
26 26
27#ifndef DESKTOP_VERSION 27#ifndef DESKTOP_VERSION
28#define private public 28#define private public
29#include <qtoolbar.h> 29#include <q3toolbar.h>
30#undef private 30#undef private
31#include <qpe/qpetoolbar.h> 31#include <qpe/qpetoolbar.h>
32#else 32#else
33#include <qtoolbar.h> 33#include <q3toolbar.h>
34#endif 34#endif
35 35
36 36
37#include <qmainwindow.h> 37#include <q3mainwindow.h>
38#include <qcombobox.h> 38#include <qcombobox.h>
39#include <qmap.h> 39#include <qmap.h>
40#include <qptrlist.h> 40#include <q3ptrlist.h>
41//Added by qt3to4:
42#include <QPixmap>
43#include <QResizeEvent>
44#include <Q3PopupMenu>
45#include <QMouseEvent>
46#include <QChildEvent>
47#include <QEvent>
48#include <QShowEvent>
41#include <kglobal.h> 49#include <kglobal.h>
42#include <qguardedptr.h> 50#include <qpointer.h>
43#include <qframe.h> 51#include <q3frame.h>
44#include <qiconset.h> 52#include <qicon.h>
45 53
46class QDomElement; 54class QDomElement;
47class QSize; 55class QSize;
48class QPixmap; 56class QPixmap;
49class QPopupMenu; 57class Q3PopupMenu;
50class QStringList; 58class QStringList;
51class QDomDocument; 59class QDomDocument;
52class QTimer; 60class QTimer;
53 61
54class KLineEdit; 62class KLineEdit;
55class KToolBar; 63class KToolBar;
56class KToolBarButton; 64class KToolBarButton;
57class KToolBoxManager; 65class KToolBoxManager;
58//US class KAnimWidget; 66//US class KAnimWidget;
59//US class KPopupMenu; 67//US class KPopupMenu;
60//US class KInstance; 68//US class KInstance;
61class KComboBox; 69class KComboBox;
62class KXMLGUIClient; 70class KXMLGUIClient;
63 71
64class KToolBarPrivate; 72class KToolBarPrivate;
65 73
66class KToolBarSeparator : public QFrame 74class KToolBarSeparator : public Q3Frame
67{ 75{
68 Q_OBJECT 76 Q_OBJECT
69public: 77public:
70 KToolBarSeparator( Orientation, bool l, QToolBar *parent, const char* name=0 ); 78 KToolBarSeparator( Qt::Orientation, bool l, Q3ToolBar *parent, const char* name=0 );
71 79
72 QSize sizeHint() const; 80 QSize sizeHint() const;
73 Orientation orientation() const { return orient; } 81 Qt::Orientation orientation() const { return orient; }
74 QSizePolicy sizePolicy() const; 82 QSizePolicy sizePolicy() const;
75 bool showLine() const { return line; } 83 bool showLine() const { return line; }
76public slots: 84public slots:
77 void setOrientation( Orientation ); 85 void setOrientation( Qt::Orientation );
78protected: 86protected:
79 void styleChange( QStyle& ); 87 void styleChange( QStyle& );
80private: 88private:
81 Orientation orient; 89 Qt::Orientation orient;
82 bool line; 90 bool line;
83}; 91};
84 92
85 93
86 /** 94 /**
87 * A KDE-style toolbar. 95 * A KDE-style toolbar.
88 * 96 *
89 * KToolBar can be dragged around in and between different docks. 97 * KToolBar can be dragged around in and between different docks.
90 * 98 *
91 * A KToolBar can contain all sorts of widgets. 99 * A KToolBar can contain all sorts of widgets.
92 * 100 *
93 * KToolBar can be used as a standalone widget, but @ref KMainWindow 101 * KToolBar can be used as a standalone widget, but @ref KMainWindow
94 * provides easy factories and management of one or more toolbars. 102 * provides easy factories and management of one or more toolbars.
95 * Once you have a KToolBar object, you can insert items into it with the 103 * Once you have a KToolBar object, you can insert items into it with the
96 * insert... methods, or remove them with the @ref removeItem() method. This 104 * insert... methods, or remove them with the @ref removeItem() method. This
97 * can be done at any time; the toolbar will be automatically updated. 105 * can be done at any time; the toolbar will be automatically updated.
98 * There are also many methods to set per-child properties like alignment 106 * There are also many methods to set per-child properties like alignment
99 * and toggle behaviour. 107 * and toggle behaviour.
100 * 108 *
101 * KToolBar uses a global config group to load toolbar settings on 109 * KToolBar uses a global config group to load toolbar settings on
102 * construction. It will reread this config group on a 110 * construction. It will reread this config group on a
103 * @ref KApplication::appearanceChanged() signal. 111 * @ref KApplication::appearanceChanged() signal.
104 * 112 *
105 * @short Floatable toolbar with auto resize. 113 * @short Floatable toolbar with auto resize.
106 * @version $Id$ 114 * @version $Id$
107 * @author Reginald Stadlbauer <reggie@kde.org>, Stephan Kulow <coolo@kde.org>, Sven Radej <radej@kde.org>. 115 * @author Reginald Stadlbauer <reggie@kde.org>, Stephan Kulow <coolo@kde.org>, Sven Radej <radej@kde.org>.
108 */ 116 */
109 117
110// strange things are happening ... so I have to use strange define methods ... 118// strange things are happening ... so I have to use strange define methods ...
111// porting KToolBar back to Qt2 really needs some strange hacks 119// porting KToolBar back to Qt2 really needs some strange hacks
112 120
113#ifndef DESKTOP_VERSION 121#ifndef DESKTOP_VERSION
114#define QToolBar QPEToolBar 122#define Q3ToolBar QPEToolBar
115#endif 123#endif
116 124
117 class KToolBar : public QToolBar 125 class KToolBar : public Q3ToolBar
118{ 126{
119 Q_OBJECT 127 Q_OBJECT
120 128
121 129
122 Q_ENUMS( IconText BarPosition ) 130 Q_ENUMS( IconText BarPosition )
123 131
124 Q_PROPERTY( IconText iconText READ iconText WRITE setIconText ) 132 Q_PROPERTY( IconText iconText READ iconText WRITE setIconText )
125 Q_PROPERTY( BarPosition barPos READ barPos WRITE setBarPos ) 133 Q_PROPERTY( BarPosition barPos READ barPos WRITE setBarPos )
126 Q_PROPERTY( bool fullSize READ fullSize WRITE setFullSize ) 134 Q_PROPERTY( bool fullSize READ fullSize WRITE setFullSize )
127 Q_PROPERTY( int iconSize READ iconSize WRITE setIconSize ) 135 Q_PROPERTY( int iconSize READ iconSize WRITE setIconSize )
128 Q_PROPERTY( QString text READ text WRITE setText ) 136 Q_PROPERTY( QString text READ text WRITE setText )
129#ifndef DESKTOP_VERSION 137#ifndef DESKTOP_VERSION
130#undef QToolBar 138#undef Q3ToolBar
131#endif 139#endif
132public: 140public:
133 enum IconText{IconOnly = 0, IconTextRight, TextOnly, IconTextBottom}; 141 enum IconText{IconOnly = 0, IconTextRight, TextOnly, IconTextBottom};
134 /** 142 /**
135 * The state of the status bar. 143 * The state of the status bar.
136 * @deprecated 144 * @deprecated
137 **/ 145 **/
138 enum BarStatus{Toggle, Show, Hide}; 146 enum BarStatus{Toggle, Show, Hide};
139 /** 147 /**
140 * Possible bar positions. 148 * Possible bar positions.
141 **/ 149 **/
142 enum BarPosition{ Unmanaged, Floating, Top, Bottom, Right, Left, Flat}; 150 enum BarPosition{ Unmanaged, Floating, Top, Bottom, Right, Left, Flat};
143 151
144 /** 152 /**
145 * Constructor. 153 * Constructor.
146 * This constructor is used by the XML-GUI. If you use it, you need 154 * This constructor is used by the XML-GUI. If you use it, you need
147 * to call QMainWindow::addToolBar to specify the position of the toolbar. 155 * to call QMainWindow::addToolBar to specify the position of the toolbar.
148 * So it's simpler to use the other constructor. 156 * So it's simpler to use the other constructor.
149 * 157 *
150 * The toolbar will read in various global config settings for 158 * The toolbar will read in various global config settings for
151 * things like icon size and text position, etc. However, some of 159 * things like icon size and text position, etc. However, some of
152 * the settings will be honored only if @ref #_honor_mode is set to 160 * the settings will be honored only if @ref #_honor_mode is set to
153 * true. All other toolbars will be IconOnly and use Medium icons. 161 * true. All other toolbars will be IconOnly and use Medium icons.
154 * 162 *
155 * @param parent The standard toolbar parent (usually a 163 * @param parent The standard toolbar parent (usually a
156 * @ref KMainWindow) 164 * @ref KMainWindow)
157 * @param name The standard internal name 165 * @param name The standard internal name
158 * @param honor_style If true, then global settings for IconSize and IconText will be honored 166 * @param honor_style If true, then global settings for IconSize and IconText will be honored
159 * @param readConfig whether to apply the configuration (global and application-specific) 167 * @param readConfig whether to apply the configuration (global and application-specific)
160 */ 168 */
161 KToolBar( QWidget *parent, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); 169 KToolBar( QWidget *parent, const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE );
162 170
163 /** 171 /**
164 * Constructor for non-XML-GUI applications. 172 * Constructor for non-XML-GUI applications.
165 * 173 *
166 * The toolbar will read in various global config settings for 174 * The toolbar will read in various global config settings for
167 * things like icon size and text position, etc. However, some of 175 * things like icon size and text position, etc. However, some of
168 * the settings will be honored only if @ref #_honor_mode is set to 176 * the settings will be honored only if @ref #_honor_mode is set to
169 * true. All other toolbars will be IconOnly and use Medium icons. 177 * true. All other toolbars will be IconOnly and use Medium icons.
170 * 178 *
171 * @param parentWindow The window that should be the parent of this toolbar 179 * @param parentWindow The window that should be the parent of this toolbar
172 * @param dock The position of the toolbar. Usually QMainWindow::Top. 180 * @param dock The position of the toolbar. Usually QMainWindow::Top.
173 * @param newLine If true, start a new line in the dock for this toolbar. 181 * @param newLine If true, start a new line in the dock for this toolbar.
174 * @param name The standard internal name 182 * @param name The standard internal name
175 * @param honor_style If true, then global settings for IconSize and IconText will be honored 183 * @param honor_style If true, then global settings for IconSize and IconText will be honored
176 * @param readConfig whether to apply the configuration (global and application-specific) 184 * @param readConfig whether to apply the configuration (global and application-specific)
177 */ 185 */
178 KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false, 186 KToolBar( Q3MainWindow *parentWindow, Qt::ToolBarDock dock /*= QMainWindow::Top*/, bool newLine = false,
179 const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); 187 const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE );
180 188
181 /** 189 /**
182 * Constructor for non-XML-GUI applications. 190 * Constructor for non-XML-GUI applications.
183 * 191 *
184 * The toolbar will read in various global config settings for 192 * The toolbar will read in various global config settings for
185 * things like icon size and text position, etc. However, some of 193 * things like icon size and text position, etc. However, some of
186 * the settings will be honored only if @ref #_honor_mode is set to 194 * the settings will be honored only if @ref #_honor_mode is set to
187 * true. All other toolbars will be IconOnly and use Medium icons. 195 * true. All other toolbars will be IconOnly and use Medium icons.
188 * 196 *
189 * @param parentWindow The window that should be the parent of this toolbar 197 * @param parentWindow The window that should be the parent of this toolbar
190 * @param dock Another widget than the mainwindow to dock toolbar to. 198 * @param dock Another widget than the mainwindow to dock toolbar to.
191 * @param newLine If true, start a new line in the dock for this toolbar. 199 * @param newLine If true, start a new line in the dock for this toolbar.
192 * @param name The standard internal name 200 * @param name The standard internal name
193 * @param honor_style If true, then global settings for IconSize and IconText will be honored 201 * @param honor_style If true, then global settings for IconSize and IconText will be honored
194 * @param readConfig whether to apply the configuration (global and application-specific) 202 * @param readConfig whether to apply the configuration (global and application-specific)
195 */ 203 */
196 KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine = false, 204 KToolBar( Q3MainWindow *parentWindow, QWidget *dock, bool newLine = false,
197 const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE ); 205 const char *name = 0, bool honor_style = FALSE, bool readConfig = TRUE );
198 206
199 virtual ~KToolBar(); 207 virtual ~KToolBar();
200 208
201 /** 209 /**
202 * Insert a button (a @ref KToolBarButton) with a pixmap. The 210 * Insert a button (a @ref KToolBarButton) with a pixmap. The
203 * pixmap is loaded by the button itself based on the global icon 211 * pixmap is loaded by the button itself based on the global icon
204 * settings. 212 * settings.
205 * 213 *
206 * You should connect to one or more signals in KToolBar: 214 * You should connect to one or more signals in KToolBar:
207 * @ref clicked() , @ref pressed() , @ref released() , or 215 * @ref clicked() , @ref pressed() , @ref released() , or
208 * @ref highlighted() and if the button is a toggle button 216 * @ref highlighted() and if the button is a toggle button
209 * (@ref setToggle() ) @ref toggled() . Those signals have @p id 217 * (@ref setToggle() ) @ref toggled() . Those signals have @p id
210 * of a button that caused the signal. If you want to bind a popup 218 * of a button that caused the signal. If you want to bind a popup
211 * to button, see @ref setButton(). 219 * to button, see @ref setButton().
212 * 220 *
213 * @param icon The name of the icon to use as the active pixmap 221 * @param icon The name of the icon to use as the active pixmap
214 * @param id The id of this button 222 * @param id The id of this button
215 * @param enabled Enable or disable the button at startup 223 * @param enabled Enable or disable the button at startup
216 * @param text The tooltip or toolbar text (depending on state) 224 * @param text The tooltip or toolbar text (depending on state)
217 * @param index The position of the button. (-1 = at end). 225 * @param index The position of the button. (-1 = at end).
218 * 226 *
219 * @return The item index. 227 * @return The item index.
220 */ 228 */
221 int insertButton(const QString& icon, int id, bool enabled = true, 229 int insertButton(const QString& icon, int id, bool enabled = true,
222 const QString& text = QString::null, int index=-1/*US , 230 const QString& text = QString::null, int index=-1/*US ,
223 KInstance *_instance = KGlobal::instance()*/); 231 KInstance *_instance = KGlobal::instance()*/);
224 232
225 /** 233 /**
226 * This is the same as above, but with specified signals and 234 * This is the same as above, but with specified signals and
227 * slots to which this button will be connected. 235 * slots to which this button will be connected.
228 * 236 *
229 * You can add more signals with @ref addConnection(). 237 * You can add more signals with @ref addConnection().
230 * 238 *
231 * @param icon The name of the icon to use as the active pixmap 239 * @param icon The name of the icon to use as the active pixmap
232 * @param id The id of this button 240 * @param id The id of this button
233 * @param signal The signal to connect to 241 * @param signal The signal to connect to
234 * @param receiver The slot's parent 242 * @param receiver The slot's parent
235 * @param enabled Enable or disable the button at startup 243 * @param enabled Enable or disable the button at startup
236 * @param text The tooltip or toolbar text (depending on state) 244 * @param text The tooltip or toolbar text (depending on state)
237 * @param index The position of the button. (-1 = at end). 245 * @param index The position of the button. (-1 = at end).
238 * 246 *
239 * @return The item index. 247 * @return The item index.
240 */ 248 */
241 int insertButton(const QString& icon, int id, const char *signal, 249 int insertButton(const QString& icon, int id, const char *signal,
242 const QObject *receiver, const char *slot, 250 const QObject *receiver, const char *slot,
243 bool enabled = true, const QString& text = QString::null, 251 bool enabled = true, const QString& text = QString::null,
244 int index=-1/*US, KInstance *_instance = KGlobal::instance()*/ ); 252 int index=-1/*US, KInstance *_instance = KGlobal::instance()*/ );
245 253
246 /** 254 /**
247 * Inserts a button (a @ref KToolBarButton) with the specified 255 * Inserts a button (a @ref KToolBarButton) with the specified
248 * pixmap. This pixmap will be used as the "active" one and the 256 * pixmap. This pixmap will be used as the "active" one and the
249 * disabled and default ones will be autogenerated. 257 * disabled and default ones will be autogenerated.
250 * 258 *
251 * It is recommended that you use the insertButton function that 259 * It is recommended that you use the insertButton function that
252 * allows you to specify the icon name rather then the pixmap 260 * allows you to specify the icon name rather then the pixmap
253 * itself. Specifying the icon name is much more flexible. 261 * itself. Specifying the icon name is much more flexible.
254 * 262 *
255 * You should connect to one or more signals in KToolBar: 263 * You should connect to one or more signals in KToolBar:
256 * @ref clicked() , @ref pressed() , @ref released() , or 264 * @ref clicked() , @ref pressed() , @ref released() , or
257 * @ref highlighted() and if the button is a toggle button 265 * @ref highlighted() and if the button is a toggle button
258 * (@ref setToggle() ) @ref toggled() . Those signals have @p id 266 * (@ref setToggle() ) @ref toggled() . Those signals have @p id
259 * of a button that caused the signal. If you want to bind a popup 267 * of a button that caused the signal. If you want to bind a popup
260 * to button, see @ref setButton(). 268 * to button, see @ref setButton().
261 * 269 *
262 * @param pixmap The active pixmap 270 * @param pixmap The active pixmap
263 * @param id The id of this button 271 * @param id The id of this button
264 * @param enabled Enable or disable the button at startup 272 * @param enabled Enable or disable the button at startup
265 * @param text The tooltip or toolbar text (depending on state) 273 * @param text The tooltip or toolbar text (depending on state)
266 * @param index The position of the button. (-1 = at end). 274 * @param index The position of the button. (-1 = at end).
267 * 275 *
268 * @return The item index. 276 * @return The item index.
269 */ 277 */
270 int insertButton(const QPixmap& pixmap, int id, bool enabled = true, 278 int insertButton(const QPixmap& pixmap, int id, bool enabled = true,
271 const QString& text = QString::null, int index=-1 ); 279 const QString& text = QString::null, int index=-1 );
272 280
273 /** 281 /**
274 * This is the same as above, but with specified signals and 282 * This is the same as above, but with specified signals and
275 * slots to which this button will be connected. 283 * slots to which this button will be connected.
276 * 284 *
277 * You can add more signals with @ref addConnection(). 285 * You can add more signals with @ref addConnection().
278 * 286 *
279 * @param icon The name of the icon to use as the active pixmap 287 * @param icon The name of the icon to use as the active pixmap
280 * @param id The id of this button 288 * @param id The id of this button
281 * @param signal The signal to connect to 289 * @param signal The signal to connect to
282 * @param receiver The slot's parent 290 * @param receiver The slot's parent
283 * @param enabled Enable or disable the button at startup 291 * @param enabled Enable or disable the button at startup
284 * @param text The tooltip or toolbar text (depending on state) 292 * @param text The tooltip or toolbar text (depending on state)
285 * @param index The position of the button. (-1 = at end). 293 * @param index The position of the button. (-1 = at end).
286 * 294 *
287 * @return The item index. 295 * @return The item index.
288 */ 296 */
289 int insertButton(const QPixmap& pixmap, int id, const char *signal, 297 int insertButton(const QPixmap& pixmap, int id, const char *signal,
290 const QObject *receiver, const char *slot, 298 const QObject *receiver, const char *slot,
291 bool enabled = true, const QString& text = QString::null, 299 bool enabled = true, const QString& text = QString::null,
292 int index=-1 ); 300 int index=-1 );
293 301
294 /** 302 /**
295 * Inserts a button with popupmenu. 303 * Inserts a button with popupmenu.
296 * 304 *
297 * Button will have small 305 * Button will have small
298 * triangle. You have to connect to popup's signals. The 306 * triangle. You have to connect to popup's signals. The
299 * signals @ref KButton::pressed(), @ref KButton::released(), 307 * signals @ref KButton::pressed(), @ref KButton::released(),
300 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not 308 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not
301 * emmited by 309 * emmited by
302 * this button (see @ref setDelayedPopup() for that). 310 * this button (see @ref setDelayedPopup() for that).
303 * You can add custom popups which inherit @ref QPopupMenu to get popups 311 * You can add custom popups which inherit @ref QPopupMenu to get popups
304 * with tables, drawings etc. Just don't fiddle with events there. 312 * with tables, drawings etc. Just don't fiddle with events there.
305 */ 313 */
306 int insertButton(const QString& icon, int id, QPopupMenu *popup, 314 int insertButton(const QString& icon, int id, Q3PopupMenu *popup,
307 bool enabled, const QString&_text, int index=-1); 315 bool enabled, const QString&_text, int index=-1);
308 316
309 /** 317 /**
310 * Inserts a button with popupmenu. 318 * Inserts a button with popupmenu.
311 * 319 *
312 * Button will have small 320 * Button will have small
313 * triangle. You have to connect to popup's signals. The 321 * triangle. You have to connect to popup's signals. The
314 * signals @ref KButton::pressed(), @ref KButton::released(), 322 * signals @ref KButton::pressed(), @ref KButton::released(),
315 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not 323 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not
316 * emmited by 324 * emmited by
317 * this button (see @ref setDelayedPopup() for that). 325 * this button (see @ref setDelayedPopup() for that).
318 * You can add custom popups which inherit @ref QPopupMenu to get popups 326 * You can add custom popups which inherit @ref QPopupMenu to get popups
319 * with tables, drawings etc. Just don't fiddle with events there. 327 * with tables, drawings etc. Just don't fiddle with events there.
320 */ 328 */
321 int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, 329 int insertButton(const QPixmap& pixmap, int id, Q3PopupMenu *popup,
322 bool enabled, const QString&_text, int index=-1); 330 bool enabled, const QString&_text, int index=-1);
323 331
324 /** 332 /**
325 * Inserts a @ref KLineEdit. You have to specify signals and slots to 333 * Inserts a @ref KLineEdit. You have to specify signals and slots to
326 * which KLineEdit will be connected. KLineEdit has all slots QLineEdit 334 * which KLineEdit will be connected. KLineEdit has all slots QLineEdit
327 * has, plus signals @ref KLineEdit::completion and @ref KLineEdit::textRotation 335 * has, plus signals @ref KLineEdit::completion and @ref KLineEdit::textRotation
328 * KLineEdit can be set to autoresize itself to full free width 336 * KLineEdit can be set to autoresize itself to full free width
329 * in toolbar, that is to last right aligned item. For that, 337 * in toolbar, that is to last right aligned item. For that,
330 * toolbar must be set to full width (which it is by default). 338 * toolbar must be set to full width (which it is by default).
331 * @see setFullWidth() 339 * @see setFullWidth()
332 * @see setItemAutoSized() 340 * @see setItemAutoSized()
333 * @see KLineEdit 341 * @see KLineEdit
334 * @return Item index. 342 * @return Item index.
335 */ 343 */
336 int insertLined (const QString& text, int id, 344 int insertLined (const QString& text, int id,
337 const char *signal, 345 const char *signal,
338 const QObject *receiver, const char *slot, 346 const QObject *receiver, const char *slot,
339 bool enabled = true, 347 bool enabled = true,
340 const QString& toolTipText = QString::null, 348 const QString& toolTipText = QString::null,
341 int size = 70, int index =-1); 349 int size = 70, int index =-1);
342 350
343 /** 351 /**
344 * Inserts a @ref KComboBox with list. 352 * Inserts a @ref KComboBox with list.
345 * 353 *
346 * Can be writable, but cannot contain 354 * Can be writable, but cannot contain
347 * pixmaps. By default inserting policy is AtBottom, i.e. typed items 355 * pixmaps. By default inserting policy is AtBottom, i.e. typed items
348 * are placed at the bottom of the list. Can be autosized. If the size 356 * are placed at the bottom of the list. Can be autosized. If the size
349 * argument is specified as -1, the width of the combobox is automatically 357 * argument is specified as -1, the width of the combobox is automatically
350 * computed. 358 * computed.
351 * 359 *
352 * @see setFullWidth() 360 * @see setFullWidth()
353 * @see setItemAutoSized() 361 * @see setItemAutoSized()
354 * @see KComboBox 362 * @see KComboBox
355 * @return Item index. 363 * @return Item index.
356 */ 364 */
357 int insertCombo (const QStringList &list, int id, bool writable, 365 int insertCombo (const QStringList &list, int id, bool writable,
358 const char *signal, const QObject *receiver, 366 const char *signal, const QObject *receiver,
359 const char *slot, bool enabled=true, 367 const char *slot, bool enabled=true,
360 const QString& tooltiptext=QString::null, 368 const QString& tooltiptext=QString::null,
361 int size=70, int index=-1, 369 int size=70, int index=-1,
362 QComboBox::Policy policy = QComboBox::AtBottom); 370 QComboBox::Policy policy = QComboBox::InsertAtBottom);
363 371
364 /** 372 /**
365 * Insert a @ref KComboBox with text. 373 * Insert a @ref KComboBox with text.
366 * 374 *
367 * The rest is the same as above. 375 * The rest is the same as above.
368 * @see setItemAutoSized() 376 * @see setItemAutoSized()
369 * 377 *
370 * @see KComboBox 378 * @see KComboBox
371 * @return Item index. 379 * @return Item index.
372 */ 380 */
373 int insertCombo (const QString& text, int id, bool writable, 381 int insertCombo (const QString& text, int id, bool writable,
374 const char *signal, QObject *recevier, 382 const char *signal, QObject *recevier,
375 const char *slot, bool enabled=true, 383 const char *slot, bool enabled=true,
376 const QString& tooltiptext=QString::null, 384 const QString& tooltiptext=QString::null,
377 int size=70, int index=-1, 385 int size=70, int index=-1,
378 QComboBox::Policy policy = QComboBox::AtBottom); 386 QComboBox::Policy policy = QComboBox::InsertAtBottom);
379 387
380 /** 388 /**
381 * Inserts a separator into the toolbar with the given id. 389 * Inserts a separator into the toolbar with the given id.
382 * Returns the separator's index 390 * Returns the separator's index
383 */ 391 */
384 int insertSeparator( int index = -1, int id = -1 ); 392 int insertSeparator( int index = -1, int id = -1 );
385 393
386 /** 394 /**
387 * Inserts a line separator into the toolbar with the given id. 395 * Inserts a line separator into the toolbar with the given id.
388 * Returns the separator's index 396 * Returns the separator's index
389 */ 397 */
390 int insertLineSeparator( int index = -1, int id = -1 ); 398 int insertLineSeparator( int index = -1, int id = -1 );
391 399
392 /** 400 /**
393 * Inserts a user-defined widget. The widget @p must have this 401 * Inserts a user-defined widget. The widget @p must have this
394 * toolbar as its parent. 402 * toolbar as its parent.
395 * 403 *
396 * Widget must have a QWidget for base class. Widget can be 404 * Widget must have a QWidget for base class. Widget can be
397 * autosized to full width. If you forget about it, you can get a 405 * autosized to full width. If you forget about it, you can get a
398 * pointer to this widget with @ref getWidget(). 406 * pointer to this widget with @ref getWidget().
399 * @see setItemAutoSized() 407 * @see setItemAutoSized()
400 * @return Item index. 408 * @return Item index.
401 */ 409 */
402 int insertWidget(int id, int width, QWidget *_widget, int index=-1); 410 int insertWidget(int id, int width, QWidget *_widget, int index=-1);
403 411
404 /** 412 /**
405 * Inserts an animated widget. A @ref KAnimWidget will be created 413 * Inserts an animated widget. A @ref KAnimWidget will be created
406 * internally using the icon name you provide. 414 * internally using the icon name you provide.
407 * This will emit a signal (clicked()) whenever the 415 * This will emit a signal (clicked()) whenever the
408 * animation widget is clicked. 416 * animation widget is clicked.
409 * 417 *
410 * @see animatedWidget() 418 * @see animatedWidget()
411 * 419 *
412 * @param id The id for this toolbar item 420 * @param id The id for this toolbar item
413 * @param receiver The parent of your slot 421 * @param receiver The parent of your slot
414 * @param slot The slot to receive the clicked() signal 422 * @param slot The slot to receive the clicked() signal
415 * @param icons The name of the animation icon group to use 423 * @param icons The name of the animation icon group to use
416 * @param index The item index 424 * @param index The item index
417 * 425 *
418 * @return The item index 426 * @return The item index
419 */ 427 */
420/*US 428/*US
421 int insertAnimatedWidget(int id, QObject *receiver, const char *slot, 429 int insertAnimatedWidget(int id, QObject *receiver, const char *slot,
422 const QString& icons, int index = -1); 430 const QString& icons, int index = -1);
423*/ 431*/
424 /** 432 /**
425 * This will return a pointer to the given animated widget, if it 433 * This will return a pointer to the given animated widget, if it
426 * exists. 434 * exists.
427 * 435 *
428 * @see insertAnimatedWidget 436 * @see insertAnimatedWidget
429 * 437 *
430 * @param id The id for the widget you want to get a pointer to 438 * @param id The id for the widget you want to get a pointer to
431 * 439 *
432 * @return A pointer to the current animated widget or 0L 440 * @return A pointer to the current animated widget or 0L
433 */ 441 */
434//US KAnimWidget *animatedWidget( int id ); 442//US KAnimWidget *animatedWidget( int id );
435 443
436 /** 444 /**
437 * Adds connections to items. 445 * Adds connections to items.
438 * 446 *
439 * It is important that you 447 * It is important that you
440 * know the @p id of particular item. Nothing happens if you forget @p id. 448 * know the @p id of particular item. Nothing happens if you forget @p id.
441 */ 449 */
442 void addConnection (int id, const char *signal, 450 void addConnection (int id, const char *signal,
443 const QObject *receiver, const char *slot); 451 const QObject *receiver, const char *slot);
444 /** 452 /**
445 * Enables/disables item. 453 * Enables/disables item.
446 */ 454 */
447 void setItemEnabled( int id, bool enabled ); 455 void setItemEnabled( int id, bool enabled );
448 456
449 /** 457 /**
450 * Sets the icon for a button. 458 * Sets the icon for a button.
451 * 459 *
452 * Can be used while button is visible. 460 * Can be used while button is visible.
453 */ 461 */
454 void setButtonIcon( int id, const QString& _icon ); 462 void setButtonIcon( int id, const QString& _icon );
455 463
456 /** 464 /**
457 * Sets button pixmap. 465 * Sets button pixmap.
458 * 466 *
459 * Can be used while button is visible. 467 * Can be used while button is visible.
460 */ 468 */
461 void setButtonPixmap( int id, const QPixmap& _pixmap ); 469 void setButtonPixmap( int id, const QPixmap& _pixmap );
462 470
463 /** 471 /**
464 * Sets a button icon from a QIconSet. 472 * Sets a button icon from a QIconSet.
465 * 473 *
466 * Can be used while button is visible. 474 * Can be used while button is visible.
467 */ 475 */
468 void setButtonIconSet( int id, const QIconSet& iconset ); 476 void setButtonIconSet( int id, const QIcon& iconset );
469 477
470 /** 478 /**
471 * Sets a delayed popup for a button. 479 * Sets a delayed popup for a button.
472 * 480 *
473 * Delayed popup is what you see in 481 * Delayed popup is what you see in
474 * Netscape Navigator's Previous and Next buttons: If you click them you 482 * Netscape Navigator's Previous and Next buttons: If you click them you
475 * go back 483 * go back
476 * or forth. If you press them long enough, you get a history-menu. 484 * or forth. If you press them long enough, you get a history-menu.
477 * This is exactly what we do here. 485 * This is exactly what we do here.
478 * 486 *
479 * You will insert normal a button with connection (or use signals from 487 * You will insert normal a button with connection (or use signals from
480 * toolbar): 488 * toolbar):
481 * <pre> 489 * <pre>
482 * bar->insertButton(icon, id, SIGNAL(clicked ()), this, 490 * bar->insertButton(icon, id, SIGNAL(clicked ()), this,
483 * SLOT (slotClick()), true, "click or wait for popup"); 491 * SLOT (slotClick()), true, "click or wait for popup");
484 * </pre> And then add a delayed popup: 492 * </pre> And then add a delayed popup:
485 * <pre> 493 * <pre>
486 * bar->setDelayedPopup (id, historyPopup); </pre> 494 * bar->setDelayedPopup (id, historyPopup); </pre>
487 * 495 *
488 * Don't add delayed popups to buttons which have normal popups. 496 * Don't add delayed popups to buttons which have normal popups.
489 * 497 *
490 * You may add popups which are derived from @ref QPopupMenu. You may 498 * You may add popups which are derived from @ref QPopupMenu. You may
491 * add popups that are already in the menu bar or are submenus of 499 * add popups that are already in the menu bar or are submenus of
492 * other popups. 500 * other popups.
493 */ 501 */
494 void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false); 502 void setDelayedPopup (int id , Q3PopupMenu *_popup, bool toggle = false);
495 503
496 /** 504 /**
497 * Turns a button into an autorepeat button. 505 * Turns a button into an autorepeat button.
498 * 506 *
499 * Toggle buttons, buttons with menus, or 507 * Toggle buttons, buttons with menus, or
500 * buttons with delayed menus cannot be made into autorepeat buttons. 508 * buttons with delayed menus cannot be made into autorepeat buttons.
501 * Moreover, you can and will receive 509 * Moreover, you can and will receive
502 * only the signal clicked(), but not pressed() or released(). 510 * only the signal clicked(), but not pressed() or released().
503 * When the user presses this button, you will receive the signal clicked(), 511 * When the user presses this button, you will receive the signal clicked(),
504 * and if the button is still pressed after some time, 512 * and if the button is still pressed after some time,
505 * you will receive more clicked() signals separated by regular 513 * you will receive more clicked() signals separated by regular
506 * intervals. Since this uses @ref QButton::setAutoRepeat() , 514 * intervals. Since this uses @ref QButton::setAutoRepeat() ,
507 * I can't quantify 'some'. 515 * I can't quantify 'some'.
508 */ 516 */
509 void setAutoRepeat (int id, bool flag=true); 517 void setAutoRepeat (int id, bool flag=true);
510 518
511 519
512 /** 520 /**
513 * Turns button into a toggle button if @p flag is true. 521 * Turns button into a toggle button if @p flag is true.
514 */ 522 */
515 void setToggle (int id, bool flag = true); 523 void setToggle (int id, bool flag = true);
516 524
517 /** 525 /**
518 * Toggles a togglebutton. 526 * Toggles a togglebutton.
519 * 527 *
520 * If the button is a toggle button (see @ref setToggle()) 528 * If the button is a toggle button (see @ref setToggle())
521 * the button state will be toggled. This will also cause the toolbar to 529 * the button state will be toggled. This will also cause the toolbar to
522 * emit the signal @ref KButton::toggled() with parameter @p id. You must connect to 530 * emit the signal @ref KButton::toggled() with parameter @p id. You must connect to
523 * this signal, or use @ref addConnection() to connect directly to the 531 * this signal, or use @ref addConnection() to connect directly to the
524 * button signal @ref KButton::toggled(). 532 * button signal @ref KButton::toggled().
525 */ 533 */
526 void toggleButton (int id); 534 void toggleButton (int id);
527 535
528 /** 536 /**
529 * Sets a toggle button state. 537 * Sets a toggle button state.
530 * 538 *
531 * If the button is a toggle button (see @ref setToggle()) 539 * If the button is a toggle button (see @ref setToggle())
532 * this will set its state flag. This will also emit the signal 540 * this will set its state flag. This will also emit the signal
533 * @ref KButton::toggled(). 541 * @ref KButton::toggled().
534 * 542 *
535 * @see setToggle() 543 * @see setToggle()
536 */ 544 */
537 void setButton (int id, bool flag); 545 void setButton (int id, bool flag);
538 546
539 /** 547 /**
540 * @return @p true if button is on, @p false if button is off or if the 548 * @return @p true if button is on, @p false if button is off or if the
541 * button is not a toggle button. 549 * button is not a toggle button.
542 * @see setToggle() 550 * @see setToggle()
543 */ 551 */
544 bool isButtonOn (int id) const; 552 bool isButtonOn (int id) const;
545 553
546 /** 554 /**
547 * Sets the text of a line editor. 555 * Sets the text of a line editor.
548 * 556 *
549 * Cursor is set at end of text. 557 * Cursor is set at end of text.
550 */ 558 */
551 void setLinedText (int id, const QString& text); 559 void setLinedText (int id, const QString& text);
552 560
553 /** 561 /**
554 * Returns a line editor text. 562 * Returns a line editor text.
555 */ 563 */
556 QString getLinedText (int id) const; 564 QString getLinedText (int id) const;
557 565
558 /** 566 /**
559 * Inserts @p text in combobox @p id at position @p index. 567 * Inserts @p text in combobox @p id at position @p index.
560 */ 568 */
561 void insertComboItem (int id, const QString& text, int index); 569 void insertComboItem (int id, const QString& text, int index);
562 570
563 /** 571 /**
564 * Inserts @p list in combobox @p id at position @p index. 572 * Inserts @p list in combobox @p id at position @p index.
565 */ 573 */
566 void insertComboList (int id, const QStringList &list, int index); 574 void insertComboList (int id, const QStringList &list, int index);
567 575
568 /** 576 /**
569 * Removes item @p index from combobox @p id. 577 * Removes item @p index from combobox @p id.
570 */ 578 */
571 void removeComboItem (int id, int index); 579 void removeComboItem (int id, int index);
572 580
573 /** 581 /**
574 * Sets item @p index to be current item in combobox @p id. 582 * Sets item @p index to be current item in combobox @p id.
575 */ 583 */
576 void setCurrentComboItem (int id, int index); 584 void setCurrentComboItem (int id, int index);
577 585
578 /** 586 /**
579 * Changes item @p index in combobox @p id to text. 587 * Changes item @p index in combobox @p id to text.
580 * 588 *
581 * @p index = -1 refers current item (one displayed in the button). 589 * @p index = -1 refers current item (one displayed in the button).
582 */ 590 */
583 void changeComboItem (int id, const QString& text, int index=-1); 591 void changeComboItem (int id, const QString& text, int index=-1);
584 592
585 /** 593 /**
586 * Clears the combobox @p id. 594 * Clears the combobox @p id.
587 * 595 *
588 * Does not delete it or hide it. 596 * Does not delete it or hide it.
589 */ 597 */
590 void clearCombo (int id); 598 void clearCombo (int id);
591 599
592 /** 600 /**
593 * Returns text of item @p index from combobox @p id. 601 * Returns text of item @p index from combobox @p id.
594 * 602 *
595 * @p index = -1 refers to current item. 603 * @p index = -1 refers to current item.
596 */ 604 */
597 605
598 QString getComboItem (int id, int index=-1) const; 606 QString getComboItem (int id, int index=-1) const;
599 607
600 /** 608 /**
601 * Returns a pointer to the combobox. 609 * Returns a pointer to the combobox.
602 * 610 *
603 * Example: 611 * Example:
604 * <pre> 612 * <pre>
605 * KComboBox *combo = toolbar->getCombo(combo_id); 613 * KComboBox *combo = toolbar->getCombo(combo_id);
606 * </pre> 614 * </pre>
607 * That way you can get access to other public methods 615 * That way you can get access to other public methods
608 * that @ref KComboBox provides. 616 * that @ref KComboBox provides.
609 */ 617 */
610 KComboBox * getCombo(int id); 618 KComboBox * getCombo(int id);
611 619
612 /** 620 /**
613 * Returns a pointer to KToolBarLined. 621 * Returns a pointer to KToolBarLined.
614 * 622 *
615 * Example: 623 * Example:
616 * <pre> 624 * <pre>
617 * KLineEdit * lined = toolbar->getKToolBarLined(lined_id); 625 * KLineEdit * lined = toolbar->getKToolBarLined(lined_id);
618 * </pre> 626 * </pre>
619 * That way you can get access to other public methods 627 * That way you can get access to other public methods
620 * that @ref KLineEdit provides. @ref KLineEdit is the same thing 628 * that @ref KLineEdit provides. @ref KLineEdit is the same thing
621 * as @ref QLineEdit plus completion signals. 629 * as @ref QLineEdit plus completion signals.
622 */ 630 */
623 KLineEdit * getLined (int id); 631 KLineEdit * getLined (int id);
624 632
625 /** 633 /**
626 * Returns a pointer to KToolBarButton. 634 * Returns a pointer to KToolBarButton.
627 * 635 *
628 * Example: 636 * Example:
629 * <pre> 637 * <pre>
630 * KToolBarButton * button = toolbar->getButton(button_id); 638 * KToolBarButton * button = toolbar->getButton(button_id);
631 * </pre> 639 * </pre>
632 * That way you can get access to other public methods 640 * That way you can get access to other public methods
633 * that @ref KToolBarButton provides. 641 * that @ref KToolBarButton provides.
634 * 642 *
635 * Using this method is not recommended. 643 * Using this method is not recommended.
636 */ 644 */
637 KToolBarButton * getButton (int id); 645 KToolBarButton * getButton (int id);
638 646
639 /** 647 /**
640 * Align item to the right. 648 * Align item to the right.
641 * 649 *
642 * This works only if toolbar is set to full width. 650 * This works only if toolbar is set to full width.
643 * @see setFullWidth() 651 * @see setFullWidth()
644 */ 652 */
645 void alignItemRight (int id, bool right = true); 653 void alignItemRight (int id, bool right = true);
646 654
647 /** 655 /**
648 * Returns a pointer to an inserted widget. 656 * Returns a pointer to an inserted widget.
649 * 657 *
650 * Wrong ids are not tested. 658 * Wrong ids are not tested.
651 * You can do with this whatever you want, 659 * You can do with this whatever you want,
652 * except change its height (hardcoded). If you change its width 660 * except change its height (hardcoded). If you change its width
653 * you will probably have to call QToolBar::updateRects(true) 661 * you will probably have to call QToolBar::updateRects(true)
654 * @see QWidget 662 * @see QWidget
655 * @see updateRects() 663 * @see updateRects()
656 * 664 *
657 * KDE4: make this const! 665 * KDE4: make this const!
658 */ 666 */
659 QWidget *getWidget (int id); 667 QWidget *getWidget (int id);
660 668
661 /** 669 /**
662 * Set item autosized. 670 * Set item autosized.
663 * 671 *
664 * This works only if the toolbar is set to full width. 672 * This works only if the toolbar is set to full width.
665 * Only @p one item can be autosized, and it has to be 673 * Only @p one item can be autosized, and it has to be
666 * the last left-aligned item. Items that come after this must be right 674 * the last left-aligned item. Items that come after this must be right
667 * aligned. Items that can be right aligned are Lineds, Frames, Widgets and 675 * aligned. Items that can be right aligned are Lineds, Frames, Widgets and
668 * Combos. An autosized item will resize itself whenever the toolbar geometry 676 * Combos. An autosized item will resize itself whenever the toolbar geometry
669 * changes to the last right-aligned item (or to end of toolbar if there 677 * changes to the last right-aligned item (or to end of toolbar if there
670 * are no right-aligned items.) 678 * are no right-aligned items.)
671 * @see setFullWidth() 679 * @see setFullWidth()
672 * @see alignItemRight() 680 * @see alignItemRight()
673 */ 681 */
674 void setItemAutoSized (int id, bool yes = true); 682 void setItemAutoSized (int id, bool yes = true);
675 683
676 /** 684 /**
677 * Remove all items. 685 * Remove all items.
678 * 686 *
679 * The toolbar is redrawn after it. 687 * The toolbar is redrawn after it.
680 */ 688 */
681 void clear (); 689 void clear ();
682 690
683 /** 691 /**
684 * Remove item @p id. 692 * Remove item @p id.
685 * 693 *
686 * Item is deleted. Toolbar is redrawn after it. 694 * Item is deleted. Toolbar is redrawn after it.
687 */ 695 */
688 void removeItem (int id); 696 void removeItem (int id);
689 697
690 /** 698 /**
691 * Remove item @p id. 699 * Remove item @p id.
692 * 700 *
693 * Item is deleted when toolbar is redrawn. 701 * Item is deleted when toolbar is redrawn.
694 */ 702 */
695 void removeItemDelayed (int id); 703 void removeItemDelayed (int id);
696 704
697 /** 705 /**
698 * Hide item. 706 * Hide item.
699 */ 707 */
700 void hideItem (int id); 708 void hideItem (int id);
701 709
702 /** 710 /**
703 * Show item. 711 * Show item.
704 */ 712 */
705 void showItem (int id); 713 void showItem (int id);
706 714
707 /** 715 /**
708 * Returns the index of the given item. 716 * Returns the index of the given item.
709 * 717 *
710 * KDE4: make this const! 718 * KDE4: make this const!
711 */ 719 */
712 int itemIndex (int id); 720 int itemIndex (int id);
713 721
714 /** 722 /**
715 * Set toolbar to full parent size (default). 723 * Set toolbar to full parent size (default).
716 * 724 *
717 * In full size mode the bar 725 * In full size mode the bar
718 * extends over the parent's full width or height. If the mode is disabled 726 * extends over the parent's full width or height. If the mode is disabled
719 * the toolbar tries to take as much space as it needs without wrapping, but 727 * the toolbar tries to take as much space as it needs without wrapping, but
720 * it does not exceed the parent box. You can force a certain width or 728 * it does not exceed the parent box. You can force a certain width or
721 * height with @ref setMaxWidth() or @ref setMaxHeight(). 729 * height with @ref setMaxWidth() or @ref setMaxHeight().
722 * 730 *
723 * If you want to use right-aligned items or auto-sized items you must use 731 * If you want to use right-aligned items or auto-sized items you must use
724 * full size mode. 732 * full size mode.
725 */ 733 */
726 void setFullSize(bool flag = true); 734 void setFullSize(bool flag = true);
727 735
728 /** 736 /**
729 * @return @p true if the full-size mode is enabled. Otherwise 737 * @return @p true if the full-size mode is enabled. Otherwise
730 * it returns @false. 738 * it returns @false.
731 */ 739 */
732 bool fullSize() const; 740 bool fullSize() const;
733 741
734 /** 742 /**
735 * @deprecated use setMovingEnabled(bool) instead. 743 * @deprecated use setMovingEnabled(bool) instead.
736 * Enable or disable moving of toolbar. 744 * Enable or disable moving of toolbar.
737 */ 745 */
738 void enableMoving(bool flag = true); 746 void enableMoving(bool flag = true);
739 747
740 /** 748 /**
741 * Set position of toolbar. 749 * Set position of toolbar.
742 * @see BarPosition() 750 * @see BarPosition()
743 */ 751 */
744 void setBarPos (BarPosition bpos); 752 void setBarPos (BarPosition bpos);
745 753
746 /** 754 /**
747 * Returns position of toolbar. 755 * Returns position of toolbar.
748 */ 756 */
749 const BarPosition barPos(); 757 const BarPosition barPos();
750 758
751 /** 759 /**
752 * @deprecated 760 * @deprecated
753 * Show, hide, or toggle toolbar. 761 * Show, hide, or toggle toolbar.
754 * 762 *
755 * This method is provided for compatibility only, 763 * This method is provided for compatibility only,
756 * please use show() and/or hide() instead. 764 * please use show() and/or hide() instead.
757 * @see BarStatus 765 * @see BarStatus
758 */ 766 */
759 bool enable(BarStatus stat); 767 bool enable(BarStatus stat);
760 768
761 /** 769 /**
762 * @deprecated 770 * @deprecated
763 * Use setMaximumHeight() instead. 771 * Use setMaximumHeight() instead.
764 */ 772 */
765 void setMaxHeight (int h); // Set max height for vertical toolbars 773 void setMaxHeight (int h); // Set max height for vertical toolbars
766 774
767 /** 775 /**
768 * @deprecated 776 * @deprecated
769 * Use maximumHeight() instead. 777 * Use maximumHeight() instead.
770 * Returns the value that was set with @ref setMaxHeight(). 778 * Returns the value that was set with @ref setMaxHeight().
771 */ 779 */
772 int maxHeight(); 780 int maxHeight();
773 781
774 /** 782 /**
775 * @deprecated 783 * @deprecated
776 * Use setMaximumWidth() instead. 784 * Use setMaximumWidth() instead.
777 * Set maximal width of horizontal (top or bottom) toolbar. 785 * Set maximal width of horizontal (top or bottom) toolbar.
778 */ 786 */
779 void setMaxWidth (int dw); 787 void setMaxWidth (int dw);
780 788
781 /** 789 /**
782 * @deprecated 790 * @deprecated
783 * Use maximumWidth() instead. 791 * Use maximumWidth() instead.
784 * Returns the value that was set with @ref setMaxWidth(). 792 * Returns the value that was set with @ref setMaxWidth().
785 */ 793 */
786 int maxWidth(); 794 int maxWidth();
787 795
788 /** 796 /**
789 * Set title for toolbar when it floats. 797 * Set title for toolbar when it floats.
790 * 798 *
791 * Titles are however not (yet) 799 * Titles are however not (yet)
792 * visible. You can't change toolbar's title while it's floating. 800 * visible. You can't change toolbar's title while it's floating.
793 */ 801 */
794 void setTitle (const QString& _title); 802 void setTitle (const QString& _title);
795 803
796 /** 804 /**
797 * @deprecated 805 * @deprecated
798 * Use enableMoving() instead. 806 * Use enableMoving() instead.
799 */ 807 */
800 void enableFloating (bool arrrrrrgh); 808 void enableFloating (bool arrrrrrgh);
801 809
802 /** 810 /**
803 * Set the kind of painting for buttons. 811 * Set the kind of painting for buttons.
804 * 812 *
805 * Choose from: 813 * Choose from:
806 * @li IconOnly (only icons), 814 * @li IconOnly (only icons),
807 * @li IconTextRight (icon and text, text is left from icons), 815 * @li IconTextRight (icon and text, text is left from icons),
808 * @li TextOnly (only text), 816 * @li TextOnly (only text),
809 * @li IconTextBottom (icons and text, text is under icons). 817 * @li IconTextBottom (icons and text, text is under icons).
810 * @see IconText 818 * @see IconText
811 * 819 *
812 */ 820 */
813 void setIconText(IconText it); 821 void setIconText(IconText it);
814 // Note: don't merge with the next one, it breaks Qt properties 822 // Note: don't merge with the next one, it breaks Qt properties
815 823
816 /** 824 /**
817 * Similar to @ref setIconText(IconText it) but allows you to 825 * Similar to @ref setIconText(IconText it) but allows you to
818 * disable or enable updating. If @p update is false, then the 826 * disable or enable updating. If @p update is false, then the
819 * buttons will not be updated. This is useful only if you know 827 * buttons will not be updated. This is useful only if you know
820 * that you will be forcing an update later. 828 * that you will be forcing an update later.
821 */ 829 */
822 void setIconText(IconText it, bool update); 830 void setIconText(IconText it, bool update);
823 831
824 /** 832 /**
825 * @return The current text style for buttons. 833 * @return The current text style for buttons.
826 */ 834 */
827 IconText iconText() const; 835 IconText iconText() const;
828 836
829 /** 837 /**
830 * Set the icon size to load. Usually you should not call 838 * Set the icon size to load. Usually you should not call
831 * this, the icon size is taken care of by KIconLoader 839 * this, the icon size is taken care of by KIconLoader
832 * and globally configured. 840 * and globally configured.
833 * By default, the toolbar will load icons of size 32 for main 841 * By default, the toolbar will load icons of size 32 for main
834 * toolbars and 22 for other toolbars 842 * toolbars and 22 for other toolbars
835 * @see KIconLoader. 843 * @see KIconLoader.
836 * 844 *
837 * @param size The size to use 845 * @param size The size to use
838 */ 846 */
839 void setIconSize(int size); 847 void setIconSize(int size);
840 // Note: don't merge with the next one, it breaks Qt properties 848 // Note: don't merge with the next one, it breaks Qt properties
841 849
842 /** 850 /**
843 * Same as @ref setIconText(int size) but allows you 851 * Same as @ref setIconText(int size) but allows you
844 * to disable the toolbar update. 852 * to disable the toolbar update.
845 * 853 *
846 * @param size The size to use 854 * @param size The size to use
847 * @param update If true, then the toolbar will be updated after 855 * @param update If true, then the toolbar will be updated after
848 * this 856 * this
849 */ 857 */
850 void setIconSize(int size, bool update); 858 void setIconSize(int size, bool update);
851 859
852 /** 860 /**
853 * @return The current icon size for buttons. 861 * @return The current icon size for buttons.
854 */ 862 */
855 int iconSize() const; 863 int iconSize() const;
856 864
857 /** 865 /**
858 * This allows you to enable or disable the context menu. 866 * This allows you to enable or disable the context menu.
859 * 867 *
860 * @param enable If false, then the context menu will be disabled 868 * @param enable If false, then the context menu will be disabled
861 */ 869 */
862 void setEnableContextMenu(bool enable = true); 870 void setEnableContextMenu(bool enable = true);
863 871
864 /** 872 /**
865 * Returns whether or not the context menu is disabled 873 * Returns whether or not the context menu is disabled
866 * 874 *
867 * @return The context menu state 875 * @return The context menu state
868 */ 876 */
869 bool contextMenuEnabled() const; 877 bool contextMenuEnabled() const;
870 878
871 /** 879 /**
872 * This will inform a toolbar button to ignore certain style 880 * This will inform a toolbar button to ignore certain style
873 * changes. Specifically, it will ignore IconText (always IconOnly) 881 * changes. Specifically, it will ignore IconText (always IconOnly)
874 * and will not allow image effects to apply. 882 * and will not allow image effects to apply.
875 * 883 *
876 * @param id The button to exclude from styles 884 * @param id The button to exclude from styles
877 * @param no_style If true, then it is excluded (default: true). 885 * @param no_style If true, then it is excluded (default: true).
878 */ 886 */
879 void setItemNoStyle(int id, bool no_style = true); 887 void setItemNoStyle(int id, bool no_style = true);
880 888
881 void setFlat (bool flag); 889 void setFlat (bool flag);
882 890
883 /** 891 /**
884 * @return the number of items in the toolbar 892 * @return the number of items in the toolbar
885 */ 893 */
886 int count() const; 894 int count() const;
887 895
888 /** 896 /**
889 * Instruct the toolbar to save it's current state to either the app 897 * Instruct the toolbar to save it's current state to either the app
890 * config file or to the XML-GUI resource file (whichever has 898 * config file or to the XML-GUI resource file (whichever has
891 * precedence). 899 * precedence).
892 */ 900 */
893 void saveState(); 901 void saveState();
894 902
895 /** 903 /**
896 * Save the toolbar settings to group @p configGroup in @p config. 904 * Save the toolbar settings to group @p configGroup in @p config.
897 */ 905 */
898 void saveSettings(KConfig *config, const QString &configGroup); 906 void saveSettings(KConfig *config, const QString &configGroup);
899 907
900 /** 908 /**
901 * Read the toolbar settings from group @p configGroup in @p config 909 * Read the toolbar settings from group @p configGroup in @p config
902 * and apply them. 910 * and apply them.
903 */ 911 */
904 void applySettings(KConfig *config, const QString &configGroup); 912 void applySettings(KConfig *config, const QString &configGroup);
905 913
906 /** 914 /**
907 * Tell the toolbar what XML-GUI resource file it should use to save 915 * Tell the toolbar what XML-GUI resource file it should use to save
908 * it's state. The state of the toolbar (position, size, etc) is 916 * it's state. The state of the toolbar (position, size, etc) is
909 * saved in KConfig files if the application does not use XML-GUI.. 917 * saved in KConfig files if the application does not use XML-GUI..
910 * but if the app does, then it's saved the XML file. This function 918 * but if the app does, then it's saved the XML file. This function
911 * allows this to happen. 919 * allows this to happen.
912 * 920 *
913 * @param xmlfile The XML-GUI resource file to write to 921 * @param xmlfile The XML-GUI resource file to write to
914 * @param xml The DOM document for the XML-GUI building 922 * @param xml The DOM document for the XML-GUI building
915 */ 923 */
916 // void setXML(const QString& xmlfile, const QDomDocument& xml); 924 // void setXML(const QString& xmlfile, const QDomDocument& xml);
917 /* @internal */ 925 /* @internal */
918 void setXMLGUIClient( KXMLGUIClient *client ); 926 void setXMLGUIClient( KXMLGUIClient *client );
919 927
920 /** 928 /**
921 * Assign a (translated) text to this toolbar. This is used 929 * Assign a (translated) text to this toolbar. This is used
922 * for the tooltip on the handle, and when listing the toolbars. 930 * for the tooltip on the handle, and when listing the toolbars.
923 */ 931 */
924 void setText( const QString & txt ); 932 void setText( const QString & txt );
925 933
926 /** 934 /**
927 * @return the toolbar's text. 935 * @return the toolbar's text.
928 */ 936 */
929 QString text() const; 937 QString text() const;
930 938
931 void setStretchableWidget( QWidget *w ); 939 void setStretchableWidget( QWidget *w );
932 QSizePolicy sizePolicy() const; 940 QSizePolicy sizePolicy() const;
933 bool highlight() const; 941 bool highlight() const;
934 QSize sizeHint() const; 942 QSize sizeHint() const;
935 QSize minimumSizeHint() const; 943 QSize minimumSizeHint() const;
936 QSize minimumSize() const; 944 QSize minimumSize() const;
937 945
938 void hide(); 946 void hide();
939 void show(); 947 void show();
940 948
941 void updateRects( bool = FALSE ) {} 949 void updateRects( bool = FALSE ) {}
942 950
943//US void loadState( const QDomElement &e ); 951//US void loadState( const QDomElement &e );
944//US void saveState( QDomElement &e ); 952//US void saveState( QDomElement &e );
945 953
946 /** 954 /**
947 * @internal 955 * @internal
948 */ 956 */
949 void positionYourself( bool force = false); 957 void positionYourself( bool force = false);
950 958
951signals: 959signals:
952 /** 960 /**
953 * Emitted when button @p id is clicked. 961 * Emitted when button @p id is clicked.
954 */ 962 */
955 void clicked(int id); 963 void clicked(int id);
956 964
957 /** 965 /**
958 * Emitted when button @p id is double-clicked. 966 * Emitted when button @p id is double-clicked.
959 * 967 *
960 * Note: you will always 968 * Note: you will always
961 * recive two @ref clicked() , @ref pressed() and @ref released() signals. 969 * recive two @ref clicked() , @ref pressed() and @ref released() signals.
962 * There is no way to avoid it - at least no easy way. 970 * There is no way to avoid it - at least no easy way.
963 * If you need to resolve this all you can do is set up timers 971 * If you need to resolve this all you can do is set up timers
964 * which wait for @ref QApplication::doubleClickInterval() to expire. 972 * which wait for @ref QApplication::doubleClickInterval() to expire.
965 * If in that time you don't get this signal, you may belive that 973 * If in that time you don't get this signal, you may belive that
966 * button was only clicked and not double-clicked. 974 * button was only clicked and not double-clicked.
967 * And please note that butons with popup menus do not emit this signal, 975 * And please note that butons with popup menus do not emit this signal,
968 * but those with delayed popup do. 976 * but those with delayed popup do.
969 */ 977 */
970 void doubleClicked (int id); 978 void doubleClicked (int id);
971 979
972 /** 980 /**
973 * Emitted when button @p id is pressed. 981 * Emitted when button @p id is pressed.
974 */ 982 */
975 void pressed(int); 983 void pressed(int);
976 984
977 /** 985 /**
978 * Emits when button @p id is released. 986 * Emits when button @p id is released.
979 */ 987 */
980 void released(int); 988 void released(int);
981 989
982 /** 990 /**
983 * Emitted when a toggle button changes state. 991 * Emitted when a toggle button changes state.
984 * 992 *
985 * Emitted also if you change state 993 * Emitted also if you change state
986 * with @ref setButton() or @ref toggleButton() 994 * with @ref setButton() or @ref toggleButton()
987 * If you make a button normal again, with 995 * If you make a button normal again, with
988 * setToggle(false), this signal won't 996 * setToggle(false), this signal won't
989 * be emitted. 997 * be emitted.
990 */ 998 */
991 void toggled(int); 999 void toggled(int);
992 1000
993 /** 1001 /**
994 * This signal is emitted when item id gets highlighted/unhighlighted 1002 * This signal is emitted when item id gets highlighted/unhighlighted
995 * (i.e when mouse enters/exits). 1003 * (i.e when mouse enters/exits).
996 * 1004 *
997 * Note that this signal is emitted from 1005 * Note that this signal is emitted from
998 * all buttons (normal, disabled and toggle) even when there is no visible 1006 * all buttons (normal, disabled and toggle) even when there is no visible
999 * change in buttons (i.e., buttons do not raise when mouse enters). 1007 * change in buttons (i.e., buttons do not raise when mouse enters).
1000 * The parameter @p isHighlighted is @p true when mouse enters and @p false when 1008 * The parameter @p isHighlighted is @p true when mouse enters and @p false when
1001 * mouse exits. 1009 * mouse exits.
1002 */ 1010 */
1003 void highlighted(int id, bool isHighlighted); 1011 void highlighted(int id, bool isHighlighted);
1004 1012
1005 /** 1013 /**
1006 * This signal is emitted when item id gets highlighted/unhighlighted 1014 * This signal is emitted when item id gets highlighted/unhighlighted
1007 * (i.e when mouse enters/exits). 1015 * (i.e when mouse enters/exits).
1008 * 1016 *
1009 * Note that this signal is emitted from 1017 * Note that this signal is emitted from
1010 * all buttons (normal, disabled and toggle) even when there is no visible 1018 * all buttons (normal, disabled and toggle) even when there is no visible
1011 * change in buttons (i.e., buttons do not raise when mouse enters). 1019 * change in buttons (i.e., buttons do not raise when mouse enters).
1012 */ 1020 */
1013 void highlighted(int id ); 1021 void highlighted(int id );
1014 1022
1015 /** 1023 /**
1016 * Emitted when toolbar changes position, or when 1024 * Emitted when toolbar changes position, or when
1017 * an item is removed from toolbar. 1025 * an item is removed from toolbar.
1018 * 1026 *
1019 * If you subclass @ref KMainWindow and reimplement 1027 * If you subclass @ref KMainWindow and reimplement
1020 * @ref KMainWindow::resizeEvent() be sure to connect to 1028 * @ref KMainWindow::resizeEvent() be sure to connect to
1021 * this signal. Note: You can connect this signal to a slot that 1029 * this signal. Note: You can connect this signal to a slot that
1022 * doesn't take parameter. 1030 * doesn't take parameter.
1023 */ 1031 */
1024 void moved( BarPosition ); 1032 void moved( BarPosition );
1025 1033
1026 /** 1034 /**
1027 * @internal 1035 * @internal
1028 * This signal is emitted when toolbar detects changing of 1036 * This signal is emitted when toolbar detects changing of
1029 * following parameters: 1037 * following parameters:
1030 * highlighting, button-size, button-mode. This signal is 1038 * highlighting, button-size, button-mode. This signal is
1031 * internal, aimed to buttons. 1039 * internal, aimed to buttons.
1032 */ 1040 */
1033 void modechange (); 1041 void modechange ();
1034 1042
1035 /** 1043 /**
1036 * This signal is emitted when the toolbar is getting deleted, 1044 * This signal is emitted when the toolbar is getting deleted,
1037 * and before ~KToolbar finishes (so it's still time to remove 1045 * and before ~KToolbar finishes (so it's still time to remove
1038 * widgets from the toolbar). 1046 * widgets from the toolbar).
1039 * Used by KWidgetAction. 1047 * Used by KWidgetAction.
1040 * @since 3.2 1048 * @since 3.2
1041 */ 1049 */
1042 void toolbarDestroyed(); 1050 void toolbarDestroyed();
1043 1051
1044public: 1052public:
1045 /** 1053 /**
1046 * @return global setting for "Highlight buttons under mouse" 1054 * @return global setting for "Highlight buttons under mouse"
1047 */ 1055 */
1048 void repaintMe(); 1056 void repaintMe();
1049 static bool highlightSetting(); 1057 static bool highlightSetting();
1050 1058
1051 /** 1059 /**
1052 * @return global setting for "Toolbars transparent when moving" 1060 * @return global setting for "Toolbars transparent when moving"
1053 */ 1061 */
1054 static bool transparentSetting(); 1062 static bool transparentSetting();
1055 1063
1056 /** 1064 /**
1057 * @return global setting for "Icon Text" 1065 * @return global setting for "Icon Text"
1058 */ 1066 */
1059 static IconText iconTextSetting(); 1067 static IconText iconTextSetting();
1060 1068
1061public slots: 1069public slots:
1062 virtual void setIconText( const QString &txt ) 1070 virtual void setIconText( const QString &txt )
1063 { QToolBar::setIconText( txt ); } 1071 { Q3ToolBar::setIconText( txt ); }
1064 void slotRepaint(); 1072 void slotRepaint();
1065 1073
1066protected: 1074protected:
1067 void mousePressEvent( QMouseEvent * ); 1075 void mousePressEvent( QMouseEvent * );
1068 void childEvent( QChildEvent *e ); 1076 void childEvent( QChildEvent *e );
1069 void showEvent( QShowEvent *e ); 1077 void showEvent( QShowEvent *e );
1070 void resizeEvent( QResizeEvent *e ); 1078 void resizeEvent( QResizeEvent *e );
1071 bool event( QEvent *e ); 1079 bool event( QEvent *e );
1072 void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); 1080 void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false);
1073 QString settingsGroup(); 1081 QString settingsGroup();
1074 1082
1075private slots: 1083private slots:
1076 void rebuildLayout(); 1084 void rebuildLayout();
1077 void slotReadConfig (); 1085 void slotReadConfig ();
1078 void slotAppearanceChanged(); 1086 void slotAppearanceChanged();
1079 void slotIconChanged(int); 1087 void slotIconChanged(int);
1080 void toolBarPosChanged( QToolBar *tb ); 1088 void toolBarPosChanged( Q3ToolBar *tb );
1081 void slotContextAboutToShow(); 1089 void slotContextAboutToShow();
1082 void widgetDestroyed(); 1090 void widgetDestroyed();
1083 1091
1084private: 1092private:
1085 int sizeHintW; 1093 int sizeHintW;
1086 int sizeHintH; 1094 int sizeHintH;
1087 void init( bool readConfig = true, bool honorStyle = false ); 1095 void init( bool readConfig = true, bool honorStyle = false );
1088 void doConnections( KToolBarButton *button ); 1096 void doConnections( KToolBarButton *button );
1089 void insertWidgetInternal( QWidget *w, int &index, int id ); 1097 void insertWidgetInternal( QWidget *w, int &index, int id );
1090 void removeWidgetInternal( QWidget *w ); 1098 void removeWidgetInternal( QWidget *w );
1091 void getAttributes( QString &position, QString &icontext, int &index ); 1099 void getAttributes( QString &position, QString &icontext, int &index );
1092//US KPopupMenu *contextMenu(); 1100//US KPopupMenu *contextMenu();
1093 QPopupMenu *contextMenu(); 1101 Q3PopupMenu *contextMenu();
1094 1102
1095 QMap<QWidget*, int > widget2id; 1103 QMap<QWidget*, int > widget2id;
1096 typedef QMap<int, QWidget* > Id2WidgetMap; 1104 typedef QMap<int, QWidget* > Id2WidgetMap;
1097 Id2WidgetMap id2widget; 1105 Id2WidgetMap id2widget;
1098//US KPopupMenu *context; 1106//US KPopupMenu *context;
1099 QPopupMenu *context; 1107 Q3PopupMenu *context;
1100 QPtrList<QWidget> widgets; 1108 Q3PtrList<QWidget> widgets;
1101 QTimer *layoutTimer; 1109 QTimer *layoutTimer;
1102 QGuardedPtr<QWidget> stretchableWidget, rightAligned; 1110 QPointer<QWidget> stretchableWidget, rightAligned;
1103protected: 1111protected:
1104 virtual void virtual_hook( int id, void* data ); 1112 virtual void virtual_hook( int id, void* data );
1105private: 1113private:
1106 KToolBarPrivate *d; 1114 KToolBarPrivate *d;
1107 bool inshutdownprocess; 1115 bool inshutdownprocess;
1108}; 1116};
1109 1117
1110#endif 1118#endif
diff --git a/microkde/kdeui/ktoolbarbutton.cpp b/microkde/kdeui/ktoolbarbutton.cpp
index 1d5d0e5..7b98b32 100644
--- a/microkde/kdeui/ktoolbarbutton.cpp
+++ b/microkde/kdeui/ktoolbarbutton.cpp
@@ -1,756 +1,770 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997, 1998 Stephan Kulow (coolo@kde.org) 2 Copyright (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
3 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) 3 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
4 (C) 1997, 1998 Sven Radej (radej@kde.org) 4 (C) 1997, 1998 Sven Radej (radej@kde.org)
5 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) 5 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
6 (C) 1999 Chris Schlaeger (cs@kde.org) 6 (C) 1999 Chris Schlaeger (cs@kde.org)
7 (C) 1999 Kurt Granroth (granroth@kde.org) 7 (C) 1999 Kurt Granroth (granroth@kde.org)
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
11 License version 2 as published by the Free Software Foundation. 11 License version 2 as published by the Free Software Foundation.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24//US #include <config.h> 24//US #include <config.h>
25#include <string.h> 25#include <string.h>
26 26
27#include "ktoolbarbutton.h" 27#include "ktoolbarbutton.h"
28#include "ktoolbar.h" 28#include "ktoolbar.h"
29 29
30#include <qstyle.h> 30#include <qstyle.h>
31#include <qimage.h> 31#include <qimage.h>
32#include <qtimer.h> 32#include <qtimer.h>
33#include <qdrawutil.h> 33#include <qdrawutil.h>
34#include <qtooltip.h> 34#include <qtooltip.h>
35#include <qbitmap.h> 35#include <qbitmap.h>
36#include <qpopupmenu.h> 36#include <q3popupmenu.h>
37#include <qcursor.h> 37#include <qcursor.h>
38#include <qpainter.h> 38#include <qpainter.h>
39#include <qlayout.h> 39#include <qlayout.h>
40//Added by qt3to4:
41#include <QPixmap>
42#include <QMouseEvent>
43#include <QEvent>
40 44
41#include <kapplication.h> 45#include <kapplication.h>
42#include <kdebug.h> 46#include <kdebug.h>
43#include <kglobal.h> 47#include <kglobal.h>
44#include <kglobalsettings.h> 48#include <kglobalsettings.h>
45//US #include <kiconeffect.h> 49//US #include <kiconeffect.h>
46#include <kiconloader.h> 50#include <kiconloader.h>
47 51
48// needed to get our instance 52// needed to get our instance
49#include <kmainwindow.h> 53#include <kmainwindow.h>
50 54
51template class QIntDict<KToolBarButton>; 55template class Q3IntDict<KToolBarButton>;
52 56
53class KToolBarButtonPrivate 57class KToolBarButtonPrivate
54{ 58{
55public: 59public:
56 KToolBarButtonPrivate() 60 KToolBarButtonPrivate()
57 { 61 {
58 m_noStyle = false; 62 m_noStyle = false;
59 m_isSeparator = false; 63 m_isSeparator = false;
60 m_isRadio = false; 64 m_isRadio = false;
61 m_highlight = false; 65 m_highlight = false;
62 m_isRaised = false; 66 m_isRaised = false;
63 m_isActive = false; 67 m_isActive = false;
64 68
65 m_iconName = QString::null; 69 m_iconName = QString::null;
66 m_iconText = KToolBar::IconOnly; 70 m_iconText = KToolBar::IconOnly;
67 m_iconSize = 0; 71 m_iconSize = 0;
68 72
69//US m_instance = KGlobal::instance(); 73//US m_instance = KGlobal::instance();
70 } 74 }
71 ~KToolBarButtonPrivate() 75 ~KToolBarButtonPrivate()
72 { 76 {
73 } 77 }
74 78
75 int m_id; 79 int m_id;
76 bool m_noStyle: 1; 80 bool m_noStyle: 1;
77 bool m_isSeparator: 1; 81 bool m_isSeparator: 1;
78 bool m_isRadio: 1; 82 bool m_isRadio: 1;
79 bool m_highlight: 1; 83 bool m_highlight: 1;
80 bool m_isRaised: 1; 84 bool m_isRaised: 1;
81 bool m_isActive: 1; 85 bool m_isActive: 1;
82 86
83 QString m_iconName; 87 QString m_iconName;
84 88
85 KToolBar *m_parent; 89 KToolBar *m_parent;
86 KToolBar::IconText m_iconText; 90 KToolBar::IconText m_iconText;
87 int m_iconSize; 91 int m_iconSize;
88 QSize size; 92 QSize size;
89 93
90 QPoint m_mousePressPos; 94 QPoint m_mousePressPos;
91 95
92//US KInstance *m_instance; 96//US KInstance *m_instance;
93}; 97};
94 98
95// This will construct a separator 99// This will construct a separator
96KToolBarButton::KToolBarButton( QWidget *_parent, const char *_name ) 100KToolBarButton::KToolBarButton( QWidget *_parent, const char *_name )
97 : QToolButton( _parent , _name) 101 : QToolButton( _parent , _name)
98{ 102{
99 d = new KToolBarButtonPrivate; 103 d = new KToolBarButtonPrivate;
100 104
101 resize(6,6); 105 resize(6,6);
102 hide(); 106 hide();
103 d->m_isSeparator = true; 107 d->m_isSeparator = true;
104} 108}
105 109
106KToolBarButton::KToolBarButton( const QString& _icon, int _id, 110KToolBarButton::KToolBarButton( const QString& _icon, int _id,
107 QWidget *_parent, const char *_name, 111 QWidget *_parent, const char *_name,
108 const QString &_txt/*US, KInstance *_instance*/ ) 112 const QString &_txt/*US, KInstance *_instance*/ )
109 : QToolButton( _parent, _name ), d( 0 ) 113 : QToolButton( _parent, _name ), d( 0 )
110{ 114{
111 d = new KToolBarButtonPrivate; 115 d = new KToolBarButtonPrivate;
112 116
113 d->m_id = _id; 117 d->m_id = _id;
114 d->m_parent = (KToolBar*)_parent; 118 d->m_parent = (KToolBar*)_parent;
115 QToolButton::setTextLabel(_txt); 119 QToolButton::setTextLabel(_txt);
116//US d->m_instance = _instance; 120//US d->m_instance = _instance;
117 121
118 setFocusPolicy( NoFocus ); 122 setFocusPolicy( Qt::NoFocus );
119 123
120 // connect all of our slots and start trapping events 124 // connect all of our slots and start trapping events
121 connect(d->m_parent, SIGNAL( modechange() ), 125 connect(d->m_parent, SIGNAL( modechange() ),
122 this, SLOT( modeChange() )); 126 this, SLOT( modeChange() ));
123 127
124 connect(this, SIGNAL( clicked() ), 128 connect(this, SIGNAL( clicked() ),
125 this, SLOT( slotClicked() ) ); 129 this, SLOT( slotClicked() ) );
126 connect(this, SIGNAL( pressed() ), 130 connect(this, SIGNAL( pressed() ),
127 this, SLOT( slotPressed() ) ); 131 this, SLOT( slotPressed() ) );
128 connect(this, SIGNAL( released() ), 132 connect(this, SIGNAL( released() ),
129 this, SLOT( slotReleased() ) ); 133 this, SLOT( slotReleased() ) );
130 installEventFilter(this); 134 installEventFilter(this);
131 135
132 d->m_iconName = _icon; 136 d->m_iconName = _icon;
133 137
134 // do our initial setup 138 // do our initial setup
135 modeChange(); 139 modeChange();
136} 140}
137 141
138KToolBarButton::KToolBarButton( const QPixmap& pixmap, int _id, 142KToolBarButton::KToolBarButton( const QPixmap& pixmap, int _id,
139 QWidget *_parent, const char *name, 143 QWidget *_parent, const char *name,
140 const QString& txt) 144 const QString& txt)
141 : QToolButton( _parent, name ), d( 0 ) 145 : QToolButton( _parent, name ), d( 0 )
142{ 146{
143 d = new KToolBarButtonPrivate; 147 d = new KToolBarButtonPrivate;
144 148
145 d->m_id = _id; 149 d->m_id = _id;
146 d->m_parent = (KToolBar *) _parent; 150 d->m_parent = (KToolBar *) _parent;
147 QToolButton::setTextLabel(txt); 151 QToolButton::setTextLabel(txt);
148 152
149 setFocusPolicy( NoFocus ); 153 setFocusPolicy( Qt::NoFocus );
150 154
151 // connect all of our slots and start trapping events 155 // connect all of our slots and start trapping events
152 connect(d->m_parent, SIGNAL( modechange()), 156 connect(d->m_parent, SIGNAL( modechange()),
153 this, SLOT(modeChange())); 157 this, SLOT(modeChange()));
154 158
155 connect(this, SIGNAL( clicked() ), 159 connect(this, SIGNAL( clicked() ),
156 this, SLOT( slotClicked() )); 160 this, SLOT( slotClicked() ));
157 connect(this, SIGNAL( pressed() ), 161 connect(this, SIGNAL( pressed() ),
158 this, SLOT( slotPressed() )); 162 this, SLOT( slotPressed() ));
159 connect(this, SIGNAL( released() ), 163 connect(this, SIGNAL( released() ),
160 this, SLOT( slotReleased() )); 164 this, SLOT( slotReleased() ));
161 installEventFilter(this); 165 installEventFilter(this);
162 166
163 // set our pixmap and do our initial setup 167 // set our pixmap and do our initial setup
164 setIconSet( QIconSet( pixmap )); 168 setIconSet( QIcon( pixmap ));
165 modeChange(); 169 modeChange();
166} 170}
167 171
168KToolBarButton::~KToolBarButton() 172KToolBarButton::~KToolBarButton()
169{ 173{
170 delete d; d = 0; 174 delete d; d = 0;
171} 175}
172 176
173void KToolBarButton::modeChange() 177void KToolBarButton::modeChange()
174{ 178{
175 QSize mysize; 179 QSize mysize;
176 180
177 // grab a few global variables for use in this function and others 181 // grab a few global variables for use in this function and others
178 d->m_highlight = d->m_parent->highlight(); 182 d->m_highlight = d->m_parent->highlight();
179 d->m_iconText = d->m_parent->iconText(); 183 d->m_iconText = d->m_parent->iconText();
180 184
181 d->m_iconSize = d->m_parent->iconSize(); 185 d->m_iconSize = d->m_parent->iconSize();
182 if (!d->m_iconName.isNull()) 186 if (!d->m_iconName.isNull())
183 setIcon(d->m_iconName); 187 setIcon(d->m_iconName);
184 188
185 // we'll start with the size of our pixmap 189 // we'll start with the size of our pixmap
186 int pix_width = d->m_iconSize; 190 int pix_width = d->m_iconSize;
187 191
188 if ( d->m_iconSize == 0 ) { 192 if ( d->m_iconSize == 0 ) {
189 if (!strcmp(d->m_parent->name(), "mainToolBar")) 193 if (!strcmp(d->m_parent->name(), "mainToolBar"))
190/*US 194/*US
191 pix_width = IconSize( KIcon::MainToolbar ); 195 pix_width = IconSize( KIcon::MainToolbar );
192 else 196 else
193 pix_width = IconSize( KIcon::Toolbar ); 197 pix_width = IconSize( KIcon::Toolbar );
194*/ 198*/
195//qDebug("KToolBarButton::modeChange make iconsize configurable"); 199//qDebug("KToolBarButton::modeChange make iconsize configurable");
196 pix_width = 16; 200 pix_width = 16;
197 } 201 }
198 int pix_height = pix_width; 202 int pix_height = pix_width;
199 203
200 int text_height = 0; 204 int text_height = 0;
201 int text_width = 0; 205 int text_width = 0;
202 206
203 QToolTip::remove(this); 207 QToolTip::remove(this);
204 if (d->m_iconText != KToolBar::IconOnly) 208 if (d->m_iconText != KToolBar::IconOnly)
205 { 209 {
206 // okay, we have to deal with fonts. let's get our information now 210 // okay, we have to deal with fonts. let's get our information now
207/*US 211/*US
208 QFont tmp_font = KGlobalSettings::toolBarFont(); 212 QFont tmp_font = KGlobalSettings::toolBarFont();
209 213
210 // now parse out our font sizes from our chosen font 214 // now parse out our font sizes from our chosen font
211 QFontMetrics fm(tmp_font); 215 QFontMetrics fm(tmp_font);
212 216
213 text_height = fm.lineSpacing(); 217 text_height = fm.lineSpacing();
214 text_width = fm.width(textLabel()); 218 text_width = fm.width(textLabel());
215*/ 219*/
216//qDebug("KToolBarButton::modeChange make textsize configurable"); 220//qDebug("KToolBarButton::modeChange make textsize configurable");
217 221
218 // none of the other modes want tooltips 222 // none of the other modes want tooltips
219 } 223 }
220 else 224 else
221 { 225 {
222 QToolTip::add(this, textLabel()); 226 QToolTip::add(this, textLabel());
223 } 227 }
224 228
225 switch (d->m_iconText) 229 switch (d->m_iconText)
226 { 230 {
227 case KToolBar::IconOnly: 231 case KToolBar::IconOnly:
228 mysize = QSize(pix_width, pix_height); 232 mysize = QSize(pix_width, pix_height);
229 break; 233 break;
230 234
231 case KToolBar::IconTextRight: 235 case KToolBar::IconTextRight:
232 mysize = QSize(pix_width + text_width + 4, pix_height); 236 mysize = QSize(pix_width + text_width + 4, pix_height);
233 break; 237 break;
234 238
235 case KToolBar::TextOnly: 239 case KToolBar::TextOnly:
236 mysize = QSize(text_width + 4, text_height); 240 mysize = QSize(text_width + 4, text_height);
237 break; 241 break;
238 242
239 case KToolBar::IconTextBottom: 243 case KToolBar::IconTextBottom:
240 mysize = QSize((text_width + 4 > pix_width) ? text_width + 4 : pix_width, pix_height + text_height); 244 mysize = QSize((text_width + 4 > pix_width) ? text_width + 4 : pix_width, pix_height + text_height);
241 break; 245 break;
242 246
243 default: 247 default:
244 break; 248 break;
245 } 249 }
246/*US 250/*US
247 mysize = style().sizeFromContents(QStyle::CT_ToolButton, this, mysize). 251 mysize = style().sizeFromContents(QStyle::CT_ToolButton, this, mysize).
248 expandedTo(QApplication::globalStrut()); 252 expandedTo(QApplication::globalStrut());
249*/ 253*/
250 // make sure that this isn't taller then it is wide 254 // make sure that this isn't taller then it is wide
251 if (mysize.height() > mysize.width()) 255 if (mysize.height() > mysize.width())
252 mysize.setWidth(mysize.height()); 256 mysize.setWidth(mysize.height());
253 257
254 d->size = mysize; 258 d->size = mysize;
255 setFixedSize(mysize); 259 setFixedSize(mysize);
256 updateGeometry(); 260 updateGeometry();
257} 261}
258 262
259void KToolBarButton::setTextLabel( const QString& text, bool tipToo) 263void KToolBarButton::setTextLabel( const QString& text, bool tipToo)
260{ 264{
261 if (text.isNull()) 265 if (text.isNull())
262 return; 266 return;
263 267
264 QString txt(text); 268 QString txt(text);
265 if (txt.right(3) == QString::fromLatin1("...")) 269 if (txt.right(3) == QString::fromLatin1("..."))
266 txt.truncate(txt.length() - 3); 270 txt.truncate(txt.length() - 3);
267 271
268 QToolButton::setTextLabel(txt, tipToo); 272 QToolButton::setTextLabel(txt, tipToo);
269 update(); 273 update();
270} 274}
271 275
272void KToolBarButton::setText( const QString& text) 276void KToolBarButton::setText( const QString& text)
273{ 277{
274 setTextLabel(text, true); 278 setTextLabel(text, true);
275 modeChange(); 279 modeChange();
276} 280}
277 281
278void KToolBarButton::setIcon( const QString &icon ) 282void KToolBarButton::setIcon( const QString &icon )
279{ 283{
280 d->m_iconName = icon; 284 d->m_iconName = icon;
281 d->m_iconSize = d->m_parent->iconSize(); 285 d->m_iconSize = d->m_parent->iconSize();
282 // QObject::name() return "const char *" instead of QString. 286 // QObject::name() return "const char *" instead of QString.
283 if (!strcmp(d->m_parent->name(), "mainToolBar")) 287 if (!strcmp(d->m_parent->name(), "mainToolBar"))
284/*US QToolButton::setIconSet( d->m_instance->iconLoader()->loadIconSet( 288/*US QToolButton::setIconSet( d->m_instance->iconLoader()->loadIconSet(
285 d->m_iconName, KIcon::MainToolbar, d->m_iconSize )); 289 d->m_iconName, KIcon::MainToolbar, d->m_iconSize ));
286*/ 290*/
287 QToolButton::setIconSet( KGlobal::iconLoader()->loadIconSet(d->m_iconName )); 291 QToolButton::setIconSet( KGlobal::iconLoader()->loadIconSet(d->m_iconName ));
288 else 292 else
289/*US QToolButton::setIconSet(d->m_instance->iconLoader()->loadIconSet( 293/*US QToolButton::setIconSet(d->m_instance->iconLoader()->loadIconSet(
290 d->m_iconName, KIcon::Toolbar, d->m_iconSize )); 294 d->m_iconName, KIcon::Toolbar, d->m_iconSize ));
291*/ 295*/
292 QToolButton::setIconSet(KGlobal::iconLoader()->loadIconSet(d->m_iconName)); 296 QToolButton::setIconSet(KGlobal::iconLoader()->loadIconSet(d->m_iconName));
293} 297}
294 298
295void KToolBarButton::setIconSet( const QIconSet &iconset ) 299void KToolBarButton::setIconSet( const QIcon &iconset )
296{ 300{
297 QToolButton::setIconSet( iconset ); 301 QToolButton::setIconSet( iconset );
298} 302}
299 303
300// remove? 304// remove?
301void KToolBarButton::setPixmap( const QPixmap &pixmap ) 305void KToolBarButton::setPixmap( const QPixmap &pixmap )
302{ 306{
303 if( pixmap.isNull()) // called by QToolButton 307 if( pixmap.isNull()) // called by QToolButton
304 { 308 {
305 QToolButton::setPixmap( pixmap ); 309 QToolButton::setPixmap( pixmap );
306 return; 310 return;
307 } 311 }
308 QIconSet set = iconSet(); 312 QIcon set = iconSet();
309 set.setPixmap( pixmap, QIconSet::Automatic, QIconSet::Active ); 313 set.setPixmap( pixmap, QIcon::Automatic, QIcon::Active );
310 QToolButton::setIconSet( set ); 314 QToolButton::setIconSet( set );
311} 315}
312 316
313void KToolBarButton::setDefaultPixmap( const QPixmap &pixmap ) 317void KToolBarButton::setDefaultPixmap( const QPixmap &pixmap )
314{ 318{
315 QIconSet set = iconSet(); 319 QIcon set = iconSet();
316 set.setPixmap( pixmap, QIconSet::Automatic, QIconSet::Normal ); 320 set.setPixmap( pixmap, QIcon::Automatic, QIcon::Normal );
317 QToolButton::setIconSet( set ); 321 QToolButton::setIconSet( set );
318} 322}
319 323
320void KToolBarButton::setDisabledPixmap( const QPixmap &pixmap ) 324void KToolBarButton::setDisabledPixmap( const QPixmap &pixmap )
321{ 325{
322 QIconSet set = iconSet(); 326 QIcon set = iconSet();
323 set.setPixmap( pixmap, QIconSet::Automatic, QIconSet::Disabled ); 327 set.setPixmap( pixmap, QIcon::Automatic, QIcon::Disabled );
324 QToolButton::setIconSet( set ); 328 QToolButton::setIconSet( set );
325} 329}
326 330
327void KToolBarButton::setDefaultIcon( const QString& icon ) 331void KToolBarButton::setDefaultIcon( const QString& icon )
328{ 332{
329 QIconSet set = iconSet(); 333 QIcon set = iconSet();
330 QPixmap pm; 334 QPixmap pm;
331 if (!strcmp(d->m_parent->name(), "mainToolBar")) 335 if (!strcmp(d->m_parent->name(), "mainToolBar"))
332 pm = /*US d->m_instance->iconLoader()*/KGlobal::iconLoader()->loadIcon( icon, KIcon::MainToolbar, 336 pm = /*US d->m_instance->iconLoader()*/KGlobal::iconLoader()->loadIcon( icon, KIcon::MainToolbar,
333 d->m_iconSize ); 337 d->m_iconSize );
334 else 338 else
335 pm = /*US d->m_instance->iconLoader()*/KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar, 339 pm = /*US d->m_instance->iconLoader()*/KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar,
336 d->m_iconSize ); 340 d->m_iconSize );
337 set.setPixmap( pm, QIconSet::Automatic, QIconSet::Normal ); 341 set.setPixmap( pm, QIcon::Automatic, QIcon::Normal );
338 QToolButton::setIconSet( set ); 342 QToolButton::setIconSet( set );
339} 343}
340 344
341void KToolBarButton::setDisabledIcon( const QString& icon ) 345void KToolBarButton::setDisabledIcon( const QString& icon )
342{ 346{
343 QIconSet set = iconSet(); 347 QIcon set = iconSet();
344 QPixmap pm; 348 QPixmap pm;
345 if (!strcmp(d->m_parent->name(), "mainToolBar")) 349 if (!strcmp(d->m_parent->name(), "mainToolBar"))
346 pm = /*US d->m_instance->iconLoader()*/ KGlobal::iconLoader()->loadIcon( icon, KIcon::MainToolbar, 350 pm = /*US d->m_instance->iconLoader()*/ KGlobal::iconLoader()->loadIcon( icon, KIcon::MainToolbar,
347 d->m_iconSize ); 351 d->m_iconSize );
348 else 352 else
349 pm = /*US d->m_instance->iconLoader()*/ KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar, 353 pm = /*US d->m_instance->iconLoader()*/ KGlobal::iconLoader()->loadIcon( icon, KIcon::Toolbar,
350 d->m_iconSize ); 354 d->m_iconSize );
351 set.setPixmap( pm, QIconSet::Automatic, QIconSet::Disabled ); 355 set.setPixmap( pm, QIcon::Automatic, QIcon::Disabled );
352 QToolButton::setIconSet( set ); 356 QToolButton::setIconSet( set );
353} 357}
354 358
355QPopupMenu *KToolBarButton::popup() 359QMenu *KToolBarButton::popup()
356{ 360{
357 // obsolete 361 // obsolete
358 // KDE4: remove me 362 // KDE4: remove me
359 return QToolButton::popup(); 363 return QToolButton::popup();
360} 364}
361 365
362void KToolBarButton::setPopup(QPopupMenu *p, bool) 366void KToolBarButton::setPopup(Q3PopupMenu *p, bool)
363{ 367{
364 QToolButton::setPopup(p); 368 QToolButton::setPopup(p);
365 QToolButton::setPopupDelay(1); 369 QToolButton::setPopupDelay(1);
366} 370}
367 371
368 372
369void KToolBarButton::setDelayedPopup (QPopupMenu *p, bool) 373void KToolBarButton::setDelayedPopup (Q3PopupMenu *p, bool)
370{ 374{
371 QToolButton::setPopup(p); 375 QToolButton::setPopup(p);
372//US QToolButton::setPopupDelay(QApplication::startDragTime()); 376//US QToolButton::setPopupDelay(QApplication::startDragTime());
373} 377}
374 378
375void KToolBarButton::leaveEvent(QEvent *) 379void KToolBarButton::leaveEvent(QEvent *)
376{ 380{
377 if( d->m_isRaised || d->m_isActive ) 381 if( d->m_isRaised || d->m_isActive )
378 { 382 {
379 d->m_isRaised = false; 383 d->m_isRaised = false;
380 d->m_isActive = false; 384 d->m_isActive = false;
381 repaint(false); 385 repaint(false);
382 } 386 }
383 387
384 emit highlighted(d->m_id, false); 388 emit highlighted(d->m_id, false);
385} 389}
386 390
387void KToolBarButton::enterEvent(QEvent *) 391void KToolBarButton::enterEvent(QEvent *)
388{ 392{
389 if (d->m_highlight) 393 if (d->m_highlight)
390 { 394 {
391 if (isEnabled()) 395 if (isEnabled())
392 { 396 {
393 d->m_isActive = true; 397 d->m_isActive = true;
394 if (!isToggleButton()) 398 if (!isToggleButton())
395 d->m_isRaised = true; 399 d->m_isRaised = true;
396 } 400 }
397 else 401 else
398 { 402 {
399 d->m_isRaised = false; 403 d->m_isRaised = false;
400 d->m_isActive = false; 404 d->m_isActive = false;
401 } 405 }
402 406
403 repaint(false); 407 repaint(false);
404 } 408 }
405 emit highlighted(d->m_id, true); 409 emit highlighted(d->m_id, true);
406} 410}
407 411
408bool KToolBarButton::eventFilter(QObject *o, QEvent *ev) 412bool KToolBarButton::eventFilter(QObject *o, QEvent *ev)
409{ 413{
410 if ((KToolBarButton *)o == this) 414 if ((KToolBarButton *)o == this)
411 { 415 {
412 416
413 // Popup the menu when the left mousebutton is pressed and the mouse 417 // Popup the menu when the left mousebutton is pressed and the mouse
414 // is moved by a small distance. 418 // is moved by a small distance.
415 if (QToolButton::popup()) 419 if (QToolButton::popup())
416 { 420 {
417 if (ev->type() == QEvent::MouseButtonPress) 421 if (ev->type() == QEvent::MouseButtonPress)
418 { 422 {
419 QMouseEvent* mev = static_cast<QMouseEvent*>(ev); 423 QMouseEvent* mev = static_cast<QMouseEvent*>(ev);
420 d->m_mousePressPos = mev->pos(); 424 d->m_mousePressPos = mev->pos();
421 } 425 }
422 else if (ev->type() == QEvent::MouseMove) 426 else if (ev->type() == QEvent::MouseMove)
423 { 427 {
424 QMouseEvent* mev = static_cast<QMouseEvent*>(ev); 428 QMouseEvent* mev = static_cast<QMouseEvent*>(ev);
425 if ((mev->pos() - d->m_mousePressPos).manhattanLength() 429 if ((mev->pos() - d->m_mousePressPos).manhattanLength()
426//US > KGlobalSettings::dndEventDelay()) 430//US > KGlobalSettings::dndEventDelay())
427 > 5 ) 431 > 5 )
428 { 432 {
429//US openPopup(); 433//US openPopup();
430 return true; 434 return true;
431 } 435 }
432 } 436 }
433 } 437 }
434 438
435 if ((ev->type() == QEvent::MouseButtonPress || 439 if ((ev->type() == QEvent::MouseButtonPress ||
436 ev->type() == QEvent::MouseButtonRelease || 440 ev->type() == QEvent::MouseButtonRelease ||
437 ev->type() == QEvent::MouseButtonDblClick) && d->m_isRadio && isOn()) 441 ev->type() == QEvent::MouseButtonDblClick) && d->m_isRadio && isOn())
438 return true; 442 return true;
439 443
440 // From Kai-Uwe Sattler <kus@iti.CS.Uni-Magdeburg.De> 444 // From Kai-Uwe Sattler <kus@iti.CS.Uni-Magdeburg.De>
441 if (ev->type() == QEvent::MouseButtonDblClick) 445 if (ev->type() == QEvent::MouseButtonDblClick)
442 { 446 {
443 emit doubleClicked(d->m_id); 447 emit doubleClicked(d->m_id);
444 return true; 448 return true;
445 } 449 }
446 } 450 }
447 451
448 return QToolButton::eventFilter(o, ev); 452 return QToolButton::eventFilter(o, ev);
449} 453}
450 454
451void KToolBarButton::drawButton( QPainter *_painter ) 455void KToolBarButton::drawButton( QPainter *_painter )
452{ 456{
453#ifdef DESKTOP_VERSION 457#ifdef DESKTOP_VERSION
454 QStyle::SFlags flags = QStyle::Style_Default; 458 QStyle::State flags = QStyle::State_None;
455 QStyle::SCFlags active = QStyle::SC_None; 459 QStyle::SubControls active = QStyle::SC_None;
456 460
457 if (isDown()) { 461 if (isDown()) {
458 flags |= QStyle::Style_Down; 462 flags |= QStyle::State_DownArrow;
459 active |= QStyle::SC_ToolButton; 463 active |= QStyle::SC_ToolButton;
460 } 464 }
461 if (isEnabled()) flags |= QStyle::Style_Enabled; 465 if (isEnabled()) flags |= QStyle::State_Enabled;
462 if (isOn()) flags |= QStyle::Style_On; 466 if (isOn()) flags |= QStyle::State_On;
463 if (isEnabled() && d->m_isRaised)flags |= QStyle::Style_Raised; 467 if (isEnabled() && d->m_isRaised)flags |= QStyle::State_Raised;
464 if (hasFocus())flags |= QStyle::Style_HasFocus; 468 if (hasFocus())flags |= QStyle::State_HasFocus;
469
470 QStyleOptionToolButton qsotb;
471 qsotb.initFrom(this);
472 qsotb.state = flags;
473 qsotb.activeSubControls = active;
474 qsotb.rect = rect();
475 qsotb.palette = palette();
465 476
466 // Draw a styled toolbutton 477 // Draw a styled toolbutton
467 style().drawComplexControl(QStyle::CC_ToolButton, _painter, this, rect(), 478 style()->drawComplexControl(QStyle::CC_ToolButton, &qsotb, _painter, this);
468 colorGroup(), flags, QStyle::SC_ToolButton, active, QStyleOption());
469 479
470#else 480#else
471 style().drawToolButton(_painter, rect().x(), rect().y(), rect().width(), rect().height(), colorGroup()); 481 style().drawToolButton(_painter, rect().x(), rect().y(), rect().width(), rect().height(), colorGroup());
472#endif 482#endif
473 int dx, dy; 483 int dx, dy;
474 QFont tmp_font(KGlobalSettings::toolBarFont()); 484 QFont tmp_font(KGlobalSettings::toolBarFont());
475 QFontMetrics fm(tmp_font); 485 QFontMetrics fm(tmp_font);
476 QRect textRect; 486 QRect textRect;
477 int textFlags = 0; 487 int textFlags = 0;
478 488
479 if (d->m_iconText == KToolBar::IconOnly) // icon only 489 if (d->m_iconText == KToolBar::IconOnly) // icon only
480 { 490 {
481/*US 491/*US
482 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 492 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
483 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 493 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
484 QIconSet::Disabled, 494 QIconSet::Disabled,
485 isOn() ? QIconSet::On : QIconSet::Off ); 495 isOn() ? QIconSet::On : QIconSet::Off );
486*/ 496*/
487 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 497 QPixmap pixmap = iconSet().pixmap( QIcon::Automatic,
488 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 498 isEnabled() ? (d->m_isActive ? QIcon::Active : QIcon::Normal) :
489 QIconSet::Disabled); 499 QIcon::Disabled);
490 500
491 if( !pixmap.isNull()) 501 if( !pixmap.isNull())
492 { 502 {
493 dx = ( width() - pixmap.width() ) / 2; 503 dx = ( width() - pixmap.width() ) / 2;
494 dy = ( height() - pixmap.height() ) / 2; 504 dy = ( height() - pixmap.height() ) / 2;
495 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 505 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
496 { 506 {
497 ++dx; 507 ++dx;
498 ++dy; 508 ++dy;
499 } 509 }
500 _painter->drawPixmap( dx, dy, pixmap ); 510 _painter->drawPixmap( dx, dy, pixmap );
501 } 511 }
502 } 512 }
503 else if (d->m_iconText == KToolBar::IconTextRight) // icon and text (if any) 513 else if (d->m_iconText == KToolBar::IconTextRight) // icon and text (if any)
504 { 514 {
505/*US 515/*US
506 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 516 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
507 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 517 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
508 QIconSet::Disabled, 518 QIconSet::Disabled,
509 isOn() ? QIconSet::On : QIconSet::Off ); 519 isOn() ? QIconSet::On : QIconSet::Off );
510*/ 520*/
511 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 521 QPixmap pixmap = iconSet().pixmap( QIcon::Automatic,
512 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 522 isEnabled() ? (d->m_isActive ? QIcon::Active : QIcon::Normal) :
513 QIconSet::Disabled); 523 QIcon::Disabled);
514 524
515 if( !pixmap.isNull()) 525 if( !pixmap.isNull())
516 { 526 {
517 dx = 4; 527 dx = 4;
518 dy = ( height() - pixmap.height() ) / 2; 528 dy = ( height() - pixmap.height() ) / 2;
519 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 529 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
520 { 530 {
521 ++dx; 531 ++dx;
522 ++dy; 532 ++dy;
523 } 533 }
524 _painter->drawPixmap( dx, dy, pixmap ); 534 _painter->drawPixmap( dx, dy, pixmap );
525 } 535 }
526 536
527 if (!textLabel().isNull()) 537 if (!textLabel().isNull())
528 { 538 {
529 textFlags = AlignVCenter|AlignLeft; 539 textFlags = Qt::AlignVCenter|Qt::AlignLeft;
530 if (!pixmap.isNull()) 540 if (!pixmap.isNull())
531 dx = 4 + pixmap.width() + 2; 541 dx = 4 + pixmap.width() + 2;
532 else 542 else
533 dx = 4; 543 dx = 4;
534 dy = 0; 544 dy = 0;
535 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 545 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
536 { 546 {
537 ++dx; 547 ++dx;
538 ++dy; 548 ++dy;
539 } 549 }
540 textRect = QRect(dx, dy, width()-dx, height()); 550 textRect = QRect(dx, dy, width()-dx, height());
541 } 551 }
542 } 552 }
543 else if (d->m_iconText == KToolBar::TextOnly) 553 else if (d->m_iconText == KToolBar::TextOnly)
544 { 554 {
545 if (!textLabel().isNull()) 555 if (!textLabel().isNull())
546 { 556 {
547 textFlags = AlignVCenter|AlignLeft; 557 textFlags = Qt::AlignVCenter|Qt::AlignLeft;
548 dx = (width() - fm.width(textLabel())) / 2; 558 dx = (width() - fm.width(textLabel())) / 2;
549 dy = (height() - fm.lineSpacing()) / 2; 559 dy = (height() - fm.lineSpacing()) / 2;
550 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 560 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
551 { 561 {
552 ++dx; 562 ++dx;
553 ++dy; 563 ++dy;
554 } 564 }
555 textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() ); 565 textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() );
556 } 566 }
557 } 567 }
558 else if (d->m_iconText == KToolBar::IconTextBottom) 568 else if (d->m_iconText == KToolBar::IconTextBottom)
559 { 569 {
560/*US 570/*US
561 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 571 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic,
562 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 572 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) :
563 QIconSet::Disabled, 573 QIconSet::Disabled,
564 isOn() ? QIconSet::On : QIconSet::Off ); 574 isOn() ? QIconSet::On : QIconSet::Off );
565*/ 575*/
566 QPixmap pixmap = iconSet().pixmap( QIconSet::Automatic, 576 QPixmap pixmap = iconSet().pixmap( QIcon::Automatic,
567 isEnabled() ? (d->m_isActive ? QIconSet::Active : QIconSet::Normal) : 577 isEnabled() ? (d->m_isActive ? QIcon::Active : QIcon::Normal) :
568 QIconSet::Disabled); 578 QIcon::Disabled);
569 579
570 if( !pixmap.isNull()) 580 if( !pixmap.isNull())
571 { 581 {
572 dx = (width() - pixmap.width()) / 2; 582 dx = (width() - pixmap.width()) / 2;
573 dy = (height() - fm.lineSpacing() - pixmap.height()) / 2; 583 dy = (height() - fm.lineSpacing() - pixmap.height()) / 2;
574 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 584 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
575 { 585 {
576 ++dx; 586 ++dx;
577 ++dy; 587 ++dy;
578 } 588 }
579 _painter->drawPixmap( dx, dy, pixmap ); 589 _painter->drawPixmap( dx, dy, pixmap );
580 } 590 }
581 591
582 if (!textLabel().isNull()) 592 if (!textLabel().isNull())
583 { 593 {
584 textFlags = AlignBottom|AlignHCenter; 594 textFlags = Qt::AlignBottom|Qt::AlignHCenter;
585 dx = (width() - fm.width(textLabel())) / 2; 595 dx = (width() - fm.width(textLabel())) / 2;
586 dy = height() - fm.lineSpacing() - 4; 596 dy = height() - fm.lineSpacing() - 4;
587 597
588 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ ) 598 if ( isDown() /*US && style().styleHint(QStyle::SH_GUIStyle) == WindowsStyle*/ )
589 { 599 {
590 ++dx; 600 ++dx;
591 ++dy; 601 ++dy;
592 } 602 }
593 textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() ); 603 textRect = QRect( dx, dy, fm.width(textLabel()), fm.lineSpacing() );
594 } 604 }
595 } 605 }
596 606
597 // Draw the text at the position given by textRect, and using textFlags 607 // Draw the text at the position given by textRect, and using textFlags
598 if (!textLabel().isNull() && !textRect.isNull()) 608 if (!textLabel().isNull() && !textRect.isNull())
599 { 609 {
600 _painter->setFont(KGlobalSettings::toolBarFont()); 610 _painter->setFont(KGlobalSettings::toolBarFont());
601 if (!isEnabled()) 611 if (!isEnabled())
602 _painter->setPen(palette().disabled().dark()); 612 _painter->setPen(palette().disabled().dark());
603 else if(d->m_isRaised) 613 else if(d->m_isRaised)
604 _painter->setPen(KGlobalSettings::toolBarHighlightColor()); 614 _painter->setPen(KGlobalSettings::toolBarHighlightColor());
605 else 615 else
606 _painter->setPen( colorGroup().buttonText() ); 616 _painter->setPen( colorGroup().buttonText() );
607 _painter->drawText(textRect, textFlags, textLabel()); 617 _painter->drawText(textRect, textFlags, textLabel());
608 } 618 }
609 619
610 if (QToolButton::popup()) 620 if (QToolButton::popup())
611 { 621 {
612#ifdef DESKTOP_VERSION 622#ifdef DESKTOP_VERSION
613 QStyle::SFlags arrowFlags = QStyle::Style_Default; 623 QStyle::State arrowFlags = QStyle::State_None;
624
625 if (isDown())arrowFlags |= QStyle::State_DownArrow;
626 if (isEnabled()) arrowFlags |= QStyle::State_Enabled;
614 627
615 if (isDown())arrowFlags |= QStyle::Style_Down; 628 QStyleOption qso;
616 if (isEnabled()) arrowFlags |= QStyle::Style_Enabled; 629 qso.initFrom(this);
630 qso.state = arrowFlags;
631 qso.rect = QRect(width()-7, height()-7, 7, 7);
632 qso.palette = palette();
617 633
618 style().drawPrimitive(QStyle::PE_ArrowDown, _painter, 634 style()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &qso, _painter);
619 QRect(width()-7, height()-7, 7, 7), colorGroup(),
620 arrowFlags, QStyleOption() );
621#else 635#else
622 style().drawArrow(_painter, Qt::DownArrow, isDown(), 636 style().drawArrow(_painter, Qt::DownArrow, isDown(),
623 width()-7, height()-7, 7, 7, colorGroup(), isEnabled() ); 637 width()-7, height()-7, 7, 7, colorGroup(), isEnabled() );
624#endif 638#endif
625 639
626 } 640 }
627} 641}
628 642
629void KToolBarButton::paletteChange(const QPalette &) 643void KToolBarButton::paletteChange(const QPalette &)
630{ 644{
631 if(!d->m_isSeparator) 645 if(!d->m_isSeparator)
632 { 646 {
633 modeChange(); 647 modeChange();
634 repaint(false); // no need to delete it first therefore only false 648 repaint(false); // no need to delete it first therefore only false
635 } 649 }
636} 650}
637 651
638void KToolBarButton::showMenu() 652void KToolBarButton::showMenu()
639{ 653{
640 // obsolete 654 // obsolete
641 // KDE4: remove me 655 // KDE4: remove me
642} 656}
643 657
644void KToolBarButton::slotDelayTimeout() 658void KToolBarButton::slotDelayTimeout()
645{ 659{
646 // obsolete 660 // obsolete
647 // KDE4: remove me 661 // KDE4: remove me
648} 662}
649 663
650void KToolBarButton::slotClicked() 664void KToolBarButton::slotClicked()
651{ 665{
652 emit clicked( d->m_id ); 666 emit clicked( d->m_id );
653} 667}
654 668
655void KToolBarButton::slotPressed() 669void KToolBarButton::slotPressed()
656{ 670{
657 emit pressed( d->m_id ); 671 emit pressed( d->m_id );
658} 672}
659 673
660void KToolBarButton::slotReleased() 674void KToolBarButton::slotReleased()
661{ 675{
662 emit released( d->m_id ); 676 emit released( d->m_id );
663} 677}
664 678
665void KToolBarButton::slotToggled() 679void KToolBarButton::slotToggled()
666{ 680{
667 emit toggled( d->m_id ); 681 emit toggled( d->m_id );
668} 682}
669 683
670void KToolBarButton::setNoStyle(bool no_style) 684void KToolBarButton::setNoStyle(bool no_style)
671{ 685{
672 d->m_noStyle = no_style; 686 d->m_noStyle = no_style;
673 687
674 modeChange(); 688 modeChange();
675 d->m_iconText = KToolBar::IconTextRight; 689 d->m_iconText = KToolBar::IconTextRight;
676 repaint(false); 690 repaint(false);
677} 691}
678 692
679void KToolBarButton::setRadio (bool f) 693void KToolBarButton::setRadio (bool f)
680{ 694{
681 if ( d ) 695 if ( d )
682 d->m_isRadio = f; 696 d->m_isRadio = f;
683} 697}
684 698
685void KToolBarButton::on(bool flag) 699void KToolBarButton::on(bool flag)
686{ 700{
687 if(isToggleButton() == true) 701 if(isToggleButton() == true)
688 setOn(flag); 702 setOn(flag);
689 else 703 else
690 { 704 {
691 setDown(flag); 705 setDown(flag);
692 leaveEvent((QEvent *) 0); 706 leaveEvent((QEvent *) 0);
693 } 707 }
694 repaint(); 708 repaint();
695} 709}
696 710
697void KToolBarButton::toggle() 711void KToolBarButton::toggle()
698{ 712{
699 setOn(!isOn()); 713 setOn(!isOn());
700 repaint(); 714 repaint();
701} 715}
702 716
703void KToolBarButton::setToggle(bool flag) 717void KToolBarButton::setToggle(bool flag)
704{ 718{
705 setToggleButton(flag); 719 setToggleButton(flag);
706 if (flag == true) 720 if (flag == true)
707 connect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled())); 721 connect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled()));
708 else 722 else
709 disconnect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled())); 723 disconnect(this, SIGNAL(toggled(bool)), this, SLOT(slotToggled()));
710} 724}
711 725
712QSize KToolBarButton::sizeHint() const 726QSize KToolBarButton::sizeHint() const
713{ 727{
714 return d->size; 728 return d->size;
715} 729}
716 730
717QSize KToolBarButton::minimumSizeHint() const 731QSize KToolBarButton::minimumSizeHint() const
718{ 732{
719 return d->size; 733 return d->size;
720} 734}
721 735
722QSize KToolBarButton::minimumSize() const 736QSize KToolBarButton::minimumSize() const
723{ 737{
724 return d->size; 738 return d->size;
725} 739}
726 740
727bool KToolBarButton::isRaised() const 741bool KToolBarButton::isRaised() const
728{ 742{
729 return d->m_isRaised; 743 return d->m_isRaised;
730} 744}
731 745
732bool KToolBarButton::isActive() const 746bool KToolBarButton::isActive() const
733{ 747{
734 return d->m_isActive; 748 return d->m_isActive;
735} 749}
736 750
737int KToolBarButton::iconTextMode() const 751int KToolBarButton::iconTextMode() const
738{ 752{
739 return static_cast<int>( d->m_iconText ); 753 return static_cast<int>( d->m_iconText );
740} 754}
741 755
742int KToolBarButton::id() const 756int KToolBarButton::id() const
743{ 757{
744 return d->m_id; 758 return d->m_id;
745} 759}
746 760
747// KToolBarButtonList 761// KToolBarButtonList
748KToolBarButtonList::KToolBarButtonList() 762KToolBarButtonList::KToolBarButtonList()
749{ 763{
750 setAutoDelete(false); 764 setAutoDelete(false);
751} 765}
752 766
753void KToolBarButton::virtual_hook( int, void* ) 767void KToolBarButton::virtual_hook( int, void* )
754{ /*BASE::virtual_hook( id, data );*/ } 768{ /*BASE::virtual_hook( id, data );*/ }
755 769
756//US #include "ktoolbarbutton.moc" 770//US #include "ktoolbarbutton.moc"
diff --git a/microkde/kdeui/ktoolbarbutton.h b/microkde/kdeui/ktoolbarbutton.h
index 9aaa13c..ad02e4e 100644
--- a/microkde/kdeui/ktoolbarbutton.h
+++ b/microkde/kdeui/ktoolbarbutton.h
@@ -1,313 +1,316 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1997, 1998 Stephan Kulow (coolo@kde.org) 2 Copyright (C) 1997, 1998 Stephan Kulow (coolo@kde.org)
3 (C) 1997, 1998 Sven Radej (radej@kde.org) 3 (C) 1997, 1998 Sven Radej (radej@kde.org)
4 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org) 4 (C) 1997, 1998 Mark Donohoe (donohoe@kde.org)
5 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org) 5 (C) 1997, 1998 Matthias Ettrich (ettrich@kde.org)
6 (C) 2000 Kurt Granroth (granroth@kde.org) 6 (C) 2000 Kurt Granroth (granroth@kde.org)
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License version 2 as published by the Free Software Foundation. 10 License version 2 as published by the Free Software Foundation.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23// $Id$ 23// $Id$
24#ifndef _KTOOLBARBUTTON_H 24#ifndef _KTOOLBARBUTTON_H
25#define _KTOOLBARBUTTON_H 25#define _KTOOLBARBUTTON_H
26 26
27#include <qpixmap.h> 27#include <qpixmap.h>
28#include <qtoolbutton.h> 28#include <qtoolbutton.h>
29#include <qintdict.h> 29#include <q3intdict.h>
30#include <qstring.h> 30#include <qstring.h>
31//Added by qt3to4:
32#include <QEvent>
33#include <Q3PopupMenu>
31#include <kglobal.h> 34#include <kglobal.h>
32 35
33class KToolBar; 36class KToolBar;
34class KToolBarButtonPrivate; 37class KToolBarButtonPrivate;
35//USclass KInstance; 38//USclass KInstance;
36class QEvent; 39class QEvent;
37class QPopupMenu; 40class Q3PopupMenu;
38class QPainter; 41class QPainter;
39 42
40/** 43/**
41 * A toolbar button. This is used internally by @ref KToolBar, use the 44 * A toolbar button. This is used internally by @ref KToolBar, use the
42 * KToolBar methods instead. 45 * KToolBar methods instead.
43 * @internal 46 * @internal
44 */ 47 */
45class KToolBarButton : public QToolButton 48class KToolBarButton : public QToolButton
46{ 49{
47 Q_OBJECT 50 Q_OBJECT
48 51
49public: 52public:
50 /** 53 /**
51 * Construct a button with an icon loaded by the button itself. 54 * Construct a button with an icon loaded by the button itself.
52 * This will trust the button to load the correct icon with the 55 * This will trust the button to load the correct icon with the
53 * correct size. 56 * correct size.
54 * 57 *
55 * @param icon Name of icon to load (may be absolute or relative) 58 * @param icon Name of icon to load (may be absolute or relative)
56 * @param id Id of this button 59 * @param id Id of this button
57 * @param parent This button's parent 60 * @param parent This button's parent
58 * @param name This button's internal name 61 * @param name This button's internal name
59 * @param txt This button's text (in a tooltip or otherwise) 62 * @param txt This button's text (in a tooltip or otherwise)
60 */ 63 */
61 KToolBarButton(const QString& icon, int id, QWidget *parent, 64 KToolBarButton(const QString& icon, int id, QWidget *parent,
62 const char *name=0L, const QString &txt=QString::null/*US, 65 const char *name=0L, const QString &txt=QString::null/*US,
63 KInstance *_instance = KGlobal::instance()*/); 66 KInstance *_instance = KGlobal::instance()*/);
64 67
65 /** 68 /**
66 * Construct a button with an existing pixmap. It is not 69 * Construct a button with an existing pixmap. It is not
67 * recommended that you use this as the internal icon loading code 70 * recommended that you use this as the internal icon loading code
68 * will almost always get it "right". 71 * will almost always get it "right".
69 * 72 *
70 * @param icon Name of icon to load (may be absolute or relative) 73 * @param icon Name of icon to load (may be absolute or relative)
71 * @param id Id of this button 74 * @param id Id of this button
72 * @param parent This button's parent 75 * @param parent This button's parent
73 * @param name This button's internal name 76 * @param name This button's internal name
74 * @param txt This button's text (in a tooltip or otherwise) 77 * @param txt This button's text (in a tooltip or otherwise)
75 */ 78 */
76 KToolBarButton(const QPixmap& pixmap, int id, QWidget *parent, 79 KToolBarButton(const QPixmap& pixmap, int id, QWidget *parent,
77 const char *name=0L, const QString &txt=QString::null); 80 const char *name=0L, const QString &txt=QString::null);
78 81
79 /** 82 /**
80 * Construct a separator button 83 * Construct a separator button
81 * 84 *
82 * @param parent This button's parent 85 * @param parent This button's parent
83 * @param name This button's internal name 86 * @param name This button's internal name
84 */ 87 */
85 KToolBarButton(QWidget *parent=0L, const char *name=0L); 88 KToolBarButton(QWidget *parent=0L, const char *name=0L);
86 89
87 /** 90 /**
88 * Standard destructor 91 * Standard destructor
89 */ 92 */
90 ~KToolBarButton(); 93 ~KToolBarButton();
91 QSize sizeHint() const; 94 QSize sizeHint() const;
92 QSize minimumSizeHint() const; 95 QSize minimumSizeHint() const;
93 QSize minimumSize() const; 96 QSize minimumSize() const;
94 97
95#ifndef KDE_NO_COMPAT 98#ifndef KDE_NO_COMPAT
96 /** 99 /**
97 * @deprecated 100 * @deprecated
98 * Set the pixmap directly for this button. This pixmap should be 101 * Set the pixmap directly for this button. This pixmap should be
99 * the active one... the dimmed and disabled pixmaps are constructed 102 * the active one... the dimmed and disabled pixmaps are constructed
100 * based on this one. However, don't use this function unless you 103 * based on this one. However, don't use this function unless you
101 * are positive that you don't want to use @ref setIcon. 104 * are positive that you don't want to use @ref setIcon.
102 * 105 *
103 * @param pixmap The active pixmap 106 * @param pixmap The active pixmap
104 */ 107 */
105 // this one is from QButton, so #ifdef-ing it out doesn't break BC 108 // this one is from QButton, so #ifdef-ing it out doesn't break BC
106 virtual void setPixmap(const QPixmap &pixmap); 109 virtual void setPixmap(const QPixmap &pixmap);
107 110
108 /** 111 /**
109 * @deprecated 112 * @deprecated
110 * Force the button to use this pixmap as the default one rather 113 * Force the button to use this pixmap as the default one rather
111 * then generating it using effects. 114 * then generating it using effects.
112 * 115 *
113 * @param pixmap The pixmap to use as the default (normal) one 116 * @param pixmap The pixmap to use as the default (normal) one
114 */ 117 */
115 void setDefaultPixmap(const QPixmap& pixmap); 118 void setDefaultPixmap(const QPixmap& pixmap);
116 119
117 /** 120 /**
118 * @deprecated 121 * @deprecated
119 * Force the button to use this pixmap when disabled one rather then 122 * Force the button to use this pixmap when disabled one rather then
120 * generating it using effects. 123 * generating it using effects.
121 * 124 *
122 * @param pixmap The pixmap to use when disabled 125 * @param pixmap The pixmap to use when disabled
123 */ 126 */
124 void setDisabledPixmap(const QPixmap& pixmap); 127 void setDisabledPixmap(const QPixmap& pixmap);
125#endif 128#endif
126 129
127 /** 130 /**
128 * Set the text for this button. The text will be either used as a 131 * Set the text for this button. The text will be either used as a
129 * tooltip (IconOnly) or will be along side the icon 132 * tooltip (IconOnly) or will be along side the icon
130 * 133 *
131 * @param text The button (or tooltip) text 134 * @param text The button (or tooltip) text
132 */ 135 */
133 virtual void setText(const QString &text); 136 virtual void setText(const QString &text);
134 137
135 /** 138 /**
136 * Set the icon for this button. The icon will be loaded internally 139 * Set the icon for this button. The icon will be loaded internally
137 * with the correct size. This function is preferred over @ref setIconSet 140 * with the correct size. This function is preferred over @ref setIconSet
138 * 141 *
139 * @param icon The name of the icon 142 * @param icon The name of the icon
140 */ 143 */
141 virtual void setIcon(const QString &icon); 144 virtual void setIcon(const QString &icon);
142 145
143 /// @since 3.1 146 /// @since 3.1
144 virtual void setIcon( const QPixmap &pixmap ) 147 virtual void setIcon( const QPixmap &pixmap )
145 { QToolButton::setIcon( pixmap ); } 148 { QToolButton::setIcon( pixmap ); }
146 149
147 /** 150 /**
148 * Set the pixmaps for this toolbar button from a QIconSet. 151 * Set the pixmaps for this toolbar button from a QIconSet.
149 * If you call this you don't need to call any of the other methods 152 * If you call this you don't need to call any of the other methods
150 * that set icons or pixmaps. 153 * that set icons or pixmaps.
151 * @param iconset The iconset to use 154 * @param iconset The iconset to use
152 */ 155 */
153 virtual void setIconSet( const QIconSet &iconset ); 156 virtual void setIconSet( const QIcon &iconset );
154 157
155#ifndef KDE_NO_COMPAT 158#ifndef KDE_NO_COMPAT
156 /** 159 /**
157 * @deprecated 160 * @deprecated
158 * Set the active icon for this button. The pixmap itself is loaded 161 * Set the active icon for this button. The pixmap itself is loaded
159 * internally based on the icon size... .. the disabled and default 162 * internally based on the icon size... .. the disabled and default
160 * pixmaps, however will only be constructed if @ref #generate is 163 * pixmaps, however will only be constructed if @ref #generate is
161 * true. This function is preferred over @ref setPixmap 164 * true. This function is preferred over @ref setPixmap
162 * 165 *
163 * @param icon The name of the active icon 166 * @param icon The name of the active icon
164 * @param generate If true, then the other icons are automagically 167 * @param generate If true, then the other icons are automagically
165 * generated from this one 168 * generated from this one
166 */ 169 */
167 void setIcon(const QString &icon, bool /*generate*/ ) { setIcon( icon ); } 170 void setIcon(const QString &icon, bool /*generate*/ ) { setIcon( icon ); }
168 171
169 /** 172 /**
170 * @deprecated 173 * @deprecated
171 * Force the button to use this icon as the default one rather 174 * Force the button to use this icon as the default one rather
172 * then generating it using effects. 175 * then generating it using effects.
173 * 176 *
174 * @param icon The icon to use as the default (normal) one 177 * @param icon The icon to use as the default (normal) one
175 */ 178 */
176 void setDefaultIcon(const QString& icon); 179 void setDefaultIcon(const QString& icon);
177 180
178 /** 181 /**
179 * @deprecated 182 * @deprecated
180 * Force the button to use this icon when disabled one rather then 183 * Force the button to use this icon when disabled one rather then
181 * generating it using effects. 184 * generating it using effects.
182 * 185 *
183 * @param icon The icon to use when disabled 186 * @param icon The icon to use when disabled
184 */ 187 */
185 void setDisabledIcon(const QString& icon); 188 void setDisabledIcon(const QString& icon);
186#endif 189#endif
187 190
188 /** 191 /**
189 * Turn this button on or off 192 * Turn this button on or off
190 * 193 *
191 * @param flag true or false 194 * @param flag true or false
192 */ 195 */
193 void on(bool flag = true); 196 void on(bool flag = true);
194 197
195 /** 198 /**
196 * Toggle this button 199 * Toggle this button
197 */ 200 */
198 void toggle(); 201 void toggle();
199 202
200 /** 203 /**
201 * Turn this button into a toggle button or disable the toggle 204 * Turn this button into a toggle button or disable the toggle
202 * aspects of it. This does not toggle the button itself. 205 * aspects of it. This does not toggle the button itself.
203 * Use @ref toggle() for that. 206 * Use @ref toggle() for that.
204 * 207 *
205 * @param toggle true or false 208 * @param toggle true or false
206 */ 209 */
207 void setToggle(bool toggle = true); 210 void setToggle(bool toggle = true);
208 211
209 /** 212 /**
210 * Return a pointer to this button's popup menu (if it exists) 213 * Return a pointer to this button's popup menu (if it exists)
211 */ 214 */
212 QPopupMenu *popup(); 215 QMenu *popup();
213 216
214 /** 217 /**
215 * Returns the button's id. 218 * Returns the button's id.
216 * @since 3.2 219 * @since 3.2
217 */ 220 */
218 int id() const; 221 int id() const;
219 222
220 /** 223 /**
221 * Give this button a popup menu. There will not be a delay when 224 * Give this button a popup menu. There will not be a delay when
222 * you press the button. Use @ref setDelayedPopup if you want that 225 * you press the button. Use @ref setDelayedPopup if you want that
223 * behavior. 226 * behavior.
224 * 227 *
225 * @param p The new popup menu 228 * @param p The new popup menu
226 */ 229 */
227 void setPopup (QPopupMenu *p, bool unused = false); 230 void setPopup (Q3PopupMenu *p, bool unused = false);
228 231
229 /** 232 /**
230 * Gives this button a delayed popup menu. 233 * Gives this button a delayed popup menu.
231 * 234 *
232 * This function allows you to add a delayed popup menu to the button. 235 * This function allows you to add a delayed popup menu to the button.
233 * The popup menu is then only displayed when the button is pressed and 236 * The popup menu is then only displayed when the button is pressed and
234 * held down for about half a second. 237 * held down for about half a second.
235 * 238 *
236 * @param p the new popup menu 239 * @param p the new popup menu
237 */ 240 */
238 void setDelayedPopup(QPopupMenu *p, bool unused = false); 241 void setDelayedPopup(Q3PopupMenu *p, bool unused = false);
239 242
240 /** 243 /**
241 * Turn this button into a radio button 244 * Turn this button into a radio button
242 * 245 *
243 * @param f true or false 246 * @param f true or false
244 */ 247 */
245 void setRadio(bool f = true); 248 void setRadio(bool f = true);
246 249
247 /** 250 /**
248 * Toolbar buttons naturally will assume the global styles 251 * Toolbar buttons naturally will assume the global styles
249 * concerning icons, icons sizes, etc. You can use this function to 252 * concerning icons, icons sizes, etc. You can use this function to
250 * explicitely turn this off, if you like. 253 * explicitely turn this off, if you like.
251 * 254 *
252 * @param no_style Will disable styles if true 255 * @param no_style Will disable styles if true
253 */ 256 */
254 void setNoStyle(bool no_style = true); 257 void setNoStyle(bool no_style = true);
255 258
256signals: 259signals:
257 void clicked(int); 260 void clicked(int);
258 void doubleClicked(int); 261 void doubleClicked(int);
259 void pressed(int); 262 void pressed(int);
260 void released(int); 263 void released(int);
261 void toggled(int); 264 void toggled(int);
262 void highlighted(int, bool); 265 void highlighted(int, bool);
263 266
264public slots: 267public slots:
265 /** 268 /**
266 * This slot should be called whenever the toolbar mode has 269 * This slot should be called whenever the toolbar mode has
267 * potentially changed. This includes such events as text changing, 270 * potentially changed. This includes such events as text changing,
268 * orientation changing, etc. 271 * orientation changing, etc.
269 */ 272 */
270 void modeChange(); 273 void modeChange();
271 virtual void setTextLabel(const QString&, bool tipToo); 274 virtual void setTextLabel(const QString&, bool tipToo);
272 275
273protected: 276protected:
274 void paletteChange(const QPalette &); 277 void paletteChange(const QPalette &);
275 void leaveEvent(QEvent *e); 278 void leaveEvent(QEvent *e);
276 void enterEvent(QEvent *e); 279 void enterEvent(QEvent *e);
277 void drawButton(QPainter *p); 280 void drawButton(QPainter *p);
278 bool eventFilter (QObject *o, QEvent *e); 281 bool eventFilter (QObject *o, QEvent *e);
279 void showMenu(); 282 void showMenu();
280 283
281 /// @since 3.1 284 /// @since 3.1
282 bool isRaised() const; 285 bool isRaised() const;
283 /// @since 3.1 286 /// @since 3.1
284 bool isActive() const; 287 bool isActive() const;
285 /// @since 3.1 288 /// @since 3.1
286 int iconTextMode() const; 289 int iconTextMode() const;
287 290
288protected slots: 291protected slots:
289 void slotClicked(); 292 void slotClicked();
290 void slotPressed(); 293 void slotPressed();
291 void slotReleased(); 294 void slotReleased();
292 void slotToggled(); 295 void slotToggled();
293 void slotDelayTimeout(); 296 void slotDelayTimeout();
294 297
295protected: 298protected:
296 virtual void virtual_hook( int id, void* data ); 299 virtual void virtual_hook( int id, void* data );
297private: 300private:
298 KToolBarButtonPrivate *d; 301 KToolBarButtonPrivate *d;
299}; 302};
300 303
301/** 304/**
302* List of @ref KToolBarButton objects. 305* List of @ref KToolBarButton objects.
303* @internal 306* @internal
304* @version $Id$ 307* @version $Id$
305*/ 308*/
306class KToolBarButtonList : public QIntDict<KToolBarButton> 309class KToolBarButtonList : public Q3IntDict<KToolBarButton>
307{ 310{
308public: 311public:
309 KToolBarButtonList(); 312 KToolBarButtonList();
310 ~KToolBarButtonList() {} 313 ~KToolBarButtonList() {}
311}; 314};
312 315
313#endif 316#endif
diff --git a/microkde/kdeui/ktoolbarhandler.cpp b/microkde/kdeui/ktoolbarhandler.cpp
index 7b97233..4d3ace7 100644
--- a/microkde/kdeui/ktoolbarhandler.cpp
+++ b/microkde/kdeui/ktoolbarhandler.cpp
@@ -1,253 +1,255 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19#include "ktoolbarhandler.h" 19#include "ktoolbarhandler.h"
20 20
21#include <qpopupmenu.h> 21#include <q3popupmenu.h>
22//Added by qt3to4:
23#include <Q3PtrList>
22#include <kapplication.h> 24#include <kapplication.h>
23#include <ktoolbar.h> 25#include <ktoolbar.h>
24#include <kmainwindow.h> 26#include <kmainwindow.h>
25#include <klocale.h> 27#include <klocale.h>
26#include <kaction.h> 28#include <kaction.h>
27#include <assert.h> 29#include <assert.h>
28 30
29namespace 31namespace
30{ 32{
31 const char *actionListName = "show_menu_and_toolbar_actionlist"; 33 const char *actionListName = "show_menu_and_toolbar_actionlist";
32 34
33 const char *guiDescription = "" 35 const char *guiDescription = ""
34 "<!DOCTYPE kpartgui><kpartgui name=\"StandardToolBarMenuHandler\">" 36 "<!DOCTYPE kpartgui><kpartgui name=\"StandardToolBarMenuHandler\">"
35 "<MenuBar>" 37 "<MenuBar>"
36 " <Menu name=\"settings\">" 38 " <Menu name=\"settings\">"
37 " <ActionList name=\"%1\" />" 39 " <ActionList name=\"%1\" />"
38 " </Menu>" 40 " </Menu>"
39 "</MenuBar>" 41 "</MenuBar>"
40 "</kpartgui>"; 42 "</kpartgui>";
41 43
42 const char *resourceFileName = "barhandler.rc"; 44 const char *resourceFileName = "barhandler.rc";
43 45
44 class BarActionBuilder 46 class BarActionBuilder
45 { 47 {
46 public: 48 public:
47 BarActionBuilder( KActionCollection *actionCollection, KMainWindow *mainWindow, QPtrList<KToolBar> &oldToolBarList ) 49 BarActionBuilder( KActionCollection *actionCollection, KMainWindow *mainWindow, Q3PtrList<KToolBar> &oldToolBarList )
48 : m_actionCollection( actionCollection ), m_mainWindow( mainWindow ), m_needsRebuild( false ) 50 : m_actionCollection( actionCollection ), m_mainWindow( mainWindow ), m_needsRebuild( false )
49 { 51 {
50/*US 52/*US
51 QPtrList<QDockWindow> dockWindows = m_mainWindow->dockWindows(); 53 QPtrList<QDockWindow> dockWindows = m_mainWindow->dockWindows();
52 QPtrListIterator<QDockWindow> dockWindowIt( dockWindows ); 54 QPtrListIterator<QDockWindow> dockWindowIt( dockWindows );
53 for ( ; dockWindowIt.current(); ++dockWindowIt ) { 55 for ( ; dockWindowIt.current(); ++dockWindowIt ) {
54 56
55//US KToolBar *toolBar = dynamic_cast<KToolBar *>( dockWindowIt.current() ); 57//US KToolBar *toolBar = dynamic_cast<KToolBar *>( dockWindowIt.current() );
56 KToolBar *toolBar = (KToolBar *)( dockWindowIt.current() ); 58 KToolBar *toolBar = (KToolBar *)( dockWindowIt.current() );
57 if ( !toolBar ) 59 if ( !toolBar )
58 continue; 60 continue;
59 61
60 if ( oldToolBarList.findRef( toolBar ) == -1 ) 62 if ( oldToolBarList.findRef( toolBar ) == -1 )
61 m_needsRebuild = true; 63 m_needsRebuild = true;
62 64
63 m_toolBars.append( toolBar ); 65 m_toolBars.append( toolBar );
64 } 66 }
65*/ 67*/
66 if ( !m_needsRebuild ) 68 if ( !m_needsRebuild )
67 m_needsRebuild = ( oldToolBarList.count() != m_toolBars.count() ); 69 m_needsRebuild = ( oldToolBarList.count() != m_toolBars.count() );
68 70
69 } 71 }
70 72
71 bool needsRebuild() const { return m_needsRebuild; } 73 bool needsRebuild() const { return m_needsRebuild; }
72 74
73 QPtrList<KAction> create() 75 Q3PtrList<KAction> create()
74 { 76 {
75 if ( !m_needsRebuild ) 77 if ( !m_needsRebuild )
76 return QPtrList<KAction>(); 78 return Q3PtrList<KAction>();
77 79
78 QPtrListIterator<KToolBar> toolBarIt( m_toolBars ); 80 Q3PtrListIterator<KToolBar> toolBarIt( m_toolBars );
79 for ( ; toolBarIt.current(); ++toolBarIt ) 81 for ( ; toolBarIt.current(); ++toolBarIt )
80 handleToolBar( toolBarIt.current() ); 82 handleToolBar( toolBarIt.current() );
81 83
82 QPtrList<KAction> actions; 84 Q3PtrList<KAction> actions;
83 85
84 if ( m_toolBarActions.count() == 0 ) 86 if ( m_toolBarActions.count() == 0 )
85 return actions; 87 return actions;
86 88
87 if ( m_toolBarActions.count() == 1 ) { 89 if ( m_toolBarActions.count() == 1 ) {
88 m_toolBarActions.getFirst()->setText( i18n( "Show Toolbar" ) ); 90 m_toolBarActions.getFirst()->setText( i18n( "Show Toolbar" ) );
89 return m_toolBarActions; 91 return m_toolBarActions;
90 } 92 }
91 93
92 KActionMenu *menuAction = new KActionMenu( i18n( "Toolbars" ), m_actionCollection, "toolbars_submenu_action" ); 94 KActionMenu *menuAction = new KActionMenu( i18n( "Toolbars" ), m_actionCollection, "toolbars_submenu_action" );
93 95
94 QPtrListIterator<KAction> actionIt( m_toolBarActions ); 96 Q3PtrListIterator<KAction> actionIt( m_toolBarActions );
95 for ( ; actionIt.current(); ++actionIt ) 97 for ( ; actionIt.current(); ++actionIt )
96 menuAction->insert( actionIt.current() ); 98 menuAction->insert( actionIt.current() );
97 99
98 actions.append( menuAction ); 100 actions.append( menuAction );
99 return actions; 101 return actions;
100 } 102 }
101 103
102 const QPtrList<KToolBar> &toolBars() const { return m_toolBars; } 104 const Q3PtrList<KToolBar> &toolBars() const { return m_toolBars; }
103 105
104 private: 106 private:
105 void handleToolBar( KToolBar *toolBar ) 107 void handleToolBar( KToolBar *toolBar )
106 { 108 {
107 KAction *action = new KToggleToolBarAction( toolBar, 109 KAction *action = new KToggleToolBarAction( toolBar,
108 i18n( "Show %1" ).arg( toolBar->label() ), 110 i18n( "Show %1" ).arg( toolBar->label() ),
109 m_actionCollection, 111 m_actionCollection,
110 toolBar->name() ); 112 toolBar->name() );
111 113
112 m_toolBarActions.append( action ); 114 m_toolBarActions.append( action );
113 } 115 }
114 116
115 KActionCollection *m_actionCollection; 117 KActionCollection *m_actionCollection;
116 KMainWindow *m_mainWindow; 118 KMainWindow *m_mainWindow;
117 119
118 QPtrList<KToolBar> m_toolBars; 120 Q3PtrList<KToolBar> m_toolBars;
119 QPtrList<KAction> m_toolBarActions; 121 Q3PtrList<KAction> m_toolBarActions;
120 122
121 bool m_needsRebuild : 1; 123 bool m_needsRebuild : 1;
122 }; 124 };
123} 125}
124 126
125using namespace KDEPrivate; 127using namespace KDEPrivate;
126 128
127ToolBarHandler::ToolBarHandler( KMainWindow *mainWindow, const char *name ) 129ToolBarHandler::ToolBarHandler( KMainWindow *mainWindow, const char *name )
128 : QObject( mainWindow, name ), KXMLGUIClient( mainWindow ) 130 : QObject( mainWindow, name ), KXMLGUIClient( mainWindow )
129{ 131{
130 init( mainWindow ); 132 init( mainWindow );
131} 133}
132 134
133ToolBarHandler::ToolBarHandler( KMainWindow *mainWindow, QObject *parent, const char *name ) 135ToolBarHandler::ToolBarHandler( KMainWindow *mainWindow, QObject *parent, const char *name )
134 : QObject( parent, name ), KXMLGUIClient( mainWindow ) 136 : QObject( parent, name ), KXMLGUIClient( mainWindow )
135{ 137{
136 init( mainWindow ); 138 init( mainWindow );
137} 139}
138 140
139ToolBarHandler::~ToolBarHandler() 141ToolBarHandler::~ToolBarHandler()
140{ 142{
141 m_actions.setAutoDelete( true ); 143 m_actions.setAutoDelete( true );
142 m_actions.clear(); 144 m_actions.clear();
143} 145}
144 146
145KAction *ToolBarHandler::toolBarMenuAction() 147KAction *ToolBarHandler::toolBarMenuAction()
146{ 148{
147 assert( m_actions.count() == 1 ); 149 assert( m_actions.count() == 1 );
148 return m_actions.getFirst(); 150 return m_actions.getFirst();
149} 151}
150 152
151void ToolBarHandler::setupActions() 153void ToolBarHandler::setupActions()
152{ 154{
153//US if ( !factory() || !m_mainWindow ) 155//US if ( !factory() || !m_mainWindow )
154 if ( !m_mainWindow ) 156 if ( !m_mainWindow )
155 return; 157 return;
156 158
157 BarActionBuilder builder( actionCollection(), m_mainWindow, m_toolBars ); 159 BarActionBuilder builder( actionCollection(), m_mainWindow, m_toolBars );
158 160
159 if ( !builder.needsRebuild() ) 161 if ( !builder.needsRebuild() )
160 return; 162 return;
161 163
162 unplugActionList( actionListName ); 164 unplugActionList( actionListName );
163 165
164 m_actions.setAutoDelete( true ); 166 m_actions.setAutoDelete( true );
165 167
166 m_actions.clear(); 168 m_actions.clear();
167 m_actions.setAutoDelete( false ); 169 m_actions.setAutoDelete( false );
168 170
169 m_actions = builder.create(); 171 m_actions = builder.create();
170 172
171 /* 173 /*
172 for ( QPtrListIterator<KToolBar> toolBarIt( m_toolBars ); 174 for ( QPtrListIterator<KToolBar> toolBarIt( m_toolBars );
173 toolBarIt.current(); ++toolBarIt ) 175 toolBarIt.current(); ++toolBarIt )
174 toolBarIt.current()->disconnect( this ); 176 toolBarIt.current()->disconnect( this );
175 */ 177 */
176 178
177 m_toolBars = builder.toolBars(); 179 m_toolBars = builder.toolBars();
178 180
179 /* 181 /*
180 for ( QPtrListIterator<KToolBar> toolBarIt( m_toolBars ); 182 for ( QPtrListIterator<KToolBar> toolBarIt( m_toolBars );
181 toolBarIt.current(); ++toolBarIt ) 183 toolBarIt.current(); ++toolBarIt )
182 connect( toolBarIt.current(), SIGNAL( destroyed() ), 184 connect( toolBarIt.current(), SIGNAL( destroyed() ),
183 this, SLOT( setupActions() ) ); 185 this, SLOT( setupActions() ) );
184 */ 186 */
185 187
186//US if (kapp && kapp->authorizeKAction("options_show_toolbar")) 188//US if (kapp && kapp->authorizeKAction("options_show_toolbar"))
187 plugActionList( actionListName, m_actions ); 189 plugActionList( actionListName, m_actions );
188 190
189 connectToActionContainers(); 191 connectToActionContainers();
190} 192}
191 193
192/*US 194/*US
193void ToolBarHandler::clientAdded( KXMLGUIClient *client ) 195void ToolBarHandler::clientAdded( KXMLGUIClient *client )
194{ 196{
195 if ( client == this ) 197 if ( client == this )
196 setupActions(); 198 setupActions();
197} 199}
198*/ 200*/
199 201
200void ToolBarHandler::init( KMainWindow *mainWindow ) 202void ToolBarHandler::init( KMainWindow *mainWindow )
201{ 203{
202 d = 0; 204 d = 0;
203 m_mainWindow = mainWindow; 205 m_mainWindow = mainWindow;
204 206
205/*US 207/*US
206 connect( m_mainWindow->guiFactory(), SIGNAL( clientAdded( KXMLGUIClient * ) ), 208 connect( m_mainWindow->guiFactory(), SIGNAL( clientAdded( KXMLGUIClient * ) ),
207 this, SLOT( clientAdded( KXMLGUIClient * ) ) ); 209 this, SLOT( clientAdded( KXMLGUIClient * ) ) );
208*/ 210*/
209 /* re-use an existing resource file if it exists. can happen if the user launches the 211 /* re-use an existing resource file if it exists. can happen if the user launches the
210 * toolbar editor */ 212 * toolbar editor */
211 /* 213 /*
212 setXMLFile( resourceFileName ); 214 setXMLFile( resourceFileName );
213 */ 215 */
214/*US 216/*US
215 if ( domDocument().documentElement().isNull() ) { 217 if ( domDocument().documentElement().isNull() ) {
216 218
217 QString completeDescription = QString::fromLatin1( guiDescription ) 219 QString completeDescription = QString::fromLatin1( guiDescription )
218 .arg( actionListName ); 220 .arg( actionListName );
219 221
220 setXML( completeDescription, false*/ /*merge*/ /*); 222 setXML( completeDescription, false*/ /*merge*/ /*);
221 } 223 }
222*/ 224*/
223} 225}
224 226
225void ToolBarHandler::connectToActionContainers() 227void ToolBarHandler::connectToActionContainers()
226{ 228{
227 QPtrListIterator<KAction> actionIt( m_actions ); 229 Q3PtrListIterator<KAction> actionIt( m_actions );
228 for ( ; actionIt.current(); ++actionIt ) 230 for ( ; actionIt.current(); ++actionIt )
229 connectToActionContainer( actionIt.current() ); 231 connectToActionContainer( actionIt.current() );
230} 232}
231 233
232void ToolBarHandler::connectToActionContainer( KAction *action ) 234void ToolBarHandler::connectToActionContainer( KAction *action )
233{ 235{
234 uint containerCount = action->containerCount(); 236 uint containerCount = action->containerCount();
235 for ( uint i = 0; i < containerCount; ++i ) 237 for ( uint i = 0; i < containerCount; ++i )
236 connectToActionContainer( action->container( i ) ); 238 connectToActionContainer( action->container( i ) );
237} 239}
238 240
239void ToolBarHandler::connectToActionContainer( QWidget *container ) 241void ToolBarHandler::connectToActionContainer( QWidget *container )
240{ 242{
241//US QPopupMenu *popupMenu = dynamic_cast<QPopupMenu *>( container ); 243//US QPopupMenu *popupMenu = dynamic_cast<QPopupMenu *>( container );
242 QPopupMenu *popupMenu = (QPopupMenu *)( container ); 244 Q3PopupMenu *popupMenu = (Q3PopupMenu *)( container );
243 if ( !popupMenu ) 245 if ( !popupMenu )
244 return; 246 return;
245 247
246 connect( popupMenu, SIGNAL( aboutToShow() ), 248 connect( popupMenu, SIGNAL( aboutToShow() ),
247 this, SLOT( setupActions() ) ); 249 this, SLOT( setupActions() ) );
248} 250}
249 251
250//US #include "ktoolbarhandler.moc" 252//US #include "ktoolbarhandler.moc"
251 253
252/* vim: et sw=4 ts=4 254/* vim: et sw=4 ts=4
253 */ 255 */
diff --git a/microkde/kdeui/ktoolbarhandler.h b/microkde/kdeui/ktoolbarhandler.h
index a1340ae..35f0d18 100644
--- a/microkde/kdeui/ktoolbarhandler.h
+++ b/microkde/kdeui/ktoolbarhandler.h
@@ -1,70 +1,70 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2002 Simon Hausmann <hausmann@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation. 6 License version 2 as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19#ifndef KBARHANDLER_H 19#ifndef KBARHANDLER_H
20#define KBARHANDLER_H 20#define KBARHANDLER_H
21 21
22#include <qobject.h> 22#include <qobject.h>
23#include <qguardedptr.h> 23#include <qpointer.h>
24#include <qptrlist.h> 24#include <q3ptrlist.h>
25#include <kxmlguiclient.h> 25#include <kxmlguiclient.h>
26#include <kaction.h> 26#include <kaction.h>
27 27
28class KMainWindow; 28class KMainWindow;
29class KToolBar; 29class KToolBar;
30 30
31namespace KDEPrivate 31namespace KDEPrivate
32{ 32{
33 33
34/// @since 3.1 34/// @since 3.1
35class ToolBarHandler : public QObject, public KXMLGUIClient 35class ToolBarHandler : public QObject, public KXMLGUIClient
36{ 36{
37 Q_OBJECT 37 Q_OBJECT
38public: 38public:
39 ToolBarHandler( KMainWindow *mainWindow, const char *name = 0 ); 39 ToolBarHandler( KMainWindow *mainWindow, const char *name = 0 );
40 ToolBarHandler( KMainWindow *mainWindow, QObject *parent, const char *name = 0 ); 40 ToolBarHandler( KMainWindow *mainWindow, QObject *parent, const char *name = 0 );
41 virtual ~ToolBarHandler(); 41 virtual ~ToolBarHandler();
42 42
43 KAction *toolBarMenuAction(); 43 KAction *toolBarMenuAction();
44 44
45public slots: 45public slots:
46 void setupActions(); 46 void setupActions();
47 47
48private slots: 48private slots:
49//US void clientAdded( KXMLGUIClient *client ); 49//US void clientAdded( KXMLGUIClient *client );
50 50
51private: 51private:
52 void init( KMainWindow *mainWindow ); 52 void init( KMainWindow *mainWindow );
53 void connectToActionContainers(); 53 void connectToActionContainers();
54 void connectToActionContainer( KAction *action ); 54 void connectToActionContainer( KAction *action );
55 void connectToActionContainer( QWidget *container ); 55 void connectToActionContainer( QWidget *container );
56 56
57 struct Data; 57 struct Data;
58 Data *d; 58 Data *d;
59 59
60 QGuardedPtr<KMainWindow> m_mainWindow; 60 QPointer<KMainWindow> m_mainWindow;
61 QPtrList<KAction> m_actions; 61 Q3PtrList<KAction> m_actions;
62 QPtrList<KToolBar> m_toolBars; 62 Q3PtrList<KToolBar> m_toolBars;
63}; 63};
64 64
65} // namespace KDEPrivate 65} // namespace KDEPrivate
66 66
67#endif // KBARHANDLER_H 67#endif // KBARHANDLER_H
68 68
69/* vim: et sw=4 ts=4 69/* vim: et sw=4 ts=4
70 */ 70 */
diff --git a/microkde/kdeui/kxmlguiclient.cpp b/microkde/kdeui/kxmlguiclient.cpp
index 073e30b..8740bde 100644
--- a/microkde/kdeui/kxmlguiclient.cpp
+++ b/microkde/kdeui/kxmlguiclient.cpp
@@ -1,958 +1,960 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
3 Copyright (C) 2000 Kurt Granroth <granroth@kde.org> 3 Copyright (C) 2000 Kurt Granroth <granroth@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include "kxmlguiclient.h" 20#include "kxmlguiclient.h"
21 21
22/*US 22/*US
23#include "kxmlguifactory.h" 23#include "kxmlguifactory.h"
24#include "kxmlguibuilder.h" 24#include "kxmlguibuilder.h"
25*/ 25*/
26 26
27/*US 27/*US
28#include <qdir.h> 28#include <qdir.h>
29#include <qfile.h> 29#include <qfile.h>
30#include <qdom.h> 30#include <qdom.h>
31#include <qtextstream.h> 31#include <qtextstream.h>
32#include <qregexp.h> 32#include <qregexp.h>
33*/ 33*/
34 34
35//US #include <kinstance.h> 35//US #include <kinstance.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37#include <kdebug.h> 37#include <kdebug.h>
38#include <kaction.h> 38#include <kaction.h>
39#include <kapplication.h> 39#include <kapplication.h>
40 40
41#include <assert.h> 41#include <assert.h>
42//Added by qt3to4:
43#include <Q3PtrList>
42 44
43class KXMLGUIClientPrivate 45class KXMLGUIClientPrivate
44{ 46{
45public: 47public:
46 KXMLGUIClientPrivate() 48 KXMLGUIClientPrivate()
47 { 49 {
48//US m_instance = KGlobal::instance(); 50//US m_instance = KGlobal::instance();
49//US m_factory = 0L; 51//US m_factory = 0L;
50 m_parent = 0L; 52 m_parent = 0L;
51//US m_builder = 0L; 53//US m_builder = 0L;
52 m_actionCollection = 0; 54 m_actionCollection = 0;
53 } 55 }
54 ~KXMLGUIClientPrivate() 56 ~KXMLGUIClientPrivate()
55 { 57 {
56 } 58 }
57 59
58//US KInstance *m_instance; 60//US KInstance *m_instance;
59 61
60//US QDomDocument m_doc; 62//US QDomDocument m_doc;
61 KActionCollection *m_actionCollection; 63 KActionCollection *m_actionCollection;
62//US QDomDocument m_buildDocument; 64//US QDomDocument m_buildDocument;
63//US KXMLGUIFactory *m_factory; 65//US KXMLGUIFactory *m_factory;
64 KXMLGUIClient *m_parent; 66 KXMLGUIClient *m_parent;
65 //QPtrList<KXMLGUIClient> m_supers; 67 //QPtrList<KXMLGUIClient> m_supers;
66 QPtrList<KXMLGUIClient> m_children; 68 Q3PtrList<KXMLGUIClient> m_children;
67//US KXMLGUIBuilder *m_builder; 69//US KXMLGUIBuilder *m_builder;
68//US QString m_xmlFile; 70//US QString m_xmlFile;
69//US QString m_localXMLFile; 71//US QString m_localXMLFile;
70}; 72};
71 73
72KXMLGUIClient::KXMLGUIClient() 74KXMLGUIClient::KXMLGUIClient()
73{ 75{
74 d = new KXMLGUIClientPrivate; 76 d = new KXMLGUIClientPrivate;
75} 77}
76 78
77KXMLGUIClient::KXMLGUIClient( KXMLGUIClient *parent ) 79KXMLGUIClient::KXMLGUIClient( KXMLGUIClient *parent )
78{ 80{
79 d = new KXMLGUIClientPrivate; 81 d = new KXMLGUIClientPrivate;
80 parent->insertChildClient( this ); 82 parent->insertChildClient( this );
81} 83}
82 84
83KXMLGUIClient::~KXMLGUIClient() 85KXMLGUIClient::~KXMLGUIClient()
84{ 86{
85 if ( d->m_parent ) 87 if ( d->m_parent )
86 d->m_parent->removeChildClient( this ); 88 d->m_parent->removeChildClient( this );
87 89
88 QPtrListIterator<KXMLGUIClient> it( d->m_children ); 90 Q3PtrListIterator<KXMLGUIClient> it( d->m_children );
89 for ( ; it.current(); ++it ) { 91 for ( ; it.current(); ++it ) {
90 assert( it.current()->d->m_parent == this ); 92 assert( it.current()->d->m_parent == this );
91 it.current()->d->m_parent = 0; 93 it.current()->d->m_parent = 0;
92 } 94 }
93 95
94 delete d->m_actionCollection; 96 delete d->m_actionCollection;
95 delete d; 97 delete d;
96} 98}
97 99
98KAction *KXMLGUIClient::action( const char *name ) const 100KAction *KXMLGUIClient::action( const char *name ) const
99{ 101{
100 KAction* act = actionCollection()->action( name ); 102 KAction* act = actionCollection()->action( name );
101 if ( !act ) { 103 if ( !act ) {
102 QPtrListIterator<KXMLGUIClient> childIt( d->m_children ); 104 Q3PtrListIterator<KXMLGUIClient> childIt( d->m_children );
103 for (; childIt.current(); ++childIt ) { 105 for (; childIt.current(); ++childIt ) {
104 act = childIt.current()->actionCollection()->action( name ); 106 act = childIt.current()->actionCollection()->action( name );
105 if ( act ) 107 if ( act )
106 break; 108 break;
107 } 109 }
108 } 110 }
109 return act; 111 return act;
110} 112}
111 113
112KActionCollection *KXMLGUIClient::actionCollection() const 114KActionCollection *KXMLGUIClient::actionCollection() const
113{ 115{
114 if ( !d->m_actionCollection ) 116 if ( !d->m_actionCollection )
115 d->m_actionCollection = new KActionCollection( 0, 0, 117 d->m_actionCollection = new KActionCollection( 0, 0,
116 "KXMLGUILClient-KActionCollection" ); 118 "KXMLGUILClient-KActionCollection" );
117 return d->m_actionCollection; 119 return d->m_actionCollection;
118} 120}
119 121
120/*US 122/*US
121KAction *KXMLGUIClient::action( const QDomElement &element ) const 123KAction *KXMLGUIClient::action( const QDomElement &element ) const
122{ 124{
123 static const QString &attrName = KGlobal::staticQString( "name" ); 125 static const QString &attrName = KGlobal::staticQString( "name" );
124 return actionCollection()->action( element.attribute( attrName ).latin1() ); 126 return actionCollection()->action( element.attribute( attrName ).latin1() );
125} 127}
126 128
127KInstance *KXMLGUIClient::instance() const 129KInstance *KXMLGUIClient::instance() const
128{ 130{
129 return d->m_instance; 131 return d->m_instance;
130} 132}
131 133
132QDomDocument KXMLGUIClient::domDocument() const 134QDomDocument KXMLGUIClient::domDocument() const
133{ 135{
134 return d->m_doc; 136 return d->m_doc;
135} 137}
136 138
137QString KXMLGUIClient::xmlFile() const 139QString KXMLGUIClient::xmlFile() const
138{ 140{
139 return d->m_xmlFile; 141 return d->m_xmlFile;
140} 142}
141 143
142QString KXMLGUIClient::localXMLFile() const 144QString KXMLGUIClient::localXMLFile() const
143{ 145{
144 if ( !d->m_localXMLFile.isEmpty() ) 146 if ( !d->m_localXMLFile.isEmpty() )
145 return d->m_localXMLFile; 147 return d->m_localXMLFile;
146 148
147 if ( d->m_xmlFile[0] == '/' ) 149 if ( d->m_xmlFile[0] == '/' )
148 return QString::null; // can't save anything here 150 return QString::null; // can't save anything here
149 151
150 return locateLocal( "data", QString::fromLatin1( instance()->instanceName() + '/' ) + d->m_xmlFile ); 152 return locateLocal( "data", QString::fromLatin1( instance()->instanceName() + '/' ) + d->m_xmlFile );
151} 153}
152 154
153 155
154void KXMLGUIClient::reloadXML() 156void KXMLGUIClient::reloadXML()
155{ 157{
156 QString file( xmlFile() ); 158 QString file( xmlFile() );
157 if ( !file.isEmpty() ) 159 if ( !file.isEmpty() )
158 setXMLFile( file ); 160 setXMLFile( file );
159} 161}
160 162
161void KXMLGUIClient::setInstance( KInstance *instance ) 163void KXMLGUIClient::setInstance( KInstance *instance )
162{ 164{
163 d->m_instance = instance; 165 d->m_instance = instance;
164 actionCollection()->setInstance( instance ); 166 actionCollection()->setInstance( instance );
165 if ( d->m_builder ) 167 if ( d->m_builder )
166 d->m_builder->setBuilderClient( this ); 168 d->m_builder->setBuilderClient( this );
167} 169}
168 170
169void KXMLGUIClient::setXMLFile( const QString& _file, bool merge, bool setXMLDoc ) 171void KXMLGUIClient::setXMLFile( const QString& _file, bool merge, bool setXMLDoc )
170{ 172{
171 // store our xml file name 173 // store our xml file name
172 if ( !_file.isNull() ) { 174 if ( !_file.isNull() ) {
173 d->m_xmlFile = _file; 175 d->m_xmlFile = _file;
174 actionCollection()->setXMLFile( _file ); 176 actionCollection()->setXMLFile( _file );
175 } 177 }
176 178
177 if ( !setXMLDoc ) 179 if ( !setXMLDoc )
178 return; 180 return;
179 181
180 QString file = _file; 182 QString file = _file;
181 if ( file[0] != '/' ) 183 if ( file[0] != '/' )
182 { 184 {
183 QString doc; 185 QString doc;
184 186
185 QString filter = QString::fromLatin1( instance()->instanceName() + '/' ) + _file; 187 QString filter = QString::fromLatin1( instance()->instanceName() + '/' ) + _file;
186 188
187 QStringList allFiles = instance()->dirs()->findAllResources( "data", filter ) + instance()->dirs()->findAllResources( "data", _file ); 189 QStringList allFiles = instance()->dirs()->findAllResources( "data", filter ) + instance()->dirs()->findAllResources( "data", _file );
188 190
189 file = findMostRecentXMLFile( allFiles, doc ); 191 file = findMostRecentXMLFile( allFiles, doc );
190 192
191 if ( file.isEmpty() ) 193 if ( file.isEmpty() )
192 { 194 {
193 // this might or might not be an error. for the time being, 195 // this might or might not be an error. for the time being,
194 // let's treat this as if it isn't a problem and the user just 196 // let's treat this as if it isn't a problem and the user just
195 // wants the global standards file 197 // wants the global standards file
196 setXML( QString::null, true ); 198 setXML( QString::null, true );
197 return; 199 return;
198 } 200 }
199 else if ( !doc.isEmpty() ) 201 else if ( !doc.isEmpty() )
200 { 202 {
201 setXML( doc, merge ); 203 setXML( doc, merge );
202 return; 204 return;
203 } 205 }
204 } 206 }
205 207
206 QString xml = KXMLGUIFactory::readConfigFile( file ); 208 QString xml = KXMLGUIFactory::readConfigFile( file );
207 setXML( xml, merge ); 209 setXML( xml, merge );
208} 210}
209 211
210void KXMLGUIClient::setLocalXMLFile( const QString &file ) 212void KXMLGUIClient::setLocalXMLFile( const QString &file )
211{ 213{
212 d->m_localXMLFile = file; 214 d->m_localXMLFile = file;
213} 215}
214 216
215void KXMLGUIClient::setXML( const QString &document, bool merge ) 217void KXMLGUIClient::setXML( const QString &document, bool merge )
216{ 218{
217 QDomDocument doc; 219 QDomDocument doc;
218 doc.setContent( document ); 220 doc.setContent( document );
219 setDOMDocument( doc, merge ); 221 setDOMDocument( doc, merge );
220} 222}
221 223
222void KXMLGUIClient::setDOMDocument( const QDomDocument &document, bool merge ) 224void KXMLGUIClient::setDOMDocument( const QDomDocument &document, bool merge )
223{ 225{
224 if ( merge ) 226 if ( merge )
225 { 227 {
226 QDomElement base = d->m_doc.documentElement(); 228 QDomElement base = d->m_doc.documentElement();
227 229
228 QDomElement e = document.documentElement(); 230 QDomElement e = document.documentElement();
229 KXMLGUIFactory::removeDOMComments( e ); 231 KXMLGUIFactory::removeDOMComments( e );
230 232
231 // merge our original (global) xml with our new one 233 // merge our original (global) xml with our new one
232 mergeXML(base, e, actionCollection()); 234 mergeXML(base, e, actionCollection());
233 235
234 // reassign our pointer as mergeXML might have done something 236 // reassign our pointer as mergeXML might have done something
235 // strange to it 237 // strange to it
236 base = d->m_doc.documentElement(); 238 base = d->m_doc.documentElement();
237 239
238 // we want some sort of failsafe.. just in case 240 // we want some sort of failsafe.. just in case
239 if ( base.isNull() ) 241 if ( base.isNull() )
240 d->m_doc = document; 242 d->m_doc = document;
241 } 243 }
242 else 244 else
243 { 245 {
244 d->m_doc = document; 246 d->m_doc = document;
245 KXMLGUIFactory::removeDOMComments( d->m_doc ); 247 KXMLGUIFactory::removeDOMComments( d->m_doc );
246 } 248 }
247 249
248 setXMLGUIBuildDocument( QDomDocument() ); 250 setXMLGUIBuildDocument( QDomDocument() );
249} 251}
250*/ 252*/
251 253
252/*US 254/*US
253bool KXMLGUIClient::mergeXML( QDomElement &base, const QDomElement &additive, KActionCollection *actionCollection ) 255bool KXMLGUIClient::mergeXML( QDomElement &base, const QDomElement &additive, KActionCollection *actionCollection )
254{ 256{
255 static const QString &tagAction = KGlobal::staticQString( "Action" ); 257 static const QString &tagAction = KGlobal::staticQString( "Action" );
256 static const QString &tagMerge = KGlobal::staticQString( "Merge" ); 258 static const QString &tagMerge = KGlobal::staticQString( "Merge" );
257 static const QString &tagSeparator = KGlobal::staticQString( "Separator" ); 259 static const QString &tagSeparator = KGlobal::staticQString( "Separator" );
258 static const QString &attrName = KGlobal::staticQString( "name" ); 260 static const QString &attrName = KGlobal::staticQString( "name" );
259 static const QString &attrAppend = KGlobal::staticQString( "append" ); 261 static const QString &attrAppend = KGlobal::staticQString( "append" );
260 static const QString &attrWeakSeparator = KGlobal::staticQString( "weakSeparator" ); 262 static const QString &attrWeakSeparator = KGlobal::staticQString( "weakSeparator" );
261 static const QString &tagMergeLocal = KGlobal::staticQString( "MergeLocal" ); 263 static const QString &tagMergeLocal = KGlobal::staticQString( "MergeLocal" );
262 static const QString &tagText = KGlobal::staticQString( "text" ); 264 static const QString &tagText = KGlobal::staticQString( "text" );
263 static const QString &attrAlreadyVisited = KGlobal::staticQString( "alreadyVisited" ); 265 static const QString &attrAlreadyVisited = KGlobal::staticQString( "alreadyVisited" );
264 static const QString &attrNoMerge = KGlobal::staticQString( "noMerge" ); 266 static const QString &attrNoMerge = KGlobal::staticQString( "noMerge" );
265 static const QString &attrOne = KGlobal::staticQString( "1" ); 267 static const QString &attrOne = KGlobal::staticQString( "1" );
266 268
267 // there is a possibility that we don't want to merge in the 269 // there is a possibility that we don't want to merge in the
268 // additive.. rather, we might want to *replace* the base with the 270 // additive.. rather, we might want to *replace* the base with the
269 // additive. this can be for any container.. either at a file wide 271 // additive. this can be for any container.. either at a file wide
270 // level or a simple container level. we look for the 'noMerge' 272 // level or a simple container level. we look for the 'noMerge'
271 // tag, in any event and just replace the old with the new 273 // tag, in any event and just replace the old with the new
272 if ( additive.attribute(attrNoMerge) == attrOne ) // ### use toInt() instead? (Simon) 274 if ( additive.attribute(attrNoMerge) == attrOne ) // ### use toInt() instead? (Simon)
273 { 275 {
274 base.parentNode().replaceChild(additive, base); 276 base.parentNode().replaceChild(additive, base);
275 return true; 277 return true;
276 } 278 }
277 279
278 QString tag; 280 QString tag;
279 281
280 QDomElement e = base.firstChild().toElement(); 282 QDomElement e = base.firstChild().toElement();
281 // iterate over all elements in the container (of the global DOM tree) 283 // iterate over all elements in the container (of the global DOM tree)
282 while ( !e.isNull() ) 284 while ( !e.isNull() )
283 { 285 {
284 tag = e.tagName(); 286 tag = e.tagName();
285 287
286 // if there's an action tag in the global tree and the action is 288 // if there's an action tag in the global tree and the action is
287 // not implemented, then we remove the element 289 // not implemented, then we remove the element
288 if ( tag == tagAction ) 290 if ( tag == tagAction )
289 { 291 {
290 QCString name = e.attribute( attrName ).utf8(); // WABA 292 QCString name = e.attribute( attrName ).utf8(); // WABA
291 if ( !actionCollection->action( name ) || 293 if ( !actionCollection->action( name ) ||
292 (kapp && !kapp->authorizeKAction(name))) 294 (kapp && !kapp->authorizeKAction(name)))
293 { 295 {
294 // remove this child as we aren't using it 296 // remove this child as we aren't using it
295 QDomElement oldChild = e; 297 QDomElement oldChild = e;
296 e = e.nextSibling().toElement(); 298 e = e.nextSibling().toElement();
297 base.removeChild( oldChild ); 299 base.removeChild( oldChild );
298 continue; 300 continue;
299 } 301 }
300 } 302 }
301 303
302 // if there's a separator defined in the global tree, then add an 304 // if there's a separator defined in the global tree, then add an
303 // attribute, specifying that this is a "weak" separator 305 // attribute, specifying that this is a "weak" separator
304 else if ( tag == tagSeparator ) 306 else if ( tag == tagSeparator )
305 { 307 {
306 e.setAttribute( attrWeakSeparator, (uint)1 ); 308 e.setAttribute( attrWeakSeparator, (uint)1 );
307 309
308 // okay, hack time. if the last item was a weak separator OR 310 // okay, hack time. if the last item was a weak separator OR
309 // this is the first item in a container, then we nuke the 311 // this is the first item in a container, then we nuke the
310 // current one 312 // current one
311 QDomElement prev = e.previousSibling().toElement(); 313 QDomElement prev = e.previousSibling().toElement();
312 if ( prev.isNull() || 314 if ( prev.isNull() ||
313 ( prev.tagName() == tagSeparator && !prev.attribute( attrWeakSeparator ).isNull() ) || 315 ( prev.tagName() == tagSeparator && !prev.attribute( attrWeakSeparator ).isNull() ) ||
314 ( prev.tagName() == tagText ) ) 316 ( prev.tagName() == tagText ) )
315 { 317 {
316 // the previous element was a weak separator or didn't exist 318 // the previous element was a weak separator or didn't exist
317 QDomElement oldChild = e; 319 QDomElement oldChild = e;
318 e = e.nextSibling().toElement(); 320 e = e.nextSibling().toElement();
319 base.removeChild( oldChild ); 321 base.removeChild( oldChild );
320 continue; 322 continue;
321 } 323 }
322 } 324 }
323 325
324 // the MergeLocal tag lets us specify where non-standard elements 326 // the MergeLocal tag lets us specify where non-standard elements
325 // of the local tree shall be merged in. After inserting the 327 // of the local tree shall be merged in. After inserting the
326 // elements we delete this element 328 // elements we delete this element
327 else if ( tag == tagMergeLocal ) 329 else if ( tag == tagMergeLocal )
328 { 330 {
329 QDomElement currElement = e; 331 QDomElement currElement = e;
330 332
331 // switch our iterator "e" to the next sibling, so that we don't 333 // switch our iterator "e" to the next sibling, so that we don't
332 // process the local tree's inserted items! 334 // process the local tree's inserted items!
333 e = e.nextSibling().toElement(); 335 e = e.nextSibling().toElement();
334 336
335 QDomElement it = additive.firstChild().toElement(); 337 QDomElement it = additive.firstChild().toElement();
336 while ( !it.isNull() ) 338 while ( !it.isNull() )
337 { 339 {
338 QDomElement newChild = it; 340 QDomElement newChild = it;
339 341
340 it = it.nextSibling().toElement(); 342 it = it.nextSibling().toElement();
341 343
342 if ( newChild.tagName() == tagText ) 344 if ( newChild.tagName() == tagText )
343 continue; 345 continue;
344 346
345 if ( newChild.attribute( attrAlreadyVisited ) == attrOne ) 347 if ( newChild.attribute( attrAlreadyVisited ) == attrOne )
346 continue; 348 continue;
347 349
348 QString itAppend( newChild.attribute( attrAppend ) ); 350 QString itAppend( newChild.attribute( attrAppend ) );
349 QString elemName( currElement.attribute( attrName ) ); 351 QString elemName( currElement.attribute( attrName ) );
350 352
351 if ( ( itAppend.isNull() && elemName.isEmpty() ) || 353 if ( ( itAppend.isNull() && elemName.isEmpty() ) ||
352 ( itAppend == elemName ) ) 354 ( itAppend == elemName ) )
353 { 355 {
354 // first, see if this new element matches a standard one in 356 // first, see if this new element matches a standard one in
355 // the global file. if it does, then we skip it as it will 357 // the global file. if it does, then we skip it as it will
356 // be merged in, later 358 // be merged in, later
357 QDomElement matchingElement = findMatchingElement( newChild, base ); 359 QDomElement matchingElement = findMatchingElement( newChild, base );
358 if ( matchingElement.isNull() || newChild.tagName() == tagSeparator ) 360 if ( matchingElement.isNull() || newChild.tagName() == tagSeparator )
359 base.insertBefore( newChild, currElement ); 361 base.insertBefore( newChild, currElement );
360 } 362 }
361 } 363 }
362 364
363 base.removeChild( currElement ); 365 base.removeChild( currElement );
364 continue; 366 continue;
365 } 367 }
366 368
367 // in this last case we check for a separator tag and, if not, we 369 // in this last case we check for a separator tag and, if not, we
368 // can be sure that its a container --> proceed with child nodes 370 // can be sure that its a container --> proceed with child nodes
369 // recursively and delete the just proceeded container item in 371 // recursively and delete the just proceeded container item in
370 // case its empty (if the recursive call returns true) 372 // case its empty (if the recursive call returns true)
371 else if ( tag != tagMerge ) 373 else if ( tag != tagMerge )
372 { 374 {
373 // handle the text tag 375 // handle the text tag
374 if ( tag == tagText ) 376 if ( tag == tagText )
375 { 377 {
376 e = e.nextSibling().toElement(); 378 e = e.nextSibling().toElement();
377 continue; 379 continue;
378 } 380 }
379 381
380 QDomElement matchingElement = findMatchingElement( e, additive ); 382 QDomElement matchingElement = findMatchingElement( e, additive );
381 383
382 QDomElement currElement = e; 384 QDomElement currElement = e;
383 e = e.nextSibling().toElement(); 385 e = e.nextSibling().toElement();
384 386
385 if ( !matchingElement.isNull() ) 387 if ( !matchingElement.isNull() )
386 { 388 {
387 matchingElement.setAttribute( attrAlreadyVisited, (uint)1 ); 389 matchingElement.setAttribute( attrAlreadyVisited, (uint)1 );
388 390
389 if ( mergeXML( currElement, matchingElement, actionCollection ) ) 391 if ( mergeXML( currElement, matchingElement, actionCollection ) )
390 { 392 {
391 base.removeChild( currElement ); 393 base.removeChild( currElement );
392 continue; 394 continue;
393 } 395 }
394 396
395 // Merge attributes 397 // Merge attributes
396 QDomNamedNodeMap attribs = matchingElement.attributes(); 398 QDomNamedNodeMap attribs = matchingElement.attributes();
397 for(uint i = 0; i < attribs.count(); i++) 399 for(uint i = 0; i < attribs.count(); i++)
398 { 400 {
399 QDomNode node = attribs.item(i); 401 QDomNode node = attribs.item(i);
400 currElement.setAttribute(node.nodeName(), node.nodeValue()); 402 currElement.setAttribute(node.nodeName(), node.nodeValue());
401 } 403 }
402 404
403 continue; 405 continue;
404 } 406 }
405 else 407 else
406 { 408 {
407 // this is an important case here! We reach this point if the 409 // this is an important case here! We reach this point if the
408 // "local" tree does not contain a container definition for 410 // "local" tree does not contain a container definition for
409 // this container. However we have to call mergeXML recursively 411 // this container. However we have to call mergeXML recursively
410 // and make it check if there are actions implemented for this 412 // and make it check if there are actions implemented for this
411 // container. *If* none, then we can remove this container now 413 // container. *If* none, then we can remove this container now
412 if ( mergeXML( currElement, QDomElement(), actionCollection ) ) 414 if ( mergeXML( currElement, QDomElement(), actionCollection ) )
413 base.removeChild( currElement ); 415 base.removeChild( currElement );
414 continue; 416 continue;
415 } 417 }
416 } 418 }
417 419
418 //I think this can be removed ;-) 420 //I think this can be removed ;-)
419 e = e.nextSibling().toElement(); 421 e = e.nextSibling().toElement();
420 } 422 }
421 423
422 //here we append all child elements which were not inserted 424 //here we append all child elements which were not inserted
423 //previously via the LocalMerge tag 425 //previously via the LocalMerge tag
424 e = additive.firstChild().toElement(); 426 e = additive.firstChild().toElement();
425 while ( !e.isNull() ) 427 while ( !e.isNull() )
426 { 428 {
427 QDomElement matchingElement = findMatchingElement( e, base ); 429 QDomElement matchingElement = findMatchingElement( e, base );
428 430
429 if ( matchingElement.isNull() ) 431 if ( matchingElement.isNull() )
430 { 432 {
431 QDomElement newChild = e; 433 QDomElement newChild = e;
432 e = e.nextSibling().toElement(); 434 e = e.nextSibling().toElement();
433 base.appendChild( newChild ); 435 base.appendChild( newChild );
434 } 436 }
435 else 437 else
436 e = e.nextSibling().toElement(); 438 e = e.nextSibling().toElement();
437 } 439 }
438 440
439 // do one quick check to make sure that the last element was not 441 // do one quick check to make sure that the last element was not
440 // a weak separator 442 // a weak separator
441 QDomElement last = base.lastChild().toElement(); 443 QDomElement last = base.lastChild().toElement();
442 if ( (last.tagName() == tagSeparator) && (!last.attribute( attrWeakSeparator ).isNull()) ) 444 if ( (last.tagName() == tagSeparator) && (!last.attribute( attrWeakSeparator ).isNull()) )
443 { 445 {
444 base.removeChild( base.lastChild() ); 446 base.removeChild( base.lastChild() );
445 } 447 }
446 448
447 // now we check if we are empty (in which case we return "true", to 449 // now we check if we are empty (in which case we return "true", to
448 // indicate the caller that it can delete "us" (the base element 450 // indicate the caller that it can delete "us" (the base element
449 // argument of "this" call) 451 // argument of "this" call)
450 bool deleteMe = true; 452 bool deleteMe = true;
451 e = base.firstChild().toElement(); 453 e = base.firstChild().toElement();
452 for ( ; !e.isNull(); e = e.nextSibling().toElement() ) 454 for ( ; !e.isNull(); e = e.nextSibling().toElement() )
453 { 455 {
454 tag = e.tagName(); 456 tag = e.tagName();
455 457
456 if ( tag == tagAction ) 458 if ( tag == tagAction )
457 { 459 {
458 // if base contains an implemented action, then we must not get 460 // if base contains an implemented action, then we must not get
459 // deleted (note that the actionCollection contains both, 461 // deleted (note that the actionCollection contains both,
460 // "global" and "local" actions 462 // "global" and "local" actions
461 if ( actionCollection->action( e.attribute( attrName ).utf8() ) ) 463 if ( actionCollection->action( e.attribute( attrName ).utf8() ) )
462 { 464 {
463 deleteMe = false; 465 deleteMe = false;
464 break; 466 break;
465 } 467 }
466 } 468 }
467 else if ( tag == tagSeparator ) 469 else if ( tag == tagSeparator )
468 { 470 {
469 // if we have a separator which has *not* the weak attribute 471 // if we have a separator which has *not* the weak attribute
470 // set, then it must be owned by the "local" tree in which case 472 // set, then it must be owned by the "local" tree in which case
471 // we must not get deleted either 473 // we must not get deleted either
472 QString weakAttr = e.attribute( attrWeakSeparator ); 474 QString weakAttr = e.attribute( attrWeakSeparator );
473 if ( weakAttr.isEmpty() || weakAttr.toInt() != 1 ) 475 if ( weakAttr.isEmpty() || weakAttr.toInt() != 1 )
474 { 476 {
475 deleteMe = false; 477 deleteMe = false;
476 break; 478 break;
477 } 479 }
478 } 480 }
479 481
480 // in case of a merge tag we have unlimited lives, too ;-) 482 // in case of a merge tag we have unlimited lives, too ;-)
481 else if ( tag == tagMerge ) 483 else if ( tag == tagMerge )
482 { 484 {
483// deleteMe = false; 485// deleteMe = false;
484// break; 486// break;
485 continue; 487 continue;
486 } 488 }
487 489
488 // a text tag is NOT enough to spare this container 490 // a text tag is NOT enough to spare this container
489 else if ( tag == tagText ) 491 else if ( tag == tagText )
490 { 492 {
491 continue; 493 continue;
492 } 494 }
493 495
494 // what's left are non-empty containers! *don't* delete us in this 496 // what's left are non-empty containers! *don't* delete us in this
495 // case (at this position we can be *sure* that the container is 497 // case (at this position we can be *sure* that the container is
496 // *not* empty, as the recursive call for it was in the first loop 498 // *not* empty, as the recursive call for it was in the first loop
497 // which deleted the element in case the call returned "true" 499 // which deleted the element in case the call returned "true"
498 else 500 else
499 { 501 {
500 deleteMe = false; 502 deleteMe = false;
501 break; 503 break;
502 } 504 }
503 } 505 }
504 506
505 return deleteMe; 507 return deleteMe;
506} 508}
507 509
508QDomElement KXMLGUIClient::findMatchingElement( const QDomElement &base, const QDomElement &additive ) 510QDomElement KXMLGUIClient::findMatchingElement( const QDomElement &base, const QDomElement &additive )
509{ 511{
510 static const QString &tagAction = KGlobal::staticQString( "Action" ); 512 static const QString &tagAction = KGlobal::staticQString( "Action" );
511 static const QString &tagMergeLocal = KGlobal::staticQString( "MergeLocal" ); 513 static const QString &tagMergeLocal = KGlobal::staticQString( "MergeLocal" );
512 static const QString &attrName = KGlobal::staticQString( "name" ); 514 static const QString &attrName = KGlobal::staticQString( "name" );
513 515
514 QDomElement e = additive.firstChild().toElement(); 516 QDomElement e = additive.firstChild().toElement();
515 for ( ; !e.isNull(); e = e.nextSibling().toElement() ) 517 for ( ; !e.isNull(); e = e.nextSibling().toElement() )
516 { 518 {
517 // skip all action and merge tags as we will never use them 519 // skip all action and merge tags as we will never use them
518 if ( ( e.tagName() == tagAction ) || ( e.tagName() == tagMergeLocal ) ) 520 if ( ( e.tagName() == tagAction ) || ( e.tagName() == tagMergeLocal ) )
519 { 521 {
520 continue; 522 continue;
521 } 523 }
522 524
523 // now see if our tags are equivalent 525 // now see if our tags are equivalent
524 if ( ( e.tagName() == base.tagName() ) && 526 if ( ( e.tagName() == base.tagName() ) &&
525 ( e.attribute( attrName ) == base.attribute( attrName ) ) ) 527 ( e.attribute( attrName ) == base.attribute( attrName ) ) )
526 { 528 {
527 return e; 529 return e;
528 } 530 }
529 } 531 }
530 532
531 // nope, return a (now) null element 533 // nope, return a (now) null element
532 return e; 534 return e;
533} 535}
534 536
535void KXMLGUIClient::conserveMemory() 537void KXMLGUIClient::conserveMemory()
536{ 538{
537 d->m_doc = QDomDocument(); 539 d->m_doc = QDomDocument();
538 d->m_buildDocument = QDomDocument(); 540 d->m_buildDocument = QDomDocument();
539} 541}
540 542
541void KXMLGUIClient::setXMLGUIBuildDocument( const QDomDocument &doc ) 543void KXMLGUIClient::setXMLGUIBuildDocument( const QDomDocument &doc )
542{ 544{
543 d->m_buildDocument = doc; 545 d->m_buildDocument = doc;
544} 546}
545 547
546QDomDocument KXMLGUIClient::xmlguiBuildDocument() const 548QDomDocument KXMLGUIClient::xmlguiBuildDocument() const
547{ 549{
548 return d->m_buildDocument; 550 return d->m_buildDocument;
549} 551}
550*/ 552*/
551 553
552/*US 554/*US
553void KXMLGUIClient::setFactory( KXMLGUIFactory *factory ) 555void KXMLGUIClient::setFactory( KXMLGUIFactory *factory )
554{ 556{
555 d->m_factory = factory; 557 d->m_factory = factory;
556} 558}
557 559
558KXMLGUIFactory *KXMLGUIClient::factory() const 560KXMLGUIFactory *KXMLGUIClient::factory() const
559{ 561{
560 return d->m_factory; 562 return d->m_factory;
561} 563}
562*/ 564*/
563KXMLGUIClient *KXMLGUIClient::parentClient() const 565KXMLGUIClient *KXMLGUIClient::parentClient() const
564{ 566{
565 return d->m_parent; 567 return d->m_parent;
566} 568}
567 569
568void KXMLGUIClient::insertChildClient( KXMLGUIClient *child ) 570void KXMLGUIClient::insertChildClient( KXMLGUIClient *child )
569{ 571{
570 if ( child->d->m_parent ) 572 if ( child->d->m_parent )
571 child->d->m_parent->removeChildClient( child ); 573 child->d->m_parent->removeChildClient( child );
572 d->m_children.append( child ); 574 d->m_children.append( child );
573 child->d->m_parent = this; 575 child->d->m_parent = this;
574} 576}
575 577
576void KXMLGUIClient::removeChildClient( KXMLGUIClient *child ) 578void KXMLGUIClient::removeChildClient( KXMLGUIClient *child )
577{ 579{
578 assert( d->m_children.containsRef( child ) ); 580 assert( d->m_children.containsRef( child ) );
579 d->m_children.removeRef( child ); 581 d->m_children.removeRef( child );
580 child->d->m_parent = 0; 582 child->d->m_parent = 0;
581} 583}
582 584
583/*bool KXMLGUIClient::addSuperClient( KXMLGUIClient *super ) 585/*bool KXMLGUIClient::addSuperClient( KXMLGUIClient *super )
584{ 586{
585 if ( d->m_supers.contains( super ) ) 587 if ( d->m_supers.contains( super ) )
586 return false; 588 return false;
587 d->m_supers.append( super ); 589 d->m_supers.append( super );
588 return true; 590 return true;
589}*/ 591}*/
590 592
591const QPtrList<KXMLGUIClient> *KXMLGUIClient::childClients() 593const Q3PtrList<KXMLGUIClient> *KXMLGUIClient::childClients()
592{ 594{
593 return &d->m_children; 595 return &d->m_children;
594} 596}
595/*US 597/*US
596void KXMLGUIClient::setClientBuilder( KXMLGUIBuilder *builder ) 598void KXMLGUIClient::setClientBuilder( KXMLGUIBuilder *builder )
597{ 599{
598 d->m_builder = builder; 600 d->m_builder = builder;
599 if ( builder ) 601 if ( builder )
600 builder->setBuilderInstance( instance() ); 602 builder->setBuilderInstance( instance() );
601} 603}
602 604
603KXMLGUIBuilder *KXMLGUIClient::clientBuilder() const 605KXMLGUIBuilder *KXMLGUIClient::clientBuilder() const
604{ 606{
605 return d->m_builder; 607 return d->m_builder;
606} 608}
607*/ 609*/
608 610
609void KXMLGUIClient::plugActionList( const QString &name, const QPtrList<KAction> &actionList ) 611void KXMLGUIClient::plugActionList( const QString &name, const Q3PtrList<KAction> &actionList )
610{ 612{
611/*US 613/*US
612 if ( !d->m_factory ) 614 if ( !d->m_factory )
613 return; 615 return;
614 616
615 d->m_factory->plugActionList( this, name, actionList ); 617 d->m_factory->plugActionList( this, name, actionList );
616*/ 618*/
617} 619}
618 620
619void KXMLGUIClient::unplugActionList( const QString &name ) 621void KXMLGUIClient::unplugActionList( const QString &name )
620{ 622{
621/*US 623/*US
622 if ( !d->m_factory ) 624 if ( !d->m_factory )
623 return; 625 return;
624 626
625 d->m_factory->unplugActionList( this, name ); 627 d->m_factory->unplugActionList( this, name );
626*/ 628*/
627} 629}
628 630
629/*US 631/*US
630QString KXMLGUIClient::findMostRecentXMLFile( const QStringList &files, QString &doc ) 632QString KXMLGUIClient::findMostRecentXMLFile( const QStringList &files, QString &doc )
631{ 633{
632 634
633 QValueList<DocStruct> allDocuments; 635 QValueList<DocStruct> allDocuments;
634 636
635 QStringList::ConstIterator it = files.begin(); 637 QStringList::ConstIterator it = files.begin();
636 QStringList::ConstIterator end = files.end(); 638 QStringList::ConstIterator end = files.end();
637 for (; it != end; ++it ) 639 for (; it != end; ++it )
638 { 640 {
639 //kdDebug() << "KXMLGUIClient::findMostRecentXMLFile " << *it << endl; 641 //kdDebug() << "KXMLGUIClient::findMostRecentXMLFile " << *it << endl;
640 QString data = KXMLGUIFactory::readConfigFile( *it ); 642 QString data = KXMLGUIFactory::readConfigFile( *it );
641 DocStruct d; 643 DocStruct d;
642 d.file = *it; 644 d.file = *it;
643 d.data = data; 645 d.data = data;
644 allDocuments.append( d ); 646 allDocuments.append( d );
645 } 647 }
646 648
647 QValueList<DocStruct>::Iterator best = allDocuments.end(); 649 QValueList<DocStruct>::Iterator best = allDocuments.end();
648 uint bestVersion = 0; 650 uint bestVersion = 0;
649 651
650 QValueList<DocStruct>::Iterator docIt = allDocuments.begin(); 652 QValueList<DocStruct>::Iterator docIt = allDocuments.begin();
651 QValueList<DocStruct>::Iterator docEnd = allDocuments.end(); 653 QValueList<DocStruct>::Iterator docEnd = allDocuments.end();
652 for (; docIt != docEnd; ++docIt ) 654 for (; docIt != docEnd; ++docIt )
653 { 655 {
654 QString versionStr = findVersionNumber( (*docIt).data ); 656 QString versionStr = findVersionNumber( (*docIt).data );
655 if ( versionStr.isEmpty() ) 657 if ( versionStr.isEmpty() )
656 continue; 658 continue;
657 659
658 bool ok = false; 660 bool ok = false;
659 uint version = versionStr.toUInt( &ok ); 661 uint version = versionStr.toUInt( &ok );
660 if ( !ok ) 662 if ( !ok )
661 continue; 663 continue;
662 //kdDebug() << "FOUND VERSION " << version << endl; 664 //kdDebug() << "FOUND VERSION " << version << endl;
663 665
664 if ( version > bestVersion ) 666 if ( version > bestVersion )
665 { 667 {
666 best = docIt; 668 best = docIt;
667 //kdDebug() << "best version is now " << version << endl; 669 //kdDebug() << "best version is now " << version << endl;
668 bestVersion = version; 670 bestVersion = version;
669 } 671 }
670 } 672 }
671 673
672 if ( best != docEnd ) 674 if ( best != docEnd )
673 { 675 {
674 if ( best != allDocuments.begin() ) 676 if ( best != allDocuments.begin() )
675 { 677 {
676 QValueList<DocStruct>::Iterator local = allDocuments.begin(); 678 QValueList<DocStruct>::Iterator local = allDocuments.begin();
677 679
678 // load the local document and extract the action properties 680 // load the local document and extract the action properties
679 QDomDocument document; 681 QDomDocument document;
680 document.setContent( (*local).data ); 682 document.setContent( (*local).data );
681 683
682 ActionPropertiesMap properties = extractActionProperties( document ); 684 ActionPropertiesMap properties = extractActionProperties( document );
683 685
684 // in case the document has a ActionProperties section 686 // in case the document has a ActionProperties section
685 // we must not delete it but copy over the global doc 687 // we must not delete it but copy over the global doc
686 // to the local and insert the ActionProperties section 688 // to the local and insert the ActionProperties section
687 if ( !properties.isEmpty() ) 689 if ( !properties.isEmpty() )
688 { 690 {
689 // now load the global one with the higher version number 691 // now load the global one with the higher version number
690 // into memory 692 // into memory
691 document.setContent( (*best).data ); 693 document.setContent( (*best).data );
692 // and store the properties in there 694 // and store the properties in there
693 storeActionProperties( document, properties ); 695 storeActionProperties( document, properties );
694 696
695 (*local).data = document.toString(); 697 (*local).data = document.toString();
696 // make sure we pick up the new local doc, when we return later 698 // make sure we pick up the new local doc, when we return later
697 best = local; 699 best = local;
698 700
699 // write out the new version of the local document 701 // write out the new version of the local document
700 QFile f( (*local).file ); 702 QFile f( (*local).file );
701 if ( f.open( IO_WriteOnly ) ) 703 if ( f.open( IO_WriteOnly ) )
702 { 704 {
703 QCString utf8data = (*local).data.utf8(); 705 QCString utf8data = (*local).data.utf8();
704 f.writeBlock( utf8data.data(), utf8data.length() ); 706 f.writeBlock( utf8data.data(), utf8data.length() );
705 f.close(); 707 f.close();
706 } 708 }
707 } 709 }
708 else 710 else
709 { 711 {
710 QString f = (*local).file; 712 QString f = (*local).file;
711 QString backup = f + QString::fromLatin1( ".backup" ); 713 QString backup = f + QString::fromLatin1( ".backup" );
712 QDir dir; 714 QDir dir;
713 dir.rename( f, backup ); 715 dir.rename( f, backup );
714 } 716 }
715 } 717 }
716 doc = (*best).data; 718 doc = (*best).data;
717 return (*best).file; 719 return (*best).file;
718 } 720 }
719 else if ( files.count() > 0 ) 721 else if ( files.count() > 0 )
720 { 722 {
721 //kdDebug() << "returning first one..." << endl; 723 //kdDebug() << "returning first one..." << endl;
722 doc = (*allDocuments.begin()).data; 724 doc = (*allDocuments.begin()).data;
723 return (*allDocuments.begin()).file; 725 return (*allDocuments.begin()).file;
724 } 726 }
725 727
726 return QString::null; 728 return QString::null;
727} 729}
728 730
729 731
730 732
731QString KXMLGUIClient::findVersionNumber( const QString &xml ) 733QString KXMLGUIClient::findVersionNumber( const QString &xml )
732{ 734{
733 enum { ST_START, ST_AFTER_OPEN, ST_AFTER_GUI, 735 enum { ST_START, ST_AFTER_OPEN, ST_AFTER_GUI,
734 ST_EXPECT_VERSION, ST_VERSION_NUM} state = ST_START; 736 ST_EXPECT_VERSION, ST_VERSION_NUM} state = ST_START;
735 for (unsigned int pos = 0; pos < xml.length(); pos++) 737 for (unsigned int pos = 0; pos < xml.length(); pos++)
736 { 738 {
737 switch (state) 739 switch (state)
738 { 740 {
739 case ST_START: 741 case ST_START:
740 if (xml[pos] == '<') 742 if (xml[pos] == '<')
741 state = ST_AFTER_OPEN; 743 state = ST_AFTER_OPEN;
742 break; 744 break;
743 case ST_AFTER_OPEN: 745 case ST_AFTER_OPEN:
744 { 746 {
745 //Jump to gui.. 747 //Jump to gui..
746 int guipos = xml.find("gui", pos, false); 748 int guipos = xml.find("gui", pos, false);
747 if (guipos == -1) 749 if (guipos == -1)
748 return QString::null; //Reject 750 return QString::null; //Reject
749 751
750 pos = guipos + 2; //Position at i, so we're moved ahead to the next character by the ++; 752 pos = guipos + 2; //Position at i, so we're moved ahead to the next character by the ++;
751 state = ST_AFTER_GUI; 753 state = ST_AFTER_GUI;
752 break; 754 break;
753 } 755 }
754 case ST_AFTER_GUI: 756 case ST_AFTER_GUI:
755 state = ST_EXPECT_VERSION; 757 state = ST_EXPECT_VERSION;
756 break; 758 break;
757 case ST_EXPECT_VERSION: 759 case ST_EXPECT_VERSION:
758 { 760 {
759 int verpos = xml.find("version=\"", pos, false ); 761 int verpos = xml.find("version=\"", pos, false );
760 if (verpos == -1) 762 if (verpos == -1)
761 return QString::null; //Reject 763 return QString::null; //Reject
762 764
763 pos = verpos + 8; //v = 0, e = +1, r = +2, s = +3 , i = +4, o = +5, n = +6, = = +7, " = + 8 765 pos = verpos + 8; //v = 0, e = +1, r = +2, s = +3 , i = +4, o = +5, n = +6, = = +7, " = + 8
764 state = ST_VERSION_NUM; 766 state = ST_VERSION_NUM;
765 break; 767 break;
766 } 768 }
767 case ST_VERSION_NUM: 769 case ST_VERSION_NUM:
768 { 770 {
769 unsigned int endpos; 771 unsigned int endpos;
770 for (endpos = pos; endpos < xml.length(); endpos++) 772 for (endpos = pos; endpos < xml.length(); endpos++)
771 { 773 {
772 if (xml[endpos].unicode() >= '0' && xml[endpos].unicode() <= '9') 774 if (xml[endpos].unicode() >= '0' && xml[endpos].unicode() <= '9')
773 continue; //Number.. 775 continue; //Number..
774 if (xml[endpos].unicode() == '"') //End of parameter 776 if (xml[endpos].unicode() == '"') //End of parameter
775 break; 777 break;
776 else //This shouldn't be here.. 778 else //This shouldn't be here..
777 { 779 {
778 endpos = xml.length(); 780 endpos = xml.length();
779 } 781 }
780 } 782 }
781 783
782 if (endpos != pos && endpos < xml.length() ) 784 if (endpos != pos && endpos < xml.length() )
783 { 785 {
784 QString matchCandidate = xml.mid(pos, endpos - pos); //Don't include " ". 786 QString matchCandidate = xml.mid(pos, endpos - pos); //Don't include " ".
785 return matchCandidate; 787 return matchCandidate;
786 } 788 }
787 789
788 state = ST_EXPECT_VERSION; //Try to match a well-formed version.. 790 state = ST_EXPECT_VERSION; //Try to match a well-formed version..
789 break; 791 break;
790 } //case.. 792 } //case..
791 } //switch 793 } //switch
792 } //for 794 } //for
793 795
794 return QString::null; 796 return QString::null;
795} 797}
796 798
797KXMLGUIClient::ActionPropertiesMap KXMLGUIClient::extractActionProperties( const QDomDocument &doc ) 799KXMLGUIClient::ActionPropertiesMap KXMLGUIClient::extractActionProperties( const QDomDocument &doc )
798{ 800{
799 ActionPropertiesMap properties; 801 ActionPropertiesMap properties;
800 802
801 QDomElement actionPropElement = doc.documentElement().namedItem( "ActionProperties" ).toElement(); 803 QDomElement actionPropElement = doc.documentElement().namedItem( "ActionProperties" ).toElement();
802 804
803 if ( actionPropElement.isNull() ) 805 if ( actionPropElement.isNull() )
804 return properties; 806 return properties;
805 807
806 QDomNode n = actionPropElement.firstChild(); 808 QDomNode n = actionPropElement.firstChild();
807 for (; !n.isNull(); n = n.nextSibling() ) 809 for (; !n.isNull(); n = n.nextSibling() )
808 { 810 {
809 QDomElement e = n.toElement(); 811 QDomElement e = n.toElement();
810 if ( e.isNull() ) 812 if ( e.isNull() )
811 continue; 813 continue;
812 814
813 if ( e.tagName().lower() != "action" ) 815 if ( e.tagName().lower() != "action" )
814 continue; 816 continue;
815 817
816 QString actionName = e.attribute( "name" ); 818 QString actionName = e.attribute( "name" );
817 819
818 if ( actionName.isEmpty() ) 820 if ( actionName.isEmpty() )
819 continue; 821 continue;
820 822
821 QMap<QString, QMap<QString, QString> >::Iterator propIt = properties.find( actionName ); 823 QMap<QString, QMap<QString, QString> >::Iterator propIt = properties.find( actionName );
822 if ( propIt == properties.end() ) 824 if ( propIt == properties.end() )
823 propIt = properties.insert( actionName, QMap<QString, QString>() ); 825 propIt = properties.insert( actionName, QMap<QString, QString>() );
824 826
825 QDomNamedNodeMap attributes = e.attributes(); 827 QDomNamedNodeMap attributes = e.attributes();
826 for ( uint i = 0; i < attributes.length(); ++i ) 828 for ( uint i = 0; i < attributes.length(); ++i )
827 { 829 {
828 QDomAttr attr = attributes.item( i ).toAttr(); 830 QDomAttr attr = attributes.item( i ).toAttr();
829 831
830 if ( attr.isNull() ) 832 if ( attr.isNull() )
831 continue; 833 continue;
832 834
833 QString name = attr.name(); 835 QString name = attr.name();
834 836
835 if ( name == "name" || name.isEmpty() ) 837 if ( name == "name" || name.isEmpty() )
836 continue; 838 continue;
837 839
838 (*propIt)[ name ] = attr.value(); 840 (*propIt)[ name ] = attr.value();
839 } 841 }
840 842
841 } 843 }
842 844
843 return properties; 845 return properties;
844} 846}
845 847
846void KXMLGUIClient::storeActionProperties( QDomDocument &doc, const ActionPropertiesMap &properties ) 848void KXMLGUIClient::storeActionProperties( QDomDocument &doc, const ActionPropertiesMap &properties )
847{ 849{
848 QDomElement actionPropElement = doc.documentElement().namedItem( "ActionProperties" ).toElement(); 850 QDomElement actionPropElement = doc.documentElement().namedItem( "ActionProperties" ).toElement();
849 851
850 if ( actionPropElement.isNull() ) 852 if ( actionPropElement.isNull() )
851 { 853 {
852 actionPropElement = doc.createElement( "ActionProperties" ); 854 actionPropElement = doc.createElement( "ActionProperties" );
853 doc.documentElement().appendChild( actionPropElement ); 855 doc.documentElement().appendChild( actionPropElement );
854 } 856 }
855 857
856 while ( !actionPropElement.firstChild().isNull() ) 858 while ( !actionPropElement.firstChild().isNull() )
857 actionPropElement.removeChild( actionPropElement.firstChild() ); 859 actionPropElement.removeChild( actionPropElement.firstChild() );
858 860
859 ActionPropertiesMap::ConstIterator it = properties.begin(); 861 ActionPropertiesMap::ConstIterator it = properties.begin();
860 ActionPropertiesMap::ConstIterator end = properties.end(); 862 ActionPropertiesMap::ConstIterator end = properties.end();
861 for (; it != end; ++it ) 863 for (; it != end; ++it )
862 { 864 {
863 QDomElement action = doc.createElement( "Action" ); 865 QDomElement action = doc.createElement( "Action" );
864 action.setAttribute( "name", it.key() ); 866 action.setAttribute( "name", it.key() );
865 actionPropElement.appendChild( action ); 867 actionPropElement.appendChild( action );
866 868
867 QMap<QString, QString> attributes = (*it); 869 QMap<QString, QString> attributes = (*it);
868 QMap<QString, QString>::ConstIterator attrIt = attributes.begin(); 870 QMap<QString, QString>::ConstIterator attrIt = attributes.begin();
869 QMap<QString, QString>::ConstIterator attrEnd = attributes.end(); 871 QMap<QString, QString>::ConstIterator attrEnd = attributes.end();
870 for (; attrIt != attrEnd; ++attrIt ) 872 for (; attrIt != attrEnd; ++attrIt )
871 action.setAttribute( attrIt.key(), attrIt.data() ); 873 action.setAttribute( attrIt.key(), attrIt.data() );
872 } 874 }
873} 875}
874*/ 876*/
875 877
876void KXMLGUIClient::addStateActionEnabled(const QString& state, 878void KXMLGUIClient::addStateActionEnabled(const QString& state,
877 const QString& action) 879 const QString& action)
878{ 880{
879 StateChange stateChange = getActionsToChangeForState(state); 881 StateChange stateChange = getActionsToChangeForState(state);
880 882
881 stateChange.actionsToEnable.append( action ); 883 stateChange.actionsToEnable.append( action );
882 //kdDebug() << "KXMLGUIClient::addStateActionEnabled( " << state << ", " << action << ")" << endl; 884 //kdDebug() << "KXMLGUIClient::addStateActionEnabled( " << state << ", " << action << ")" << endl;
883 885
884 m_actionsStateMap.replace( state, stateChange ); 886 m_actionsStateMap.replace( state, stateChange );
885} 887}
886 888
887 889
888void KXMLGUIClient::addStateActionDisabled(const QString& state, 890void KXMLGUIClient::addStateActionDisabled(const QString& state,
889 const QString& action) 891 const QString& action)
890{ 892{
891 StateChange stateChange = getActionsToChangeForState(state); 893 StateChange stateChange = getActionsToChangeForState(state);
892 894
893 stateChange.actionsToDisable.append( action ); 895 stateChange.actionsToDisable.append( action );
894 //kdDebug() << "KXMLGUIClient::addStateActionDisabled( " << state << ", " << action << ")" << endl; 896 //kdDebug() << "KXMLGUIClient::addStateActionDisabled( " << state << ", " << action << ")" << endl;
895 897
896 m_actionsStateMap.replace( state, stateChange ); 898 m_actionsStateMap.replace( state, stateChange );
897} 899}
898 900
899 901
900KXMLGUIClient::StateChange KXMLGUIClient::getActionsToChangeForState(const QString& state) 902KXMLGUIClient::StateChange KXMLGUIClient::getActionsToChangeForState(const QString& state)
901{ 903{
902 return m_actionsStateMap[state]; 904 return m_actionsStateMap[state];
903} 905}
904 906
905 907
906void KXMLGUIClient::stateChanged(const QString &newstate, KXMLGUIClient::ReverseStateChange reverse) 908void KXMLGUIClient::stateChanged(const QString &newstate, KXMLGUIClient::ReverseStateChange reverse)
907{ 909{
908 StateChange stateChange = getActionsToChangeForState(newstate); 910 StateChange stateChange = getActionsToChangeForState(newstate);
909 911
910 bool setTrue = (reverse == StateNoReverse); 912 bool setTrue = (reverse == StateNoReverse);
911 bool setFalse = !setTrue; 913 bool setFalse = !setTrue;
912 914
913 // Enable actions which need to be enabled... 915 // Enable actions which need to be enabled...
914 // 916 //
915 for ( QStringList::Iterator it = stateChange.actionsToEnable.begin(); 917 for ( QStringList::Iterator it = stateChange.actionsToEnable.begin();
916 it != stateChange.actionsToEnable.end(); ++it ) { 918 it != stateChange.actionsToEnable.end(); ++it ) {
917 919
918 KAction *action = actionCollection()->action((*it).latin1()); 920 KAction *action = actionCollection()->action((*it).latin1());
919 if (action) action->setEnabled(setTrue); 921 if (action) action->setEnabled(setTrue);
920 } 922 }
921 923
922 // and disable actions which need to be disabled... 924 // and disable actions which need to be disabled...
923 // 925 //
924 for ( QStringList::Iterator it = stateChange.actionsToDisable.begin(); 926 for ( QStringList::Iterator it = stateChange.actionsToDisable.begin();
925 it != stateChange.actionsToDisable.end(); ++it ) { 927 it != stateChange.actionsToDisable.end(); ++it ) {
926 928
927 KAction *action = actionCollection()->action((*it).latin1()); 929 KAction *action = actionCollection()->action((*it).latin1());
928 if (action) action->setEnabled(setFalse); 930 if (action) action->setEnabled(setFalse);
929 } 931 }
930 932
931} 933}
932/*US 934/*US
933void KXMLGUIClient::beginXMLPlug( QWidget *w ) 935void KXMLGUIClient::beginXMLPlug( QWidget *w )
934{ 936{
935 actionCollection()->beginXMLPlug( w ); 937 actionCollection()->beginXMLPlug( w );
936 QPtrListIterator<KXMLGUIClient> childIt( d->m_children ); 938 QPtrListIterator<KXMLGUIClient> childIt( d->m_children );
937 for (; childIt.current(); ++childIt ) 939 for (; childIt.current(); ++childIt )
938 childIt.current()->actionCollection()->beginXMLPlug( w ); 940 childIt.current()->actionCollection()->beginXMLPlug( w );
939} 941}
940 942
941void KXMLGUIClient::endXMLPlug() 943void KXMLGUIClient::endXMLPlug()
942{ 944{
943 actionCollection()->endXMLPlug(); 945 actionCollection()->endXMLPlug();
944 QPtrListIterator<KXMLGUIClient> childIt( d->m_children ); 946 QPtrListIterator<KXMLGUIClient> childIt( d->m_children );
945 for (; childIt.current(); ++childIt ) 947 for (; childIt.current(); ++childIt )
946 childIt.current()->actionCollection()->endXMLPlug(); 948 childIt.current()->actionCollection()->endXMLPlug();
947} 949}
948 950
949void KXMLGUIClient::prepareXMLUnplug( QWidget * ) 951void KXMLGUIClient::prepareXMLUnplug( QWidget * )
950{ 952{
951 actionCollection()->prepareXMLUnplug(); 953 actionCollection()->prepareXMLUnplug();
952 QPtrListIterator<KXMLGUIClient> childIt( d->m_children ); 954 QPtrListIterator<KXMLGUIClient> childIt( d->m_children );
953 for (; childIt.current(); ++childIt ) 955 for (; childIt.current(); ++childIt )
954 childIt.current()->actionCollection()->prepareXMLUnplug(); 956 childIt.current()->actionCollection()->prepareXMLUnplug();
955} 957}
956*/ 958*/
957void KXMLGUIClient::virtual_hook( int, void* ) 959void KXMLGUIClient::virtual_hook( int, void* )
958{ /*BASE::virtual_hook( id, data );*/ } 960{ /*BASE::virtual_hook( id, data );*/ }
diff --git a/microkde/kdeui/kxmlguiclient.h b/microkde/kdeui/kxmlguiclient.h
index cd74c8e..b9d7b09 100644
--- a/microkde/kdeui/kxmlguiclient.h
+++ b/microkde/kdeui/kxmlguiclient.h
@@ -1,361 +1,361 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org> 2 Copyright (C) 2000 Simon Hausmann <hausmann@kde.org>
3 Copyright (C) 2000 Kurt Granroth <granroth@kde.org> 3 Copyright (C) 2000 Kurt Granroth <granroth@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19#ifndef _KXMLGUICLIENT_H 19#ifndef _KXMLGUICLIENT_H
20#define _KXMLGUICLIENT_H 20#define _KXMLGUICLIENT_H
21 21
22 22
23//US #include <qdom.h> 23//US #include <qdom.h>
24#include <qptrlist.h> 24#include <q3ptrlist.h>
25#include <qmap.h> 25#include <qmap.h>
26#include <qstringlist.h> 26#include <qstringlist.h>
27 27
28class QWidget; 28class QWidget;
29class KAction; 29class KAction;
30class KActionCollection; 30class KActionCollection;
31class KInstance; 31class KInstance;
32 32
33class KXMLGUIClientPrivate; 33class KXMLGUIClientPrivate;
34class KXMLGUIFactory; 34class KXMLGUIFactory;
35class KXMLGUIBuilder; 35class KXMLGUIBuilder;
36 36
37/** 37/**
38 * 38 *
39 * A KXMLGUIClient can be used with @ref KXMLGUIFactory to create a 39 * A KXMLGUIClient can be used with @ref KXMLGUIFactory to create a
40 * GUI from actions and an XML document, and can be dynamically merged 40 * GUI from actions and an XML document, and can be dynamically merged
41 * with other KXMLGUIClients. 41 * with other KXMLGUIClients.
42 */ 42 */
43class KXMLGUIClient 43class KXMLGUIClient
44{ 44{
45 friend class KEditToolbarWidget; // for setXMLFile(3 args) 45 friend class KEditToolbarWidget; // for setXMLFile(3 args)
46public: 46public:
47 /** 47 /**
48 * Constructs a KXMLGUIClient which can be used with a 48 * Constructs a KXMLGUIClient which can be used with a
49 * @ref KXMLGUIFactory to create a GUI from actions and an XML document, and 49 * @ref KXMLGUIFactory to create a GUI from actions and an XML document, and
50 * which can be dynamically merged with other KXMLGUIClients. 50 * which can be dynamically merged with other KXMLGUIClients.
51 */ 51 */
52 KXMLGUIClient(); 52 KXMLGUIClient();
53 53
54 /** 54 /**
55 * Constructs a KXMLGUIClient which can be used with a @ref KXMLGUIFactory 55 * Constructs a KXMLGUIClient which can be used with a @ref KXMLGUIFactory
56 * to create a GUI from actions and an XML document, 56 * to create a GUI from actions and an XML document,
57 * and which can be dynamically merged with other KXMLGUIClients. 57 * and which can be dynamically merged with other KXMLGUIClients.
58 * 58 *
59 * This constructor takes an additional @p parent argument, which makes 59 * This constructor takes an additional @p parent argument, which makes
60 * the client a child client of the parent. 60 * the client a child client of the parent.
61 * 61 *
62 * Child clients are automatically added to the GUI if the parent is added. 62 * Child clients are automatically added to the GUI if the parent is added.
63 * 63 *
64 */ 64 */
65 KXMLGUIClient( KXMLGUIClient *parent ); 65 KXMLGUIClient( KXMLGUIClient *parent );
66 66
67 /** 67 /**
68 * Destructs the KXMLGUIClient. 68 * Destructs the KXMLGUIClient.
69 */ 69 */
70 virtual ~KXMLGUIClient(); 70 virtual ~KXMLGUIClient();
71 71
72 /** 72 /**
73 * Retrieves an action of the client by name. If not found, it looks in its child clients. 73 * Retrieves an action of the client by name. If not found, it looks in its child clients.
74 * This method is provided for convenience, as it uses @ref #actionCollection() 74 * This method is provided for convenience, as it uses @ref #actionCollection()
75 * to get the action object. 75 * to get the action object.
76 */ 76 */
77 KAction* action( const char* name ) const; 77 KAction* action( const char* name ) const;
78 78
79 /** 79 /**
80 * Retrieves an action for a given @ref QDomElement. The default 80 * Retrieves an action for a given @ref QDomElement. The default
81 * implementation uses the "name" attribute to query the action 81 * implementation uses the "name" attribute to query the action
82 * object via the other action() method. 82 * object via the other action() method.
83 */ 83 */
84//US virtual KAction *action( const QDomElement &element ) const; 84//US virtual KAction *action( const QDomElement &element ) const;
85 85
86 /** 86 /**
87 * Retrieves the entire action collection for the GUI client 87 * Retrieves the entire action collection for the GUI client
88 */ 88 */
89 virtual KActionCollection* actionCollection() const; 89 virtual KActionCollection* actionCollection() const;
90 90
91 /** 91 /**
92 * @return The instance (@ref KInstance) for this part. 92 * @return The instance (@ref KInstance) for this part.
93 */ 93 */
94//US virtual KInstance *instance() const; 94//US virtual KInstance *instance() const;
95 95
96 /** 96 /**
97 * @return The parsed XML in a @ref QDomDocument, set by @ref 97 * @return The parsed XML in a @ref QDomDocument, set by @ref
98 * setXMLFile() or @ref setXML(). 98 * setXMLFile() or @ref setXML().
99 * This document describes the layout of the GUI. 99 * This document describes the layout of the GUI.
100 */ 100 */
101//US virtual QDomDocument domDocument() const; 101//US virtual QDomDocument domDocument() const;
102 102
103 /** 103 /**
104 * This will return the name of the XML file as set by @ref #setXMLFile(). 104 * This will return the name of the XML file as set by @ref #setXMLFile().
105 * If @ref #setXML() is used directly, then this will return NULL. 105 * If @ref #setXML() is used directly, then this will return NULL.
106 * 106 *
107 * The filename that this returns is obvious for components as each 107 * The filename that this returns is obvious for components as each
108 * component has exactly one XML file. In non-components, however, 108 * component has exactly one XML file. In non-components, however,
109 * there are usually two: the global file and the local file. This 109 * there are usually two: the global file and the local file. This
110 * function doesn't really care about that, though. It will always 110 * function doesn't really care about that, though. It will always
111 * return the last XML file set. This, in almost all cases, will 111 * return the last XML file set. This, in almost all cases, will
112 * be the local XML file. 112 * be the local XML file.
113 * 113 *
114 * @return The name of the XML file or QString::null 114 * @return The name of the XML file or QString::null
115 */ 115 */
116//US virtual QString xmlFile() const; 116//US virtual QString xmlFile() const;
117 117
118//US virtual QString localXMLFile() const; 118//US virtual QString localXMLFile() const;
119 119
120 /** 120 /**
121 * @internal 121 * @internal
122 */ 122 */
123//US void setXMLGUIBuildDocument( const QDomDocument &doc ); 123//US void setXMLGUIBuildDocument( const QDomDocument &doc );
124 /** 124 /**
125 * @internal 125 * @internal
126 */ 126 */
127//US QDomDocument xmlguiBuildDocument() const; 127//US QDomDocument xmlguiBuildDocument() const;
128 128
129 /** 129 /**
130 * This method is called by the @ref KXMLGUIFactory as soon as the client 130 * This method is called by the @ref KXMLGUIFactory as soon as the client
131 * is added to the KXMLGUIFactory's GUI. 131 * is added to the KXMLGUIFactory's GUI.
132 */ 132 */
133//US void setFactory( KXMLGUIFactory *factory ); 133//US void setFactory( KXMLGUIFactory *factory );
134 /** 134 /**
135 * Retrieves a pointer to the @ref KXMLGUIFactory this client is 135 * Retrieves a pointer to the @ref KXMLGUIFactory this client is
136 * associated with (will return 0L if the client's GUI has not been built 136 * associated with (will return 0L if the client's GUI has not been built
137 * by a KXMLGUIFactory. 137 * by a KXMLGUIFactory.
138 */ 138 */
139//US KXMLGUIFactory *factory() const; 139//US KXMLGUIFactory *factory() const;
140 140
141 /** 141 /**
142 * KXMLGUIClients can form a simple child/parent object tree. This 142 * KXMLGUIClients can form a simple child/parent object tree. This
143 * method returns a pointer to the parent client or 0L if it has no 143 * method returns a pointer to the parent client or 0L if it has no
144 * parent client assigned. 144 * parent client assigned.
145 */ 145 */
146 KXMLGUIClient *parentClient() const; 146 KXMLGUIClient *parentClient() const;
147 147
148 /** 148 /**
149 * Use this method to make a client a child client of another client. 149 * Use this method to make a client a child client of another client.
150 * Usually you don't need to call this method, as it is called 150 * Usually you don't need to call this method, as it is called
151 * automatically when using the second constructor, which takes a 151 * automatically when using the second constructor, which takes a
152 * arent argument. 152 * arent argument.
153 */ 153 */
154 void insertChildClient( KXMLGUIClient *child ); 154 void insertChildClient( KXMLGUIClient *child );
155 155
156 /** 156 /**
157 * Removes the given @p child from the client's children list. 157 * Removes the given @p child from the client's children list.
158 */ 158 */
159 void removeChildClient( KXMLGUIClient *child ); 159 void removeChildClient( KXMLGUIClient *child );
160 160
161 /** 161 /**
162 * Retrieves a list of all child clients. 162 * Retrieves a list of all child clients.
163 */ 163 */
164 const QPtrList<KXMLGUIClient> *childClients(); 164 const Q3PtrList<KXMLGUIClient> *childClients();
165 165
166 /** 166 /**
167 * A client can have an own @ref KXMLGUIBuilder. 167 * A client can have an own @ref KXMLGUIBuilder.
168 * Use this method to assign your builder instance to the client (so that the 168 * Use this method to assign your builder instance to the client (so that the
169 * @ref KXMLGUIFactory can use it when building the client's GUI) 169 * @ref KXMLGUIFactory can use it when building the client's GUI)
170 * 170 *
171 * Client specific guibuilders are useful if you want to create 171 * Client specific guibuilders are useful if you want to create
172 * custom container widgets for your GUI. 172 * custom container widgets for your GUI.
173 */ 173 */
174//US void setClientBuilder( KXMLGUIBuilder *builder ); 174//US void setClientBuilder( KXMLGUIBuilder *builder );
175 175
176 /** 176 /**
177 * Retrieves the client's GUI builder or 0L if no client specific 177 * Retrieves the client's GUI builder or 0L if no client specific
178 * builder has been assigned via @ref #setClientBuilder() 178 * builder has been assigned via @ref #setClientBuilder()
179 */ 179 */
180//US KXMLGUIBuilder *clientBuilder() const; 180//US KXMLGUIBuilder *clientBuilder() const;
181 181
182 /** 182 /**
183 * Forces this client to re-read its XML resource file. This is 183 * Forces this client to re-read its XML resource file. This is
184 * intended to be used when you know that the resource file has 184 * intended to be used when you know that the resource file has
185 * changed and you will soon be rebuilding the GUI. It has no 185 * changed and you will soon be rebuilding the GUI. It has no
186 * useful effect with non-KParts GUIs, so don't bother using it 186 * useful effect with non-KParts GUIs, so don't bother using it
187 * unless your app is component based. 187 * unless your app is component based.
188 */ 188 */
189//US void reloadXML(); 189//US void reloadXML();
190 190
191 /** 191 /**
192 * ActionLists are a way for XMLGUI to support dynamic lists of 192 * ActionLists are a way for XMLGUI to support dynamic lists of
193 * actions. E.g. if you are writing a file manager, and there is a 193 * actions. E.g. if you are writing a file manager, and there is a
194 * menu file whose contents depend on the mimetype of the file that 194 * menu file whose contents depend on the mimetype of the file that
195 * is selected, then you can achieve this using ActionLists. It 195 * is selected, then you can achieve this using ActionLists. It
196 * works as follows: 196 * works as follows:
197 * In your xxxui.rc file ( the one that you set in @ref setXMLFile() 197 * In your xxxui.rc file ( the one that you set in @ref setXMLFile()
198 * ), you put an <ActionList name="xxx"> tag. E.g. 198 * ), you put an <ActionList name="xxx"> tag. E.g.
199 * \verbatim 199 * \verbatim
200 * <kpartgui name="xxx_part" version="1"> 200 * <kpartgui name="xxx_part" version="1">
201 * <MenuBar> 201 * <MenuBar>
202 * <Menu name="file"> 202 * <Menu name="file">
203 * ... <!-- some useful actions--> 203 * ... <!-- some useful actions-->
204 * <ActionList name="xxx_file_actionlist" /> 204 * <ActionList name="xxx_file_actionlist" />
205 * ... <!-- even more useful actions--> 205 * ... <!-- even more useful actions-->
206 * </Menu> 206 * </Menu>
207 * ... 207 * ...
208 * </MenuBar> 208 * </MenuBar>
209 * </kpartgui> 209 * </kpartgui>
210 * \endverbatim 210 * \endverbatim
211 * 211 *
212 * This tag will get expanded to a list of actions. In the example 212 * This tag will get expanded to a list of actions. In the example
213 * above ( a file manager with a dynamic file menu ), you would call 213 * above ( a file manager with a dynamic file menu ), you would call
214 * \code 214 * \code
215 * QPtrList<KAction> file_actions; 215 * QPtrList<KAction> file_actions;
216 * for( ... ) 216 * for( ... )
217 * if( ... ) 217 * if( ... )
218 * file_actions.append( cool_action ); 218 * file_actions.append( cool_action );
219 * unplugActionList( "xxx_file_actionlist" ); 219 * unplugActionList( "xxx_file_actionlist" );
220 * plugActionList( "xxx_file_actionlist", file_actions ); 220 * plugActionList( "xxx_file_actionlist", file_actions );
221 * \endcode 221 * \endcode
222 * every time a file is selected, unselected or ... 222 * every time a file is selected, unselected or ...
223 * 223 *
224 * \note You should not call createGUI() after calling this 224 * \note You should not call createGUI() after calling this
225 * function. In fact, that would remove the newly added 225 * function. In fact, that would remove the newly added
226 * actionlists again... 226 * actionlists again...
227 * \note Forgetting to call unplugActionList() before 227 * \note Forgetting to call unplugActionList() before
228 * plugActionList() would leave the previous actions in the 228 * plugActionList() would leave the previous actions in the
229 * menu too.. 229 * menu too..
230 */ 230 */
231 void plugActionList( const QString &name, const QPtrList<KAction> &actionList ); 231 void plugActionList( const QString &name, const Q3PtrList<KAction> &actionList );
232 232
233 /** 233 /**
234 * The complement of \ref plugActionList() ... 234 * The complement of \ref plugActionList() ...
235 */ 235 */
236 void unplugActionList( const QString &name ); 236 void unplugActionList( const QString &name );
237 237
238//US static QString findMostRecentXMLFile( const QStringList &files, QString &doc ); 238//US static QString findMostRecentXMLFile( const QStringList &files, QString &doc );
239 239
240 void addStateActionEnabled(const QString& state, const QString& action); 240 void addStateActionEnabled(const QString& state, const QString& action);
241 241
242 void addStateActionDisabled(const QString& state, const QString& action); 242 void addStateActionDisabled(const QString& state, const QString& action);
243 243
244 enum ReverseStateChange { StateNoReverse, StateReverse }; 244 enum ReverseStateChange { StateNoReverse, StateReverse };
245 struct StateChange 245 struct StateChange
246 { 246 {
247 QStringList actionsToEnable; 247 QStringList actionsToEnable;
248 QStringList actionsToDisable; 248 QStringList actionsToDisable;
249 }; 249 };
250 250
251 StateChange getActionsToChangeForState(const QString& state); 251 StateChange getActionsToChangeForState(const QString& state);
252 252
253 /// @since 3.1 253 /// @since 3.1
254//US void beginXMLPlug( QWidget * ); 254//US void beginXMLPlug( QWidget * );
255 /// @since 3.1 255 /// @since 3.1
256//US void endXMLPlug(); 256//US void endXMLPlug();
257 /// @since 3.1 257 /// @since 3.1
258//US void prepareXMLUnplug( QWidget * ); 258//US void prepareXMLUnplug( QWidget * );
259 259
260protected: 260protected:
261 /** 261 /**
262 * Returns true if client was added to super client list. 262 * Returns true if client was added to super client list.
263 * Returns false if client was already in list. 263 * Returns false if client was already in list.
264 */ 264 */
265 //bool addSuperClient( KXMLGUIClient * ); 265 //bool addSuperClient( KXMLGUIClient * );
266 266
267 /** 267 /**
268 * Sets the instance (@ref KInstance) for this part. 268 * Sets the instance (@ref KInstance) for this part.
269 * 269 *
270 * Call this first in the inherited class constructor. 270 * Call this first in the inherited class constructor.
271 * (At least before @ref setXMLFile().) 271 * (At least before @ref setXMLFile().)
272 */ 272 */
273//US virtual void setInstance( KInstance *instance ); 273//US virtual void setInstance( KInstance *instance );
274 274
275 /** 275 /**
276 * Sets the name of the rc file containing the XML for the part. 276 * Sets the name of the rc file containing the XML for the part.
277 * 277 *
278 * Call this in the Part-inherited class constructor. 278 * Call this in the Part-inherited class constructor.
279 * 279 *
280 * @param file Either an absolute path for the file, or simply the 280 * @param file Either an absolute path for the file, or simply the
281 * filename, which will then be assumed to be installed 281 * filename, which will then be assumed to be installed
282 * in the "data" resource, under a directory named like 282 * in the "data" resource, under a directory named like
283 * the instance. 283 * the instance.
284 * @param setXML Specify whether to call setXML. Default is true. 284 * @param setXML Specify whether to call setXML. Default is true.
285 * and the DOM document at once. 285 * and the DOM document at once.
286 **/ 286 **/
287//US virtual void setXMLFile( const QString& file, bool merge = false, bool setXMLDoc = true ); 287//US virtual void setXMLFile( const QString& file, bool merge = false, bool setXMLDoc = true );
288 288
289//US virtual void setLocalXMLFile( const QString &file ); 289//US virtual void setLocalXMLFile( const QString &file );
290 290
291 /** 291 /**
292 * Sets the XML for the part. 292 * Sets the XML for the part.
293 * 293 *
294 * Call this in the Part-inherited class constructor if you 294 * Call this in the Part-inherited class constructor if you
295 * don't call @ref setXMLFile(). 295 * don't call @ref setXMLFile().
296 **/ 296 **/
297//US virtual void setXML( const QString &document, bool merge = false ); 297//US virtual void setXML( const QString &document, bool merge = false );
298 298
299 /** 299 /**
300 * Sets the Document for the part, describing the layout of the GUI. 300 * Sets the Document for the part, describing the layout of the GUI.
301 * 301 *
302 * Call this in the Part-inherited class constructor if you don't call 302 * Call this in the Part-inherited class constructor if you don't call
303 * @ref setXMLFile or @ref setXML . 303 * @ref setXMLFile or @ref setXML .
304 */ 304 */
305//US virtual void setDOMDocument( const QDomDocument &document, bool merge = false ); 305//US virtual void setDOMDocument( const QDomDocument &document, bool merge = false );
306 306
307 /** 307 /**
308 * This function will attempt to give up some memory after the GUI 308 * This function will attempt to give up some memory after the GUI
309 * is built. It should never be used in apps where the GUI may be 309 * is built. It should never be used in apps where the GUI may be
310 * rebuilt at some later time (components, for instance). 310 * rebuilt at some later time (components, for instance).
311 */ 311 */
312//US virtual void conserveMemory(); 312//US virtual void conserveMemory();
313 313
314 /** 314 /**
315 * Actions can collectively be assigned a "State". To accomplish this 315 * Actions can collectively be assigned a "State". To accomplish this
316 * the respective actions are tagged as <enable> or <disable> in 316 * the respective actions are tagged as <enable> or <disable> in
317 * a <State> </State> group of the XMLfile. During program execution the 317 * a <State> </State> group of the XMLfile. During program execution the
318 * programmer can call stateChanged() to set actions to a defined state. 318 * programmer can call stateChanged() to set actions to a defined state.
319 * 319 *
320 * @param newstate Name of a State in the XMLfile. 320 * @param newstate Name of a State in the XMLfile.
321 * @param reverse If the flag reverse is set to StateReverse, the State is reversed. 321 * @param reverse If the flag reverse is set to StateReverse, the State is reversed.
322 * (actions to be enabled will be disabled and action to be disabled will be enabled) 322 * (actions to be enabled will be disabled and action to be disabled will be enabled)
323 * Default is reverse=false. 323 * Default is reverse=false.
324 */ 324 */
325 virtual void stateChanged(const QString &newstate, ReverseStateChange reverse = StateNoReverse); 325 virtual void stateChanged(const QString &newstate, ReverseStateChange reverse = StateNoReverse);
326 326
327 // Use this one for KDE 4.0 327 // Use this one for KDE 4.0
328 //virtual void stateChanged(const QString &newstate, bool reverse = false); 328 //virtual void stateChanged(const QString &newstate, bool reverse = false);
329 329
330private: 330private:
331/*US 331/*US
332 struct DocStruct 332 struct DocStruct
333 { 333 {
334 QString file; 334 QString file;
335 QString data; 335 QString data;
336 }; 336 };
337 337
338 bool mergeXML( QDomElement &base, const QDomElement &additive, 338 bool mergeXML( QDomElement &base, const QDomElement &additive,
339 KActionCollection *actionCollection ); 339 KActionCollection *actionCollection );
340 340
341 QDomElement findMatchingElement( const QDomElement &base, 341 QDomElement findMatchingElement( const QDomElement &base,
342 const QDomElement &additive ); 342 const QDomElement &additive );
343*/ 343*/
344 typedef QMap<QString, QMap<QString, QString> > ActionPropertiesMap; 344 typedef QMap<QString, QMap<QString, QString> > ActionPropertiesMap;
345 345
346//US static ActionPropertiesMap extractActionProperties( const QDomDocument &doc ); 346//US static ActionPropertiesMap extractActionProperties( const QDomDocument &doc );
347 347
348//US static void storeActionProperties( QDomDocument &doc, const ActionPropertiesMap &properties ); 348//US static void storeActionProperties( QDomDocument &doc, const ActionPropertiesMap &properties );
349 349
350//US static QString findVersionNumber( const QString &_xml ); 350//US static QString findVersionNumber( const QString &_xml );
351 351
352 // Actions to enable/disable on a state change 352 // Actions to enable/disable on a state change
353 QMap<QString,StateChange> m_actionsStateMap; 353 QMap<QString,StateChange> m_actionsStateMap;
354 354
355protected: 355protected:
356 virtual void virtual_hook( int id, void* data ); 356 virtual void virtual_hook( int id, void* data );
357private: 357private:
358 KXMLGUIClientPrivate *d; 358 KXMLGUIClientPrivate *d;
359}; 359};
360 360
361#endif 361#endif
diff --git a/microkde/kdialog.cpp b/microkde/kdialog.cpp
index 8398956..57e7ea6 100644
--- a/microkde/kdialog.cpp
+++ b/microkde/kdialog.cpp
@@ -1,72 +1,74 @@
1 1
2#include <kdialog.h> 2#include <kdialog.h>
3#include <qapp.h> 3#include <qapplication.h>
4#include <qlabel.h> 4#include <qlabel.h>
5#include <qpushbutton.h> 5#include <qpushbutton.h>
6#include <qlayout.h> 6#include <qlayout.h>
7#include <qprogressbar.h> 7#include <q3progressbar.h>
8//Added by qt3to4:
9#include <Q3VBoxLayout>
8#include <klocale.h> 10#include <klocale.h>
9 11
10KDialog::KDialog( QWidget *parent, const char *name, bool modal ) : 12KDialog::KDialog( QWidget *parent, const char *name, bool modal ) :
11 QDialog( parent, name, modal ) 13 QDialog( parent, name, modal )
12{ 14{
13 ; 15 ;
14 16
15} 17}
16#ifdef DESKTOP_VERSION 18#ifdef DESKTOP_VERSION
17int KDialog::spacingHint() { return 7; } 19int KDialog::spacingHint() { return 7; }
18int KDialog::marginHint() { return 7; } 20int KDialog::marginHint() { return 7; }
19 21
20int KDialog::spacingHintSmall() { return 4; } 22int KDialog::spacingHintSmall() { return 4; }
21int KDialog::marginHintSmall() { return 4; } 23int KDialog::marginHintSmall() { return 4; }
22 24
23#else 25#else
24int KDialog::spacingHint() { return 3; } 26int KDialog::spacingHint() { return 3; }
25int KDialog::marginHint() { return 3; } 27int KDialog::marginHint() { return 3; }
26 28
27int KDialog::spacingHintSmall() { return 1; } 29int KDialog::spacingHintSmall() { return 1; }
28int KDialog::marginHintSmall() { return 1; } 30int KDialog::marginHintSmall() { return 1; }
29#endif 31#endif
30KProgressDialog::KProgressDialog( QWidget *parent, const char *name, bool modal ) : 32KProgressDialog::KProgressDialog( QWidget *parent, const char *name, bool modal ) :
31 QDialog( parent, name, modal ) 33 QDialog( parent, name, modal )
32{ 34{
33 QVBoxLayout* lay= new QVBoxLayout ( this ); 35 Q3VBoxLayout* lay= new Q3VBoxLayout ( this );
34 mLabel = new QLabel ( "abc",this ); 36 mLabel = new QLabel ( "abc",this );
35 mBar = new QProgressBar ( this ); 37 mBar = new Q3ProgressBar ( this );
36 mButton = new QPushButton ( i18n("Cancel"),this ); 38 mButton = new QPushButton ( i18n("Cancel"),this );
37 lay->addWidget ( mLabel ); 39 lay->addWidget ( mLabel );
38 lay->addWidget ( mBar ); 40 lay->addWidget ( mBar );
39 lay->addWidget ( mButton ); 41 lay->addWidget ( mButton );
40 connect ( mButton , SIGNAL ( clicked () ), this, SIGNAL ( cancelled () )); 42 connect ( mButton , SIGNAL ( clicked () ), this, SIGNAL ( cancelled () ));
41 resize ( 220, sizeHint().height() +mLabel->sizeHint().height()); 43 resize ( 220, sizeHint().height() +mLabel->sizeHint().height());
42 44
43} 45}
44 46
45void KProgressDialog::setLabelText ( const QString & t) 47void KProgressDialog::setLabelText ( const QString & t)
46{ 48{
47 mLabel->setText( t ); 49 mLabel->setText( t );
48} 50}
49 51
50void KProgressDialog::setTotalSteps ( int totalSteps ) 52void KProgressDialog::setTotalSteps ( int totalSteps )
51{ 53{
52 setActiveWindow(); 54 setActiveWindow();
53 setFocus(); 55 setFocus();
54 mBar->setTotalSteps ( totalSteps ); 56 mBar->setTotalSteps ( totalSteps );
55} 57}
56void KProgressDialog::setProgress ( int progress ) 58void KProgressDialog::setProgress ( int progress )
57{ 59{
58 setActiveWindow(); 60 setActiveWindow();
59 setFocus(); 61 setFocus();
60 mBar->setProgress ( progress ); 62 mBar->setProgress ( progress );
61} 63}
62void KProgressDialog::accept() 64void KProgressDialog::accept()
63{ 65{
64 mLabel->setText( i18n("Eeek, there I am ticklish!") ); 66 mLabel->setText( i18n("Eeek, there I am ticklish!") );
65 move ( geometry().x()-20,geometry().y()+20); 67 move ( geometry().x()-20,geometry().y()+20);
66 // QDialog::accept(); 68 // QDialog::accept();
67} 69}
68void KProgressDialog::reject() 70void KProgressDialog::reject()
69{ 71{
70 emit cancelled (); 72 emit cancelled ();
71 //QDialog::reject(); 73 //QDialog::reject();
72} 74}
diff --git a/microkde/kdialog.h b/microkde/kdialog.h
index bc80689..5f9bf0e 100644
--- a/microkde/kdialog.h
+++ b/microkde/kdialog.h
@@ -1,38 +1,40 @@
1#ifndef MINIKDE_KDIALOG_H 1#ifndef MINIKDE_KDIALOG_H
2#define MINIKDE_KDIALOG_H 2#define MINIKDE_KDIALOG_H
3 3
4#include <qdialog.h> 4#include <qdialog.h>
5//Added by qt3to4:
6#include <QLabel>
5class QLabel; 7class QLabel;
6class QProgressBar; 8class Q3ProgressBar;
7class QPushButton ; 9class QPushButton ;
8 10
9class KDialog : public QDialog 11class KDialog : public QDialog
10{ 12{
11 Q_OBJECT 13 Q_OBJECT
12 public: 14 public:
13 KDialog( QWidget *parent=0, const char *name=0, bool modal=true ); 15 KDialog( QWidget *parent=0, const char *name=0, bool modal=true );
14 16
15 static int spacingHint(); 17 static int spacingHint();
16 static int marginHint(); 18 static int marginHint();
17 static int spacingHintSmall(); 19 static int spacingHintSmall();
18 static int marginHintSmall(); 20 static int marginHintSmall();
19}; 21};
20class KProgressDialog : public QDialog 22class KProgressDialog : public QDialog
21{ 23{
22 Q_OBJECT 24 Q_OBJECT
23 public: 25 public:
24 KProgressDialog( QWidget *parent=0, const char *name=0, bool modal=false ); 26 KProgressDialog( QWidget *parent=0, const char *name=0, bool modal=false );
25 void setLabelText ( const QString & ); 27 void setLabelText ( const QString & );
26 void setTotalSteps ( int totalSteps ); 28 void setTotalSteps ( int totalSteps );
27 void setProgress ( int progress ); 29 void setProgress ( int progress );
28 void accept(); 30 void accept();
29 void reject(); 31 void reject();
30 private: 32 private:
31 QLabel * mLabel; 33 QLabel * mLabel;
32 QProgressBar *mBar; 34 Q3ProgressBar *mBar;
33 QPushButton *mButton; 35 QPushButton *mButton;
34 signals: 36 signals:
35 void cancelled (); 37 void cancelled ();
36}; 38};
37 39
38#endif 40#endif
diff --git a/microkde/kdialogbase.cpp b/microkde/kdialogbase.cpp
index d5c7e61..a40bad6 100644
--- a/microkde/kdialogbase.cpp
+++ b/microkde/kdialogbase.cpp
@@ -1,301 +1,305 @@
1#include <qtabwidget.h> 1#include <qtabwidget.h>
2#include <qpushbutton.h> 2#include <qpushbutton.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qframe.h> 4#include <q3frame.h>
5//Added by qt3to4:
6#include <QPixmap>
7#include <Q3HBoxLayout>
8#include <Q3VBoxLayout>
5 9
6 10
7#include "klocale.h" 11#include "klocale.h"
8#include "kdebug.h" 12#include "kdebug.h"
9 13
10#include "kdialogbase.h" 14#include "kdialogbase.h"
11 15
12KDialogBase::KDialogBase() 16KDialogBase::KDialogBase()
13{ 17{
14} 18}
15 19
16KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal, 20KDialogBase::KDialogBase( QWidget *parent, const char *name, bool modal,
17 const QString &caption, 21 const QString &caption,
18 int buttonMask, ButtonCode defaultButton, 22 int buttonMask, ButtonCode defaultButton,
19 bool separator, 23 bool separator,
20 const QString &user1, 24 const QString &user1,
21 const QString &user2, 25 const QString &user2,
22 const QString &user3) : 26 const QString &user3) :
23 KDialog( parent, name, modal ) 27 KDialog( parent, name, modal )
24{ 28{
25 init( caption, buttonMask, user1, user2 ); 29 init( caption, buttonMask, user1, user2 );
26 if (findButton( defaultButton ) ) { 30 if (findButton( defaultButton ) ) {
27 (findButton( defaultButton ) )->setFocus(); 31 (findButton( defaultButton ) )->setFocus();
28 (findButton( defaultButton ) )->setDefault( true ); 32 (findButton( defaultButton ) )->setDefault( true );
29 } 33 }
30 34
31} 35}
32 36
33KDialogBase::KDialogBase( int dialogFace, const QString &caption, 37KDialogBase::KDialogBase( int dialogFace, const QString &caption,
34 int buttonMask, ButtonCode defaultButton, 38 int buttonMask, ButtonCode defaultButton,
35 QWidget *parent, const char *name, bool modal, 39 QWidget *parent, const char *name, bool modal,
36 bool separator, 40 bool separator,
37 const QString &user1, 41 const QString &user1,
38 const QString &user2, 42 const QString &user2,
39 const QString &user3) : 43 const QString &user3) :
40 KDialog( parent, name, modal ) 44 KDialog( parent, name, modal )
41{ 45{
42 init( caption, buttonMask, user1, user2 ); 46 init( caption, buttonMask, user1, user2 );
43 if (findButton( defaultButton ) ) { 47 if (findButton( defaultButton ) ) {
44 (findButton( defaultButton ) )->setFocus(); 48 (findButton( defaultButton ) )->setFocus();
45 (findButton( defaultButton ) )->setDefault( true ); 49 (findButton( defaultButton ) )->setDefault( true );
46 } 50 }
47 51
48} 52}
49 53
50KDialogBase::~KDialogBase() 54KDialogBase::~KDialogBase()
51{ 55{
52} 56}
53 57
54void KDialogBase::init( const QString &caption, int buttonMask, 58void KDialogBase::init( const QString &caption, int buttonMask,
55 const QString &user1 ,const QString &user2 ) 59 const QString &user1 ,const QString &user2 )
56{ 60{
57 mMainWidget = 0; 61 mMainWidget = 0;
58 mTabWidget = 0; 62 mTabWidget = 0;
59 mPlainPage = 0; 63 mPlainPage = 0;
60 mTopLayout = 0; 64 mTopLayout = 0;
61 if ( !caption.isEmpty() ) { 65 if ( !caption.isEmpty() ) {
62 setCaption( caption ); 66 setCaption( caption );
63 } 67 }
64 68
65 if ( buttonMask & User1 ) { 69 if ( buttonMask & User1 ) {
66 mUser1Button = new QPushButton( user1, this ); 70 mUser1Button = new QPushButton( user1, this );
67 connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) ); 71 connect( mUser1Button, SIGNAL( clicked() ), SLOT( slotUser1() ) );
68 } else { 72 } else {
69 mUser1Button = 0; 73 mUser1Button = 0;
70 } 74 }
71 if ( buttonMask & User2 ) { 75 if ( buttonMask & User2 ) {
72 mUser2Button = new QPushButton( user2, this ); 76 mUser2Button = new QPushButton( user2, this );
73 connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) ); 77 connect( mUser2Button, SIGNAL( clicked() ), SLOT( slotUser2() ) );
74 } else { 78 } else {
75 mUser2Button = 0; 79 mUser2Button = 0;
76 } 80 }
77 81
78 if ( buttonMask & Ok ) { 82 if ( buttonMask & Ok ) {
79 mOkButton = new QPushButton( i18n("Ok"), this ); 83 mOkButton = new QPushButton( i18n("Ok"), this );
80 connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) ); 84 connect( mOkButton, SIGNAL( clicked() ), SLOT( slotOk() ) );
81 //mOkButton->setDefault( true ); 85 //mOkButton->setDefault( true );
82 } else { 86 } else {
83 mOkButton = 0; 87 mOkButton = 0;
84 } 88 }
85 if ( buttonMask & Default ) { 89 if ( buttonMask & Default ) {
86 mDefaultButton = new QPushButton( i18n("Default"), this ); 90 mDefaultButton = new QPushButton( i18n("Default"), this );
87 connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) ); 91 connect( mDefaultButton, SIGNAL( clicked() ), SIGNAL( defaultClicked() ) );
88 } else { 92 } else {
89 mDefaultButton = 0; 93 mDefaultButton = 0;
90 } 94 }
91 95
92 if ( buttonMask & Apply ) { 96 if ( buttonMask & Apply ) {
93 mApplyButton = new QPushButton( i18n("Apply"), this ); 97 mApplyButton = new QPushButton( i18n("Apply"), this );
94 connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) ); 98 connect( mApplyButton, SIGNAL( clicked() ), SLOT( slotApply() ) );
95 } else { 99 } else {
96 mApplyButton = 0; 100 mApplyButton = 0;
97 } 101 }
98 102
99 if ( buttonMask & Cancel ) { 103 if ( buttonMask & Cancel ) {
100 mCancelButton = new QPushButton( i18n("Cancel"), this ); 104 mCancelButton = new QPushButton( i18n("Cancel"), this );
101 connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) ); 105 connect( mCancelButton, SIGNAL( clicked() ), SLOT( slotCancel() ) );
102 } else { 106 } else {
103 mCancelButton = 0; 107 mCancelButton = 0;
104 } 108 }
105 109
106 if ( buttonMask & Close ) { 110 if ( buttonMask & Close ) {
107 mCloseButton = new QPushButton( i18n("Close"), this ); 111 mCloseButton = new QPushButton( i18n("Close"), this );
108 connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) ); 112 connect( mCloseButton, SIGNAL( clicked() ), SLOT( slotClose() ) );
109 } else { 113 } else {
110 mCloseButton = 0; 114 mCloseButton = 0;
111 } 115 }
112} 116}
113 117
114QTabWidget *KDialogBase::tabWidget() 118QTabWidget *KDialogBase::tabWidget()
115{ 119{
116 if ( !mTabWidget ) { 120 if ( !mTabWidget ) {
117 mTabWidget = new QTabWidget( this ); 121 mTabWidget = new QTabWidget( this );
118 setMainWidget( mTabWidget ); 122 setMainWidget( mTabWidget );
119 } 123 }
120 return mTabWidget; 124 return mTabWidget;
121} 125}
122 126
123void KDialogBase::hideButtons() 127void KDialogBase::hideButtons()
124{ 128{
125 if ( mUser1Button ) mUser1Button->hide() ; 129 if ( mUser1Button ) mUser1Button->hide() ;
126 if ( mUser2Button ) mUser2Button->hide() ; 130 if ( mUser2Button ) mUser2Button->hide() ;
127 if ( mOkButton ) mOkButton->hide() ; 131 if ( mOkButton ) mOkButton->hide() ;
128 if ( mApplyButton ) mApplyButton->hide() ; 132 if ( mApplyButton ) mApplyButton->hide() ;
129 if ( mDefaultButton ) mDefaultButton->hide(); 133 if ( mDefaultButton ) mDefaultButton->hide();
130 if ( mCancelButton ) mCancelButton->hide() ; 134 if ( mCancelButton ) mCancelButton->hide() ;
131 if ( mCloseButton ) mCloseButton->hide() ; 135 if ( mCloseButton ) mCloseButton->hide() ;
132 136
133} 137}
134void KDialogBase::initLayout() 138void KDialogBase::initLayout()
135{ 139{
136 140
137 delete mTopLayout; 141 delete mTopLayout;
138 mTopLayout = new QVBoxLayout( this ); 142 mTopLayout = new Q3VBoxLayout( this );
139 mTopLayout->setMargin( marginHintSmall() ); 143 mTopLayout->setMargin( marginHintSmall() );
140 mTopLayout->setSpacing( spacingHintSmall() ); 144 mTopLayout->setSpacing( spacingHintSmall() );
141 145
142 mTopLayout->addWidget( mMainWidget ); 146 mTopLayout->addWidget( mMainWidget );
143 147
144 QBoxLayout *buttonLayout = new QHBoxLayout; 148 Q3BoxLayout *buttonLayout = new Q3HBoxLayout;
145 mTopLayout->addLayout( buttonLayout ); 149 mTopLayout->addLayout( buttonLayout );
146 150
147 if ( mUser1Button ) buttonLayout->addWidget( mUser1Button ); 151 if ( mUser1Button ) buttonLayout->addWidget( mUser1Button );
148 if ( mUser2Button ) buttonLayout->addWidget( mUser2Button ); 152 if ( mUser2Button ) buttonLayout->addWidget( mUser2Button );
149 if ( mOkButton ) buttonLayout->addWidget( mOkButton ); 153 if ( mOkButton ) buttonLayout->addWidget( mOkButton );
150 if ( mApplyButton ) buttonLayout->addWidget( mApplyButton ); 154 if ( mApplyButton ) buttonLayout->addWidget( mApplyButton );
151 if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton ); 155 if ( mDefaultButton ) buttonLayout->addWidget( mDefaultButton );
152 if ( mCancelButton ) buttonLayout->addWidget( mCancelButton ); 156 if ( mCancelButton ) buttonLayout->addWidget( mCancelButton );
153 if ( mCloseButton ) buttonLayout->addWidget( mCloseButton ); 157 if ( mCloseButton ) buttonLayout->addWidget( mCloseButton );
154 buttonLayout->setMargin( marginHintSmall() ); 158 buttonLayout->setMargin( marginHintSmall() );
155 buttonLayout->setSpacing( spacingHintSmall() ); 159 buttonLayout->setSpacing( spacingHintSmall() );
156} 160}
157 161
158QFrame *KDialogBase::addPage( const QString &name ) 162Q3Frame *KDialogBase::addPage( const QString &name )
159{ 163{
160// kdDebug() << "KDialogBase::addPage(): " << name << endl; 164// kdDebug() << "KDialogBase::addPage(): " << name << endl;
161 QFrame *frame = new QFrame( tabWidget() ); 165 Q3Frame *frame = new Q3Frame( tabWidget() );
162 tabWidget()->addTab( frame, name ); 166 tabWidget()->addTab( frame, name );
163 return frame; 167 return frame;
164} 168}
165 169
166QFrame *KDialogBase::addPage( const QString &name, int, const QPixmap & ) 170Q3Frame *KDialogBase::addPage( const QString &name, int, const QPixmap & )
167{ 171{
168 return addPage( name ); 172 return addPage( name );
169} 173}
170 174
171 175
172void KDialogBase::setMainWidget( QWidget *widget ) 176void KDialogBase::setMainWidget( QWidget *widget )
173{ 177{
174 kdDebug() << "KDialogBase::setMainWidget()" << endl; 178 kdDebug() << "KDialogBase::setMainWidget()" << endl;
175 179
176 mMainWidget = widget; 180 mMainWidget = widget;
177 initLayout(); 181 initLayout();
178} 182}
179 183
180void KDialogBase::setButtonText( ButtonCode id, const QString &text ) 184void KDialogBase::setButtonText( ButtonCode id, const QString &text )
181{ 185{
182 QPushButton *button = findButton( id ); 186 QPushButton *button = findButton( id );
183 if ( button ) { 187 if ( button ) {
184 button->setText( text ); 188 button->setText( text );
185 } 189 }
186} 190}
187 191
188void KDialogBase::enableButton( ButtonCode id, bool state ) 192void KDialogBase::enableButton( ButtonCode id, bool state )
189{ 193{
190 QPushButton *button = findButton( id ); 194 QPushButton *button = findButton( id );
191 if ( button ) { 195 if ( button ) {
192 button->setEnabled( state ); 196 button->setEnabled( state );
193 } 197 }
194} 198}
195 199
196QPushButton *KDialogBase::findButton( ButtonCode id ) 200QPushButton *KDialogBase::findButton( ButtonCode id )
197{ 201{
198 QPushButton *button = 0; 202 QPushButton *button = 0;
199 switch ( id ) { 203 switch ( id ) {
200 case Ok: 204 case Ok:
201 button = mOkButton; 205 button = mOkButton;
202 break; 206 break;
203 case Apply: 207 case Apply:
204 button = mApplyButton; 208 button = mApplyButton;
205 break; 209 break;
206 case User1: 210 case User1:
207 button = mUser1Button; 211 button = mUser1Button;
208 break; 212 break;
209 case User2: 213 case User2:
210 button = mUser2Button; 214 button = mUser2Button;
211 break; 215 break;
212 case Cancel: 216 case Cancel:
213 button = mCancelButton; 217 button = mCancelButton;
214 break; 218 break;
215 case Default: 219 case Default:
216 button = mDefaultButton; 220 button = mDefaultButton;
217 break; 221 break;
218 case Close: 222 case Close:
219 button = mCloseButton; 223 button = mCloseButton;
220 break; 224 break;
221 default: 225 default:
222 break; 226 break;
223 } 227 }
224 return button; 228 return button;
225} 229}
226 230
227void KDialogBase::enableButtonOK( bool state ) 231void KDialogBase::enableButtonOK( bool state )
228{ 232{
229 enableButton( Ok, state ); 233 enableButton( Ok, state );
230} 234}
231 235
232void KDialogBase::enableButtonApply( bool state ) 236void KDialogBase::enableButtonApply( bool state )
233{ 237{
234 enableButton( Apply, state ); 238 enableButton( Apply, state );
235} 239}
236 240
237void KDialogBase::showButton( ButtonCode id, bool show ) 241void KDialogBase::showButton( ButtonCode id, bool show )
238{ 242{
239 QPushButton *button = findButton( id ); 243 QPushButton *button = findButton( id );
240 if ( button ) { 244 if ( button ) {
241 if ( show ) button->show(); 245 if ( show ) button->show();
242 else button->hide(); 246 else button->hide();
243 } 247 }
244} 248}
245 249
246int KDialogBase::pageIndex( QWidget *widget ) const 250int KDialogBase::pageIndex( QWidget *widget ) const
247{ 251{
248 return 0; 252 return 0;
249} 253}
250 254
251 255
252bool KDialogBase::showPage( int index ) 256bool KDialogBase::showPage( int index )
253{ 257{
254 tabWidget()->setCurrentPage( index );return false; 258 tabWidget()->setCurrentPage( index );return false;
255} 259}
256 260
257QFrame *KDialogBase::plainPage() 261Q3Frame *KDialogBase::plainPage()
258{ 262{
259 if ( !mPlainPage ) { 263 if ( !mPlainPage ) {
260 mPlainPage = new QFrame( this ); 264 mPlainPage = new Q3Frame( this );
261 setMainWidget( mPlainPage ); 265 setMainWidget( mPlainPage );
262 } 266 }
263 return mPlainPage; 267 return mPlainPage;
264} 268}
265 269
266void KDialogBase::slotOk() 270void KDialogBase::slotOk()
267{ 271{
268 emit okClicked(); 272 emit okClicked();
269 accept(); 273 accept();
270} 274}
271 275
272void KDialogBase::slotApply() 276void KDialogBase::slotApply()
273{ 277{
274 emit applyClicked(); 278 emit applyClicked();
275} 279}
276 280
277void KDialogBase::slotCancel() 281void KDialogBase::slotCancel()
278{ 282{
279 emit cancelClicked(); 283 emit cancelClicked();
280 reject(); 284 reject();
281} 285}
282 286
283void KDialogBase::slotClose() 287void KDialogBase::slotClose()
284{ 288{
285 emit closeClicked(); 289 emit closeClicked();
286 reject(); 290 reject();
287} 291}
288 292
289void KDialogBase::accept () 293void KDialogBase::accept ()
290{ 294{
291 emit acceptClicked(); 295 emit acceptClicked();
292 KDialog::accept(); 296 KDialog::accept();
293} 297}
294void KDialogBase::slotUser1() 298void KDialogBase::slotUser1()
295{ 299{
296 emit user1Clicked(); 300 emit user1Clicked();
297} 301}
298void KDialogBase::slotUser2() 302void KDialogBase::slotUser2()
299{ 303{
300 emit user2Clicked(); 304 emit user2Clicked();
301} 305}
diff --git a/microkde/kdialogbase.h b/microkde/kdialogbase.h
index 17c186b..64cbd17 100644
--- a/microkde/kdialogbase.h
+++ b/microkde/kdialogbase.h
@@ -1,143 +1,145 @@
1#ifndef MINIKDE_KDIALOGBASE_H 1#ifndef MINIKDE_KDIALOGBASE_H
2#define MINIKDE_KDIALOGBASE_H 2#define MINIKDE_KDIALOGBASE_H
3 3
4#include <qframe.h> 4#include <q3frame.h>
5//Added by qt3to4:
6#include <QPixmap>
5 7
6#include "kdialog.h" 8#include "kdialog.h"
7 9
8class QPushButton; 10class QPushButton;
9class QLayout; 11class QLayout;
10class QTabWidget; 12class QTabWidget;
11class QBoxLayout; 13class Q3BoxLayout;
12 14
13class KDialogBase : public KDialog 15class KDialogBase : public KDialog
14{ 16{
15 Q_OBJECT 17 Q_OBJECT
16 public: 18 public:
17 enum ButtonCode 19 enum ButtonCode
18 { 20 {
19 Help = 0x00000001, 21 Help = 0x00000001,
20 Default = 0x00000002, 22 Default = 0x00000002,
21 Ok = 0x00000004, 23 Ok = 0x00000004,
22 Apply = 0x00000008, 24 Apply = 0x00000008,
23 Try = 0x00000010, 25 Try = 0x00000010,
24 Cancel = 0x00000020, 26 Cancel = 0x00000020,
25 Close = 0x00000040, 27 Close = 0x00000040,
26 User1 = 0x00000080, 28 User1 = 0x00000080,
27 User2 = 0x00000100, 29 User2 = 0x00000100,
28 User3 = 0x00000200, 30 User3 = 0x00000200,
29 No = 0x00000080, 31 No = 0x00000080,
30 Yes = 0x00000100, 32 Yes = 0x00000100,
31 Details = 0x00000400, 33 Details = 0x00000400,
32 Filler = 0x40000000, 34 Filler = 0x40000000,
33 Stretch = 0x80000000 35 Stretch = 0x80000000
34 }; 36 };
35 37
36 enum DialogType 38 enum DialogType
37 { 39 {
38 TreeList, 40 TreeList,
39 Tabbed, 41 Tabbed,
40 Plain, 42 Plain,
41 Swallow, 43 Swallow,
42 IconList 44 IconList
43 }; 45 };
44 46
45 KDialogBase(); 47 KDialogBase();
46 KDialogBase( QWidget *parent=0, const char *name=0, bool modal=true, 48 KDialogBase( QWidget *parent=0, const char *name=0, bool modal=true,
47 const QString &caption=QString::null, 49 const QString &caption=QString::null,
48 int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok, 50 int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok,
49 bool separator=false, 51 bool separator=false,
50 const QString &user1=QString::null, 52 const QString &user1=QString::null,
51 const QString &user2=QString::null, 53 const QString &user2=QString::null,
52 const QString &user3=QString::null); 54 const QString &user3=QString::null);
53 KDialogBase( int dialogFace, const QString &caption, 55 KDialogBase( int dialogFace, const QString &caption,
54 int buttonMask, ButtonCode defaultButton, 56 int buttonMask, ButtonCode defaultButton,
55 QWidget *parent=0, const char *name=0, bool modal=true, 57 QWidget *parent=0, const char *name=0, bool modal=true,
56 bool separator=false, 58 bool separator=false,
57 const QString &user1=QString::null, 59 const QString &user1=QString::null,
58 const QString &user2=QString::null, 60 const QString &user2=QString::null,
59 const QString &user3=QString::null); 61 const QString &user3=QString::null);
60 virtual ~KDialogBase(); 62 virtual ~KDialogBase();
61 63
62 QFrame *addPage( const QString & ); 64 Q3Frame *addPage( const QString & );
63 QFrame *addPage( const QString &, int, const QPixmap & ); 65 Q3Frame *addPage( const QString &, int, const QPixmap & );
64 66
65 void setMainWidget( QWidget *widget ); 67 void setMainWidget( QWidget *widget );
66 68
67 void setButtonText( ButtonCode id, const QString &text ); 69 void setButtonText( ButtonCode id, const QString &text );
68 70
69 void enableButton( ButtonCode id, bool state ); 71 void enableButton( ButtonCode id, bool state );
70 void enableButtonOK( bool state ); 72 void enableButtonOK( bool state );
71 void enableButtonApply( bool state ); 73 void enableButtonApply( bool state );
72 74
73 void showButton( ButtonCode, bool show ); 75 void showButton( ButtonCode, bool show );
74 76
75 int pageIndex( QWidget *widget ) const; 77 int pageIndex( QWidget *widget ) const;
76 78
77 bool showPage( int index ); 79 bool showPage( int index );
78 void hideButtons(); 80 void hideButtons();
79 81
80 QFrame *plainPage(); 82 Q3Frame *plainPage();
81 83
82 signals: 84 signals:
83 void user1Clicked(); 85 void user1Clicked();
84 void user2Clicked(); 86 void user2Clicked();
85 /** 87 /**
86 * The Apply button was pressed. This signal is only emitted if 88 * The Apply button was pressed. This signal is only emitted if
87 * @ref slotApply() is not replaced. 89 * @ref slotApply() is not replaced.
88 */ 90 */
89 void applyClicked(); 91 void applyClicked();
90 92
91 /** 93 /**
92 * The OK button was pressed. This signal is only emitted if 94 * The OK button was pressed. This signal is only emitted if
93 * @ref slotOk() is not replaced. 95 * @ref slotOk() is not replaced.
94 */ 96 */
95 void okClicked(); 97 void okClicked();
96 98
97 /** 99 /**
98 * The Cancel button was pressed. This signal is only emitted if 100 * The Cancel button was pressed. This signal is only emitted if
99 * @ref slotCancel() is not replaced. 101 * @ref slotCancel() is not replaced.
100 */ 102 */
101 void cancelClicked(); 103 void cancelClicked();
102 104
103 /** 105 /**
104 * The Close button was pressed. This signal is only emitted if 106 * The Close button was pressed. This signal is only emitted if
105 * @ref slotClose() is not replaced. 107 * @ref slotClose() is not replaced.
106 */ 108 */
107 void closeClicked(); 109 void closeClicked();
108 void defaultClicked(); 110 void defaultClicked();
109 111
110 void acceptClicked(); 112 void acceptClicked();
111 113
112 protected slots: 114 protected slots:
113 virtual void slotOk(); 115 virtual void slotOk();
114 virtual void slotApply(); 116 virtual void slotApply();
115 virtual void slotCancel(); 117 virtual void slotCancel();
116 virtual void slotClose(); 118 virtual void slotClose();
117 virtual void slotUser1(); 119 virtual void slotUser1();
118 virtual void slotUser2(); 120 virtual void slotUser2();
119 virtual void accept (); 121 virtual void accept ();
120 protected: 122 protected:
121 QPushButton *findButton( ButtonCode ); 123 QPushButton *findButton( ButtonCode );
122 QTabWidget *tabWidget(); 124 QTabWidget *tabWidget();
123 125
124 private: 126 private:
125 void init( const QString &caption, int buttonMask, 127 void init( const QString &caption, int buttonMask,
126 const QString &user1=QString::null, const QString &user2=QString::null ); 128 const QString &user1=QString::null, const QString &user2=QString::null );
127 void initLayout(); 129 void initLayout();
128 130
129 QWidget *mMainWidget; 131 QWidget *mMainWidget;
130 QTabWidget *mTabWidget; 132 QTabWidget *mTabWidget;
131 QFrame *mPlainPage; 133 Q3Frame *mPlainPage;
132 QBoxLayout *mTopLayout; 134 Q3BoxLayout *mTopLayout;
133 135
134 QPushButton *mUser1Button; 136 QPushButton *mUser1Button;
135 QPushButton *mUser2Button; 137 QPushButton *mUser2Button;
136 QPushButton *mCloseButton; 138 QPushButton *mCloseButton;
137 QPushButton *mOkButton; 139 QPushButton *mOkButton;
138 QPushButton *mApplyButton; 140 QPushButton *mApplyButton;
139 QPushButton *mCancelButton; 141 QPushButton *mCancelButton;
140 QPushButton *mDefaultButton; 142 QPushButton *mDefaultButton;
141}; 143};
142 144
143#endif 145#endif
diff --git a/microkde/keditlistbox.cpp b/microkde/keditlistbox.cpp
index 55b7784..257a44a 100644
--- a/microkde/keditlistbox.cpp
+++ b/microkde/keditlistbox.cpp
@@ -1,389 +1,394 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org> 2 Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org>
3 2000, 2002 Carsten Pfeiffer <pfeiffer@kde.org> 3 2000, 2002 Carsten Pfeiffer <pfeiffer@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <qstringlist.h> 21#include <qstringlist.h>
22#include <qpushbutton.h> 22#include <qpushbutton.h>
23#include <qlayout.h> 23#include <qlayout.h>
24#include <qgroupbox.h> 24#include <q3groupbox.h>
25#include <qlistbox.h> 25#include <q3listbox.h>
26#include <qwhatsthis.h> 26#include <q3whatsthis.h>
27#include <qlabel.h> 27#include <qlabel.h>
28//Added by qt3to4:
29#include <Q3GridLayout>
30#include <Q3StrList>
28 31
29#include <kcombobox.h> 32#include <kcombobox.h>
30#include <kdebug.h> 33#include <kdebug.h>
31#include <kdialog.h> 34#include <kdialog.h>
32#include <klineedit.h> 35#include <klineedit.h>
33#include <klocale.h> 36#include <klocale.h>
34#include <kapplication.h> 37#include <kapplication.h>
35#include <knotifyclient.h> 38#include <knotifyclient.h>
36 39
37#include "keditlistbox.h" 40#include "keditlistbox.h"
38 41
39#include <assert.h> 42#include <assert.h>
40 43
41class KEditListBoxPrivate 44class KEditListBoxPrivate
42{ 45{
43public: 46public:
44 bool m_checkAtEntering; 47 bool m_checkAtEntering;
45 int buttons; 48 int buttons;
46}; 49};
47 50
48KEditListBox::KEditListBox(QWidget *parent, const char *name, 51KEditListBox::KEditListBox(QWidget *parent, const char *name,
49 bool checkAtEntering, int buttons ) 52 bool checkAtEntering, int buttons )
50 :QGroupBox(parent, name ) 53 :Q3GroupBox(parent, name )
51{ 54{
52 init( checkAtEntering, buttons ); 55 init( checkAtEntering, buttons );
53} 56}
54 57
55KEditListBox::KEditListBox(const QString& title, QWidget *parent, 58KEditListBox::KEditListBox(const QString& title, QWidget *parent,
56 const char *name, bool checkAtEntering, int buttons) 59 const char *name, bool checkAtEntering, int buttons)
57 :QGroupBox(title, parent, name ) 60 :Q3GroupBox(title, parent, name )
58{ 61{
59 init( checkAtEntering, buttons ); 62 init( checkAtEntering, buttons );
60} 63}
61 64
62KEditListBox::KEditListBox(const QString& title, const CustomEditor& custom, 65KEditListBox::KEditListBox(const QString& title, const CustomEditor& custom,
63 QWidget *parent, const char *name, 66 QWidget *parent, const char *name,
64 bool checkAtEntering, int buttons) 67 bool checkAtEntering, int buttons)
65 :QGroupBox(title, parent, name ) 68 :Q3GroupBox(title, parent, name )
66{ 69{
67 m_lineEdit = custom.lineEdit(); 70 m_lineEdit = custom.lineEdit();
68 init( checkAtEntering, buttons, custom.representationWidget() ); 71 init( checkAtEntering, buttons, custom.representationWidget() );
69} 72}
70 73
71KEditListBox::~KEditListBox() 74KEditListBox::~KEditListBox()
72{ 75{
73 delete d; 76 delete d;
74 d=0; 77 d=0;
75} 78}
76 79
77void KEditListBox::init( bool checkAtEntering, int buttons, 80void KEditListBox::init( bool checkAtEntering, int buttons,
78 QWidget *representationWidget ) 81 QWidget *representationWidget )
79{ 82{
80 d=new KEditListBoxPrivate; 83 d=new KEditListBoxPrivate;
81 d->m_checkAtEntering=checkAtEntering; 84 d->m_checkAtEntering=checkAtEntering;
82 d->buttons = buttons; 85 d->buttons = buttons;
83 86
84 int lostButtons = 0; 87 int lostButtons = 0;
85 if ( (buttons & Add) == 0 ) 88 if ( (buttons & Add) == 0 )
86 lostButtons++; 89 lostButtons++;
87 if ( (buttons & Remove) == 0 ) 90 if ( (buttons & Remove) == 0 )
88 lostButtons++; 91 lostButtons++;
89 if ( (buttons & UpDown) == 0 ) 92 if ( (buttons & UpDown) == 0 )
90 lostButtons += 2; 93 lostButtons += 2;
91 94
92 95
93 servNewButton = servRemoveButton = servUpButton = servDownButton = 0L; 96 servNewButton = servRemoveButton = servUpButton = servDownButton = 0L;
94 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, 97 setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding,
95 QSizePolicy::MinimumExpanding)); 98 QSizePolicy::MinimumExpanding));
96 99
97 QWidget * gb = this; 100 QWidget * gb = this;
98 QGridLayout * grid = new QGridLayout(gb, 7 - lostButtons, 2, 101 Q3GridLayout * grid = new Q3GridLayout(gb, 7 - lostButtons, 2,
99 KDialog::marginHint(), 102 KDialog::marginHint(),
100 KDialog::spacingHint()); 103 KDialog::spacingHint());
101 grid->addRowSpacing(0, fontMetrics().lineSpacing()); 104 grid->addRowSpacing(0, fontMetrics().lineSpacing());
102 for ( int i = 1; i < 7 - lostButtons; i++ ) 105 for ( int i = 1; i < 7 - lostButtons; i++ )
103 grid->setRowStretch(i, 1); 106 grid->setRowStretch(i, 1);
104 107
105 grid->setMargin(15); 108 grid->setMargin(15);
106 109
107 if ( representationWidget ) 110 if ( representationWidget )
108 representationWidget->reparent( gb, QPoint(0,0) ); 111 representationWidget->reparent( gb, QPoint(0,0) );
109 else 112 else
110 m_lineEdit=new KLineEdit(gb); 113 m_lineEdit=new KLineEdit(gb);
111 114
112 m_listBox = new QListBox(gb); 115 m_listBox = new Q3ListBox(gb);
113 116
114 QWidget *editingWidget = representationWidget ? 117 QWidget *editingWidget = representationWidget ?
115 representationWidget : m_lineEdit; 118 representationWidget : m_lineEdit;
116 grid->addMultiCellWidget(editingWidget,1,1,0,1); 119 grid->addMultiCellWidget(editingWidget,1,1,0,1);
117 grid->addMultiCellWidget(m_listBox, 2, 6 - lostButtons, 0, 0); 120 grid->addMultiCellWidget(m_listBox, 2, 6 - lostButtons, 0, 0);
118 int row = 2; 121 int row = 2;
119 if ( buttons & Add ) { 122 if ( buttons & Add ) {
120 servNewButton = new QPushButton(i18n("&Add"), gb); 123 servNewButton = new QPushButton(i18n("&Add"), gb);
121 servNewButton->setEnabled(false); 124 servNewButton->setEnabled(false);
122 connect(servNewButton, SIGNAL(clicked()), SLOT(addItem())); 125 connect(servNewButton, SIGNAL(clicked()), SLOT(addItem()));
123 126
124 grid->addWidget(servNewButton, row++, 1); 127 grid->addWidget(servNewButton, row++, 1);
125 } 128 }
126 129
127 if ( buttons & Remove ) { 130 if ( buttons & Remove ) {
128 servRemoveButton = new QPushButton(i18n("&Remove"), gb); 131 servRemoveButton = new QPushButton(i18n("&Remove"), gb);
129 servRemoveButton->setEnabled(false); 132 servRemoveButton->setEnabled(false);
130 connect(servRemoveButton, SIGNAL(clicked()), SLOT(removeItem())); 133 connect(servRemoveButton, SIGNAL(clicked()), SLOT(removeItem()));
131 134
132 grid->addWidget(servRemoveButton, row++, 1); 135 grid->addWidget(servRemoveButton, row++, 1);
133 } 136 }
134 137
135 if ( buttons & UpDown ) { 138 if ( buttons & UpDown ) {
136 servUpButton = new QPushButton(i18n("Move &Up"), gb); 139 servUpButton = new QPushButton(i18n("Move &Up"), gb);
137 servUpButton->setEnabled(false); 140 servUpButton->setEnabled(false);
138 connect(servUpButton, SIGNAL(clicked()), SLOT(moveItemUp())); 141 connect(servUpButton, SIGNAL(clicked()), SLOT(moveItemUp()));
139 142
140 servDownButton = new QPushButton(i18n("Move &Down"), gb); 143 servDownButton = new QPushButton(i18n("Move &Down"), gb);
141 servDownButton->setEnabled(false); 144 servDownButton->setEnabled(false);
142 connect(servDownButton, SIGNAL(clicked()), SLOT(moveItemDown())); 145 connect(servDownButton, SIGNAL(clicked()), SLOT(moveItemDown()));
143 146
144 grid->addWidget(servUpButton, row++, 1); 147 grid->addWidget(servUpButton, row++, 1);
145 grid->addWidget(servDownButton, row++, 1); 148 grid->addWidget(servDownButton, row++, 1);
146 } 149 }
147 150
148 connect(m_lineEdit,SIGNAL(textChanged(const QString&)),this,SLOT(typedSomething(const QString&))); 151 connect(m_lineEdit,SIGNAL(textChanged(const QString&)),this,SLOT(typedSomething(const QString&)));
149 m_lineEdit->setTrapReturnKey(true); 152 m_lineEdit->setTrapReturnKey(true);
150 connect(m_lineEdit,SIGNAL(returnPressed()),this,SLOT(addItem())); 153 connect(m_lineEdit,SIGNAL(returnPressed()),this,SLOT(addItem()));
151 connect(m_listBox, SIGNAL(highlighted(int)), SLOT(enableMoveButtons(int))); 154 connect(m_listBox, SIGNAL(highlighted(int)), SLOT(enableMoveButtons(int)));
152 155
153 // maybe supplied lineedit has some text already 156 // maybe supplied lineedit has some text already
154 typedSomething( m_lineEdit->text() ); 157 typedSomething( m_lineEdit->text() );
155} 158}
156 159
157void KEditListBox::typedSomething(const QString& text) 160void KEditListBox::typedSomething(const QString& text)
158{ 161{
159 if(currentItem() >= 0) { 162 if(currentItem() >= 0) {
160 if(currentText() != m_lineEdit->text()) 163 if(currentText() != m_lineEdit->text())
161 { 164 {
162 // IMHO changeItem() shouldn't do anything with the value 165 // IMHO changeItem() shouldn't do anything with the value
163 // of currentItem() ... like changing it or emitting signals ... 166 // of currentItem() ... like changing it or emitting signals ...
164 // but TT disagree with me on this one (it's been that way since ages ... grrr) 167 // but TT disagree with me on this one (it's been that way since ages ... grrr)
165 bool block = m_listBox->signalsBlocked(); 168 bool block = m_listBox->signalsBlocked();
166 m_listBox->blockSignals( true ); 169 m_listBox->blockSignals( true );
167 m_listBox->changeItem(text, currentItem()); 170 m_listBox->changeItem(text, currentItem());
168 m_listBox->blockSignals( block ); 171 m_listBox->blockSignals( block );
169 emit changed(); 172 emit changed();
170 } 173 }
171 } 174 }
172 175
173 if ( !servNewButton ) 176 if ( !servNewButton )
174 return; 177 return;
175 178
176 if (!d->m_checkAtEntering) 179 if (!d->m_checkAtEntering)
177 servNewButton->setEnabled(!text.isEmpty()); 180 servNewButton->setEnabled(!text.isEmpty());
178 else 181 else
179 { 182 {
180 if (text.isEmpty()) 183 if (text.isEmpty())
181 { 184 {
182 servNewButton->setEnabled(false); 185 servNewButton->setEnabled(false);
183 } 186 }
184 else 187 else
185 { 188 {
186 bool enable = (m_listBox->findItem( text ) == 0L); 189 bool enable = (m_listBox->findItem( text ) == 0L);
187 servNewButton->setEnabled( enable ); 190 servNewButton->setEnabled( enable );
188 } 191 }
189 } 192 }
190} 193}
191 194
192void KEditListBox::moveItemUp() 195void KEditListBox::moveItemUp()
193{ 196{
194 if (!m_listBox->isEnabled()) 197 if (!m_listBox->isEnabled())
195 { 198 {
196 KNotifyClient::beep(); 199 KNotifyClient::beep();
197 return; 200 return;
198 } 201 }
199 202
200 unsigned int selIndex = m_listBox->currentItem(); 203 unsigned int selIndex = m_listBox->currentItem();
201 if (selIndex == 0) 204 if (selIndex == 0)
202 { 205 {
203 KNotifyClient::beep(); 206 KNotifyClient::beep();
204 return; 207 return;
205 } 208 }
206 209
207 QListBoxItem *selItem = m_listBox->item(selIndex); 210 Q3ListBoxItem *selItem = m_listBox->item(selIndex);
208 m_listBox->takeItem(selItem); 211 m_listBox->takeItem(selItem);
209 m_listBox->insertItem(selItem, selIndex-1); 212 m_listBox->insertItem(selItem, selIndex-1);
210 m_listBox->setCurrentItem(selIndex - 1); 213 m_listBox->setCurrentItem(selIndex - 1);
211 214
212 emit changed(); 215 emit changed();
213} 216}
214 217
215void KEditListBox::moveItemDown() 218void KEditListBox::moveItemDown()
216{ 219{
217 if (!m_listBox->isEnabled()) 220 if (!m_listBox->isEnabled())
218 { 221 {
219 KNotifyClient::beep(); 222 KNotifyClient::beep();
220 return; 223 return;
221 } 224 }
222 225
223 unsigned int selIndex = m_listBox->currentItem(); 226 unsigned int selIndex = m_listBox->currentItem();
224 if (selIndex == m_listBox->count() - 1) 227 if (selIndex == m_listBox->count() - 1)
225 { 228 {
226 KNotifyClient::beep(); 229 KNotifyClient::beep();
227 return; 230 return;
228 } 231 }
229 232
230 QListBoxItem *selItem = m_listBox->item(selIndex); 233 Q3ListBoxItem *selItem = m_listBox->item(selIndex);
231 m_listBox->takeItem(selItem); 234 m_listBox->takeItem(selItem);
232 m_listBox->insertItem(selItem, selIndex+1); 235 m_listBox->insertItem(selItem, selIndex+1);
233 m_listBox->setCurrentItem(selIndex + 1); 236 m_listBox->setCurrentItem(selIndex + 1);
234 237
235 emit changed(); 238 emit changed();
236} 239}
237 240
238void KEditListBox::addItem() 241void KEditListBox::addItem()
239{ 242{
240 // when m_checkAtEntering is true, the add-button is disabled, but this 243 // when m_checkAtEntering is true, the add-button is disabled, but this
241 // slot can still be called through Key_Return/Key_Enter. So we guard 244 // slot can still be called through Key_Return/Key_Enter. So we guard
242 // against this. 245 // against this.
243 if ( !servNewButton || !servNewButton->isEnabled() ) 246 if ( !servNewButton || !servNewButton->isEnabled() )
244 return; 247 return;
245 248
246 const QString& currentTextLE=m_lineEdit->text(); 249 const QString& currentTextLE=m_lineEdit->text();
247 bool alreadyInList(false); 250 bool alreadyInList(false);
248 //if we didn't check for dupes at the inserting we have to do it now 251 //if we didn't check for dupes at the inserting we have to do it now
249 if (!d->m_checkAtEntering) 252 if (!d->m_checkAtEntering)
250 { 253 {
251 // first check current item instead of dumb iterating the entire list 254 // first check current item instead of dumb iterating the entire list
252 if ( m_listBox->currentText() == currentTextLE ) 255 if ( m_listBox->currentText() == currentTextLE )
253 alreadyInList = true; 256 alreadyInList = true;
254 else 257 else
255 { 258 {
256 alreadyInList =(m_listBox->findItem(currentTextLE) != 0); 259 alreadyInList =(m_listBox->findItem(currentTextLE) != 0);
257 } 260 }
258 } 261 }
259 262
260 if ( servNewButton ) 263 if ( servNewButton )
261 servNewButton->setEnabled(false); 264 servNewButton->setEnabled(false);
262 265
263 bool block = m_lineEdit->signalsBlocked(); 266 bool block = m_lineEdit->signalsBlocked();
264 m_lineEdit->blockSignals(true); 267 m_lineEdit->blockSignals(true);
265 m_lineEdit->clear(); 268 m_lineEdit->clear();
266 m_lineEdit->blockSignals(block); 269 m_lineEdit->blockSignals(block);
267 270
268 m_listBox->setSelected(currentItem(), false); 271 m_listBox->setSelected(currentItem(), false);
269 272
270 if (!alreadyInList) 273 if (!alreadyInList)
271 { 274 {
272 block = m_listBox->signalsBlocked(); 275 block = m_listBox->signalsBlocked();
273 m_listBox->blockSignals( true ); 276 m_listBox->blockSignals( true );
274 m_listBox->insertItem(currentTextLE); 277 m_listBox->insertItem(currentTextLE);
275 m_listBox->blockSignals( block ); 278 m_listBox->blockSignals( block );
276 emit changed(); 279 emit changed();
277 } 280 }
278} 281}
279 282
280int KEditListBox::currentItem() const 283int KEditListBox::currentItem() const
281{ 284{
282 int nr = m_listBox->currentItem(); 285 int nr = m_listBox->currentItem();
283 if(nr >= 0 && !m_listBox->item(nr)->selected()) return -1; 286 if(nr >= 0 && !m_listBox->item(nr)->selected()) return -1;
284 return nr; 287 return nr;
285} 288}
286 289
287void KEditListBox::removeItem() 290void KEditListBox::removeItem()
288{ 291{
289 int selected = m_listBox->currentItem(); 292 int selected = m_listBox->currentItem();
290 293
291 if ( selected >= 0 ) 294 if ( selected >= 0 )
292 { 295 {
293 m_listBox->removeItem( selected ); 296 m_listBox->removeItem( selected );
294 if ( count() > 0 ) 297 if ( count() > 0 )
295 m_listBox->setSelected( QMIN( selected, count() - 1 ), true ); 298 m_listBox->setSelected( QMIN( selected, count() - 1 ), true );
296 299
297 emit changed(); 300 emit changed();
298 } 301 }
299 302
300 if ( servRemoveButton && m_listBox->currentItem() == -1 ) 303 if ( servRemoveButton && m_listBox->currentItem() == -1 )
301 servRemoveButton->setEnabled(false); 304 servRemoveButton->setEnabled(false);
302} 305}
303 306
304void KEditListBox::enableMoveButtons(int index) 307void KEditListBox::enableMoveButtons(int index)
305{ 308{
306 // Update the lineEdit when we select a different line. 309 // Update the lineEdit when we select a different line.
307 if(currentText() != m_lineEdit->text()) 310 if(currentText() != m_lineEdit->text())
308 m_lineEdit->setText(currentText()); 311 m_lineEdit->setText(currentText());
309 312
310 bool moveEnabled = servUpButton && servDownButton; 313 bool moveEnabled = servUpButton && servDownButton;
311 314
312 if (moveEnabled ) 315 if (moveEnabled )
313 { 316 {
314 if (m_listBox->count() <= 1) 317 if (m_listBox->count() <= 1)
315 { 318 {
316 servUpButton->setEnabled(false); 319 servUpButton->setEnabled(false);
317 servDownButton->setEnabled(false); 320 servDownButton->setEnabled(false);
318 } 321 }
319 else if ((uint) index == (m_listBox->count() - 1)) 322 else if ((uint) index == (m_listBox->count() - 1))
320 { 323 {
321 servUpButton->setEnabled(true); 324 servUpButton->setEnabled(true);
322 servDownButton->setEnabled(false); 325 servDownButton->setEnabled(false);
323 } 326 }
324 else if (index == 0) 327 else if (index == 0)
325 { 328 {
326 servUpButton->setEnabled(false); 329 servUpButton->setEnabled(false);
327 servDownButton->setEnabled(true); 330 servDownButton->setEnabled(true);
328 } 331 }
329 else 332 else
330 { 333 {
331 servUpButton->setEnabled(true); 334 servUpButton->setEnabled(true);
332 servDownButton->setEnabled(true); 335 servDownButton->setEnabled(true);
333 } 336 }
334 } 337 }
335 338
336 if ( servRemoveButton ) 339 if ( servRemoveButton )
337 servRemoveButton->setEnabled(true); 340 servRemoveButton->setEnabled(true);
338} 341}
339 342
340void KEditListBox::clear() 343void KEditListBox::clear()
341{ 344{
342 m_lineEdit->clear(); 345 m_lineEdit->clear();
343 m_listBox->clear(); 346 m_listBox->clear();
344 emit changed(); 347 emit changed();
345} 348}
346 349
347void KEditListBox::insertStringList(const QStringList& list, int index) 350void KEditListBox::insertStringList(const QStringList& list, int index)
348{ 351{
349 m_listBox->insertStringList(list,index); 352 m_listBox->insertStringList(list,index);
350} 353}
351 354
352void KEditListBox::insertStrList(const QStrList* list, int index) 355void KEditListBox::insertStrList(const Q3StrList* list, int index)
353{ 356{
354 m_listBox->insertStrList(list,index); 357 for(Q3StrList::const_iterator i=list->begin();i!=list->end();++i)
358 m_listBox->insertItem(*i,index++);
355} 359}
356 360
357void KEditListBox::insertStrList(const QStrList& list, int index) 361void KEditListBox::insertStrList(const Q3StrList& list, int index)
358{ 362{
359 m_listBox->insertStrList(list,index); 363 for(Q3StrList::const_iterator i=list.begin();i!=list.end();++i)
364 m_listBox->insertItem(*i,index++);
360} 365}
361 366
362void KEditListBox::insertStrList(const char ** list, int numStrings, int index) 367void KEditListBox::insertStrList(const char ** list, int numStrings, int index)
363{ 368{
364 m_listBox->insertStrList(list,numStrings,index); 369 m_listBox->insertStrList(list,numStrings,index);
365} 370}
366 371
367QStringList KEditListBox::items() const 372QStringList KEditListBox::items() const
368{ 373{
369 QStringList list; 374 QStringList list;
370 for ( uint i = 0; i < m_listBox->count(); i++ ) 375 for ( uint i = 0; i < m_listBox->count(); i++ )
371 list.append( m_listBox->text( i )); 376 list.append( m_listBox->text( i ));
372 377
373 return list; 378 return list;
374} 379}
375 380
376void KEditListBox::virtual_hook( int, void* ) 381void KEditListBox::virtual_hook( int, void* )
377{ /*BASE::virtual_hook( id, data );*/ } 382{ /*BASE::virtual_hook( id, data );*/ }
378 383
379 384
380/////////////////////////////////////////////////////////////////// 385///////////////////////////////////////////////////////////////////
381/////////////////////////////////////////////////////////////////// 386///////////////////////////////////////////////////////////////////
382 387
383KEditListBox::CustomEditor::CustomEditor( KComboBox *combo ) 388KEditListBox::CustomEditor::CustomEditor( KComboBox *combo )
384{ 389{
385 m_representationWidget = combo; 390 m_representationWidget = combo;
386 m_lineEdit = static_cast<KLineEdit*>( combo->lineEdit() ); 391 m_lineEdit = static_cast<KLineEdit*>( combo->lineEdit() );
387 assert( m_lineEdit ); 392 assert( m_lineEdit );
388} 393}
389 394
diff --git a/microkde/keditlistbox.h b/microkde/keditlistbox.h
index 130d933..e43d958 100644
--- a/microkde/keditlistbox.h
+++ b/microkde/keditlistbox.h
@@ -1,226 +1,228 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org> 2 Copyright (C) 2000 David Faure <faure@kde.org>, Alexander Neundorf <neundorf@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef KEDITLISTBOX_H 20#ifndef KEDITLISTBOX_H
21#define KEDITLISTBOX_H 21#define KEDITLISTBOX_H
22 22
23#include <qgroupbox.h> 23#include <q3groupbox.h>
24#include <qlistbox.h> 24#include <q3listbox.h>
25//Added by qt3to4:
26#include <Q3StrList>
25 27
26class KLineEdit; 28class KLineEdit;
27class KComboBox; 29class KComboBox;
28class QPushButton; 30class QPushButton;
29 31
30class KEditListBoxPrivate; 32class KEditListBoxPrivate;
31/** 33/**
32 * An editable listbox 34 * An editable listbox
33 * 35 *
34 * This class provides a editable listbox ;-), this means 36 * This class provides a editable listbox ;-), this means
35 * a listbox which is accompanied by a line edit to enter new 37 * a listbox which is accompanied by a line edit to enter new
36 * items into the listbox and pushbuttons to add and remove 38 * items into the listbox and pushbuttons to add and remove
37 * items from the listbox and two buttons to move items up and down. 39 * items from the listbox and two buttons to move items up and down.
38 */ 40 */
39class KEditListBox : public QGroupBox 41class KEditListBox : public Q3GroupBox
40{ 42{
41 Q_OBJECT 43 Q_OBJECT
42 44
43public: 45public:
44 /// @since 3.1 46 /// @since 3.1
45 class CustomEditor 47 class CustomEditor
46 { 48 {
47 public: 49 public:
48 CustomEditor() 50 CustomEditor()
49 : m_representationWidget( 0L ), 51 : m_representationWidget( 0L ),
50 m_lineEdit( 0L ) {} 52 m_lineEdit( 0L ) {}
51 CustomEditor( QWidget *repWidget, KLineEdit *edit ) 53 CustomEditor( QWidget *repWidget, KLineEdit *edit )
52 : m_representationWidget( repWidget ), 54 : m_representationWidget( repWidget ),
53 m_lineEdit( edit ) {} 55 m_lineEdit( edit ) {}
54 CustomEditor( KComboBox *combo ); 56 CustomEditor( KComboBox *combo );
55 57
56 void setRepresentationWidget( QWidget *repWidget ) { 58 void setRepresentationWidget( QWidget *repWidget ) {
57 m_representationWidget = repWidget; 59 m_representationWidget = repWidget;
58 } 60 }
59 void setLineEdit( KLineEdit *edit ) { 61 void setLineEdit( KLineEdit *edit ) {
60 m_lineEdit = edit; 62 m_lineEdit = edit;
61 } 63 }
62 64
63 virtual QWidget *representationWidget() const { 65 virtual QWidget *representationWidget() const {
64 return m_representationWidget; 66 return m_representationWidget;
65 } 67 }
66 virtual KLineEdit *lineEdit() const { 68 virtual KLineEdit *lineEdit() const {
67 return m_lineEdit; 69 return m_lineEdit;
68 } 70 }
69 71
70 protected: 72 protected:
71 QWidget *m_representationWidget; 73 QWidget *m_representationWidget;
72 KLineEdit *m_lineEdit; 74 KLineEdit *m_lineEdit;
73 }; 75 };
74 76
75 public: 77 public:
76 78
77 /** 79 /**
78 * Enumeration of the buttons, the listbox offers. Specify them in the 80 * Enumeration of the buttons, the listbox offers. Specify them in the
79 * constructor in the buttons parameter. 81 * constructor in the buttons parameter.
80 */ 82 */
81 enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown }; 83 enum Button { Add = 1, Remove = 2, UpDown = 4, All = Add|Remove|UpDown };
82 84
83 /** 85 /**
84 * Create an editable listbox. 86 * Create an editable listbox.
85 * 87 *
86 * If @p checkAtEntering is true, after every character you type 88 * If @p checkAtEntering is true, after every character you type
87 * in the line edit KEditListBox will enable or disable 89 * in the line edit KEditListBox will enable or disable
88 * the Add-button, depending whether the current content of the 90 * the Add-button, depending whether the current content of the
89 * line edit is already in the listbox. Maybe this can become a 91 * line edit is already in the listbox. Maybe this can become a
90 * performance hit with large lists on slow machines. 92 * performance hit with large lists on slow machines.
91 * If @p checkAtEntering is false, 93 * If @p checkAtEntering is false,
92 * it will be checked if you press the Add-button. It is not 94 * it will be checked if you press the Add-button. It is not
93 * possible to enter items twice into the listbox. 95 * possible to enter items twice into the listbox.
94 */ 96 */
95 KEditListBox(QWidget *parent = 0, const char *name = 0, 97 KEditListBox(QWidget *parent = 0, const char *name = 0,
96 bool checkAtEntering=false, int buttons = All ); 98 bool checkAtEntering=false, int buttons = All );
97 /** 99 /**
98 * Create an editable listbox. 100 * Create an editable listbox.
99 * 101 *
100 * The same as the other constructor, additionally it takes 102 * The same as the other constructor, additionally it takes
101 * @title, which will be the title of the frame around the listbox. 103 * @title, which will be the title of the frame around the listbox.
102 */ 104 */
103 KEditListBox(const QString& title, QWidget *parent = 0, 105 KEditListBox(const QString& title, QWidget *parent = 0,
104 const char *name = 0, bool checkAtEntering=false, 106 const char *name = 0, bool checkAtEntering=false,
105 int buttons = All ); 107 int buttons = All );
106 108
107 /** 109 /**
108 * Another constructor, which allows to use a custom editing widget 110 * Another constructor, which allows to use a custom editing widget
109 * instead of the standard KLineEdit widget. E.g. you can use a 111 * instead of the standard KLineEdit widget. E.g. you can use a
110 * @ref KURLRequester or a @ref KComboBox as input widget. The custom 112 * @ref KURLRequester or a @ref KComboBox as input widget. The custom
111 * editor must consist of a lineedit and optionally another widget that 113 * editor must consist of a lineedit and optionally another widget that
112 * is used as representation. A KComboBox or a KURLRequester have a 114 * is used as representation. A KComboBox or a KURLRequester have a
113 * KLineEdit as child-widget for example, so the KComboBox is used as 115 * KLineEdit as child-widget for example, so the KComboBox is used as
114 * the representation widget. 116 * the representation widget.
115 * 117 *
116 * @see KURLRequester::customEditor() 118 * @see KURLRequester::customEditor()
117 * @since 3.1 119 * @since 3.1
118 */ 120 */
119 KEditListBox( const QString& title, 121 KEditListBox( const QString& title,
120 const CustomEditor &customEditor, 122 const CustomEditor &customEditor,
121 QWidget *parent = 0, const char *name = 0, 123 QWidget *parent = 0, const char *name = 0,
122 bool checkAtEntering = false, int buttons = All ); 124 bool checkAtEntering = false, int buttons = All );
123 125
124 virtual ~KEditListBox(); 126 virtual ~KEditListBox();
125 127
126 /** 128 /**
127 * Return a pointer to the embedded QListBox. 129 * Return a pointer to the embedded QListBox.
128 */ 130 */
129 QListBox* listBox() const { return m_listBox; } 131 Q3ListBox* listBox() const { return m_listBox; }
130 /** 132 /**
131 * Return a pointer to the embedded QLineEdit. 133 * Return a pointer to the embedded QLineEdit.
132 */ 134 */
133 KLineEdit* lineEdit() const { return m_lineEdit; } 135 KLineEdit* lineEdit() const { return m_lineEdit; }
134 /** 136 /**
135 * Return a pointer to the Add button 137 * Return a pointer to the Add button
136 */ 138 */
137 QPushButton* addButton() const { return servNewButton; } 139 QPushButton* addButton() const { return servNewButton; }
138 /** 140 /**
139 * Return a pointer to the Remove button 141 * Return a pointer to the Remove button
140 */ 142 */
141 QPushButton* removeButton() const { return servRemoveButton; } 143 QPushButton* removeButton() const { return servRemoveButton; }
142 /** 144 /**
143 * Return a pointer to the Up button 145 * Return a pointer to the Up button
144 */ 146 */
145 QPushButton* upButton() const { return servUpButton; } 147 QPushButton* upButton() const { return servUpButton; }
146 /** 148 /**
147 * Return a pointer to the Down button 149 * Return a pointer to the Down button
148 */ 150 */
149 QPushButton* downButton() const { return servDownButton; } 151 QPushButton* downButton() const { return servDownButton; }
150 152
151 /** 153 /**
152 * See @ref QListBox::count() 154 * See @ref QListBox::count()
153 */ 155 */
154 int count() const { return int(m_listBox->count()); } 156 int count() const { return int(m_listBox->count()); }
155 /** 157 /**
156 * See @ref QListBox::insertStringList() 158 * See @ref QListBox::insertStringList()
157 */ 159 */
158 void insertStringList(const QStringList& list, int index=-1); 160 void insertStringList(const QStringList& list, int index=-1);
159 /** 161 /**
160 * See @ref QListBox::insertStringList() 162 * See @ref QListBox::insertStringList()
161 */ 163 */
162 void insertStrList(const QStrList* list, int index=-1); 164 void insertStrList(const Q3StrList* list, int index=-1);
163 /** 165 /**
164 * See @ref QListBox::insertStrList() 166 * See @ref QListBox::insertStrList()
165 */ 167 */
166 void insertStrList(const QStrList& list, int index=-1); 168 void insertStrList(const Q3StrList& list, int index=-1);
167 /** 169 /**
168 * See @ref QListBox::insertStrList() 170 * See @ref QListBox::insertStrList()
169 */ 171 */
170 void insertStrList(const char ** list, int numStrings=-1, int index=-1); 172 void insertStrList(const char ** list, int numStrings=-1, int index=-1);
171 /** 173 /**
172 * See @ref QListBox::insertItem() 174 * See @ref QListBox::insertItem()
173 */ 175 */
174 void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);} 176 void insertItem(const QString& text, int index=-1) {m_listBox->insertItem(text,index);}
175 /** 177 /**
176 * Clears both the listbox and the line edit. 178 * Clears both the listbox and the line edit.
177 */ 179 */
178 void clear(); 180 void clear();
179 /** 181 /**
180 * See @ref QListBox::text() 182 * See @ref QListBox::text()
181 */ 183 */
182 QString text(int index) const { return m_listBox->text(index); } 184 QString text(int index) const { return m_listBox->text(index); }
183 /** 185 /**
184 * See @ref QListBox::currentItem() 186 * See @ref QListBox::currentItem()
185 */ 187 */
186 int currentItem() const; 188 int currentItem() const;
187 /** 189 /**
188 * See @ref QListBox::currentText() 190 * See @ref QListBox::currentText()
189 */ 191 */
190 QString currentText() const { return m_listBox->currentText(); } 192 QString currentText() const { return m_listBox->currentText(); }
191 193
192 /** 194 /**
193 * @returns a stringlist of all items in the listbox 195 * @returns a stringlist of all items in the listbox
194 */ 196 */
195 QStringList items() const; 197 QStringList items() const;
196 198
197 signals: 199 signals:
198 void changed(); 200 void changed();
199 201
200 protected slots: 202 protected slots:
201 //the names should be self-explaining 203 //the names should be self-explaining
202 void moveItemUp(); 204 void moveItemUp();
203 void moveItemDown(); 205 void moveItemDown();
204 void addItem(); 206 void addItem();
205 void removeItem(); 207 void removeItem();
206 void enableMoveButtons(int index); 208 void enableMoveButtons(int index);
207 void typedSomething(const QString& text); 209 void typedSomething(const QString& text);
208 210
209 private: 211 private:
210 QListBox *m_listBox; 212 Q3ListBox *m_listBox;
211 QPushButton *servUpButton, *servDownButton; 213 QPushButton *servUpButton, *servDownButton;
212 QPushButton *servNewButton, *servRemoveButton; 214 QPushButton *servNewButton, *servRemoveButton;
213 KLineEdit *m_lineEdit; 215 KLineEdit *m_lineEdit;
214 216
215 //this is called in both ctors, to avoid code duplication 217 //this is called in both ctors, to avoid code duplication
216 void init( bool checkAtEntering, int buttons, 218 void init( bool checkAtEntering, int buttons,
217 QWidget *representationWidget = 0L ); 219 QWidget *representationWidget = 0L );
218 220
219 protected: 221 protected:
220 virtual void virtual_hook( int id, void* data ); 222 virtual void virtual_hook( int id, void* data );
221 private: 223 private:
222 //our lovely private d-pointer 224 //our lovely private d-pointer
223 KEditListBoxPrivate *d; 225 KEditListBoxPrivate *d;
224}; 226};
225 227
226#endif 228#endif
diff --git a/microkde/kfiledialog.cpp b/microkde/kfiledialog.cpp
index 383e711..c1bfdef 100644
--- a/microkde/kfiledialog.cpp
+++ b/microkde/kfiledialog.cpp
@@ -1,88 +1,90 @@
1#include <kfiledialog.h> 1#include <kfiledialog.h>
2#include <qdialog.h> 2#include <qdialog.h>
3#include <qlayout.h> 3#include <qlayout.h>
4#include <qdir.h> 4#include <qdir.h>
5#include <qfileinfo.h> 5#include <qfileinfo.h>
6#include <qapplication.h> 6#include <qapplication.h>
7//Added by qt3to4:
8#include <Q3VBoxLayout>
7 9
8#ifndef DESKTOP_VERSION 10#ifndef DESKTOP_VERSION
9//US orig#include <ofileselector.h> 11//US orig#include <ofileselector.h>
10#include <ofileselector_p.h> 12#include <ofileselector_p.h>
11QString KFileDialog::getSaveFileName( const QString & fn, 13QString KFileDialog::getSaveFileName( const QString & fn,
12 const QString & cap , QWidget * par ) 14 const QString & cap , QWidget * par )
13{ 15{
14 QString retfile = ""; 16 QString retfile = "";
15 QDialog dia ( par, "input-dialog", true ); 17 QDialog dia ( par, "input-dialog", true );
16 QVBoxLayout lay( &dia ); 18 Q3VBoxLayout lay( &dia );
17 lay.setMargin(7); 19 lay.setMargin(7);
18 lay.setSpacing(7); 20 lay.setSpacing(7);
19 QString file = fn; 21 QString file = fn;
20 if ( file.isEmpty() ) 22 if ( file.isEmpty() )
21 file = QDir::homeDirPath()+"/*"; 23 file = QDir::homeDirPath()+"/*";
22 QFileInfo fi ( file ); 24 QFileInfo fi ( file );
23 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Save, fi.dirPath(true), fi.fileName() ); 25 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Save, fi.dirPath(true), fi.fileName() );
24 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); 26 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
25 lay.addWidget( &o); 27 lay.addWidget( &o);
26 // o.setNewVisible( true ); 28 // o.setNewVisible( true );
27 // o.setNameVisible( true ); 29 // o.setNameVisible( true );
28 dia.showMaximized(); 30 dia.showMaximized();
29 if ( cap.isEmpty() ) 31 if ( cap.isEmpty() )
30 dia.setCaption( file ); 32 dia.setCaption( file );
31 else 33 else
32 dia.setCaption( cap ); 34 dia.setCaption( cap );
33 int res = dia.exec(); 35 int res = dia.exec();
34 if ( res ) 36 if ( res )
35 retfile = o.selectedName(); 37 retfile = o.selectedName();
36 return retfile; 38 return retfile;
37} 39}
38 40
39QString KFileDialog::getOpenFileName( const QString & fn, 41QString KFileDialog::getOpenFileName( const QString & fn,
40 const QString & cap, QWidget * par ) 42 const QString & cap, QWidget * par )
41{ 43{
42 QString retfile = ""; 44 QString retfile = "";
43 QDialog dia ( par, "input-dialog", true ); 45 QDialog dia ( par, "input-dialog", true );
44 // QLineEdit lab ( &dia ); 46 // QLineEdit lab ( &dia );
45 QVBoxLayout lay( &dia ); 47 Q3VBoxLayout lay( &dia );
46 lay.setMargin(7); 48 lay.setMargin(7);
47 lay.setSpacing(7); 49 lay.setSpacing(7);
48 QString file = fn; 50 QString file = fn;
49 if ( file.isEmpty() ) 51 if ( file.isEmpty() )
50 file = QDir::homeDirPath()+"/*";; 52 file = QDir::homeDirPath()+"/*";;
51 QFileInfo fi ( file ); 53 QFileInfo fi ( file );
52 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Open, fi.dirPath(true), fi.fileName() ); 54 OFileSelector o ( &dia,OFileSelector::FileSelector, OFileSelector::Open, fi.dirPath(true), fi.fileName() );
53 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) ); 55 QObject::connect ( &o, SIGNAL( ok() ), &dia, SLOT ( accept () ) );
54 lay.addWidget( &o); 56 lay.addWidget( &o);
55 dia.showMaximized(); 57 dia.showMaximized();
56 dia.setCaption( cap ); 58 dia.setCaption( cap );
57 int res = dia.exec(); 59 int res = dia.exec();
58 if ( res ) 60 if ( res )
59 retfile = o.selectedName(); 61 retfile = o.selectedName();
60 return retfile; 62 return retfile;
61} 63}
62QString KFileDialog::getExistingDirectory( const QString & fn, 64QString KFileDialog::getExistingDirectory( const QString & fn,
63 const QString & cap, QWidget * par ) 65 const QString & cap, QWidget * par )
64{ 66{
65 return KFileDialog::getSaveFileName( fn, cap, par ); 67 return KFileDialog::getSaveFileName( fn, cap, par );
66} 68}
67#else 69#else
68 70
69#include <qfiledialog.h> 71#include <q3filedialog.h>
70 72
71QString KFileDialog::getSaveFileName( const QString & fn, 73QString KFileDialog::getSaveFileName( const QString & fn,
72 const QString & cap , QWidget * par ) 74 const QString & cap , QWidget * par )
73{ 75{
74 return QFileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap ); 76 return Q3FileDialog::getSaveFileName( fn, QString::null, par, "openfile", cap );
75} 77}
76QString KFileDialog::getOpenFileName( const QString & fn, 78QString KFileDialog::getOpenFileName( const QString & fn,
77 const QString & cap, QWidget * par ) 79 const QString & cap, QWidget * par )
78{ 80{
79 81
80 return QFileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap ); 82 return Q3FileDialog::getOpenFileName( fn, QString::null, par, "openfile", cap );
81} 83}
82QString KFileDialog::getExistingDirectory( const QString & fn, 84QString KFileDialog::getExistingDirectory( const QString & fn,
83 const QString & cap, QWidget * par ) 85 const QString & cap, QWidget * par )
84{ 86{
85 return QFileDialog::getExistingDirectory( fn, par, "exidtingdir", cap ); 87 return Q3FileDialog::getExistingDirectory( fn, par, "exidtingdir", cap );
86} 88}
87#endif 89#endif
88 90
diff --git a/microkde/kfontdialog.cpp b/microkde/kfontdialog.cpp
index 174123c..f83c2a8 100644
--- a/microkde/kfontdialog.cpp
+++ b/microkde/kfontdialog.cpp
@@ -1,32 +1,34 @@
1#include "kfontdialog.h" 1#include "kfontdialog.h"
2#ifndef DESKTOP_VERSION 2#ifndef DESKTOP_VERSION
3#include "ofontselector.h" 3#include "ofontselector.h"
4#else 4#else
5#include <qfontdialog.h> 5#include <qfontdialog.h>
6#endif 6#endif
7#include <qdialog.h> 7#include <qdialog.h>
8#include <qlayout.h> 8#include <qlayout.h>
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10//Added by qt3to4:
11#include <Q3VBoxLayout>
10QFont KFontDialog::getFont( const QFont & f, bool & ok ) 12QFont KFontDialog::getFont( const QFont & f, bool & ok )
11{ 13{
12#ifndef DESKTOP_VERSION 14#ifndef DESKTOP_VERSION
13 QDialog d( 0, "fd", true );; 15 QDialog d( 0, "fd", true );;
14 OFontSelector s ( true, &d, "fontsel"); 16 OFontSelector s ( true, &d, "fontsel");
15 QVBoxLayout l ( &d ); 17 Q3VBoxLayout l ( &d );
16 l.addWidget( &s ); 18 l.addWidget( &s );
17 s.setSelectedFont ( f ); 19 s.setSelectedFont ( f );
18 QPushButton b ( "OK", &d ); 20 QPushButton b ( "OK", &d );
19 l.addWidget( &b ); 21 l.addWidget( &b );
20 qDebug("size %d ", f.bold()); 22 qDebug("size %d ", f.bold());
21 QObject::connect( &b, SIGNAL( clicked () ), &d, SLOT ( accept () ) ); 23 QObject::connect( &b, SIGNAL( clicked () ), &d, SLOT ( accept () ) );
22 d.show(); 24 d.show();
23 ok = false; 25 ok = false;
24 if ( d.exec () ) { 26 if ( d.exec () ) {
25 ok = true; 27 ok = true;
26 return s.selectedFont ( ); 28 return s.selectedFont ( );
27 } 29 }
28 return f; 30 return f;
29#else 31#else
30 return QFontDialog::getFont ( &ok, f, 0, "fontdialog" ); 32 return QFontDialog::getFont ( &ok, f, 0, "fontdialog" );
31#endif 33#endif
32} 34}
diff --git a/microkde/kglobal.cpp b/microkde/kglobal.cpp
index 53edd08..9cc5835 100644
--- a/microkde/kglobal.cpp
+++ b/microkde/kglobal.cpp
@@ -1,175 +1,176 @@
1#include "kglobal.h" 1#include "kglobal.h"
2#include "kstandarddirs.h" 2#include "kstandarddirs.h"
3#include <qkeycode.h> 3#include <qnamespace.h>
4#include <qapplication.h> 4#include <qapplication.h>
5#include <QDesktopWidget>
5 6
6KLocale *KGlobal::mLocale = 0; 7KLocale *KGlobal::mLocale = 0;
7KConfig *KGlobal::mConfig = 0; 8KConfig *KGlobal::mConfig = 0;
8KIconLoader *KGlobal::mIconLoader = 0; 9KIconLoader *KGlobal::mIconLoader = 0;
9KStandardDirs *KGlobal::mDirs = 0; 10KStandardDirs *KGlobal::mDirs = 0;
10 11
11QString KGlobal::mAppName = "godot"; 12QString KGlobal::mAppName = "godot";
12 13
13KLocale *KGlobal::locale() 14KLocale *KGlobal::locale()
14{ 15{
15 if ( !mLocale ) { 16 if ( !mLocale ) {
16 ASSERT(mAppName); 17 Q_ASSERT(!mAppName.isEmpty());
17 18
18 mLocale = new KLocale();//mAppName); 19 mLocale = new KLocale();//mAppName);
19 } 20 }
20 21
21 return mLocale; 22 return mLocale;
22} 23}
23 24
24//US 25//US
25void KGlobal::setLocale(KLocale *kg) 26void KGlobal::setLocale(KLocale *kg)
26{ 27{
27 mLocale = kg; 28 mLocale = kg;
28} 29}
29 30
30KConfig *KGlobal::config() 31KConfig *KGlobal::config()
31{ 32{
32 //mConfig is set inside setAppName. Though it has to be the first function you call. 33 //mConfig is set inside setAppName. Though it has to be the first function you call.
33 return mConfig; 34 return mConfig;
34} 35}
35 36
36KGlobal::Size KGlobal::getDesktopSize() 37KGlobal::Size KGlobal::getDesktopSize()
37{ 38{
38#ifdef DESKTOP_VERSION 39#ifdef DESKTOP_VERSION
39 return KGlobal::Desktop; 40 return KGlobal::Desktop;
40#else 41#else
41 if ( QApplication::desktop()->width() <= 320 ) 42 if ( QApplication::desktop()->width() <= 320 )
42 return KGlobal::Small; 43 return KGlobal::Small;
43 else if ( QApplication::desktop()->width() > 480) 44 else if ( QApplication::desktop()->width() > 480)
44 return KGlobal::Desktop; 45 return KGlobal::Desktop;
45 else 46 else
46 return KGlobal::Medium; 47 return KGlobal::Medium;
47#endif 48#endif
48} 49}
49 50
50KGlobal::Orientation KGlobal::getOrientation() 51KGlobal::Orientation KGlobal::getOrientation()
51{ 52{
52 if (QApplication::desktop()->width() > QApplication::desktop()->height()) 53 if (QApplication::desktop()->width() > QApplication::desktop()->height())
53 return KGlobal::Landscape; 54 return KGlobal::Landscape;
54 else 55 else
55 return KGlobal::Portrait; 56 return KGlobal::Portrait;
56} 57}
57 58
58int KGlobal::getDesktopWidth() 59int KGlobal::getDesktopWidth()
59{ 60{
60 return QApplication::desktop()->width(); 61 return QApplication::desktop()->width();
61} 62}
62 63
63int KGlobal::getDesktopHeight() 64int KGlobal::getDesktopHeight()
64{ 65{
65 return QApplication::desktop()->height(); 66 return QApplication::desktop()->height();
66} 67}
67 68
68 69
69KIconLoader *KGlobal::iconLoader() 70KIconLoader *KGlobal::iconLoader()
70{ 71{
71 if ( !mIconLoader ) { 72 if ( !mIconLoader ) {
72 mIconLoader = new KIconLoader(); 73 mIconLoader = new KIconLoader();
73 } 74 }
74 75
75 return mIconLoader; 76 return mIconLoader;
76} 77}
77 78
78KStandardDirs *KGlobal::dirs() 79KStandardDirs *KGlobal::dirs()
79{ 80{
80 if ( !mDirs ) { 81 if ( !mDirs ) {
81 mDirs = new KStandardDirs(); 82 mDirs = new KStandardDirs();
82 } 83 }
83 84
84 return mDirs; 85 return mDirs;
85} 86}
86 87
87void KGlobal::setAppName( const QString &appName ) 88void KGlobal::setAppName( const QString &appName )
88{ 89{
89 mAppName = appName; 90 mAppName = appName;
90 91
91 mConfig = new KConfig( locateLocal("config", mAppName + "rc" ) ); 92 mConfig = new KConfig( locateLocal("config", mAppName + "rc" ) );
92} 93}
93 94
94//US 95//US
95QString KGlobal::getAppName() 96QString KGlobal::getAppName()
96{ 97{
97 return mAppName; 98 return mAppName;
98} 99}
99QString KGlobal::formatMessage ( QString mess, int maxlen ) 100QString KGlobal::formatMessage ( QString mess, int maxlen )
100{ 101{
101 //int maxlen = 80; 102 //int maxlen = 80;
102 if ( maxlen == 0 ) { 103 if ( maxlen == 0 ) {
103 maxlen = QApplication::desktop()->width()/10; 104 maxlen = QApplication::desktop()->width()/10;
104 if ( maxlen > 32 ) 105 if ( maxlen > 32 )
105 maxlen = (maxlen * 3) / 4; 106 maxlen = (maxlen * 3) / 4;
106 if ( maxlen > 100 ) 107 if ( maxlen > 100 )
107 maxlen = 100; 108 maxlen = 100;
108 } 109 }
109 int start = 0; 110 int start = 0;
110 int end = mess.length(); 111 int end = mess.length();
111 QString retVal = ""; 112 QString retVal = "";
112 int nl, space; 113 int nl, space;
113 while ( (end - start) > maxlen ) { 114 while ( (end - start) > maxlen ) {
114 nl = mess.find( "\n", start ); 115 nl = mess.find( "\n", start );
115 if ( nl > 0 && nl < start + maxlen ) { 116 if ( nl > 0 && nl < start + maxlen ) {
116 nl += 1; 117 nl += 1;
117 retVal += mess.mid( start, nl - start); 118 retVal += mess.mid( start, nl - start);
118 start = nl; 119 start = nl;
119 } else { 120 } else {
120 space = mess.findRev( " ", start + maxlen ); 121 space = mess.findRev( " ", start + maxlen );
121 if ( space < start ) { 122 if ( space < start ) {
122 retVal += mess.mid( start, maxlen) +"\n"; 123 retVal += mess.mid( start, maxlen) +"\n";
123 start += maxlen ; 124 start += maxlen ;
124 } else { 125 } else {
125 retVal += mess.mid( start, space - start ) +"\n"; 126 retVal += mess.mid( start, space - start ) +"\n";
126 start = space+ 1; 127 start = space+ 1;
127 } 128 }
128 } 129 }
129 } 130 }
130 retVal += mess.mid( start, end - start ); 131 retVal += mess.mid( start, end - start );
131 return retVal; 132 return retVal;
132} 133}
133int KGlobal::knumkeykonv( int k ) 134int KGlobal::knumkeykonv( int k )
134{ 135{
135 int key; 136 int key;
136switch( k ) { 137switch( k ) {
137 case Qt::Key_Q : 138 case Qt::Key_Q :
138 key = Qt::Key_1; 139 key = Qt::Key_1;
139 break; 140 break;
140 case Qt::Key_W : 141 case Qt::Key_W :
141 key = Qt::Key_2; 142 key = Qt::Key_2;
142 break; 143 break;
143 case Qt::Key_E : 144 case Qt::Key_E :
144 key = Qt::Key_3; 145 key = Qt::Key_3;
145 break; 146 break;
146 case Qt::Key_R : 147 case Qt::Key_R :
147 key = Qt::Key_4; 148 key = Qt::Key_4;
148 break; 149 break;
149 case Qt::Key_T : 150 case Qt::Key_T :
150 key = Qt::Key_5; 151 key = Qt::Key_5;
151 break; 152 break;
152 case Qt::Key_Z : 153 case Qt::Key_Z :
153 key = Qt::Key_6; 154 key = Qt::Key_6;
154 break; 155 break;
155 case Qt::Key_Y : 156 case Qt::Key_Y :
156 key = Qt::Key_6; 157 key = Qt::Key_6;
157 break; 158 break;
158 case Qt::Key_U : 159 case Qt::Key_U :
159 key = Qt::Key_7; 160 key = Qt::Key_7;
160 break; 161 break;
161 case Qt::Key_I : 162 case Qt::Key_I :
162 key = Qt::Key_8; 163 key = Qt::Key_8;
163 break; 164 break;
164 case Qt::Key_O : 165 case Qt::Key_O :
165 key = Qt::Key_9; 166 key = Qt::Key_9;
166 break; 167 break;
167 case Qt::Key_P : 168 case Qt::Key_P :
168 key = Qt::Key_0; 169 key = Qt::Key_0;
169 break; 170 break;
170 default: 171 default:
171 key = k; 172 key = k;
172 break; 173 break;
173 } // switch 174 } // switch
174 return key; 175 return key;
175} 176}
diff --git a/microkde/kglobalsettings.cpp b/microkde/kglobalsettings.cpp
index 2e483e9..1f08255 100644
--- a/microkde/kglobalsettings.cpp
+++ b/microkde/kglobalsettings.cpp
@@ -1,113 +1,114 @@
1#include "kglobalsettings.h" 1#include "kglobalsettings.h"
2#include "kconfig.h" 2#include "kconfig.h"
3#include "kglobal.h" 3#include "kglobal.h"
4#include "kconfigbase.h" 4#include "kconfigbase.h"
5 5
6#include <qapplication.h> 6#include <qapplication.h>
7#include <QDesktopWidget>
7 8
8#ifdef DESKTOP_VERSION 9#ifdef DESKTOP_VERSION
9 QColor KGlobalSettings::mAlternate = QColor( 235, 235, 235 ); 10 QColor KGlobalSettings::mAlternate = QColor( 235, 235, 235 );
10#else 11#else
11 QColor KGlobalSettings::mAlternate = QColor( 210, 210, 210 ); 12 QColor KGlobalSettings::mAlternate = QColor( 210, 210, 210 );
12#endif 13#endif
13 14
14 15
15QFont KGlobalSettings::generalFont() 16QFont KGlobalSettings::generalFont()
16{ 17{
17 int size = 12; 18 int size = 12;
18 if (QApplication::desktop()->width() < 480 ) { 19 if (QApplication::desktop()->width() < 480 ) {
19 size = 10; 20 size = 10;
20 } 21 }
21#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
22 else 23 else
23 if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 24 if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
24 size = 18; 25 size = 18;
25#endif 26#endif
26 QFont f = QApplication::font(); 27 QFont f = QApplication::font();
27 //qDebug("pointsize %d %s", f.pointSize(),f.family().latin1()); 28 //qDebug("pointsize %d %s", f.pointSize(),f.family().latin1());
28 f.setPointSize( size ); 29 f.setPointSize( size );
29 return f; 30 return f;
30} 31}
31QFont KGlobalSettings::generalMaxFont() 32QFont KGlobalSettings::generalMaxFont()
32{ 33{
33 int size = 12; 34 int size = 12;
34 if (QApplication::desktop()->width() < 480 ) { 35 if (QApplication::desktop()->width() < 480 ) {
35 size = 10; 36 size = 10;
36 } 37 }
37#ifndef DESKTOP_VERSION 38#ifndef DESKTOP_VERSION
38 else 39 else
39 if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 ) 40 if (QApplication::desktop()->width() >= 480 && QApplication::desktop()->width() <= 640 )
40 size = 18; 41 size = 18;
41#endif 42#endif
42 QFont f = QApplication::font(); 43 QFont f = QApplication::font();
43 if ( f.pointSize() > size ) 44 if ( f.pointSize() > size )
44 f.setPointSize( size ); 45 f.setPointSize( size );
45 return f; 46 return f;
46} 47}
47 48
48QString KGlobalSettings::timeTrackerDir() 49QString KGlobalSettings::timeTrackerDir()
49{ 50{
50 static QString dir; 51 static QString dir;
51 if ( dir.isEmpty() ) { 52 if ( dir.isEmpty() ) {
52 dir = locateLocal( "data", "timetrackerdir/d.ttl" ); 53 dir = locateLocal( "data", "timetrackerdir/d.ttl" );
53 dir = dir.left ( dir.length() - 5); 54 dir = dir.left ( dir.length() - 5);
54 } 55 }
55 return dir; 56 return dir;
56} 57}
57QString KGlobalSettings::backupDataDir() 58QString KGlobalSettings::backupDataDir()
58{ 59{
59 static QString dir; 60 static QString dir;
60 if ( dir.isEmpty() ) { 61 if ( dir.isEmpty() ) {
61 dir = locateLocal( "data", "backupdir/d.ttl" ); 62 dir = locateLocal( "data", "backupdir/d.ttl" );
62 dir = dir.left ( dir.length() - 5); 63 dir = dir.left ( dir.length() - 5);
63 } 64 }
64 return dir; 65 return dir;
65} 66}
66QString KGlobalSettings::calendarDir() 67QString KGlobalSettings::calendarDir()
67{ 68{
68 static QString dir; 69 static QString dir;
69 if ( dir.isEmpty() ) { 70 if ( dir.isEmpty() ) {
70 dir = locateLocal( "data", "korganizer/d.ttl" ); 71 dir = locateLocal( "data", "korganizer/d.ttl" );
71 dir = dir.left ( dir.length() - 5); 72 dir = dir.left ( dir.length() - 5);
72 } 73 }
73 return dir; 74 return dir;
74} 75}
75 76
76QFont KGlobalSettings::toolBarFont() 77QFont KGlobalSettings::toolBarFont()
77{ 78{
78 return QApplication::font(); 79 return QApplication::font();
79} 80}
80 81
81QColor KGlobalSettings::toolBarHighlightColor() 82QColor KGlobalSettings::toolBarHighlightColor()
82{ 83{
83 return QColor( "black" ); 84 return QColor( "black" );
84} 85}
85 86
86QColor KGlobalSettings::alternateBackgroundColor() 87QColor KGlobalSettings::alternateBackgroundColor()
87{ 88{
88 return mAlternate; 89 return mAlternate;
89 90
90} 91}
91void KGlobalSettings::setAlternateBackgroundColor(QColor c) 92void KGlobalSettings::setAlternateBackgroundColor(QColor c)
92{ 93{
93 mAlternate = c; 94 mAlternate = c;
94 95
95} 96}
96 97
97QRect KGlobalSettings::desktopGeometry( QWidget * ) 98QRect KGlobalSettings::desktopGeometry( QWidget * )
98{ 99{
99 return QApplication::desktop()->rect(); 100 return QApplication::desktop()->rect();
100} 101}
101 102
102 /** 103 /**
103 * Returns whether KDE runs in single (default) or double click 104 * Returns whether KDE runs in single (default) or double click
104 * mode. 105 * mode.
105 * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html 106 * see http://developer.kde.org/documentation/standards/kde/style/mouse/index.html
106 * @return true if single click mode, or false if double click mode. 107 * @return true if single click mode, or false if double click mode.
107 **/ 108 **/
108bool KGlobalSettings::singleClick() 109bool KGlobalSettings::singleClick()
109{ 110{
110 KConfig *c = KGlobal::config(); 111 KConfig *c = KGlobal::config();
111 KConfigGroupSaver cgs( c, "KDE" ); 112 KConfigGroupSaver cgs( c, "KDE" );
112 return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK); 113 return c->readBoolEntry("SingleClick", KDE_DEFAULT_SINGLECLICK);
113} 114}
diff --git a/microkde/kiconloader.cpp b/microkde/kiconloader.cpp
index 4842d71..e7f657d 100644
--- a/microkde/kiconloader.cpp
+++ b/microkde/kiconloader.cpp
@@ -1,140 +1,142 @@
1 1
2#include "kiconloader.h" 2#include "kiconloader.h"
3#include "kglobal.h" 3#include "kglobal.h"
4 4
5#ifndef DESKTOP_VERSION_OEGEL 5#ifndef DESKTOP_VERSION_OEGEL
6#include <qdir.h> 6#include <qdir.h>
7//Added by qt3to4:
8#include <QPixmap>
7QPixmap KIconLoader::loadIcon( const QString& name, KIcon::Group, int, 9QPixmap KIconLoader::loadIcon( const QString& name, KIcon::Group, int,
8 int, QString *, bool ) const 10 int, QString *, bool ) const
9{ 11{
10 QPixmap pix; 12 QPixmap pix;
11 QString file; 13 QString file;
12 file = iconPath() + name+".png"; 14 file = iconPath() + name+".png";
13 pix.load ( file ); 15 pix.load ( file );
14 // qDebug("KIconLoader::loadIcon %s -----------", file.latin1()); 16 // qDebug("KIconLoader::loadIcon %s -----------", file.latin1());
15 return pix; 17 return pix;
16} 18}
17QIconSet KIconLoader::loadIconSet( const QString& name) const 19QIcon KIconLoader::loadIconSet( const QString& name) const
18{ 20{
19 QPixmap pixmapLoader; 21 QPixmap pixmapLoader;
20 QString file; 22 QString file;
21 file = iconPath() + name+".png"; 23 file = iconPath() + name+".png";
22 pixmapLoader.load( file ); 24 pixmapLoader.load( file );
23 //qDebug("KIconLoader::loadIconSet: %s ************", file.latin1() ); 25 //qDebug("KIconLoader::loadIconSet: %s ************", file.latin1() );
24 QIconSet is ( pixmapLoader ); 26 QIcon is ( pixmapLoader );
25 return is; 27 return is;
26} 28}
27 29
28QPixmap BarIcon( const QString &name ) 30QPixmap BarIcon( const QString &name )
29{ 31{
30 QPixmap pix; 32 QPixmap pix;
31 pix.load ( KGlobal::iconLoader()->iconPath() + name +".png" ); 33 pix.load ( KGlobal::iconLoader()->iconPath() + name +".png" );
32 return pix; 34 return pix;
33} 35}
34 36
35QPixmap DesktopIcon( const QString &name, int ) 37QPixmap DesktopIcon( const QString &name, int )
36{ 38{
37 QPixmap pix; 39 QPixmap pix;
38 pix.load ( KGlobal::iconLoader()->iconPath() + name +".png" ); 40 pix.load ( KGlobal::iconLoader()->iconPath() + name +".png" );
39 return pix; 41 return pix;
40 42
41} 43}
42 44
43QPixmap SmallIcon( const QString &name ) 45QPixmap SmallIcon( const QString &name )
44{ 46{
45 QPixmap pixmapLoader; 47 QPixmap pixmapLoader;
46 QString file; 48 QString file;
47 file =KGlobal::iconLoader()->iconPath() + name +".png"; 49 file =KGlobal::iconLoader()->iconPath() + name +".png";
48 pixmapLoader.load( file ); 50 pixmapLoader.load( file );
49 return pixmapLoader; 51 return pixmapLoader;
50 52
51} 53}
52 54
53QPixmap SmallIconSet( const QString &name ) 55QPixmap SmallIconSet( const QString &name )
54{ 56{
55 QPixmap pixmapLoader; 57 QPixmap pixmapLoader;
56 QString file; 58 QString file;
57 file =KGlobal::iconLoader()->iconPath() + name +".png"; 59 file =KGlobal::iconLoader()->iconPath() + name +".png";
58 pixmapLoader.load( file ); 60 pixmapLoader.load( file );
59 return pixmapLoader; 61 return pixmapLoader;
60} 62}
61 63
62 64
63#else 65#else
64 66
65#include <qpe/resource.h> 67#include <qpe/resource.h>
66#include <kglobal.h> 68#include <kglobal.h>
67QPixmap KIconLoader::loadIcon( const QString& name, KIcon::Group, int, 69QPixmap KIconLoader::loadIcon( const QString& name, KIcon::Group, int,
68 int, QString *, bool ) const 70 int, QString *, bool ) const
69{ 71{
70 QString px = this->iconPath() + "/" + name; 72 QString px = this->iconPath() + "/" + name;
71 73
72 QPixmap p = Resource::loadPixmap( px ); 74 QPixmap p = Resource::loadPixmap( px );
73 QPixmap* pPtr = &p; 75 QPixmap* pPtr = &p;
74 if (pPtr == 0) 76 if (pPtr == 0)
75 qDebug("KIconLoader::loadIcon: %s not found", px.latin1()); 77 qDebug("KIconLoader::loadIcon: %s not found", px.latin1());
76 78
77 return p; 79 return p;
78} 80}
79 81
80QIconSet KIconLoader::loadIconSet( const QString& name) const 82QIcon KIconLoader::loadIconSet( const QString& name) const
81{ 83{
82 QString px = this->iconPath() + "/" + name; 84 QString px = this->iconPath() + "/" + name;
83 85
84 QIconSet is ;//= Resource::loadIconSet( px ); 86 QIcon is ;//= Resource::loadIconSet( px );
85 QIconSet* isPtr = 0;//LR&is; 87 QIcon* isPtr = 0;//LR&is;
86 if (isPtr == 0) 88 if (isPtr == 0)
87 qDebug("KIconLoader::loadIconSet: %s not foun", px.latin1()); 89 qDebug("KIconLoader::loadIconSet: %s not foun", px.latin1());
88 90
89 return is; 91 return is;
90} 92}
91 93
92QPixmap BarIcon( const QString &name ) 94QPixmap BarIcon( const QString &name )
93{ 95{
94 QPixmap p = KGlobal::iconLoader()->loadIcon(name, KIcon::Desktop); 96 QPixmap p = KGlobal::iconLoader()->loadIcon(name, KIcon::Desktop);
95 return p; 97 return p;
96} 98}
97 99
98QPixmap DesktopIcon( const QString &name, int ) 100QPixmap DesktopIcon( const QString &name, int )
99{ 101{
100 QPixmap p = KGlobal::iconLoader()->loadIcon(name, KIcon::Desktop); 102 QPixmap p = KGlobal::iconLoader()->loadIcon(name, KIcon::Desktop);
101 return p; 103 return p;
102} 104}
103 105
104QPixmap SmallIcon( const QString &name ) 106QPixmap SmallIcon( const QString &name )
105{ 107{
106 QPixmap p = KGlobal::iconLoader()->loadIcon(name, KIcon::Desktop); 108 QPixmap p = KGlobal::iconLoader()->loadIcon(name, KIcon::Desktop);
107 return p; 109 return p;
108} 110}
109 111
110QPixmap SmallIconSet( const QString &name ) 112QPixmap SmallIconSet( const QString &name )
111{ 113{
112 QPixmap p = KGlobal::iconLoader()->loadIcon(name, KIcon::Desktop); 114 QPixmap p = KGlobal::iconLoader()->loadIcon(name, KIcon::Desktop);
113 return p; 115 return p;
114} 116}
115 117
116#endif 118#endif
117 119
118//US 120//US
119QString KIconLoader::setIconPath( const QString &iconpath) 121QString KIconLoader::setIconPath( const QString &iconpath)
120{ 122{
121 QString _old = mIconpath; 123 QString _old = mIconpath;
122 mIconpath = iconpath; 124 mIconpath = iconpath;
123 125
124 return _old; 126 return _old;
125} 127}
126QString KIconLoader::iconPath( const QString & name, int ) const 128QString KIconLoader::iconPath( const QString & name, int ) const
127{ 129{
128 return mIconpath + name + ".png"; 130 return mIconpath + name + ".png";
129} 131}
130 132
131QString KIconLoader::iconPath( /*US const QString &, int */) const 133QString KIconLoader::iconPath( /*US const QString &, int */) const
132{ 134{
133 // LR we set the path at startup 135 // LR we set the path at startup
134 // if (KGlobal::getDesktopSize() == KGlobal::Small) 136 // if (KGlobal::getDesktopSize() == KGlobal::Small)
135 //return mIconpath + "/icons16"; 137 //return mIconpath + "/icons16";
136 138
137 //Fall back to the defaultpath 139 //Fall back to the defaultpath
138 return mIconpath; 140 return mIconpath;
139} 141}
140 142
diff --git a/microkde/kiconloader.h b/microkde/kiconloader.h
index 68fec4e..2abb667 100644
--- a/microkde/kiconloader.h
+++ b/microkde/kiconloader.h
@@ -1,52 +1,52 @@
1#ifndef MINIKDE_KICONLOADER_H 1#ifndef MINIKDE_KICONLOADER_H
2#define MINIKDE_KICONLOADER_H 2#define MINIKDE_KICONLOADER_H
3 3
4#include <qpixmap.h> 4#include <qpixmap.h>
5#include <qstring.h> 5#include <qstring.h>
6//US 6//US
7#include <qiconset.h> 7#include <qicon.h>
8 8
9class KIcon 9class KIcon
10{ 10{
11 public: 11 public:
12 enum Group { NoGroup=-1, Desktop=0, Toolbar, MainToolbar, Small, 12 enum Group { NoGroup=-1, Desktop=0, Toolbar, MainToolbar, Small,
13 Panel, LastGroup, User }; 13 Panel, LastGroup, User };
14 enum StdSizes { SizeSmall=16, SizeMedium=32, SizeLarge=48 }; 14 enum StdSizes { SizeSmall=16, SizeMedium=32, SizeLarge=48 };
15 enum States { DefaultState, ActiveState, DisabledState, LastState }; 15 enum States { DefaultState, ActiveState, DisabledState, LastState };
16}; 16};
17 17
18class KIconLoader 18class KIconLoader
19{ 19{
20 public: 20 public:
21 KIconLoader() 21 KIconLoader()
22 : mIconpath(0) {} 22 : mIconpath(0) {}
23 23
24 KIconLoader( const QString &iconpath ) 24 KIconLoader( const QString &iconpath )
25 : mIconpath(iconpath) {} 25 : mIconpath(iconpath) {}
26 26
27//US QPixmap loadIcon( const QString &name, int ); 27//US QPixmap loadIcon( const QString &name, int );
28 28
29 QPixmap loadIcon(const QString& name, KIcon::Group group, int size=0, 29 QPixmap loadIcon(const QString& name, KIcon::Group group, int size=0,
30 int state=KIcon::DefaultState, QString *path_store=0, 30 int state=KIcon::DefaultState, QString *path_store=0,
31 bool canReturnNull=false) const; 31 bool canReturnNull=false) const;
32 32
33//US 33//US
34 QString setIconPath( const QString &); 34 QString setIconPath( const QString &);
35 QString iconPath( /*US const QString &, int */) const; 35 QString iconPath( /*US const QString &, int */) const;
36 QString iconPath( const QString &, int ) const; 36 QString iconPath( const QString &, int ) const;
37 QIconSet loadIconSet( const QString &name) const; 37 QIcon loadIconSet( const QString &name) const;
38 38
39//US to make this class usable for different applications, we have to add a iconpathvariable 39//US to make this class usable for different applications, we have to add a iconpathvariable
40 private: 40 private:
41 QString mIconpath; 41 QString mIconpath;
42}; 42};
43 43
44QPixmap BarIcon(const QString& name); 44QPixmap BarIcon(const QString& name);
45 45
46QPixmap DesktopIcon(const QString& name, int); 46QPixmap DesktopIcon(const QString& name, int);
47 47
48QPixmap SmallIcon(const QString& name); 48QPixmap SmallIcon(const QString& name);
49 49
50QPixmap SmallIconSet( const QString &name ); 50QPixmap SmallIconSet( const QString &name );
51 51
52#endif 52#endif
diff --git a/microkde/kio/kfile/kurlrequester.cpp b/microkde/kio/kfile/kurlrequester.cpp
index ca94570..ce62da7 100644
--- a/microkde/kio/kfile/kurlrequester.cpp
+++ b/microkde/kio/kfile/kurlrequester.cpp
@@ -1,409 +1,411 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> 2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
3 3
4 library is free software; you can redistribute it and/or 4 library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2, as published by the Free Software Foundation. 6 License version 2, as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19 19
20#include <sys/stat.h> 20#include <sys/stat.h>
21#ifdef _WIN32_ 21#ifdef _WIN32_
22 22
23#else 23#else
24#include <unistd.h> 24#include <unistd.h>
25#endif 25#endif
26#include <qstring.h> 26#include <qstring.h>
27//US #include <qtooltip.h> 27//US #include <qtooltip.h>
28 28
29#include <qpushbutton.h> 29#include <qpushbutton.h>
30//Added by qt3to4:
31#include <QPixmap>
30 32
31//US #include <kaccel.h> 33//US #include <kaccel.h>
32//US #include <kcombobox.h> 34//US #include <kcombobox.h>
33#include <kdebug.h> 35#include <kdebug.h>
34#include <kdialog.h> 36#include <kdialog.h>
35#include <kfiledialog.h> 37#include <kfiledialog.h>
36#include <kglobal.h> 38#include <kglobal.h>
37#include <kiconloader.h> 39#include <kiconloader.h>
38#include <klineedit.h> 40#include <klineedit.h>
39#include <klocale.h> 41#include <klocale.h>
40//US #include <kurlcompletion.h> 42//US #include <kurlcompletion.h>
41//US #include <kurldrag.h> 43//US #include <kurldrag.h>
42//US #include <kprotocolinfo.h> 44//US #include <kprotocolinfo.h>
43 45
44 46
45#include "kurlrequester.h" 47#include "kurlrequester.h"
46 48
47 49
48class KURLDragPushButton : public QPushButton 50class KURLDragPushButton : public QPushButton
49{ 51{
50public: 52public:
51 KURLDragPushButton( QWidget *parent, const char *name=0 ) 53 KURLDragPushButton( QWidget *parent, const char *name=0 )
52 : QPushButton( parent, name ) { 54 : QPushButton( parent, name ) {
53 //US setDragEnabled( true ); 55 //US setDragEnabled( true );
54 } 56 }
55 ~KURLDragPushButton() {} 57 ~KURLDragPushButton() {}
56 58
57 void setURL( const KURL& url ) { 59 void setURL( const KURL& url ) {
58 m_urls.clear(); 60 m_urls.clear();
59 m_urls.append( url ); 61 m_urls.append( url );
60 } 62 }
61 63
62 /* not needed so far 64 /* not needed so far
63 void setURLs( const KURL::List& urls ) { 65 void setURLs( const KURL::List& urls ) {
64 m_urls = urls; 66 m_urls = urls;
65 } 67 }
66 const KURL::List& urls() const { return m_urls; } 68 const KURL::List& urls() const { return m_urls; }
67 */ 69 */
68 70
69protected: 71protected:
70/*US 72/*US
71 virtual QDragObject *dragObject() { 73 virtual QDragObject *dragObject() {
72 if ( m_urls.isEmpty() ) 74 if ( m_urls.isEmpty() )
73 return 0L; 75 return 0L;
74 76
75 QDragObject *drag = KURLDrag::newDrag( m_urls, this, "url drag" ); 77 QDragObject *drag = KURLDrag::newDrag( m_urls, this, "url drag" );
76 return drag; 78 return drag;
77 } 79 }
78*/ 80*/
79private: 81private:
80 KURL::List m_urls; 82 KURL::List m_urls;
81 83
82}; 84};
83 85
84 86
85/* 87/*
86************************************************************************* 88*************************************************************************
87*/ 89*/
88 90
89class KURLRequester::KURLRequesterPrivate 91class KURLRequester::KURLRequesterPrivate
90{ 92{
91public: 93public:
92 KURLRequesterPrivate() { 94 KURLRequesterPrivate() {
93 edit = 0L; 95 edit = 0L;
94 //UScombo = 0L; 96 //UScombo = 0L;
95//US fileDialogMode = KFile::File | KFile::ExistingOnly | KFile::LocalOnly; 97//US fileDialogMode = KFile::File | KFile::ExistingOnly | KFile::LocalOnly;
96 } 98 }
97 99
98 void setText( const QString& text ) { 100 void setText( const QString& text ) {
99/*US 101/*US
100 if ( combo ) 102 if ( combo )
101 { 103 {
102 if (combo->editable()) 104 if (combo->editable())
103 { 105 {
104 combo->setEditText( text ); 106 combo->setEditText( text );
105 } 107 }
106 else 108 else
107 { 109 {
108 combo->insertItem( text ); 110 combo->insertItem( text );
109 combo->setCurrentItem( combo->count()-1 ); 111 combo->setCurrentItem( combo->count()-1 );
110 } 112 }
111 } 113 }
112 else 114 else
113*/ 115*/
114 { 116 {
115 edit->setText( text ); 117 edit->setText( text );
116 } 118 }
117 } 119 }
118 120
119 void connectSignals( QObject *receiver ) { 121 void connectSignals( QObject *receiver ) {
120 QObject *sender; 122 QObject *sender;
121 /*USif ( combo ) 123 /*USif ( combo )
122 sender = combo; 124 sender = combo;
123 else 125 else
124*/ 126*/
125 sender = edit; 127 sender = edit;
126 128
127 connect( sender, SIGNAL( textChanged( const QString& )), 129 connect( sender, SIGNAL( textChanged( const QString& )),
128 receiver, SIGNAL( textChanged( const QString& ))); 130 receiver, SIGNAL( textChanged( const QString& )));
129 connect( sender, SIGNAL( returnPressed() ), 131 connect( sender, SIGNAL( returnPressed() ),
130 receiver, SIGNAL( returnPressed() )); 132 receiver, SIGNAL( returnPressed() ));
131 //USconnect( sender, SIGNAL( returnPressed( const QString& ) ), 133 //USconnect( sender, SIGNAL( returnPressed( const QString& ) ),
132 //US receiver, SIGNAL( returnPressed( const QString& ) )); 134 //US receiver, SIGNAL( returnPressed( const QString& ) ));
133 } 135 }
134/*US 136/*US
135 void setCompletionObject( KCompletion *comp ) { 137 void setCompletionObject( KCompletion *comp ) {
136 if ( combo ) 138 if ( combo )
137 combo->setCompletionObject( comp ); 139 combo->setCompletionObject( comp );
138 else 140 else
139 edit->setCompletionObject( comp ); 141 edit->setCompletionObject( comp );
140 } 142 }
141 */ 143 */
142 /** 144 /**
143 * replaces ~user or $FOO, if necessary 145 * replaces ~user or $FOO, if necessary
144 */ 146 */
145 QString url() { 147 QString url() {
146 QString txt = /*US combo ? combo->currentText() : */ edit->text(); 148 QString txt = /*US combo ? combo->currentText() : */ edit->text();
147/*US KURLCompletion *comp; 149/*US KURLCompletion *comp;
148 if ( combo ) 150 if ( combo )
149 comp = dynamic_cast<KURLCompletion*>(combo->completionObject()); 151 comp = dynamic_cast<KURLCompletion*>(combo->completionObject());
150 else 152 else
151 comp = dynamic_cast<KURLCompletion*>(edit->completionObject()); 153 comp = dynamic_cast<KURLCompletion*>(edit->completionObject());
152 154
153 if ( comp ) 155 if ( comp )
154 return comp->replacedPath( txt ); 156 return comp->replacedPath( txt );
155 else 157 else
156*/ 158*/
157 return txt; 159 return txt;
158 } 160 }
159 161
160 KLineEdit *edit; 162 KLineEdit *edit;
161//US KComboBox *combo; 163//US KComboBox *combo;
162 int fileDialogMode; 164 int fileDialogMode;
163 QString fileDialogFilter; 165 QString fileDialogFilter;
164}; 166};
165 167
166 168
167/*US 169/*US
168KURLRequester::KURLRequester( QWidget *editWidget, QWidget *parent, 170KURLRequester::KURLRequester( QWidget *editWidget, QWidget *parent,
169 const char *name ) 171 const char *name )
170 : QHBox( parent, name ) 172 : QHBox( parent, name )
171{ 173{
172 d = new KURLRequesterPrivate; 174 d = new KURLRequesterPrivate;
173 175
174 // must have this as parent 176 // must have this as parent
175 editWidget->reparent( this, 0, QPoint(0,0) ); 177 editWidget->reparent( this, 0, QPoint(0,0) );
176//US d->edit = dynamic_cast<KLineEdit*>( editWidget ); 178//US d->edit = dynamic_cast<KLineEdit*>( editWidget );
177 d->edit = (KLineEdit*)( editWidget ); 179 d->edit = (KLineEdit*)( editWidget );
178//US d->combo = dynamic_cast<KComboBox*>( editWidget ); 180//US d->combo = dynamic_cast<KComboBox*>( editWidget );
179 181
180 init(); 182 init();
181} 183}
182*/ 184*/
183 185
184KURLRequester::KURLRequester( QWidget *parent, const char *name ) 186KURLRequester::KURLRequester( QWidget *parent, const char *name )
185 : QHBox( parent, name ) 187 : Q3HBox( parent, name )
186{ 188{
187 d = new KURLRequesterPrivate; 189 d = new KURLRequesterPrivate;
188 init(); 190 init();
189} 191}
190 192
191 193
192KURLRequester::KURLRequester( const QString& url, QWidget *parent, 194KURLRequester::KURLRequester( const QString& url, QWidget *parent,
193 const char *name ) 195 const char *name )
194 : QHBox( parent, name ) 196 : Q3HBox( parent, name )
195{ 197{
196 d = new KURLRequesterPrivate; 198 d = new KURLRequesterPrivate;
197 init(); 199 init();
198 setURL( url ); 200 setURL( url );
199} 201}
200 202
201 203
202KURLRequester::~KURLRequester() 204KURLRequester::~KURLRequester()
203{ 205{
204//US delete myCompletion; 206//US delete myCompletion;
205 delete myFileDialog; 207 delete myFileDialog;
206 delete d; 208 delete d;
207} 209}
208 210
209 211
210void KURLRequester::init() 212void KURLRequester::init()
211{ 213{
212 myFileDialog = 0L; 214 myFileDialog = 0L;
213 myShowLocalProt = false; 215 myShowLocalProt = false;
214 mPathIsDir = false; 216 mPathIsDir = false;
215 if (/*US !d->combo && */ !d->edit ) 217 if (/*US !d->combo && */ !d->edit )
216 d->edit = new KLineEdit( this, "KURLRequester::KLineEdit" ); 218 d->edit = new KLineEdit( this, "KURLRequester::KLineEdit" );
217 219
218 myButton = new KURLDragPushButton( this, "kfile button"); 220 myButton = new KURLDragPushButton( this, "kfile button");
219 QIconSet iconSet = SmallIconSet("fileopen"); 221 QIcon iconSet = SmallIconSet("fileopen");
220 QPixmap pixMap = iconSet.pixmap( QIconSet::Small, QIconSet::Normal ); 222 QPixmap pixMap = iconSet.pixmap( QIcon::Small, QIcon::Normal );
221 myButton->setIconSet( iconSet ); 223 myButton->setIconSet( iconSet );
222 myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 ); 224 myButton->setFixedSize( pixMap.width()+8, pixMap.height()+8 );
223//US QToolTip::add(myButton, i18n("Open file dialog")); 225//US QToolTip::add(myButton, i18n("Open file dialog"));
224 226
225 connect( myButton, SIGNAL( pressed() ), SLOT( slotUpdateURL() )); 227 connect( myButton, SIGNAL( pressed() ), SLOT( slotUpdateURL() ));
226 228
227 setSpacing( KDialog::spacingHint() ); 229 setSpacing( KDialog::spacingHint() );
228 230
229 QWidget *widget = /*US d->combo ? (QWidget*) d->combo : */ (QWidget*) d->edit; 231 QWidget *widget = /*US d->combo ? (QWidget*) d->combo : */ (QWidget*) d->edit;
230 setFocusProxy( widget ); 232 setFocusProxy( widget );
231 233
232 d->connectSignals( this ); 234 d->connectSignals( this );
233 connect( myButton, SIGNAL( clicked() ), this, SLOT( slotOpenDialog() )); 235 connect( myButton, SIGNAL( clicked() ), this, SLOT( slotOpenDialog() ));
234/*US 236/*US
235 myCompletion = new KURLCompletion(); 237 myCompletion = new KURLCompletion();
236 d->setCompletionObject( myCompletion ); 238 d->setCompletionObject( myCompletion );
237 239
238 KAccel *accel = new KAccel( this ); 240 KAccel *accel = new KAccel( this );
239 accel->insert( KStdAccel::Open, this, SLOT( slotOpenDialog() )); 241 accel->insert( KStdAccel::Open, this, SLOT( slotOpenDialog() ));
240 accel->readSettings(); 242 accel->readSettings();
241*/ 243*/
242} 244}
243 245
244 246
245void KURLRequester::setURL( const QString& url ) 247void KURLRequester::setURL( const QString& url )
246{ 248{
247 bool hasLocalPrefix = (url.startsWith("file:")); 249 bool hasLocalPrefix = (url.startsWith("file:"));
248 250
249 if ( !myShowLocalProt && hasLocalPrefix ) 251 if ( !myShowLocalProt && hasLocalPrefix )
250 d->setText( url.mid( 5, url.length()-5 )); 252 d->setText( url.mid( 5, url.length()-5 ));
251 else 253 else
252 d->setText( url ); 254 d->setText( url );
253} 255}
254 256
255void KURLRequester::setCaption( const QString& caption ) 257void KURLRequester::setCaption( const QString& caption )
256{ 258{
257 //USfileDialog()->setCaption( caption ); 259 //USfileDialog()->setCaption( caption );
258 //USQWidget::setCaption( caption ); 260 //USQWidget::setCaption( caption );
259} 261}
260 262
261QString KURLRequester::url() const 263QString KURLRequester::url() const
262{ 264{
263 return d->url(); 265 return d->url();
264} 266}
265 267
266 268
267void KURLRequester::slotOpenDialog() 269void KURLRequester::slotOpenDialog()
268{ 270{
269 emit openFileDialog( this ); 271 emit openFileDialog( this );
270 272
271//US use our special KFIleDialog instead 273//US use our special KFIleDialog instead
272 KURL u( url() ); 274 KURL u( url() );
273 //QString fn = u.url(); 275 //QString fn = u.url();
274 QString fn = d->edit->text(); 276 QString fn = d->edit->text();
275 if ( mPathIsDir ) 277 if ( mPathIsDir )
276 fn = KFileDialog::getExistingDirectory ( fn, "", this ); 278 fn = KFileDialog::getExistingDirectory ( fn, "", this );
277 else 279 else
278 fn = KFileDialog::getSaveFileName( fn, "", this ); 280 fn = KFileDialog::getSaveFileName( fn, "", this );
279 281
280 if ( fn == "" ) 282 if ( fn == "" )
281 return; 283 return;
282 284
283 setURL( fn ); 285 setURL( fn );
284 emit urlSelected( d->url() ); 286 emit urlSelected( d->url() );
285/*US 287/*US
286 KFileDialog *dlg = fileDialog(); 288 KFileDialog *dlg = fileDialog();
287 if ( !d->url().isEmpty() ) { 289 if ( !d->url().isEmpty() ) {
288 KURL u( url() ); 290 KURL u( url() );
289 // If we won't be able to list it (e.g. http), then don't try :) 291 // If we won't be able to list it (e.g. http), then don't try :)
290 if ( KProtocolInfo::supportsListing( u.protocol() ) ) 292 if ( KProtocolInfo::supportsListing( u.protocol() ) )
291 dlg->setSelection( u.url() ); 293 dlg->setSelection( u.url() );
292 } 294 }
293 295
294 if ( dlg->exec() == QDialog::Accepted ) 296 if ( dlg->exec() == QDialog::Accepted )
295 { 297 {
296 setURL( dlg->selectedURL().prettyURL() ); 298 setURL( dlg->selectedURL().prettyURL() );
297 emit urlSelected( d->url() ); 299 emit urlSelected( d->url() );
298 } 300 }
299*/ 301*/
300 302
301} 303}
302 304
303void KURLRequester::setMode(unsigned int mode) 305void KURLRequester::setMode(unsigned int mode)
304{ 306{
305/*US 307/*US
306 Q_ASSERT( (mode & KFile::Files) == 0 ); 308 Q_ASSERT( (mode & KFile::Files) == 0 );
307 d->fileDialogMode = mode; 309 d->fileDialogMode = mode;
308 if ( (mode & KFile::Directory) && !(mode & KFile::File) ) 310 if ( (mode & KFile::Directory) && !(mode & KFile::File) )
309 myCompletion->setMode( KURLCompletion::DirCompletion ); 311 myCompletion->setMode( KURLCompletion::DirCompletion );
310 312
311 if (myFileDialog) 313 if (myFileDialog)
312 myFileDialog->setMode( d->fileDialogMode ); 314 myFileDialog->setMode( d->fileDialogMode );
313*/ 315*/
314} 316}
315 317
316void KURLRequester::setFilter(const QString &filter) 318void KURLRequester::setFilter(const QString &filter)
317{ 319{
318/*US 320/*US
319 d->fileDialogFilter = filter; 321 d->fileDialogFilter = filter;
320 if (myFileDialog) 322 if (myFileDialog)
321 myFileDialog->setFilter( d->fileDialogFilter ); 323 myFileDialog->setFilter( d->fileDialogFilter );
322*/ 324*/
323} 325}
324 326
325KFileDialog * KURLRequester::fileDialog() const 327KFileDialog * KURLRequester::fileDialog() const
326{ 328{
327/*US 329/*US
328 if ( !myFileDialog ) { 330 if ( !myFileDialog ) {
329 QWidget *p = parentWidget(); 331 QWidget *p = parentWidget();
330 myFileDialog = new KFileDialog( QString::null, QString::null, p, 332 myFileDialog = new KFileDialog( QString::null, QString::null, p,
331 "file dialog", true ); 333 "file dialog", true );
332 334
333 myFileDialog->setMode( d->fileDialogMode ); 335 myFileDialog->setMode( d->fileDialogMode );
334 myFileDialog->setFilter( d->fileDialogFilter ); 336 myFileDialog->setFilter( d->fileDialogFilter );
335 } 337 }
336 338
337 return myFileDialog; 339 return myFileDialog;
338*/ 340*/
339 return 0; 341 return 0;
340} 342}
341 343
342 344
343void KURLRequester::setShowLocalProtocol( bool b ) 345void KURLRequester::setShowLocalProtocol( bool b )
344{ 346{
345 if ( myShowLocalProt == b ) 347 if ( myShowLocalProt == b )
346 return; 348 return;
347 349
348 myShowLocalProt = b; 350 myShowLocalProt = b;
349 setURL( url() ); 351 setURL( url() );
350} 352}
351 353
352void KURLRequester::clear() 354void KURLRequester::clear()
353{ 355{
354 d->setText( QString::null ); 356 d->setText( QString::null );
355} 357}
356 358
357KLineEdit * KURLRequester::lineEdit() const 359KLineEdit * KURLRequester::lineEdit() const
358{ 360{
359 return d->edit; 361 return d->edit;
360} 362}
361/*US 363/*US
362KComboBox * KURLRequester::comboBox() const 364KComboBox * KURLRequester::comboBox() const
363{ 365{
364 return d->combo; 366 return d->combo;
365} 367}
366*/ 368*/
367void KURLRequester::slotUpdateURL() 369void KURLRequester::slotUpdateURL()
368{ 370{
369 // bin compat, myButton is declared as QPushButton 371 // bin compat, myButton is declared as QPushButton
370//US KURL u( QDir::currentDirPath() + '/', url() ); 372//US KURL u( QDir::currentDirPath() + '/', url() );
371 KURL u( url() ); 373 KURL u( url() );
372 (static_cast<KURLDragPushButton *>( myButton))->setURL( u ); 374 (static_cast<KURLDragPushButton *>( myButton))->setURL( u );
373} 375}
374 376
375QPushButton * KURLRequester::button() const 377QPushButton * KURLRequester::button() const
376{ 378{
377 return myButton; 379 return myButton;
378} 380}
379/*US 381/*US
380KEditListBox::CustomEditor KURLRequester::customEditor() 382KEditListBox::CustomEditor KURLRequester::customEditor()
381{ 383{
382 setSizePolicy(QSizePolicy( QSizePolicy::Preferred, 384 setSizePolicy(QSizePolicy( QSizePolicy::Preferred,
383 QSizePolicy::Fixed)); 385 QSizePolicy::Fixed));
384 386
385 KLineEdit *edit = d->edit; 387 KLineEdit *edit = d->edit;
386 if ( !edit && d->combo ) 388 if ( !edit && d->combo )
387 edit = dynamic_cast<KLineEdit*>( d->combo->lineEdit() ); 389 edit = dynamic_cast<KLineEdit*>( d->combo->lineEdit() );
388 390
389#ifndef NDEBUG 391#ifndef NDEBUG
390 if ( !edit ) 392 if ( !edit )
391 kdWarning() << "KURLRequester's lineedit is not a KLineEdit!??\n"; 393 kdWarning() << "KURLRequester's lineedit is not a KLineEdit!??\n";
392#endif 394#endif
393 395
394 KEditListBox::CustomEditor editor( this, edit ); 396 KEditListBox::CustomEditor editor( this, edit );
395 return editor; 397 return editor;
396} 398}
397*/ 399*/
398void KURLRequester::virtual_hook( int, void* ) 400void KURLRequester::virtual_hook( int, void* )
399{ /*BASE::virtual_hook( id, data );*/ } 401{ /*BASE::virtual_hook( id, data );*/ }
400 402
401/*US 403/*US
402KURLComboRequester::KURLComboRequester( QWidget *parent, 404KURLComboRequester::KURLComboRequester( QWidget *parent,
403 const char *name ) 405 const char *name )
404 : KURLRequester( new KComboBox(false), parent, name) 406 : KURLRequester( new KComboBox(false), parent, name)
405{ 407{
406} 408}
407*/ 409*/
408 410
409//US #include "kurlrequester.moc" 411//US #include "kurlrequester.moc"
diff --git a/microkde/kio/kfile/kurlrequester.h b/microkde/kio/kfile/kurlrequester.h
index faa3326..5d4fa11 100644
--- a/microkde/kio/kfile/kurlrequester.h
+++ b/microkde/kio/kfile/kurlrequester.h
@@ -1,271 +1,271 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org> 2 Copyright (C) 1999,2000,2001 Carsten Pfeiffer <pfeiffer@kde.org>
3 3
4 library is free software; you can redistribute it and/or 4 library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License version 2, as published by the Free Software Foundation. 6 License version 2, as published by the Free Software Foundation.
7 7
8 This library is distributed in the hope that it will be useful, 8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details. 11 Library General Public License for more details.
12 12
13 You should have received a copy of the GNU Library General Public License 13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to 14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 15 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 Boston, MA 02111-1307, USA. 16 Boston, MA 02111-1307, USA.
17*/ 17*/
18 18
19 19
20#ifndef KURLREQUESTER_H 20#ifndef KURLREQUESTER_H
21#define KURLREQUESTER_H 21#define KURLREQUESTER_H
22 22
23#include <qhbox.h> 23#include <q3hbox.h>
24 24
25#include <keditlistbox.h> 25#include <keditlistbox.h>
26//US #include <kfile.h> 26//US #include <kfile.h>
27//US #include <kpushbutton.h> 27//US #include <kpushbutton.h>
28#include <kurl.h> 28#include <kurl.h>
29 29
30//US class KComboBox; 30//US class KComboBox;
31 31
32class KFileDialog; 32class KFileDialog;
33class KLineEdit; 33class KLineEdit;
34//US class KURLCompletion; 34//US class KURLCompletion;
35class KURLDragPushButton; 35class KURLDragPushButton;
36 36
37class QPushButton; 37class QPushButton;
38class QString; 38class QString;
39class QTimer; 39class QTimer;
40 40
41/** 41/**
42 * This class is a widget showing a lineedit and a button, which invokes a 42 * This class is a widget showing a lineedit and a button, which invokes a
43 * filedialog. File name completion is available in the lineedit. 43 * filedialog. File name completion is available in the lineedit.
44 * 44 *
45 * The defaults for the filedialog are to ask for one existing local file, i.e. 45 * The defaults for the filedialog are to ask for one existing local file, i.e.
46 * KFileDialog::setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly ) 46 * KFileDialog::setMode( KFile::File | KFile::ExistingOnly | KFile::LocalOnly )
47 * The default filter is "*", i.e. show all files, and the start directory is 47 * The default filter is "*", i.e. show all files, and the start directory is
48 * the current working directory, or the last directory where a file has been 48 * the current working directory, or the last directory where a file has been
49 * selected. 49 * selected.
50 * 50 *
51 * You can change this behavior by using @ref setMode() or @ref setFilter(). 51 * You can change this behavior by using @ref setMode() or @ref setFilter().
52 * 52 *
53 * @short A widget to request a filename/url from the user 53 * @short A widget to request a filename/url from the user
54 * @author Carsten Pfeiffer <pfeiffer@kde.org> 54 * @author Carsten Pfeiffer <pfeiffer@kde.org>
55 */ 55 */
56class KURLRequester : public QHBox 56class KURLRequester : public Q3HBox
57{ 57{
58 Q_OBJECT 58 Q_OBJECT
59 Q_PROPERTY( QString url READ url WRITE setURL ) 59 Q_PROPERTY( QString url READ url WRITE setURL )
60 60
61public: 61public:
62 /** 62 /**
63 * Constructs a KURLRequester widget. 63 * Constructs a KURLRequester widget.
64 */ 64 */
65 KURLRequester( QWidget *parent=0, const char *name=0 ); 65 KURLRequester( QWidget *parent=0, const char *name=0 );
66 66
67 /** 67 /**
68 * Constructs a KURLRequester widget with the initial URL @p url. 68 * Constructs a KURLRequester widget with the initial URL @p url.
69 */ 69 */
70 KURLRequester( const QString& url, QWidget *parent=0, const char *name=0 ); 70 KURLRequester( const QString& url, QWidget *parent=0, const char *name=0 );
71 71
72 /** 72 /**
73 * Special constructor, which creates a KURLRequester widget with a custom 73 * Special constructor, which creates a KURLRequester widget with a custom
74 * edit-widget. The edit-widget can be either a KComboBox or a KLineEdit 74 * edit-widget. The edit-widget can be either a KComboBox or a KLineEdit
75 * (or inherited thereof). Note: for geometry management reasons, the 75 * (or inherited thereof). Note: for geometry management reasons, the
76 * edit-widget is reparented to have the KURLRequester as parent. 76 * edit-widget is reparented to have the KURLRequester as parent.
77 * @param modal specifies whether the filedialog should be opened as modal 77 * @param modal specifies whether the filedialog should be opened as modal
78 * or not. 78 * or not.
79 */ 79 */
80//US KURLRequester( QWidget *editWidget, QWidget *parent, const char *name=0 ); 80//US KURLRequester( QWidget *editWidget, QWidget *parent, const char *name=0 );
81 /** 81 /**
82 * Destructs the KURLRequester. 82 * Destructs the KURLRequester.
83 */ 83 */
84 ~KURLRequester(); 84 ~KURLRequester();
85 85
86 /** 86 /**
87 * @returns the current url in the lineedit. May be malformed, if the user 87 * @returns the current url in the lineedit. May be malformed, if the user
88 * entered something weird. ~user or environment variables are substituted 88 * entered something weird. ~user or environment variables are substituted
89 * for local files. 89 * for local files.
90 */ 90 */
91 QString url() const; 91 QString url() const;
92 92
93 /** 93 /**
94 * Enables/disables showing file:/ in the lineedit, when a local file has 94 * Enables/disables showing file:/ in the lineedit, when a local file has
95 * been selected in the filedialog or was set via @ref setURL(). 95 * been selected in the filedialog or was set via @ref setURL().
96 * Default is false, not showing file:/ 96 * Default is false, not showing file:/
97 * @see #showLocalProtocol 97 * @see #showLocalProtocol
98 */ 98 */
99 void setShowLocalProtocol( bool b ); 99 void setShowLocalProtocol( bool b );
100 100
101 /** 101 /**
102 * Sets the mode of the file dialog. 102 * Sets the mode of the file dialog.
103 * Note: you can only select one file with the filedialog, 103 * Note: you can only select one file with the filedialog,
104 * so KFile::Files doesn't make much sense. 104 * so KFile::Files doesn't make much sense.
105 * @see KFileDialog::setMode() 105 * @see KFileDialog::setMode()
106 */ 106 */
107 void setMode( unsigned int m ); 107 void setMode( unsigned int m );
108 void setPathIsDir( ) {mPathIsDir = true;} 108 void setPathIsDir( ) {mPathIsDir = true;}
109 109
110 /** 110 /**
111 * Sets the filter for the file dialog. 111 * Sets the filter for the file dialog.
112 * @see KFileDialog::setFilter() 112 * @see KFileDialog::setFilter()
113 */ 113 */
114 void setFilter( const QString& filter ); 114 void setFilter( const QString& filter );
115 115
116 /** 116 /**
117 * @returns whether local files will be prefixed with file:/ in the 117 * @returns whether local files will be prefixed with file:/ in the
118 * lineedit 118 * lineedit
119 * @see #setShowLocalProtocol 119 * @see #setShowLocalProtocol
120 */ 120 */
121 bool showLocalProtocol() const { return myShowLocalProt; } 121 bool showLocalProtocol() const { return myShowLocalProt; }
122 122
123 /** 123 /**
124 * @returns a pointer to the filedialog 124 * @returns a pointer to the filedialog
125 * You can use this to customize the dialog, e.g. to specify a filter. 125 * You can use this to customize the dialog, e.g. to specify a filter.
126 * Never returns 0L. 126 * Never returns 0L.
127 */ 127 */
128 virtual KFileDialog * fileDialog() const; 128 virtual KFileDialog * fileDialog() const;
129 129
130 /** 130 /**
131 * @returns a pointer to the lineedit, either the default one, or the 131 * @returns a pointer to the lineedit, either the default one, or the
132 * special one, if you used the special constructor. 132 * special one, if you used the special constructor.
133 * 133 *
134 * It is provided so that you can e.g. set an own completion object 134 * It is provided so that you can e.g. set an own completion object
135 * (e.g. @ref KShellCompletion) into it. 135 * (e.g. @ref KShellCompletion) into it.
136 */ 136 */
137 KLineEdit * lineEdit() const; 137 KLineEdit * lineEdit() const;
138 138
139 /** 139 /**
140 * @returns a pointer to the combobox, in case you have set one using the 140 * @returns a pointer to the combobox, in case you have set one using the
141 * special constructor. Returns 0L otherwise. 141 * special constructor. Returns 0L otherwise.
142 */ 142 */
143//US KComboBox * comboBox() const; 143//US KComboBox * comboBox() const;
144 144
145 /** 145 /**
146 * @returns a pointer to the pushbutton. It is provided so that you can 146 * @returns a pointer to the pushbutton. It is provided so that you can
147 * specify an own pixmap or a text, if you really need to. 147 * specify an own pixmap or a text, if you really need to.
148 */ 148 */
149 QPushButton * button() const; 149 QPushButton * button() const;
150 150
151 /** 151 /**
152 * @returns the KURLCompletion object used in the lineedit/combobox. 152 * @returns the KURLCompletion object used in the lineedit/combobox.
153 */ 153 */
154//US KURLCompletion *completionObject() const { return myCompletion; } 154//US KURLCompletion *completionObject() const { return myCompletion; }
155 155
156 /** 156 /**
157 * @returns an object, suitable for use with KEditListBox. It allows you 157 * @returns an object, suitable for use with KEditListBox. It allows you
158 * to put this KURLRequester into a KEditListBox. 158 * to put this KURLRequester into a KEditListBox.
159 * Basically, do it like this: 159 * Basically, do it like this:
160 * <pre> 160 * <pre>
161 * KURLRequester *req = new KURLRequester( someWidget ); 161 * KURLRequester *req = new KURLRequester( someWidget );
162 * [...] 162 * [...]
163 * KEditListBox *editListBox = new KEditListBox( i18n("Some Title"), req->customEditor(), someWidget ); 163 * KEditListBox *editListBox = new KEditListBox( i18n("Some Title"), req->customEditor(), someWidget );
164 * </pre> 164 * </pre>
165 * @since 3.1 165 * @since 3.1
166 */ 166 */
167//US KEditListBox::CustomEditor customEditor(); 167//US KEditListBox::CustomEditor customEditor();
168 168
169public slots: 169public slots:
170 /** 170 /**
171 * Sets the url in the lineedit to @p url. Depending on the state of 171 * Sets the url in the lineedit to @p url. Depending on the state of
172 * @ref showLocalProtocol(), file:/ on local files will be shown or not. 172 * @ref showLocalProtocol(), file:/ on local files will be shown or not.
173 * @since 3.1 173 * @since 3.1
174 */ 174 */
175 void setURL( const QString& url ); 175 void setURL( const QString& url );
176 176
177 /** 177 /**
178 * @reimp 178 * @reimp
179 * Sets the caption of the file dialog. 179 * Sets the caption of the file dialog.
180 * @since 3.1 180 * @since 3.1
181 */ 181 */
182 virtual void setCaption( const QString& caption ); 182 virtual void setCaption( const QString& caption );
183 183
184 /** 184 /**
185 * Clears the lineedit/combobox. 185 * Clears the lineedit/combobox.
186 */ 186 */
187 void clear(); 187 void clear();
188 188
189signals: 189signals:
190 // forwards from LineEdit 190 // forwards from LineEdit
191 /** 191 /**
192 * Emitted when the text in the lineedit changes. 192 * Emitted when the text in the lineedit changes.
193 * The parameter contains the contents of the lineedit. 193 * The parameter contains the contents of the lineedit.
194 * @since 3.1 194 * @since 3.1
195 */ 195 */
196 void textChanged( const QString& ); 196 void textChanged( const QString& );
197 197
198 /** 198 /**
199 * Emitted when return or enter was pressed in the lineedit. 199 * Emitted when return or enter was pressed in the lineedit.
200 */ 200 */
201 void returnPressed(); 201 void returnPressed();
202 202
203 /** 203 /**
204 * Emitted when return or enter was pressed in the lineedit. 204 * Emitted when return or enter was pressed in the lineedit.
205 * The parameter contains the contents of the lineedit. 205 * The parameter contains the contents of the lineedit.
206 */ 206 */
207 void returnPressed( const QString& ); 207 void returnPressed( const QString& );
208 208
209 /** 209 /**
210 * Emitted before the filedialog is going to open. Connect 210 * Emitted before the filedialog is going to open. Connect
211 * to this signal to "configure" the filedialog, e.g. set the 211 * to this signal to "configure" the filedialog, e.g. set the
212 * filefilter, the mode, a preview-widget, etc. It's usually 212 * filefilter, the mode, a preview-widget, etc. It's usually
213 * not necessary to set a URL for the filedialog, as it will 213 * not necessary to set a URL for the filedialog, as it will
214 * get set properly from the editfield contents. 214 * get set properly from the editfield contents.
215 * 215 *
216 * If you use multiple KURLRequesters, you can connect all of them 216 * If you use multiple KURLRequesters, you can connect all of them
217 * to the same slot and use the given KURLRequester pointer to know 217 * to the same slot and use the given KURLRequester pointer to know
218 * which one is going to open. 218 * which one is going to open.
219 */ 219 */
220 void openFileDialog( KURLRequester * ); 220 void openFileDialog( KURLRequester * );
221 221
222 /** 222 /**
223 * Emitted when the user changed the URL via the file dialog. 223 * Emitted when the user changed the URL via the file dialog.
224 * The parameter contains the contents of the lineedit. 224 * The parameter contains the contents of the lineedit.
225 */ 225 */
226 void urlSelected( const QString& ); 226 void urlSelected( const QString& );
227 227
228protected: 228protected:
229 void init(); 229 void init();
230 230
231//US KURLCompletion * myCompletion; 231//US KURLCompletion * myCompletion;
232 232
233 233
234private: 234private:
235 KURLDragPushButton * myButton; 235 KURLDragPushButton * myButton;
236 bool myShowLocalProt; 236 bool myShowLocalProt;
237 mutable KFileDialog * myFileDialog; 237 mutable KFileDialog * myFileDialog;
238 bool mPathIsDir; 238 bool mPathIsDir;
239 239
240 240
241protected slots: 241protected slots:
242 /** 242 /**
243 * Called when the button is pressed to open the filedialog. 243 * Called when the button is pressed to open the filedialog.
244 * Also called when @ref KStdAccel::Open (default is Ctrl-O) is pressed. 244 * Also called when @ref KStdAccel::Open (default is Ctrl-O) is pressed.
245 */ 245 */
246 void slotOpenDialog(); 246 void slotOpenDialog();
247 247
248private slots: 248private slots:
249 void slotUpdateURL(); 249 void slotUpdateURL();
250 250
251protected: 251protected:
252 virtual void virtual_hook( int id, void* data ); 252 virtual void virtual_hook( int id, void* data );
253private: 253private:
254 class KURLRequesterPrivate; 254 class KURLRequesterPrivate;
255 KURLRequesterPrivate *d; 255 KURLRequesterPrivate *d;
256}; 256};
257/*US 257/*US
258class KURLComboRequester : public KURLRequester // For use in Qt Designer 258class KURLComboRequester : public KURLRequester // For use in Qt Designer
259{ 259{
260 Q_OBJECT 260 Q_OBJECT
261public: 261public:
262*/ 262*/
263 /** 263 /**
264 * Constructs a KURLRequester widget with a combobox. 264 * Constructs a KURLRequester widget with a combobox.
265 */ 265 */
266/*US 266/*US
267 KURLComboRequester( QWidget *parent=0, const char *name=0 ); 267 KURLComboRequester( QWidget *parent=0, const char *name=0 );
268}; 268};
269*/ 269*/
270 270
271#endif // KURLREQUESTER_H 271#endif // KURLREQUESTER_H
diff --git a/microkde/kio/kio/kdirwatch.cpp b/microkde/kio/kio/kdirwatch.cpp
index 1596d1f..5f07c54 100644
--- a/microkde/kio/kio/kdirwatch.cpp
+++ b/microkde/kio/kio/kdirwatch.cpp
@@ -1,1394 +1,1396 @@
1// -*- c-basic-offset: 2 -*- 1// -*- c-basic-offset: 2 -*-
2/* This file is part of the KDE libraries 2/* This file is part of the KDE libraries
3 Copyright (C) 1998 Sven Radej <sven@lisa.exp.univie.ac.at> 3 Copyright (C) 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License version 2 as published by the Free Software Foundation. 7 License version 2 as published by the Free Software Foundation.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20/* 20/*
21Enhanced Version of the file for platform independent KDE tools. 21Enhanced Version of the file for platform independent KDE tools.
22Copyright (c) 2004 Ulf Schenk 22Copyright (c) 2004 Ulf Schenk
23 23
24$Id$ 24$Id$
25*/ 25*/
26 26
27 27
28// CHANGES: 28// CHANGES:
29// Februar 2002 - Add file watching and remote mount check for STAT 29// Februar 2002 - Add file watching and remote mount check for STAT
30// Mar 30, 2001 - Native support for Linux dir change notification. 30// Mar 30, 2001 - Native support for Linux dir change notification.
31// Jan 28, 2000 - Usage of FAM service on IRIX (Josef.Weidendorfer@in.tum.de) 31// Jan 28, 2000 - Usage of FAM service on IRIX (Josef.Weidendorfer@in.tum.de)
32// May 24. 1998 - List of times introduced, and some bugs are fixed. (sven) 32// May 24. 1998 - List of times introduced, and some bugs are fixed. (sven)
33// May 23. 1998 - Removed static pointer - you can have more instances. 33// May 23. 1998 - Removed static pointer - you can have more instances.
34// It was Needed for KRegistry. KDirWatch now emits signals and doesn't 34// It was Needed for KRegistry. KDirWatch now emits signals and doesn't
35// call (or need) KFM. No more URL's - just plain paths. (sven) 35// call (or need) KFM. No more URL's - just plain paths. (sven)
36// Mar 29. 1998 - added docs, stop/restart for particular Dirs and 36// Mar 29. 1998 - added docs, stop/restart for particular Dirs and
37// deep copies for list of dirs. (sven) 37// deep copies for list of dirs. (sven)
38// Mar 28. 1998 - Created. (sven) 38// Mar 28. 1998 - Created. (sven)
39 39
40 40
41//US #include <config.h> 41//US #include <config.h>
42 42
43#ifdef HAVE_DNOTIFY 43#ifdef HAVE_DNOTIFY
44#include <unistd.h> 44#include <unistd.h>
45#include <time.h> 45#include <time.h>
46#include <fcntl.h> 46#include <fcntl.h>
47#include <signal.h> 47#include <signal.h>
48#include <errno.h> 48#include <errno.h>
49#endif 49#endif
50 50
51#include <sys/stat.h> 51#include <sys/stat.h>
52#include <assert.h> 52#include <assert.h>
53#include <qdir.h> 53#include <qdir.h>
54#include <qfile.h> 54#include <qfile.h>
55#include <qintdict.h> 55#include <q3intdict.h>
56#include <qptrlist.h> 56#include <q3ptrlist.h>
57#include <qsocketnotifier.h> 57#include <qsocketnotifier.h>
58#include <qstringlist.h> 58#include <qstringlist.h>
59#include <qtimer.h> 59#include <qtimer.h>
60//Added by qt3to4:
61#include <Q3CString>
60 62
61#include <kapplication.h> 63#include <kapplication.h>
62#include <kdebug.h> 64#include <kdebug.h>
63#include <kconfig.h> 65#include <kconfig.h>
64#include <kconfigbase.h> 66#include <kconfigbase.h>
65#include <kglobal.h> 67#include <kglobal.h>
66#include <kstaticdeleter.h> 68#include <kstaticdeleter.h>
67 69
68#include "kdirwatch.h" 70#include "kdirwatch.h"
69#include "kdirwatch_p.h" 71#include "kdirwatch_p.h"
70//US #include "global.h" // KIO::probably_slow_mounted 72//US #include "global.h" // KIO::probably_slow_mounted
71 73
72#define NO_NOTIFY (time_t) 0 74#define NO_NOTIFY (time_t) 0
73 75
74static KDirWatchPrivate* dwp_self = 0; 76static KDirWatchPrivate* dwp_self = 0;
75 77
76#ifdef HAVE_DNOTIFY 78#ifdef HAVE_DNOTIFY
77 79
78#include <sys/utsname.h> 80#include <sys/utsname.h>
79 81
80static int dnotify_signal = 0; 82static int dnotify_signal = 0;
81 83
82/* DNOTIFY signal handler 84/* DNOTIFY signal handler
83 * 85 *
84 * As this is called asynchronously, only a flag is set and 86 * As this is called asynchronously, only a flag is set and
85 * a rescan is requested. 87 * a rescan is requested.
86 * This is done by writing into a pipe to trigger a QSocketNotifier 88 * This is done by writing into a pipe to trigger a QSocketNotifier
87 * watching on this pipe: a timer is started and after a timeout, 89 * watching on this pipe: a timer is started and after a timeout,
88 * the rescan is done. 90 * the rescan is done.
89 */ 91 */
90void KDirWatchPrivate::dnotify_handler(int, siginfo_t *si, void *) 92void KDirWatchPrivate::dnotify_handler(int, siginfo_t *si, void *)
91{ 93{
92 // write might change errno, we have to save it and restore it 94 // write might change errno, we have to save it and restore it
93 // (Richard Stevens, Advanced programming in the Unix Environment) 95 // (Richard Stevens, Advanced programming in the Unix Environment)
94 int saved_errno = errno; 96 int saved_errno = errno;
95 97
96 Entry* e = (dwp_self) ? dwp_self->fd_Entry.find(si->si_fd) :0; 98 Entry* e = (dwp_self) ? dwp_self->fd_Entry.find(si->si_fd) :0;
97 99
98// kdDebug(7001) << "DNOTIFY Handler: fd " << si->si_fd << " path " 100// kdDebug(7001) << "DNOTIFY Handler: fd " << si->si_fd << " path "
99 // << QString(e ? e->path:"unknown") << endl; 101 // << QString(e ? e->path:"unknown") << endl;
100 102
101 if(!e || e->dn_fd != si->si_fd) { 103 if(!e || e->dn_fd != si->si_fd) {
102 qDebug("fatal error in KDirWatch"); 104 qDebug("fatal error in KDirWatch");
103 } else 105 } else
104 e->dn_dirty = true; 106 e->dn_dirty = true;
105 107
106 char c = 0; 108 char c = 0;
107 write(dwp_self->mPipe[1], &c, 1); 109 write(dwp_self->mPipe[1], &c, 1);
108 errno = saved_errno; 110 errno = saved_errno;
109} 111}
110 112
111static struct sigaction old_sigio_act; 113static struct sigaction old_sigio_act;
112/* DNOTIFY SIGIO signal handler 114/* DNOTIFY SIGIO signal handler
113 * 115 *
114 * When the kernel queue for the dnotify_signal overflows, a SIGIO is send. 116 * When the kernel queue for the dnotify_signal overflows, a SIGIO is send.
115 */ 117 */
116void KDirWatchPrivate::dnotify_sigio_handler(int sig, siginfo_t *si, void *p) 118void KDirWatchPrivate::dnotify_sigio_handler(int sig, siginfo_t *si, void *p)
117{ 119{
118 // write might change errno, we have to save it and restore it 120 // write might change errno, we have to save it and restore it
119 // (Richard Stevens, Advanced programming in the Unix Environment) 121 // (Richard Stevens, Advanced programming in the Unix Environment)
120 int saved_errno = errno; 122 int saved_errno = errno;
121 123
122 if (dwp_self) 124 if (dwp_self)
123 dwp_self->rescan_all = true; 125 dwp_self->rescan_all = true;
124 126
125 char c = 0; 127 char c = 0;
126 write(dwp_self->mPipe[1], &c, 1); 128 write(dwp_self->mPipe[1], &c, 1);
127 129
128 errno = saved_errno; 130 errno = saved_errno;
129 131
130 // Call previous signal handler 132 // Call previous signal handler
131 if (old_sigio_act.sa_flags & SA_SIGINFO) 133 if (old_sigio_act.sa_flags & SA_SIGINFO)
132 { 134 {
133 if (old_sigio_act.sa_sigaction) 135 if (old_sigio_act.sa_sigaction)
134 (*old_sigio_act.sa_sigaction)(sig, si, p); 136 (*old_sigio_act.sa_sigaction)(sig, si, p);
135 } 137 }
136 else 138 else
137 { 139 {
138 if ((old_sigio_act.sa_handler != SIG_DFL) && 140 if ((old_sigio_act.sa_handler != SIG_DFL) &&
139 (old_sigio_act.sa_handler != SIG_IGN)) 141 (old_sigio_act.sa_handler != SIG_IGN))
140 (*old_sigio_act.sa_handler)(sig); 142 (*old_sigio_act.sa_handler)(sig);
141 } 143 }
142} 144}
143#endif 145#endif
144 146
145 147
146// 148//
147// Class KDirWatchPrivate (singleton) 149// Class KDirWatchPrivate (singleton)
148// 150//
149 151
150/* All entries (files/directories) to be watched in the 152/* All entries (files/directories) to be watched in the
151 * application (coming from multiple KDirWatch instances) 153 * application (coming from multiple KDirWatch instances)
152 * are registered in a single KDirWatchPrivate instance. 154 * are registered in a single KDirWatchPrivate instance.
153 * 155 *
154 * At the moment, the following methods for file watching 156 * At the moment, the following methods for file watching
155 * are supported: 157 * are supported:
156 * - Polling: All files to be watched are polled regularly 158 * - Polling: All files to be watched are polled regularly
157 * using stat (more precise: QFileInfo.lastModified()). 159 * using stat (more precise: QFileInfo.lastModified()).
158 * The polling frequency is determined from global kconfig 160 * The polling frequency is determined from global kconfig
159 * settings, defaulting to 500 ms for local directories 161 * settings, defaulting to 500 ms for local directories
160 * and 5000 ms for remote mounts 162 * and 5000 ms for remote mounts
161 * - FAM (File Alternation Monitor): first used on IRIX, SGI 163 * - FAM (File Alternation Monitor): first used on IRIX, SGI
162 * has ported this method to LINUX. It uses a kernel part 164 * has ported this method to LINUX. It uses a kernel part
163 * (IMON, sending change events to /dev/imon) and a user 165 * (IMON, sending change events to /dev/imon) and a user
164 * level damon (fam), to which applications connect for 166 * level damon (fam), to which applications connect for
165 * notification of file changes. For NFS, the fam damon 167 * notification of file changes. For NFS, the fam damon
166 * on the NFS server machine is used; if IMON is not built 168 * on the NFS server machine is used; if IMON is not built
167 * into the kernel, fam uses polling for local files. 169 * into the kernel, fam uses polling for local files.
168 * - DNOTIFY: In late LINUX 2.3.x, directory notification was 170 * - DNOTIFY: In late LINUX 2.3.x, directory notification was
169 * introduced. By opening a directory, you can request for 171 * introduced. By opening a directory, you can request for
170 * UNIX signals to be sent to the process when a directory 172 * UNIX signals to be sent to the process when a directory
171 * is changed. 173 * is changed.
172 */ 174 */
173 175
174KDirWatchPrivate::KDirWatchPrivate() 176KDirWatchPrivate::KDirWatchPrivate()
175{ 177{
176 timer = new QTimer(this); 178 timer = new QTimer(this);
177 connect (timer, SIGNAL(timeout()), this, SLOT(slotRescan())); 179 connect (timer, SIGNAL(timeout()), this, SLOT(slotRescan()));
178 freq = 3600000; // 1 hour as upper bound 180 freq = 3600000; // 1 hour as upper bound
179 statEntries = 0; 181 statEntries = 0;
180 delayRemove = false; 182 delayRemove = false;
181 m_ref = 0; 183 m_ref = 0;
182 184
183//US KConfigGroup config(KGlobal::config(), QCString("DirWatch")); 185//US KConfigGroup config(KGlobal::config(), QCString("DirWatch"));
184//US m_nfsPollInterval = config.readNumEntry("NFSPollInterval", 5000); 186//US m_nfsPollInterval = config.readNumEntry("NFSPollInterval", 5000);
185//US m_PollInterval = config.readNumEntry("PollInterval", 500); 187//US m_PollInterval = config.readNumEntry("PollInterval", 500);
186 KConfig *config = KGlobal::config(); 188 KConfig *config = KGlobal::config();
187 KConfigGroupSaver saver( config, QCString("DirWatch") ); 189 KConfigGroupSaver saver( config, Q3CString("DirWatch") );
188 190
189 m_nfsPollInterval = config->readNumEntry("NFSPollInterval", 5000); 191 m_nfsPollInterval = config->readNumEntry("NFSPollInterval", 5000);
190 m_PollInterval = config->readNumEntry("PollInterval", 500); 192 m_PollInterval = config->readNumEntry("PollInterval", 500);
191 193
192 194
193 QString available("Stat"); 195 QString available("Stat");
194 196
195#ifdef HAVE_FAM 197#ifdef HAVE_FAM
196 // It's possible that FAM server can't be started 198 // It's possible that FAM server can't be started
197 if (FAMOpen(&fc) ==0) { 199 if (FAMOpen(&fc) ==0) {
198 available += ", FAM"; 200 available += ", FAM";
199 use_fam=true; 201 use_fam=true;
200 sn = new QSocketNotifier( FAMCONNECTION_GETFD(&fc), 202 sn = new QSocketNotifier( FAMCONNECTION_GETFD(&fc),
201 QSocketNotifier::Read, this); 203 QSocketNotifier::Read, this);
202 connect( sn, SIGNAL(activated(int)), 204 connect( sn, SIGNAL(activated(int)),
203 this, SLOT(famEventReceived()) ); 205 this, SLOT(famEventReceived()) );
204 } 206 }
205 else { 207 else {
206 kdDebug(7001) << "Can't use FAM (fam daemon not running?)" << endl; 208 kdDebug(7001) << "Can't use FAM (fam daemon not running?)" << endl;
207 use_fam=false; 209 use_fam=false;
208 } 210 }
209#endif 211#endif
210 212
211#ifdef HAVE_DNOTIFY 213#ifdef HAVE_DNOTIFY
212 supports_dnotify = true; // not guilty until proven guilty 214 supports_dnotify = true; // not guilty until proven guilty
213 rescan_all = false; 215 rescan_all = false;
214 struct utsname uts; 216 struct utsname uts;
215 int major, minor, patch; 217 int major, minor, patch;
216 if (uname(&uts) < 0) 218 if (uname(&uts) < 0)
217 supports_dnotify = false; // *shrug* 219 supports_dnotify = false; // *shrug*
218 else if (sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch) != 3) 220 else if (sscanf(uts.release, "%d.%d.%d", &major, &minor, &patch) != 3)
219 supports_dnotify = false; // *shrug* 221 supports_dnotify = false; // *shrug*
220 else if( major * 1000000 + minor * 1000 + patch < 2004019 ) { // <2.4.19 222 else if( major * 1000000 + minor * 1000 + patch < 2004019 ) { // <2.4.19
221 kdDebug(7001) << "Can't use DNotify, Linux kernel too old" << endl; 223 kdDebug(7001) << "Can't use DNotify, Linux kernel too old" << endl;
222 supports_dnotify = false; 224 supports_dnotify = false;
223 } 225 }
224 226
225 if( supports_dnotify ) { 227 if( supports_dnotify ) {
226 available += ", DNotify"; 228 available += ", DNotify";
227 229
228 pipe(mPipe); 230 pipe(mPipe);
229 fcntl(mPipe[0], F_SETFD, FD_CLOEXEC); 231 fcntl(mPipe[0], F_SETFD, FD_CLOEXEC);
230 fcntl(mPipe[1], F_SETFD, FD_CLOEXEC); 232 fcntl(mPipe[1], F_SETFD, FD_CLOEXEC);
231 mSn = new QSocketNotifier( mPipe[0], QSocketNotifier::Read, this); 233 mSn = new QSocketNotifier( mPipe[0], QSocketNotifier::Read, this);
232 connect(mSn, SIGNAL(activated(int)), this, SLOT(slotActivated())); 234 connect(mSn, SIGNAL(activated(int)), this, SLOT(slotActivated()));
233 connect(&mTimer, SIGNAL(timeout()), this, SLOT(slotRescan())); 235 connect(&mTimer, SIGNAL(timeout()), this, SLOT(slotRescan()));
234 struct sigaction act; 236 struct sigaction act;
235 act.sa_sigaction = KDirWatchPrivate::dnotify_handler; 237 act.sa_sigaction = KDirWatchPrivate::dnotify_handler;
236 sigemptyset(&act.sa_mask); 238 sigemptyset(&act.sa_mask);
237 act.sa_flags = SA_SIGINFO; 239 act.sa_flags = SA_SIGINFO;
238#ifdef SA_RESTART 240#ifdef SA_RESTART
239 act.sa_flags |= SA_RESTART; 241 act.sa_flags |= SA_RESTART;
240#endif 242#endif
241 if( dnotify_signal == 0 ) 243 if( dnotify_signal == 0 )
242 dnotify_signal = SIGRTMIN + 8; 244 dnotify_signal = SIGRTMIN + 8;
243 sigaction(dnotify_signal, &act, NULL); 245 sigaction(dnotify_signal, &act, NULL);
244 246
245 act.sa_sigaction = KDirWatchPrivate::dnotify_sigio_handler; 247 act.sa_sigaction = KDirWatchPrivate::dnotify_sigio_handler;
246 sigaction(SIGIO, &act, &old_sigio_act); 248 sigaction(SIGIO, &act, &old_sigio_act);
247 } 249 }
248#endif 250#endif
249 251
250 kdDebug(7001) << "Available methods: " << available << endl; 252 kdDebug(7001) << "Available methods: " << available << endl;
251} 253}
252 254
253/* This should never be called, but doesn't harm */ 255/* This should never be called, but doesn't harm */
254KDirWatchPrivate::~KDirWatchPrivate() 256KDirWatchPrivate::~KDirWatchPrivate()
255{ 257{
256 timer->stop(); 258 timer->stop();
257 259
258 /* remove all entries being watched */ 260 /* remove all entries being watched */
259 removeEntries(0); 261 removeEntries(0);
260 262
261#ifdef HAVE_FAM 263#ifdef HAVE_FAM
262 if (use_fam) { 264 if (use_fam) {
263 FAMClose(&fc); 265 FAMClose(&fc);
264 kdDebug(7001) << "KDirWatch deleted (FAM closed)" << endl; 266 kdDebug(7001) << "KDirWatch deleted (FAM closed)" << endl;
265 } 267 }
266#endif 268#endif
267 269
268} 270}
269 271
270#ifdef HAVE_DNOTIFY 272#ifdef HAVE_DNOTIFY
271void KDirWatchPrivate::slotActivated() 273void KDirWatchPrivate::slotActivated()
272{ 274{
273 char dummy_buf[100]; 275 char dummy_buf[100];
274 read(mPipe[0], &dummy_buf, 100); 276 read(mPipe[0], &dummy_buf, 100);
275 277
276 if (!mTimer.isActive()) 278 if (!mTimer.isActive())
277 mTimer.start(200, true); 279 mTimer.start(200, true);
278} 280}
279 281
280/* In DNOTIFY mode, only entries which are marked dirty are scanned. 282/* In DNOTIFY mode, only entries which are marked dirty are scanned.
281 * We first need to mark all yet nonexistant, but possible created 283 * We first need to mark all yet nonexistant, but possible created
282 * entries as dirty... 284 * entries as dirty...
283 */ 285 */
284void KDirWatchPrivate::Entry::propagate_dirty() 286void KDirWatchPrivate::Entry::propagate_dirty()
285{ 287{
286 Entry* sub_entry; 288 Entry* sub_entry;
287 for(sub_entry = m_entries.first(); sub_entry; sub_entry = m_entries.next()) 289 for(sub_entry = m_entries.first(); sub_entry; sub_entry = m_entries.next())
288 { 290 {
289 if (!sub_entry->dn_dirty) 291 if (!sub_entry->dn_dirty)
290 { 292 {
291 sub_entry->dn_dirty = true; 293 sub_entry->dn_dirty = true;
292 sub_entry->propagate_dirty(); 294 sub_entry->propagate_dirty();
293 } 295 }
294 } 296 }
295} 297}
296 298
297#else // !HAVE_DNOTIFY 299#else // !HAVE_DNOTIFY
298// slots always have to be defined... 300// slots always have to be defined...
299void KDirWatchPrivate::slotActivated() {} 301void KDirWatchPrivate::slotActivated() {}
300#endif 302#endif
301 303
302/* A KDirWatch instance is interested in getting events for 304/* A KDirWatch instance is interested in getting events for
303 * this file/Dir entry. 305 * this file/Dir entry.
304 */ 306 */
305void KDirWatchPrivate::Entry::addClient(KDirWatch* instance) 307void KDirWatchPrivate::Entry::addClient(KDirWatch* instance)
306{ 308{
307 Client* client = m_clients.first(); 309 Client* client = m_clients.first();
308 for(;client; client = m_clients.next()) 310 for(;client; client = m_clients.next())
309 if (client->instance == instance) break; 311 if (client->instance == instance) break;
310 312
311 if (client) { 313 if (client) {
312 client->count++; 314 client->count++;
313 return; 315 return;
314 } 316 }
315 317
316 client = new Client; 318 client = new Client;
317 client->instance = instance; 319 client->instance = instance;
318 client->count = 1; 320 client->count = 1;
319 client->watchingStopped = instance->isStopped(); 321 client->watchingStopped = instance->isStopped();
320 client->pending = NoChange; 322 client->pending = NoChange;
321 323
322 m_clients.append(client); 324 m_clients.append(client);
323} 325}
324 326
325void KDirWatchPrivate::Entry::removeClient(KDirWatch* instance) 327void KDirWatchPrivate::Entry::removeClient(KDirWatch* instance)
326{ 328{
327 Client* client = m_clients.first(); 329 Client* client = m_clients.first();
328 for(;client; client = m_clients.next()) 330 for(;client; client = m_clients.next())
329 if (client->instance == instance) break; 331 if (client->instance == instance) break;
330 332
331 if (client) { 333 if (client) {
332 client->count--; 334 client->count--;
333 if (client->count == 0) { 335 if (client->count == 0) {
334 m_clients.removeRef(client); 336 m_clients.removeRef(client);
335 delete client; 337 delete client;
336 } 338 }
337 } 339 }
338} 340}
339 341
340/* get number of clients */ 342/* get number of clients */
341int KDirWatchPrivate::Entry::clients() 343int KDirWatchPrivate::Entry::clients()
342{ 344{
343 int clients = 0; 345 int clients = 0;
344 Client* client = m_clients.first(); 346 Client* client = m_clients.first();
345 for(;client; client = m_clients.next()) 347 for(;client; client = m_clients.next())
346 clients += client->count; 348 clients += client->count;
347 349
348 return clients; 350 return clients;
349} 351}
350 352
351 353
352KDirWatchPrivate::Entry* KDirWatchPrivate::entry(const QString& _path) 354KDirWatchPrivate::Entry* KDirWatchPrivate::entry(const QString& _path)
353{ 355{
354// we only support absolute paths 356// we only support absolute paths
355 if (_path.left(1) != "/") { 357 if (_path.left(1) != "/") {
356 return 0; 358 return 0;
357 } 359 }
358 360
359 QString path = _path; 361 QString path = _path;
360 362
361 if ( path.length() > 1 && path.right(1) == "/" ) 363 if ( path.length() > 1 && path.right(1) == "/" )
362 path.truncate( path.length() - 1 ); 364 path.truncate( path.length() - 1 );
363 365
364 EntryMap::Iterator it = m_mapEntries.find( path ); 366 EntryMap::Iterator it = m_mapEntries.find( path );
365 if ( it == m_mapEntries.end() ) 367 if ( it == m_mapEntries.end() )
366 return 0; 368 return 0;
367 else 369 else
368 return &(*it); 370 return &(*it);
369} 371}
370 372
371// set polling frequency for a entry and adjust global freq if needed 373// set polling frequency for a entry and adjust global freq if needed
372void KDirWatchPrivate::useFreq(Entry* e, int newFreq) 374void KDirWatchPrivate::useFreq(Entry* e, int newFreq)
373{ 375{
374 e->freq = newFreq; 376 e->freq = newFreq;
375 377
376 // a reasonable frequency for the global polling timer 378 // a reasonable frequency for the global polling timer
377 if (e->freq < freq) { 379 if (e->freq < freq) {
378 freq = e->freq; 380 freq = e->freq;
379 if (timer->isActive()) timer->changeInterval(freq); 381 if (timer->isActive()) timer->changeInterval(freq);
380 kdDebug(7001) << "Global Poll Freq is now " << freq << " msec" << endl; 382 kdDebug(7001) << "Global Poll Freq is now " << freq << " msec" << endl;
381 } 383 }
382} 384}
383 385
384 386
385#if defined(HAVE_FAM) 387#if defined(HAVE_FAM)
386// setup FAM notification, returns false if not possible 388// setup FAM notification, returns false if not possible
387bool KDirWatchPrivate::useFAM(Entry* e) 389bool KDirWatchPrivate::useFAM(Entry* e)
388{ 390{
389 if (!use_fam) return false; 391 if (!use_fam) return false;
390 392
391 e->m_mode = FAMMode; 393 e->m_mode = FAMMode;
392 394
393 if (e->isDir) { 395 if (e->isDir) {
394 if (e->m_status == NonExistent) { 396 if (e->m_status == NonExistent) {
395 // If the directory does not exist we watch the parent directory 397 // If the directory does not exist we watch the parent directory
396 addEntry(0, QDir::cleanDirPath(e->path+"/.."), e, true); 398 addEntry(0, QDir::cleanDirPath(e->path+"/.."), e, true);
397 } 399 }
398 else { 400 else {
399 int res =FAMMonitorDirectory(&fc, QFile::encodeName(e->path), 401 int res =FAMMonitorDirectory(&fc, QFile::encodeName(e->path),
400 &(e->fr), e); 402 &(e->fr), e);
401 if (res<0) { 403 if (res<0) {
402 e->m_mode = UnknownMode; 404 e->m_mode = UnknownMode;
403 use_fam=false; 405 use_fam=false;
404 return false; 406 return false;
405 } 407 }
406 kdDebug(7001) << " Setup FAM (Req " 408 kdDebug(7001) << " Setup FAM (Req "
407 << FAMREQUEST_GETREQNUM(&(e->fr)) 409 << FAMREQUEST_GETREQNUM(&(e->fr))
408 << ") for " << e->path << endl; 410 << ") for " << e->path << endl;
409 } 411 }
410 } 412 }
411 else { 413 else {
412 if (e->m_status == NonExistent) { 414 if (e->m_status == NonExistent) {
413 // If the file does not exist we watch the directory 415 // If the file does not exist we watch the directory
414 addEntry(0, QFileInfo(e->path).dirPath(true), e, true); 416 addEntry(0, QFileInfo(e->path).dirPath(true), e, true);
415 } 417 }
416 else { 418 else {
417 int res = FAMMonitorFile(&fc, QFile::encodeName(e->path), 419 int res = FAMMonitorFile(&fc, QFile::encodeName(e->path),
418 &(e->fr), e); 420 &(e->fr), e);
419 if (res<0) { 421 if (res<0) {
420 e->m_mode = UnknownMode; 422 e->m_mode = UnknownMode;
421 use_fam=false; 423 use_fam=false;
422 return false; 424 return false;
423 } 425 }
424 426
425 kdDebug(7001) << " Setup FAM (Req " 427 kdDebug(7001) << " Setup FAM (Req "
426 << FAMREQUEST_GETREQNUM(&(e->fr)) 428 << FAMREQUEST_GETREQNUM(&(e->fr))
427 << ") for " << e->path << endl; 429 << ") for " << e->path << endl;
428 } 430 }
429 } 431 }
430 432
431 // handle FAM events to avoid deadlock 433 // handle FAM events to avoid deadlock
432 // (FAM sends back all files in a directory when monitoring) 434 // (FAM sends back all files in a directory when monitoring)
433 famEventReceived(); 435 famEventReceived();
434 436
435 return true; 437 return true;
436} 438}
437#endif 439#endif
438 440
439 441
440#ifdef HAVE_DNOTIFY 442#ifdef HAVE_DNOTIFY
441// setup DNotify notification, returns false if not possible 443// setup DNotify notification, returns false if not possible
442bool KDirWatchPrivate::useDNotify(Entry* e) 444bool KDirWatchPrivate::useDNotify(Entry* e)
443{ 445{
444 e->dn_fd = 0; 446 e->dn_fd = 0;
445 if (!supports_dnotify) return false; 447 if (!supports_dnotify) return false;
446 448
447 e->m_mode = DNotifyMode; 449 e->m_mode = DNotifyMode;
448 450
449 if (e->isDir) { 451 if (e->isDir) {
450 e->dn_dirty = false; 452 e->dn_dirty = false;
451 if (e->m_status == Normal) { 453 if (e->m_status == Normal) {
452 int fd = open(QFile::encodeName(e->path).data(), O_RDONLY); 454 int fd = open(QFile::encodeName(e->path).data(), O_RDONLY);
453 // Migrate fd to somewhere above 128. Some libraries have 455 // Migrate fd to somewhere above 128. Some libraries have
454 // constructs like: 456 // constructs like:
455 // fd = socket(...) 457 // fd = socket(...)
456 // if (fd > ARBITRARY_LIMIT) 458 // if (fd > ARBITRARY_LIMIT)
457 // return error; 459 // return error;
458 // 460 //
459 // Since programs might end up using a lot of KDirWatch objects 461 // Since programs might end up using a lot of KDirWatch objects
460 // for a rather long time the above braindamage could get 462 // for a rather long time the above braindamage could get
461 // triggered. 463 // triggered.
462 // 464 //
463 // By moving the kdirwatch fd's to > 128, calls like socket() will keep 465 // By moving the kdirwatch fd's to > 128, calls like socket() will keep
464 // returning fd's < ARBITRARY_LIMIT for a bit longer. 466 // returning fd's < ARBITRARY_LIMIT for a bit longer.
465 int fd2 = fcntl(fd, F_DUPFD, 128); 467 int fd2 = fcntl(fd, F_DUPFD, 128);
466 if (fd2 >= 0) 468 if (fd2 >= 0)
467 { 469 {
468 close(fd); 470 close(fd);
469 fd = fd2; 471 fd = fd2;
470 } 472 }
471 if (fd<0) { 473 if (fd<0) {
472 e->m_mode = UnknownMode; 474 e->m_mode = UnknownMode;
473 return false; 475 return false;
474 } 476 }
475 477
476 int mask = DN_DELETE|DN_CREATE|DN_RENAME|DN_MULTISHOT; 478 int mask = DN_DELETE|DN_CREATE|DN_RENAME|DN_MULTISHOT;
477 // if dependant is a file watch, we check for MODIFY & ATTRIB too 479 // if dependant is a file watch, we check for MODIFY & ATTRIB too
478 for(Entry* dep=e->m_entries.first();dep;dep=e->m_entries.next()) 480 for(Entry* dep=e->m_entries.first();dep;dep=e->m_entries.next())
479 if (!dep->isDir) { mask |= DN_MODIFY|DN_ATTRIB; break; } 481 if (!dep->isDir) { mask |= DN_MODIFY|DN_ATTRIB; break; }
480 482
481 if(fcntl(fd, F_SETSIG, dnotify_signal) < 0 || 483 if(fcntl(fd, F_SETSIG, dnotify_signal) < 0 ||
482 fcntl(fd, F_NOTIFY, mask) < 0) { 484 fcntl(fd, F_NOTIFY, mask) < 0) {
483 485
484 kdDebug(7001) << "Not using Linux Directory Notifications." 486 kdDebug(7001) << "Not using Linux Directory Notifications."
485 << endl; 487 << endl;
486 supports_dnotify = false; 488 supports_dnotify = false;
487 ::close(fd); 489 ::close(fd);
488 e->m_mode = UnknownMode; 490 e->m_mode = UnknownMode;
489 return false; 491 return false;
490 } 492 }
491 493
492 fd_Entry.replace(fd, e); 494 fd_Entry.replace(fd, e);
493 e->dn_fd = fd; 495 e->dn_fd = fd;
494 496
495 kdDebug(7001) << " Setup DNotify (fd " << fd 497 kdDebug(7001) << " Setup DNotify (fd " << fd
496 << ") for " << e->path << endl; 498 << ") for " << e->path << endl;
497 } 499 }
498 else { // NotExisting 500 else { // NotExisting
499 addEntry(0, QDir::cleanDirPath(e->path+"/.."), e, true); 501 addEntry(0, QDir::cleanDirPath(e->path+"/.."), e, true);
500 } 502 }
501 } 503 }
502 else { // File 504 else { // File
503 // we always watch the directory (DNOTIFY can't watch files alone) 505 // we always watch the directory (DNOTIFY can't watch files alone)
504 // this notifies us about changes of files therein 506 // this notifies us about changes of files therein
505 addEntry(0, QFileInfo(e->path).dirPath(true), e, true); 507 addEntry(0, QFileInfo(e->path).dirPath(true), e, true);
506 } 508 }
507 509
508 return true; 510 return true;
509} 511}
510#endif 512#endif
511 513
512 514
513bool KDirWatchPrivate::useStat(Entry* e) 515bool KDirWatchPrivate::useStat(Entry* e)
514{ 516{
515//US we have no KIO::probably_slow_mounted. So disable this part 517//US we have no KIO::probably_slow_mounted. So disable this part
516//US if (KIO::probably_slow_mounted(e->path)) 518//US if (KIO::probably_slow_mounted(e->path))
517//US useFreq(e, m_nfsPollInterval); 519//US useFreq(e, m_nfsPollInterval);
518//US else 520//US else
519 useFreq(e, m_PollInterval); 521 useFreq(e, m_PollInterval);
520 522
521 if (e->m_mode != StatMode) { 523 if (e->m_mode != StatMode) {
522 e->m_mode = StatMode; 524 e->m_mode = StatMode;
523 statEntries++; 525 statEntries++;
524 526
525 if ( statEntries == 1 ) { 527 if ( statEntries == 1 ) {
526 // if this was first STAT entry (=timer was stopped) 528 // if this was first STAT entry (=timer was stopped)
527 timer->start(freq); // then start the timer 529 timer->start(freq); // then start the timer
528 kdDebug(7001) << " Started Polling Timer, freq " << freq << endl; 530 kdDebug(7001) << " Started Polling Timer, freq " << freq << endl;
529 } 531 }
530 } 532 }
531 533
532 kdDebug(7001) << " Setup Stat (freq " << e->freq 534 kdDebug(7001) << " Setup Stat (freq " << e->freq
533 << ") for " << e->path << endl; 535 << ") for " << e->path << endl;
534 536
535 return true; 537 return true;
536} 538}
537 539
538 540
539/* If <instance> !=0, this KDirWatch instance wants to watch at <_path>, 541/* If <instance> !=0, this KDirWatch instance wants to watch at <_path>,
540 * providing in <isDir> the type of the entry to be watched. 542 * providing in <isDir> the type of the entry to be watched.
541 * Sometimes, entries are dependant on each other: if <sub_entry> !=0, 543 * Sometimes, entries are dependant on each other: if <sub_entry> !=0,
542 * this entry needs another entry to watch himself (when notExistent). 544 * this entry needs another entry to watch himself (when notExistent).
543 */ 545 */
544void KDirWatchPrivate::addEntry(KDirWatch* instance, const QString& _path, 546void KDirWatchPrivate::addEntry(KDirWatch* instance, const QString& _path,
545 Entry* sub_entry, bool isDir) 547 Entry* sub_entry, bool isDir)
546{ 548{
547 QString path = _path; 549 QString path = _path;
548 if (path.startsWith("/dev/") || (path == "/dev")) 550 if (path.startsWith("/dev/") || (path == "/dev"))
549 return; // Don't even go there. 551 return; // Don't even go there.
550 552
551 if ( path.length() > 1 && path.right(1) == "/" ) 553 if ( path.length() > 1 && path.right(1) == "/" )
552 path.truncate( path.length() - 1 ); 554 path.truncate( path.length() - 1 );
553 555
554 EntryMap::Iterator it = m_mapEntries.find( path ); 556 EntryMap::Iterator it = m_mapEntries.find( path );
555 if ( it != m_mapEntries.end() ) 557 if ( it != m_mapEntries.end() )
556 { 558 {
557 if (sub_entry) { 559 if (sub_entry) {
558 (*it).m_entries.append(sub_entry); 560 (*it).m_entries.append(sub_entry);
559 kdDebug(7001) << "Added already watched Entry " << path 561 kdDebug(7001) << "Added already watched Entry " << path
560 << " (for " << sub_entry->path << ")" << endl; 562 << " (for " << sub_entry->path << ")" << endl;
561#ifdef HAVE_DNOTIFY 563#ifdef HAVE_DNOTIFY
562 Entry* e = &(*it); 564 Entry* e = &(*it);
563 if( e->dn_fd > 0 ) { 565 if( e->dn_fd > 0 ) {
564 int mask = DN_DELETE|DN_CREATE|DN_RENAME|DN_MULTISHOT; 566 int mask = DN_DELETE|DN_CREATE|DN_RENAME|DN_MULTISHOT;
565 // if dependant is a file watch, we check for MODIFY & ATTRIB too 567 // if dependant is a file watch, we check for MODIFY & ATTRIB too
566 for(Entry* dep=e->m_entries.first();dep;dep=e->m_entries.next()) 568 for(Entry* dep=e->m_entries.first();dep;dep=e->m_entries.next())
567 if (!dep->isDir) { mask |= DN_MODIFY|DN_ATTRIB; break; } 569 if (!dep->isDir) { mask |= DN_MODIFY|DN_ATTRIB; break; }
568 if( fcntl(e->dn_fd, F_NOTIFY, mask) < 0) { // shouldn't happen 570 if( fcntl(e->dn_fd, F_NOTIFY, mask) < 0) { // shouldn't happen
569 ::close(e->dn_fd); 571 ::close(e->dn_fd);
570 e->m_mode = UnknownMode; 572 e->m_mode = UnknownMode;
571 fd_Entry.remove(e->dn_fd); 573 fd_Entry.remove(e->dn_fd);
572 e->dn_fd = 0; 574 e->dn_fd = 0;
573 useStat( e ); 575 useStat( e );
574 } 576 }
575 } 577 }
576#endif 578#endif
577 } 579 }
578 else { 580 else {
579 (*it).addClient(instance); 581 (*it).addClient(instance);
580 kdDebug(7001) << "Added already watched Entry " << path 582 kdDebug(7001) << "Added already watched Entry " << path
581 << " (now " << (*it).clients() << " clients)" 583 << " (now " << (*it).clients() << " clients)"
582 << QString(" [%1]").arg(instance->name()) << endl; 584 << QString(" [%1]").arg(instance->name()) << endl;
583 } 585 }
584 return; 586 return;
585 } 587 }
586 588
587 // we have a new path to watch 589 // we have a new path to watch
588 590
589 struct stat stat_buf; 591 struct stat stat_buf;
590 bool exists = (stat(QFile::encodeName(path), &stat_buf) == 0); 592 bool exists = (stat(QFile::encodeName(path), &stat_buf) == 0);
591 593
592 Entry newEntry; 594 Entry newEntry;
593 m_mapEntries.insert( path, newEntry ); 595 m_mapEntries.insert( path, newEntry );
594 // the insert does a copy, so we have to use <e> now 596 // the insert does a copy, so we have to use <e> now
595 Entry* e = &(m_mapEntries[path]); 597 Entry* e = &(m_mapEntries[path]);
596 598
597 if (exists) { 599 if (exists) {
598 QFileInfo fi ( path ); 600 QFileInfo fi ( path );
599 e->isDir = fi.isDir(); 601 e->isDir = fi.isDir();
600 602
601 if (e->isDir && !isDir) 603 if (e->isDir && !isDir)
602 qWarning("KDirWatch: %s is a directory. Use addDir!", path.ascii()); 604 qWarning("KDirWatch: %s is a directory. Use addDir!", path.ascii());
603 else if (!e->isDir && isDir) 605 else if (!e->isDir && isDir)
604 qWarning("KDirWatch: %s is a file. Use addFile!", path.ascii()); 606 qWarning("KDirWatch: %s is a file. Use addFile!", path.ascii());
605 607
606 e->m_ctime = stat_buf.st_ctime; 608 e->m_ctime = stat_buf.st_ctime;
607 e->m_status = Normal; 609 e->m_status = Normal;
608 e->m_nlink = stat_buf.st_nlink; 610 e->m_nlink = stat_buf.st_nlink;
609 } 611 }
610 else { 612 else {
611 e->isDir = isDir; 613 e->isDir = isDir;
612 e->m_ctime = invalid_ctime; 614 e->m_ctime = invalid_ctime;
613 e->m_status = NonExistent; 615 e->m_status = NonExistent;
614 e->m_nlink = 0; 616 e->m_nlink = 0;
615 } 617 }
616 618
617 e->path = path; 619 e->path = path;
618 if (sub_entry) 620 if (sub_entry)
619 e->m_entries.append(sub_entry); 621 e->m_entries.append(sub_entry);
620 else 622 else
621 e->addClient(instance); 623 e->addClient(instance);
622 624
623 kdDebug(7001) << "Added " << (e->isDir ? "Dir ":"File ") << path 625 kdDebug(7001) << "Added " << (e->isDir ? "Dir ":"File ") << path
624 << (e->m_status == NonExistent ? " NotExisting" : "") 626 << (e->m_status == NonExistent ? " NotExisting" : "")
625 << (sub_entry ? QString(" for %1").arg(sub_entry->path) : QString("")) 627 << (sub_entry ? QString(" for %1").arg(sub_entry->path) : QString(""))
626 << (instance ? QString(" [%1]").arg(instance->name()) : QString("")) 628 << (instance ? QString(" [%1]").arg(instance->name()) : QString(""))
627 << endl; 629 << endl;
628 630
629 631
630 // now setup the notification method 632 // now setup the notification method
631 e->m_mode = UnknownMode; 633 e->m_mode = UnknownMode;
632 e->msecLeft = 0; 634 e->msecLeft = 0;
633 635
634#if defined(HAVE_FAM) 636#if defined(HAVE_FAM)
635 if (useFAM(e)) return; 637 if (useFAM(e)) return;
636#endif 638#endif
637 639
638#ifdef HAVE_DNOTIFY 640#ifdef HAVE_DNOTIFY
639 if (useDNotify(e)) return; 641 if (useDNotify(e)) return;
640#endif 642#endif
641 643
642 useStat(e); 644 useStat(e);
643} 645}
644 646
645 647
646void KDirWatchPrivate::removeEntry( KDirWatch* instance, 648void KDirWatchPrivate::removeEntry( KDirWatch* instance,
647 const QString& _path, Entry* sub_entry ) 649 const QString& _path, Entry* sub_entry )
648{ 650{
649 Entry* e = entry(_path); 651 Entry* e = entry(_path);
650 if (!e) { 652 if (!e) {
651 kdWarning(7001) << "KDirWatch::removeDir can't handle '" << _path << "'" << endl; 653 kdWarning(7001) << "KDirWatch::removeDir can't handle '" << _path << "'" << endl;
652 return; 654 return;
653 } 655 }
654 656
655 if (sub_entry) 657 if (sub_entry)
656 e->m_entries.removeRef(sub_entry); 658 e->m_entries.removeRef(sub_entry);
657 else 659 else
658 e->removeClient(instance); 660 e->removeClient(instance);
659 661
660 if (e->m_clients.count() || e->m_entries.count()) 662 if (e->m_clients.count() || e->m_entries.count())
661 return; 663 return;
662 664
663 if (delayRemove) { 665 if (delayRemove) {
664 // removeList is allowed to contain any entry at most once 666 // removeList is allowed to contain any entry at most once
665 if (removeList.findRef(e)==-1) 667 if (removeList.findRef(e)==-1)
666 removeList.append(e); 668 removeList.append(e);
667 // now e->isValid() is false 669 // now e->isValid() is false
668 return; 670 return;
669 } 671 }
670 672
671#ifdef HAVE_FAM 673#ifdef HAVE_FAM
672 if (e->m_mode == FAMMode) { 674 if (e->m_mode == FAMMode) {
673 if ( e->m_status == Normal) { 675 if ( e->m_status == Normal) {
674 FAMCancelMonitor(&fc, &(e->fr) ); 676 FAMCancelMonitor(&fc, &(e->fr) );
675 kdDebug(7001) << "Cancelled FAM (Req " 677 kdDebug(7001) << "Cancelled FAM (Req "
676 << FAMREQUEST_GETREQNUM(&(e->fr)) 678 << FAMREQUEST_GETREQNUM(&(e->fr))
677 << ") for " << e->path << endl; 679 << ") for " << e->path << endl;
678 } 680 }
679 else { 681 else {
680 if (e->isDir) 682 if (e->isDir)
681 removeEntry(0, QDir::cleanDirPath(e->path+"/.."), e); 683 removeEntry(0, QDir::cleanDirPath(e->path+"/.."), e);
682 else 684 else
683 removeEntry(0, QFileInfo(e->path).dirPath(true), e); 685 removeEntry(0, QFileInfo(e->path).dirPath(true), e);
684 } 686 }
685 } 687 }
686#endif 688#endif
687 689
688#ifdef HAVE_DNOTIFY 690#ifdef HAVE_DNOTIFY
689 if (e->m_mode == DNotifyMode) { 691 if (e->m_mode == DNotifyMode) {
690 if (!e->isDir) { 692 if (!e->isDir) {
691 removeEntry(0, QFileInfo(e->path).dirPath(true), e); 693 removeEntry(0, QFileInfo(e->path).dirPath(true), e);
692 } 694 }
693 else { // isDir 695 else { // isDir
694 // must close the FD. 696 // must close the FD.
695 if ( e->m_status == Normal) { 697 if ( e->m_status == Normal) {
696 if (e->dn_fd) { 698 if (e->dn_fd) {
697 ::close(e->dn_fd); 699 ::close(e->dn_fd);
698 fd_Entry.remove(e->dn_fd); 700 fd_Entry.remove(e->dn_fd);
699 701
700 kdDebug(7001) << "Cancelled DNotify (fd " << e->dn_fd 702 kdDebug(7001) << "Cancelled DNotify (fd " << e->dn_fd
701 << ") for " << e->path << endl; 703 << ") for " << e->path << endl;
702 e->dn_fd = 0; 704 e->dn_fd = 0;
703 705
704 } 706 }
705 } 707 }
706 else { 708 else {
707 removeEntry(0, QDir::cleanDirPath(e->path+"/.."), e); 709 removeEntry(0, QDir::cleanDirPath(e->path+"/.."), e);
708 } 710 }
709 } 711 }
710 } 712 }
711#endif 713#endif
712 714
713 if (e->m_mode == StatMode) { 715 if (e->m_mode == StatMode) {
714 statEntries--; 716 statEntries--;
715 if ( statEntries == 0 ) { 717 if ( statEntries == 0 ) {
716 timer->stop(); // stop timer if lists are empty 718 timer->stop(); // stop timer if lists are empty
717 kdDebug(7001) << " Stopped Polling Timer" << endl; 719 kdDebug(7001) << " Stopped Polling Timer" << endl;
718 } 720 }
719 } 721 }
720 722
721 kdDebug(7001) << "Removed " << (e->isDir ? "Dir ":"File ") << e->path 723 kdDebug(7001) << "Removed " << (e->isDir ? "Dir ":"File ") << e->path
722 << (sub_entry ? QString(" for %1").arg(sub_entry->path) : QString("")) 724 << (sub_entry ? QString(" for %1").arg(sub_entry->path) : QString(""))
723 << (instance ? QString(" [%1]").arg(instance->name()) : QString("")) 725 << (instance ? QString(" [%1]").arg(instance->name()) : QString(""))
724 << endl; 726 << endl;
725 m_mapEntries.remove( e->path ); // <e> not valid any more 727 m_mapEntries.remove( e->path ); // <e> not valid any more
726} 728}
727 729
728 730
729/* Called from KDirWatch destructor: 731/* Called from KDirWatch destructor:
730 * remove <instance> as client from all entries 732 * remove <instance> as client from all entries
731 */ 733 */
732void KDirWatchPrivate::removeEntries( KDirWatch* instance ) 734void KDirWatchPrivate::removeEntries( KDirWatch* instance )
733{ 735{
734 QPtrList<Entry> list; 736 Q3PtrList<Entry> list;
735 int minfreq = 3600000; 737 int minfreq = 3600000;
736 738
737 // put all entries where instance is a client in list 739 // put all entries where instance is a client in list
738 EntryMap::Iterator it = m_mapEntries.begin(); 740 EntryMap::Iterator it = m_mapEntries.begin();
739 for( ; it != m_mapEntries.end(); ++it ) { 741 for( ; it != m_mapEntries.end(); ++it ) {
740 Client* c = (*it).m_clients.first(); 742 Client* c = (*it).m_clients.first();
741 for(;c;c=(*it).m_clients.next()) 743 for(;c;c=(*it).m_clients.next())
742 if (c->instance == instance) break; 744 if (c->instance == instance) break;
743 if (c) { 745 if (c) {
744 c->count = 1; // forces deletion of instance as client 746 c->count = 1; // forces deletion of instance as client
745 list.append(&(*it)); 747 list.append(&(*it));
746 } 748 }
747 else if ( (*it).m_mode == StatMode && (*it).freq < minfreq ) 749 else if ( (*it).m_mode == StatMode && (*it).freq < minfreq )
748 minfreq = (*it).freq; 750 minfreq = (*it).freq;
749 } 751 }
750 752
751 for(Entry* e=list.first();e;e=list.next()) 753 for(Entry* e=list.first();e;e=list.next())
752 removeEntry(instance, e->path, 0); 754 removeEntry(instance, e->path, 0);
753 755
754 if (minfreq > freq) { 756 if (minfreq > freq) {
755 // we can decrease the global polling frequency 757 // we can decrease the global polling frequency
756 freq = minfreq; 758 freq = minfreq;
757 if (timer->isActive()) timer->changeInterval(freq); 759 if (timer->isActive()) timer->changeInterval(freq);
758 kdDebug(7001) << "Poll Freq now " << freq << " msec" << endl; 760 kdDebug(7001) << "Poll Freq now " << freq << " msec" << endl;
759 } 761 }
760} 762}
761 763
762// instance ==0: stop scanning for all instances 764// instance ==0: stop scanning for all instances
763bool KDirWatchPrivate::stopEntryScan( KDirWatch* instance, Entry* e) 765bool KDirWatchPrivate::stopEntryScan( KDirWatch* instance, Entry* e)
764{ 766{
765 int stillWatching = 0; 767 int stillWatching = 0;
766 Client* c = e->m_clients.first(); 768 Client* c = e->m_clients.first();
767 for(;c;c=e->m_clients.next()) { 769 for(;c;c=e->m_clients.next()) {
768 if (!instance || instance == c->instance) 770 if (!instance || instance == c->instance)
769 c->watchingStopped = true; 771 c->watchingStopped = true;
770 else if (!c->watchingStopped) 772 else if (!c->watchingStopped)
771 stillWatching += c->count; 773 stillWatching += c->count;
772 } 774 }
773 775
774 kdDebug(7001) << instance->name() << " stopped scanning " << e->path 776 kdDebug(7001) << instance->name() << " stopped scanning " << e->path
775 << " (now " << stillWatching << " watchers)" << endl; 777 << " (now " << stillWatching << " watchers)" << endl;
776 778
777 if (stillWatching == 0) { 779 if (stillWatching == 0) {
778 // if nobody is interested, we don't watch 780 // if nobody is interested, we don't watch
779 e->m_ctime = invalid_ctime; // invalid 781 e->m_ctime = invalid_ctime; // invalid
780 // e->m_status = Normal; 782 // e->m_status = Normal;
781 } 783 }
782 return true; 784 return true;
783} 785}
784 786
785// instance ==0: start scanning for all instances 787// instance ==0: start scanning for all instances
786bool KDirWatchPrivate::restartEntryScan( KDirWatch* instance, Entry* e, 788bool KDirWatchPrivate::restartEntryScan( KDirWatch* instance, Entry* e,
787 bool notify) 789 bool notify)
788{ 790{
789 int wasWatching = 0, newWatching = 0; 791 int wasWatching = 0, newWatching = 0;
790 Client* c = e->m_clients.first(); 792 Client* c = e->m_clients.first();
791 for(;c;c=e->m_clients.next()) { 793 for(;c;c=e->m_clients.next()) {
792 if (!c->watchingStopped) 794 if (!c->watchingStopped)
793 wasWatching += c->count; 795 wasWatching += c->count;
794 else if (!instance || instance == c->instance) { 796 else if (!instance || instance == c->instance) {
795 c->watchingStopped = false; 797 c->watchingStopped = false;
796 newWatching += c->count; 798 newWatching += c->count;
797 } 799 }
798 } 800 }
799 if (newWatching == 0) 801 if (newWatching == 0)
800 return false; 802 return false;
801 803
802 kdDebug(7001) << instance->name() << " restarted scanning " << e->path 804 kdDebug(7001) << instance->name() << " restarted scanning " << e->path
803 << " (now " << wasWatching+newWatching << " watchers)" << endl; 805 << " (now " << wasWatching+newWatching << " watchers)" << endl;
804 806
805 // restart watching and emit pending events 807 // restart watching and emit pending events
806 808
807 int ev = NoChange; 809 int ev = NoChange;
808 if (wasWatching == 0) { 810 if (wasWatching == 0) {
809 if (!notify) { 811 if (!notify) {
810 struct stat stat_buf; 812 struct stat stat_buf;
811 bool exists = (stat(QFile::encodeName(e->path), &stat_buf) == 0); 813 bool exists = (stat(QFile::encodeName(e->path), &stat_buf) == 0);
812 if (exists) { 814 if (exists) {
813 e->m_ctime = stat_buf.st_ctime; 815 e->m_ctime = stat_buf.st_ctime;
814 e->m_status = Normal; 816 e->m_status = Normal;
815 e->m_nlink = stat_buf.st_nlink; 817 e->m_nlink = stat_buf.st_nlink;
816 } 818 }
817 else { 819 else {
818 e->m_ctime = invalid_ctime; 820 e->m_ctime = invalid_ctime;
819 e->m_status = NonExistent; 821 e->m_status = NonExistent;
820 e->m_nlink = 0; 822 e->m_nlink = 0;
821 } 823 }
822 } 824 }
823 e->msecLeft = 0; 825 e->msecLeft = 0;
824 ev = scanEntry(e); 826 ev = scanEntry(e);
825 } 827 }
826 emitEvent(e,ev); 828 emitEvent(e,ev);
827 829
828 return true; 830 return true;
829} 831}
830 832
831// instance ==0: stop scanning for all instances 833// instance ==0: stop scanning for all instances
832void KDirWatchPrivate::stopScan(KDirWatch* instance) 834void KDirWatchPrivate::stopScan(KDirWatch* instance)
833{ 835{
834 EntryMap::Iterator it = m_mapEntries.begin(); 836 EntryMap::Iterator it = m_mapEntries.begin();
835 for( ; it != m_mapEntries.end(); ++it ) 837 for( ; it != m_mapEntries.end(); ++it )
836 stopEntryScan(instance, &(*it)); 838 stopEntryScan(instance, &(*it));
837} 839}
838 840
839 841
840void KDirWatchPrivate::startScan(KDirWatch* instance, 842void KDirWatchPrivate::startScan(KDirWatch* instance,
841 bool notify, bool skippedToo ) 843 bool notify, bool skippedToo )
842{ 844{
843 if (!notify) 845 if (!notify)
844 resetList(instance,skippedToo); 846 resetList(instance,skippedToo);
845 847
846 EntryMap::Iterator it = m_mapEntries.begin(); 848 EntryMap::Iterator it = m_mapEntries.begin();
847 for( ; it != m_mapEntries.end(); ++it ) 849 for( ; it != m_mapEntries.end(); ++it )
848 restartEntryScan(instance, &(*it), notify); 850 restartEntryScan(instance, &(*it), notify);
849 851
850 // timer should still be running when in polling mode 852 // timer should still be running when in polling mode
851} 853}
852 854
853 855
854// clear all pending events, also from stopped 856// clear all pending events, also from stopped
855void KDirWatchPrivate::resetList( KDirWatch* /*instance*/, 857void KDirWatchPrivate::resetList( KDirWatch* /*instance*/,
856 bool skippedToo ) 858 bool skippedToo )
857{ 859{
858 EntryMap::Iterator it = m_mapEntries.begin(); 860 EntryMap::Iterator it = m_mapEntries.begin();
859 for( ; it != m_mapEntries.end(); ++it ) { 861 for( ; it != m_mapEntries.end(); ++it ) {
860 862
861 Client* c = (*it).m_clients.first(); 863 Client* c = (*it).m_clients.first();
862 for(;c;c=(*it).m_clients.next()) 864 for(;c;c=(*it).m_clients.next())
863 if (!c->watchingStopped || skippedToo) 865 if (!c->watchingStopped || skippedToo)
864 c->pending = NoChange; 866 c->pending = NoChange;
865 } 867 }
866} 868}
867 869
868// Return event happened on <e> 870// Return event happened on <e>
869// 871//
870int KDirWatchPrivate::scanEntry(Entry* e) 872int KDirWatchPrivate::scanEntry(Entry* e)
871{ 873{
872#ifdef HAVE_FAM 874#ifdef HAVE_FAM
873 // we do not stat entries using FAM 875 // we do not stat entries using FAM
874 if (e->m_mode == FAMMode) return NoChange; 876 if (e->m_mode == FAMMode) return NoChange;
875#endif 877#endif
876 878
877 // Shouldn't happen: Ignore "unknown" notification method 879 // Shouldn't happen: Ignore "unknown" notification method
878 if (e->m_mode == UnknownMode) return NoChange; 880 if (e->m_mode == UnknownMode) return NoChange;
879 881
880#ifdef HAVE_DNOTIFY 882#ifdef HAVE_DNOTIFY
881 if (e->m_mode == DNotifyMode) { 883 if (e->m_mode == DNotifyMode) {
882 // we know nothing has changed, no need to stat 884 // we know nothing has changed, no need to stat
883 if(!e->dn_dirty) return NoChange; 885 if(!e->dn_dirty) return NoChange;
884 e->dn_dirty = false; 886 e->dn_dirty = false;
885 } 887 }
886#endif 888#endif
887 889
888 if (e->m_mode == StatMode) { 890 if (e->m_mode == StatMode) {
889 // only scan if timeout on entry timer happens; 891 // only scan if timeout on entry timer happens;
890 // e.g. when using 500msec global timer, a entry 892 // e.g. when using 500msec global timer, a entry
891 // with freq=5000 is only watched every 10th time 893 // with freq=5000 is only watched every 10th time
892 894
893 e->msecLeft -= freq; 895 e->msecLeft -= freq;
894 if (e->msecLeft>0) return NoChange; 896 if (e->msecLeft>0) return NoChange;
895 e->msecLeft += e->freq; 897 e->msecLeft += e->freq;
896 } 898 }
897 899
898 struct stat stat_buf; 900 struct stat stat_buf;
899 bool exists = (stat(QFile::encodeName(e->path), &stat_buf) == 0); 901 bool exists = (stat(QFile::encodeName(e->path), &stat_buf) == 0);
900 if (exists) { 902 if (exists) {
901 903
902 if (e->m_status == NonExistent) { 904 if (e->m_status == NonExistent) {
903 e->m_ctime = stat_buf.st_ctime; 905 e->m_ctime = stat_buf.st_ctime;
904 e->m_status = Normal; 906 e->m_status = Normal;
905 e->m_nlink = stat_buf.st_nlink; 907 e->m_nlink = stat_buf.st_nlink;
906 return Created; 908 return Created;
907 } 909 }
908 910
909 if ( (e->m_ctime != invalid_ctime) && 911 if ( (e->m_ctime != invalid_ctime) &&
910 ((stat_buf.st_ctime != e->m_ctime) || 912 ((stat_buf.st_ctime != e->m_ctime) ||
911 // (stat_buf.st_nlink != (nlink_t) e->m_nlink)) ) { 913 // (stat_buf.st_nlink != (nlink_t) e->m_nlink)) ) {
912 (stat_buf.st_nlink != e->m_nlink)) ) { 914 (stat_buf.st_nlink != e->m_nlink)) ) {
913 e->m_ctime = stat_buf.st_ctime; 915 e->m_ctime = stat_buf.st_ctime;
914 e->m_nlink = stat_buf.st_nlink; 916 e->m_nlink = stat_buf.st_nlink;
915 return Changed; 917 return Changed;
916 } 918 }
917 919
918 return NoChange; 920 return NoChange;
919 } 921 }
920 922
921 // dir/file doesn't exist 923 // dir/file doesn't exist
922 924
923 if (e->m_ctime == invalid_ctime) 925 if (e->m_ctime == invalid_ctime)
924 return NoChange; 926 return NoChange;
925 927
926 e->m_ctime = invalid_ctime; 928 e->m_ctime = invalid_ctime;
927 e->m_nlink = 0; 929 e->m_nlink = 0;
928 e->m_status = NonExistent; 930 e->m_status = NonExistent;
929 931
930 return Deleted; 932 return Deleted;
931} 933}
932 934
933/* Notify all interested KDirWatch instances about a given event on an entry 935/* Notify all interested KDirWatch instances about a given event on an entry
934 * and stored pending events. When watching is stopped, the event is 936 * and stored pending events. When watching is stopped, the event is
935 * added to the pending events. 937 * added to the pending events.
936 */ 938 */
937void KDirWatchPrivate::emitEvent(Entry* e, int event, const QString &fileName) 939void KDirWatchPrivate::emitEvent(Entry* e, int event, const QString &fileName)
938{ 940{
939 QString path = e->path; 941 QString path = e->path;
940 if (!fileName.isEmpty()) { 942 if (!fileName.isEmpty()) {
941 if (fileName[0] == '/') 943 if (fileName[0] == '/')
942 path = fileName; 944 path = fileName;
943 else 945 else
944 path += "/" + fileName; 946 path += "/" + fileName;
945 } 947 }
946 948
947 Client* c = e->m_clients.first(); 949 Client* c = e->m_clients.first();
948 for(;c;c=e->m_clients.next()) { 950 for(;c;c=e->m_clients.next()) {
949 if (c->instance==0 || c->count==0) continue; 951 if (c->instance==0 || c->count==0) continue;
950 952
951 if (c->watchingStopped) { 953 if (c->watchingStopped) {
952 // add event to pending... 954 // add event to pending...
953 if (event == Changed) 955 if (event == Changed)
954 c->pending |= event; 956 c->pending |= event;
955 else if (event == Created || event == Deleted) 957 else if (event == Created || event == Deleted)
956 c->pending = event; 958 c->pending = event;
957 continue; 959 continue;
958 } 960 }
959 // not stopped 961 // not stopped
960 if (event == NoChange || event == Changed) 962 if (event == NoChange || event == Changed)
961 event |= c->pending; 963 event |= c->pending;
962 c->pending = NoChange; 964 c->pending = NoChange;
963 if (event == NoChange) continue; 965 if (event == NoChange) continue;
964 966
965 if (event & Deleted) { 967 if (event & Deleted) {
966 c->instance->setDeleted(path); 968 c->instance->setDeleted(path);
967 // emit only Deleted event... 969 // emit only Deleted event...
968 continue; 970 continue;
969 } 971 }
970 972
971 if (event & Created) { 973 if (event & Created) {
972 c->instance->setCreated(path); 974 c->instance->setCreated(path);
973 // possible emit Change event after creation 975 // possible emit Change event after creation
974 } 976 }
975 977
976 if (event & Changed) 978 if (event & Changed)
977 c->instance->setDirty(path); 979 c->instance->setDirty(path);
978 } 980 }
979} 981}
980 982
981// Remove entries which were marked to be removed 983// Remove entries which were marked to be removed
982void KDirWatchPrivate::slotRemoveDelayed() 984void KDirWatchPrivate::slotRemoveDelayed()
983{ 985{
984 Entry* e; 986 Entry* e;
985 delayRemove = false; 987 delayRemove = false;
986 for(e=removeList.first();e;e=removeList.next()) 988 for(e=removeList.first();e;e=removeList.next())
987 removeEntry(0, e->path, 0); 989 removeEntry(0, e->path, 0);
988 removeList.clear(); 990 removeList.clear();
989} 991}
990 992
991/* Scan all entries to be watched for changes. This is done regularly 993/* Scan all entries to be watched for changes. This is done regularly
992 * when polling and once after a DNOTIFY signal. This is NOT used by FAM. 994 * when polling and once after a DNOTIFY signal. This is NOT used by FAM.
993 */ 995 */
994void KDirWatchPrivate::slotRescan() 996void KDirWatchPrivate::slotRescan()
995{ 997{
996 EntryMap::Iterator it; 998 EntryMap::Iterator it;
997 999
998 // People can do very long things in the slot connected to dirty(), 1000 // People can do very long things in the slot connected to dirty(),
999 // like showing a message box. We don't want to keep polling during 1001 // like showing a message box. We don't want to keep polling during
1000 // that time, otherwise the value of 'delayRemove' will be reset. 1002 // that time, otherwise the value of 'delayRemove' will be reset.
1001 bool timerRunning = timer->isActive(); 1003 bool timerRunning = timer->isActive();
1002 if ( timerRunning ) 1004 if ( timerRunning )
1003 timer->stop(); 1005 timer->stop();
1004 1006
1005 // We delay deletions of entries this way. 1007 // We delay deletions of entries this way.
1006 // removeDir(), when called in slotDirty(), can cause a crash otherwise 1008 // removeDir(), when called in slotDirty(), can cause a crash otherwise
1007 delayRemove = true; 1009 delayRemove = true;
1008 1010
1009#ifdef HAVE_DNOTIFY 1011#ifdef HAVE_DNOTIFY
1010 QPtrList<Entry> dList, cList; 1012 Q3PtrList<Entry> dList, cList;
1011 1013
1012 // for DNotify method, 1014 // for DNotify method,
1013 if (rescan_all) 1015 if (rescan_all)
1014 { 1016 {
1015 // mark all as dirty 1017 // mark all as dirty
1016 it = m_mapEntries.begin(); 1018 it = m_mapEntries.begin();
1017 for( ; it != m_mapEntries.end(); ++it ) 1019 for( ; it != m_mapEntries.end(); ++it )
1018 (*it).dn_dirty = true; 1020 (*it).dn_dirty = true;
1019 rescan_all = false; 1021 rescan_all = false;
1020 } 1022 }
1021 else 1023 else
1022 { 1024 {
1023 // progate dirty flag to dependant entries (e.g. file watches) 1025 // progate dirty flag to dependant entries (e.g. file watches)
1024 it = m_mapEntries.begin(); 1026 it = m_mapEntries.begin();
1025 for( ; it != m_mapEntries.end(); ++it ) 1027 for( ; it != m_mapEntries.end(); ++it )
1026 if ( ((*it).m_mode == DNotifyMode) && (*it).dn_dirty ) 1028 if ( ((*it).m_mode == DNotifyMode) && (*it).dn_dirty )
1027 (*it).propagate_dirty(); 1029 (*it).propagate_dirty();
1028 } 1030 }
1029 1031
1030#endif 1032#endif
1031 1033
1032 it = m_mapEntries.begin(); 1034 it = m_mapEntries.begin();
1033 for( ; it != m_mapEntries.end(); ++it ) { 1035 for( ; it != m_mapEntries.end(); ++it ) {
1034 // we don't check invalid entries (i.e. remove delayed) 1036 // we don't check invalid entries (i.e. remove delayed)
1035 if (!(*it).isValid()) continue; 1037 if (!(*it).isValid()) continue;
1036 1038
1037 int ev = scanEntry( &(*it) ); 1039 int ev = scanEntry( &(*it) );
1038 1040
1039#ifdef HAVE_DNOTIFY 1041#ifdef HAVE_DNOTIFY
1040 if ((*it).m_mode == DNotifyMode) { 1042 if ((*it).m_mode == DNotifyMode) {
1041 if ((*it).isDir && (ev == Deleted)) { 1043 if ((*it).isDir && (ev == Deleted)) {
1042 dList.append( &(*it) ); 1044 dList.append( &(*it) );
1043 1045
1044 // must close the FD. 1046 // must close the FD.
1045 if ((*it).dn_fd) { 1047 if ((*it).dn_fd) {
1046 ::close((*it).dn_fd); 1048 ::close((*it).dn_fd);
1047 fd_Entry.remove((*it).dn_fd); 1049 fd_Entry.remove((*it).dn_fd);
1048 (*it).dn_fd = 0; 1050 (*it).dn_fd = 0;
1049 } 1051 }
1050 } 1052 }
1051 1053
1052 else if ((*it).isDir && (ev == Created)) { 1054 else if ((*it).isDir && (ev == Created)) {
1053 // For created, but yet without DNOTIFYing ... 1055 // For created, but yet without DNOTIFYing ...
1054 if ( (*it).dn_fd == 0) { 1056 if ( (*it).dn_fd == 0) {
1055 cList.append( &(*it) ); 1057 cList.append( &(*it) );
1056 if (! useDNotify( &(*it) )) { 1058 if (! useDNotify( &(*it) )) {
1057 // if DNotify setup fails... 1059 // if DNotify setup fails...
1058 useStat( &(*it) ); 1060 useStat( &(*it) );
1059 } 1061 }
1060 } 1062 }
1061 } 1063 }
1062 } 1064 }
1063#endif 1065#endif
1064 1066
1065 if ( ev != NoChange ) 1067 if ( ev != NoChange )
1066 emitEvent( &(*it), ev); 1068 emitEvent( &(*it), ev);
1067 } 1069 }
1068 1070
1069 1071
1070#ifdef HAVE_DNOTIFY 1072#ifdef HAVE_DNOTIFY
1071 // Scan parent of deleted directories for new creation 1073 // Scan parent of deleted directories for new creation
1072 Entry* e; 1074 Entry* e;
1073 for(e=dList.first();e;e=dList.next()) 1075 for(e=dList.first();e;e=dList.next())
1074 addEntry(0, QDir::cleanDirPath( e->path+"/.."), e, true); 1076 addEntry(0, QDir::cleanDirPath( e->path+"/.."), e, true);
1075 1077
1076 // Remove watch of parent of new created directories 1078 // Remove watch of parent of new created directories
1077 for(e=cList.first();e;e=cList.next()) 1079 for(e=cList.first();e;e=cList.next())
1078 removeEntry(0, QDir::cleanDirPath( e->path+"/.."), e); 1080 removeEntry(0, QDir::cleanDirPath( e->path+"/.."), e);
1079#endif 1081#endif
1080 1082
1081 if ( timerRunning ) 1083 if ( timerRunning )
1082 timer->start(freq); 1084 timer->start(freq);
1083 1085
1084 QTimer::singleShot(0, this, SLOT(slotRemoveDelayed())); 1086 QTimer::singleShot(0, this, SLOT(slotRemoveDelayed()));
1085} 1087}
1086 1088
1087#ifdef HAVE_FAM 1089#ifdef HAVE_FAM
1088void KDirWatchPrivate::famEventReceived() 1090void KDirWatchPrivate::famEventReceived()
1089{ 1091{
1090 static FAMEvent fe; 1092 static FAMEvent fe;
1091 1093
1092 delayRemove = true; 1094 delayRemove = true;
1093 1095
1094 while(use_fam && FAMPending(&fc)) { 1096 while(use_fam && FAMPending(&fc)) {
1095 if (FAMNextEvent(&fc, &fe) == -1) { 1097 if (FAMNextEvent(&fc, &fe) == -1) {
1096 kdWarning(7001) << "FAM connection problem, switching to polling." 1098 kdWarning(7001) << "FAM connection problem, switching to polling."
1097 << endl; 1099 << endl;
1098 use_fam = false; 1100 use_fam = false;
1099 delete sn; sn = 0; 1101 delete sn; sn = 0;
1100 1102
1101 // Replace all FAMMode entries with DNotify/Stat 1103 // Replace all FAMMode entries with DNotify/Stat
1102 EntryMap::Iterator it; 1104 EntryMap::Iterator it;
1103 it = m_mapEntries.begin(); 1105 it = m_mapEntries.begin();
1104 for( ; it != m_mapEntries.end(); ++it ) 1106 for( ; it != m_mapEntries.end(); ++it )
1105 if ((*it).m_mode == FAMMode && (*it).m_clients.count()>0) { 1107 if ((*it).m_mode == FAMMode && (*it).m_clients.count()>0) {
1106#ifdef HAVE_DNOTIFY 1108#ifdef HAVE_DNOTIFY
1107 if (useDNotify( &(*it) )) continue; 1109 if (useDNotify( &(*it) )) continue;
1108#endif 1110#endif
1109 useStat( &(*it) ); 1111 useStat( &(*it) );
1110 } 1112 }
1111 } 1113 }
1112 else 1114 else
1113 checkFAMEvent(&fe); 1115 checkFAMEvent(&fe);
1114 } 1116 }
1115 1117
1116 QTimer::singleShot(0, this, SLOT(slotRemoveDelayed())); 1118 QTimer::singleShot(0, this, SLOT(slotRemoveDelayed()));
1117} 1119}
1118 1120
1119void KDirWatchPrivate::checkFAMEvent(FAMEvent* fe) 1121void KDirWatchPrivate::checkFAMEvent(FAMEvent* fe)
1120{ 1122{
1121 // Don't be too verbose ;-) 1123 // Don't be too verbose ;-)
1122 if ((fe->code == FAMExists) || 1124 if ((fe->code == FAMExists) ||
1123 (fe->code == FAMEndExist) || 1125 (fe->code == FAMEndExist) ||
1124 (fe->code == FAMAcknowledge)) return; 1126 (fe->code == FAMAcknowledge)) return;
1125 1127
1126 // $HOME/.X.err grows with debug output, so don't notify change 1128 // $HOME/.X.err grows with debug output, so don't notify change
1127 if ( *(fe->filename) == '.') { 1129 if ( *(fe->filename) == '.') {
1128 if (strncmp(fe->filename, ".X.err", 6) == 0) return; 1130 if (strncmp(fe->filename, ".X.err", 6) == 0) return;
1129 if (strncmp(fe->filename, ".xsession-errors", 16) == 0) return; 1131 if (strncmp(fe->filename, ".xsession-errors", 16) == 0) return;
1130 } 1132 }
1131 1133
1132 Entry* e = 0; 1134 Entry* e = 0;
1133 EntryMap::Iterator it = m_mapEntries.begin(); 1135 EntryMap::Iterator it = m_mapEntries.begin();
1134 for( ; it != m_mapEntries.end(); ++it ) 1136 for( ; it != m_mapEntries.end(); ++it )
1135 if (FAMREQUEST_GETREQNUM(&( (*it).fr )) == 1137 if (FAMREQUEST_GETREQNUM(&( (*it).fr )) ==
1136 FAMREQUEST_GETREQNUM(&(fe->fr)) ) { 1138 FAMREQUEST_GETREQNUM(&(fe->fr)) ) {
1137 e = &(*it); 1139 e = &(*it);
1138 break; 1140 break;
1139 } 1141 }
1140 1142
1141 // Entry* e = static_cast<Entry*>(fe->userdata); 1143 // Entry* e = static_cast<Entry*>(fe->userdata);
1142 1144
1143 kdDebug(7001) << "Processing FAM event (" 1145 kdDebug(7001) << "Processing FAM event ("
1144 << ((fe->code == FAMChanged) ? "FAMChanged" : 1146 << ((fe->code == FAMChanged) ? "FAMChanged" :
1145 (fe->code == FAMDeleted) ? "FAMDeleted" : 1147 (fe->code == FAMDeleted) ? "FAMDeleted" :
1146 (fe->code == FAMStartExecuting) ? "FAMStartExecuting" : 1148 (fe->code == FAMStartExecuting) ? "FAMStartExecuting" :
1147 (fe->code == FAMStopExecuting) ? "FAMStopExecuting" : 1149 (fe->code == FAMStopExecuting) ? "FAMStopExecuting" :
1148 (fe->code == FAMCreated) ? "FAMCreated" : 1150 (fe->code == FAMCreated) ? "FAMCreated" :
1149 (fe->code == FAMMoved) ? "FAMMoved" : 1151 (fe->code == FAMMoved) ? "FAMMoved" :
1150 (fe->code == FAMAcknowledge) ? "FAMAcknowledge" : 1152 (fe->code == FAMAcknowledge) ? "FAMAcknowledge" :
1151 (fe->code == FAMExists) ? "FAMExists" : 1153 (fe->code == FAMExists) ? "FAMExists" :
1152 (fe->code == FAMEndExist) ? "FAMEndExist" : "Unknown Code") 1154 (fe->code == FAMEndExist) ? "FAMEndExist" : "Unknown Code")
1153 << ", " << fe->filename 1155 << ", " << fe->filename
1154 << ", Req " << FAMREQUEST_GETREQNUM(&(fe->fr)) 1156 << ", Req " << FAMREQUEST_GETREQNUM(&(fe->fr))
1155 << ")" << endl; 1157 << ")" << endl;
1156 1158
1157 if (!e) { 1159 if (!e) {
1158 // this happens e.g. for FAMAcknowledge after deleting a dir... 1160 // this happens e.g. for FAMAcknowledge after deleting a dir...
1159 // kdDebug(7001) << "No entry for FAM event ?!" << endl; 1161 // kdDebug(7001) << "No entry for FAM event ?!" << endl;
1160 return; 1162 return;
1161 } 1163 }
1162 1164
1163 if (e->m_status == NonExistent) { 1165 if (e->m_status == NonExistent) {
1164 kdDebug(7001) << "FAM event for nonExistent entry " << e->path << endl; 1166 kdDebug(7001) << "FAM event for nonExistent entry " << e->path << endl;
1165 return; 1167 return;
1166 } 1168 }
1167 1169
1168 if (e->isDir) 1170 if (e->isDir)
1169 switch (fe->code) 1171 switch (fe->code)
1170 { 1172 {
1171 case FAMDeleted: 1173 case FAMDeleted:
1172 // file absolute: watched dir 1174 // file absolute: watched dir
1173 if (fe->filename[0] == '/') 1175 if (fe->filename[0] == '/')
1174 { 1176 {
1175 // a watched directory was deleted 1177 // a watched directory was deleted
1176 1178
1177 e->m_status = NonExistent; 1179 e->m_status = NonExistent;
1178 FAMCancelMonitor(&fc, &(e->fr) ); // needed ? 1180 FAMCancelMonitor(&fc, &(e->fr) ); // needed ?
1179 kdDebug(7001) << "Cancelled FAMReq " 1181 kdDebug(7001) << "Cancelled FAMReq "
1180 << FAMREQUEST_GETREQNUM(&(e->fr)) 1182 << FAMREQUEST_GETREQNUM(&(e->fr))
1181 << " for " << e->path << endl; 1183 << " for " << e->path << endl;
1182 // Scan parent for a new creation 1184 // Scan parent for a new creation
1183 addEntry(0, QDir::cleanDirPath( e->path+"/.."), e, true); 1185 addEntry(0, QDir::cleanDirPath( e->path+"/.."), e, true);
1184 } 1186 }
1185 emitEvent(e, Deleted, QFile::decodeName(fe->filename)); 1187 emitEvent(e, Deleted, QFile::decodeName(fe->filename));
1186 break; 1188 break;
1187 1189
1188 case FAMCreated: { 1190 case FAMCreated: {
1189 // check for creation of a directory we have to watch 1191 // check for creation of a directory we have to watch
1190 Entry *sub_entry = e->m_entries.first(); 1192 Entry *sub_entry = e->m_entries.first();
1191 for(;sub_entry; sub_entry = e->m_entries.next()) 1193 for(;sub_entry; sub_entry = e->m_entries.next())
1192 if (sub_entry->path == e->path + "/" + fe->filename) break; 1194 if (sub_entry->path == e->path + "/" + fe->filename) break;
1193 if (sub_entry && sub_entry->isDir) { 1195 if (sub_entry && sub_entry->isDir) {
1194 QString path = e->path; 1196 QString path = e->path;
1195 removeEntry(0,e->path,sub_entry); // <e> can be invalid here!! 1197 removeEntry(0,e->path,sub_entry); // <e> can be invalid here!!
1196 sub_entry->m_status = Normal; 1198 sub_entry->m_status = Normal;
1197 if (!useFAM(sub_entry)) 1199 if (!useFAM(sub_entry))
1198 useStat(sub_entry); 1200 useStat(sub_entry);
1199 1201
1200 emitEvent(sub_entry, Created); 1202 emitEvent(sub_entry, Created);
1201 } 1203 }
1202 else emitEvent(e, Created, QFile::decodeName(fe->filename)); 1204 else emitEvent(e, Created, QFile::decodeName(fe->filename));
1203 break; 1205 break;
1204 } 1206 }
1205 1207
1206 case FAMChanged: 1208 case FAMChanged:
1207 emitEvent(e, Changed, QFile::decodeName(fe->filename)); 1209 emitEvent(e, Changed, QFile::decodeName(fe->filename));
1208 1210
1209 default: 1211 default:
1210 break; 1212 break;
1211 } 1213 }
1212 else switch (fe->code) 1214 else switch (fe->code)
1213 { 1215 {
1214 case FAMCreated: emitEvent(e, Created); 1216 case FAMCreated: emitEvent(e, Created);
1215 break; 1217 break;
1216 case FAMDeleted: emitEvent(e, Deleted); 1218 case FAMDeleted: emitEvent(e, Deleted);
1217 break; 1219 break;
1218 case FAMChanged: emitEvent(e, Changed); 1220 case FAMChanged: emitEvent(e, Changed);
1219 break; 1221 break;
1220 default: break; 1222 default: break;
1221 } 1223 }
1222} 1224}
1223#else 1225#else
1224void KDirWatchPrivate::famEventReceived() {} 1226void KDirWatchPrivate::famEventReceived() {}
1225#endif 1227#endif
1226 1228
1227 1229
1228void KDirWatchPrivate::statistics() 1230void KDirWatchPrivate::statistics()
1229{ 1231{
1230 EntryMap::Iterator it; 1232 EntryMap::Iterator it;
1231 1233
1232 kdDebug(7001) << "Entries watched:" << endl; 1234 kdDebug(7001) << "Entries watched:" << endl;
1233 if (m_mapEntries.count()==0) { 1235 if (m_mapEntries.count()==0) {
1234 kdDebug(7001) << " None." << endl; 1236 kdDebug(7001) << " None." << endl;
1235 } 1237 }
1236 else { 1238 else {
1237 it = m_mapEntries.begin(); 1239 it = m_mapEntries.begin();
1238 for( ; it != m_mapEntries.end(); ++it ) { 1240 for( ; it != m_mapEntries.end(); ++it ) {
1239 Entry* e = &(*it); 1241 Entry* e = &(*it);
1240 kdDebug(7001) << " " << e->path << " (" 1242 kdDebug(7001) << " " << e->path << " ("
1241 << ((e->m_status==Normal)?"":"Nonexistent ") 1243 << ((e->m_status==Normal)?"":"Nonexistent ")
1242 << (e->isDir ? "Dir":"File") << ", using " 1244 << (e->isDir ? "Dir":"File") << ", using "
1243 << ((e->m_mode == FAMMode) ? "FAM" : 1245 << ((e->m_mode == FAMMode) ? "FAM" :
1244 (e->m_mode == DNotifyMode) ? "DNotify" : 1246 (e->m_mode == DNotifyMode) ? "DNotify" :
1245 (e->m_mode == StatMode) ? "Stat" : "Unknown Method") 1247 (e->m_mode == StatMode) ? "Stat" : "Unknown Method")
1246 << ")" << endl; 1248 << ")" << endl;
1247 1249
1248 Client* c = e->m_clients.first(); 1250 Client* c = e->m_clients.first();
1249 for(;c; c = e->m_clients.next()) { 1251 for(;c; c = e->m_clients.next()) {
1250 QString pending; 1252 QString pending;
1251 if (c->watchingStopped) { 1253 if (c->watchingStopped) {
1252 if (c->pending & Deleted) pending += "deleted "; 1254 if (c->pending & Deleted) pending += "deleted ";
1253 if (c->pending & Created) pending += "created "; 1255 if (c->pending & Created) pending += "created ";
1254 if (c->pending & Changed) pending += "changed "; 1256 if (c->pending & Changed) pending += "changed ";
1255 if (!pending.isEmpty()) pending = " (pending: " + pending + ")"; 1257 if (!pending.isEmpty()) pending = " (pending: " + pending + ")";
1256 pending = ", stopped" + pending; 1258 pending = ", stopped" + pending;
1257 } 1259 }
1258 kdDebug(7001) << " by " << c->instance->name() 1260 kdDebug(7001) << " by " << c->instance->name()
1259 << " (" << c->count << " times)" 1261 << " (" << c->count << " times)"
1260 << pending << endl; 1262 << pending << endl;
1261 } 1263 }
1262 if (e->m_entries.count()>0) { 1264 if (e->m_entries.count()>0) {
1263 kdDebug(7001) << " dependent entries:" << endl; 1265 kdDebug(7001) << " dependent entries:" << endl;
1264 Entry* d = e->m_entries.first(); 1266 Entry* d = e->m_entries.first();
1265 for(;d; d = e->m_entries.next()) { 1267 for(;d; d = e->m_entries.next()) {
1266 kdDebug(7001) << " " << d->path << endl; 1268 kdDebug(7001) << " " << d->path << endl;
1267 } 1269 }
1268 } 1270 }
1269 } 1271 }
1270 } 1272 }
1271} 1273}
1272 1274
1273 1275
1274// 1276//
1275// Class KDirWatch 1277// Class KDirWatch
1276// 1278//
1277 1279
1278static KStaticDeleter<KDirWatch> sd_dw; 1280static KStaticDeleter<KDirWatch> sd_dw;
1279KDirWatch* KDirWatch::s_pSelf = 0L; 1281KDirWatch* KDirWatch::s_pSelf = 0L;
1280 1282
1281KDirWatch* KDirWatch::self() 1283KDirWatch* KDirWatch::self()
1282{ 1284{
1283 if ( !s_pSelf ) { 1285 if ( !s_pSelf ) {
1284//US sd_dw.setObject( s_pSelf, new KDirWatch ); 1286//US sd_dw.setObject( s_pSelf, new KDirWatch );
1285 s_pSelf = sd_dw.setObject( new KDirWatch ); 1287 s_pSelf = sd_dw.setObject( new KDirWatch );
1286 } 1288 }
1287 1289
1288 return s_pSelf; 1290 return s_pSelf;
1289} 1291}
1290 1292
1291bool KDirWatch::exists() 1293bool KDirWatch::exists()
1292{ 1294{
1293 return s_pSelf != 0; 1295 return s_pSelf != 0;
1294} 1296}
1295 1297
1296KDirWatch::KDirWatch (QObject* parent, const char* name) 1298KDirWatch::KDirWatch (QObject* parent, const char* name)
1297 : QObject(parent,name) 1299 : QObject(parent,name)
1298{ 1300{
1299 if (!name) { 1301 if (!name) {
1300 static int nameCounter = 0; 1302 static int nameCounter = 0;
1301 1303
1302 nameCounter++; 1304 nameCounter++;
1303 setName(QString("KDirWatch-%1").arg(nameCounter).ascii()); 1305 setName(QString("KDirWatch-%1").arg(nameCounter).ascii());
1304 } 1306 }
1305 1307
1306 if (!dwp_self) 1308 if (!dwp_self)
1307 dwp_self = new KDirWatchPrivate; 1309 dwp_self = new KDirWatchPrivate;
1308 d = dwp_self; 1310 d = dwp_self;
1309 d->ref(); 1311 d->ref();
1310 1312
1311 _isStopped = false; 1313 _isStopped = false;
1312} 1314}
1313 1315
1314KDirWatch::~KDirWatch() 1316KDirWatch::~KDirWatch()
1315{ 1317{
1316 if (d) d->removeEntries(this); 1318 if (d) d->removeEntries(this);
1317 if ( d->deref() ) 1319 if ( d->deref() )
1318 { 1320 {
1319 // delete it if it's the last one 1321 // delete it if it's the last one
1320 delete d; 1322 delete d;
1321 dwp_self = 0L; 1323 dwp_self = 0L;
1322 } 1324 }
1323} 1325}
1324 1326
1325 1327
1326// TODO: add watchFiles/recursive support 1328// TODO: add watchFiles/recursive support
1327void KDirWatch::addDir( const QString& _path, 1329void KDirWatch::addDir( const QString& _path,
1328 bool watchFiles, bool recursive) 1330 bool watchFiles, bool recursive)
1329{ 1331{
1330 if (watchFiles || recursive) { 1332 if (watchFiles || recursive) {
1331 kdDebug(7001) << "addDir - recursive/watchFiles not supported in KDE 3.0" 1333 kdDebug(7001) << "addDir - recursive/watchFiles not supported in KDE 3.0"
1332 << endl; 1334 << endl;
1333 } 1335 }
1334 if (d) d->addEntry(this, _path, 0, true); 1336 if (d) d->addEntry(this, _path, 0, true);
1335} 1337}
1336 1338
1337void KDirWatch::addFile( const QString& _path ) 1339void KDirWatch::addFile( const QString& _path )
1338{ 1340{
1339 if (d) d->addEntry(this, _path, 0, false); 1341 if (d) d->addEntry(this, _path, 0, false);
1340} 1342}
1341 1343
1342QDateTime KDirWatch::ctime( const QString &_path ) 1344QDateTime KDirWatch::ctime( const QString &_path )
1343{ 1345{
1344 KDirWatchPrivate::Entry* e = d->entry(_path); 1346 KDirWatchPrivate::Entry* e = d->entry(_path);
1345 1347
1346 if (!e) 1348 if (!e)
1347 return QDateTime(); 1349 return QDateTime();
1348 1350
1349 QDateTime result; 1351 QDateTime result;
1350 result.setTime_t(e->m_ctime); 1352 result.setTime_t(e->m_ctime);
1351 return result; 1353 return result;
1352} 1354}
1353 1355
1354void KDirWatch::removeDir( const QString& _path ) 1356void KDirWatch::removeDir( const QString& _path )
1355{ 1357{
1356 if (d) d->removeEntry(this, _path, 0); 1358 if (d) d->removeEntry(this, _path, 0);
1357} 1359}
1358 1360
1359void KDirWatch::removeFile( const QString& _path ) 1361void KDirWatch::removeFile( const QString& _path )
1360{ 1362{
1361 if (d) d->removeEntry(this, _path, 0); 1363 if (d) d->removeEntry(this, _path, 0);
1362} 1364}
1363 1365
1364bool KDirWatch::stopDirScan( const QString& _path ) 1366bool KDirWatch::stopDirScan( const QString& _path )
1365{ 1367{
1366 if (d) { 1368 if (d) {
1367 KDirWatchPrivate::Entry *e = d->entry(_path); 1369 KDirWatchPrivate::Entry *e = d->entry(_path);
1368 if (e && e->isDir) return d->stopEntryScan(this, e); 1370 if (e && e->isDir) return d->stopEntryScan(this, e);
1369 } 1371 }
1370 return false; 1372 return false;
1371} 1373}
1372 1374
1373bool KDirWatch::restartDirScan( const QString& _path ) 1375bool KDirWatch::restartDirScan( const QString& _path )
1374{ 1376{
1375 if (d) { 1377 if (d) {
1376 KDirWatchPrivate::Entry *e = d->entry(_path); 1378 KDirWatchPrivate::Entry *e = d->entry(_path);
1377 if (e && e->isDir) 1379 if (e && e->isDir)
1378 // restart without notifying pending events 1380 // restart without notifying pending events
1379 return d->restartEntryScan(this, e, false); 1381 return d->restartEntryScan(this, e, false);
1380 } 1382 }
1381 return false; 1383 return false;
1382} 1384}
1383 1385
1384void KDirWatch::stopScan() 1386void KDirWatch::stopScan()
1385{ 1387{
1386 if (d) d->stopScan(this); 1388 if (d) d->stopScan(this);
1387 _isStopped = true; 1389 _isStopped = true;
1388} 1390}
1389 1391
1390void KDirWatch::startScan( bool notify, bool skippedToo ) 1392void KDirWatch::startScan( bool notify, bool skippedToo )
1391{ 1393{
1392 _isStopped = false; 1394 _isStopped = false;
1393 if (d) d->startScan(this, notify, skippedToo); 1395 if (d) d->startScan(this, notify, skippedToo);
1394} 1396}
diff --git a/microkde/kio/kio/kdirwatch_p.h b/microkde/kio/kio/kdirwatch_p.h
index 0ab482f..be74f2a 100644
--- a/microkde/kio/kio/kdirwatch_p.h
+++ b/microkde/kio/kio/kdirwatch_p.h
@@ -1,153 +1,153 @@
1/* Private Header for class of KDirWatchPrivate 1/* Private Header for class of KDirWatchPrivate
2 * 2 *
3 * this separate header file is needed for MOC processing 3 * this separate header file is needed for MOC processing
4 * because KDirWatchPrivate has signals and slots 4 * because KDirWatchPrivate has signals and slots
5 */ 5 */
6 6
7/* 7/*
8Enhanced Version of the file for platform independent KDE tools. 8Enhanced Version of the file for platform independent KDE tools.
9Copyright (c) 2004 Ulf Schenk 9Copyright (c) 2004 Ulf Schenk
10 10
11$Id$ 11$Id$
12*/ 12*/
13 13
14#ifndef _KDIRWATCH_P_H 14#ifndef _KDIRWATCH_P_H
15#define _KDIRWATCH_P_H 15#define _KDIRWATCH_P_H
16 16
17#ifdef HAVE_FAM 17#ifdef HAVE_FAM
18#include <fam.h> 18#include <fam.h>
19#endif 19#endif
20 20
21#include <qptrlist.h> 21#include <q3ptrlist.h>
22 22
23#include <kdirwatch.h> 23#include <kdirwatch.h>
24 24
25#include <ctime> 25#include <ctime>
26 26
27#define invalid_ctime ((time_t)-1) 27#define invalid_ctime ((time_t)-1)
28 28
29/* KDirWatchPrivate is a singleton and does the watching 29/* KDirWatchPrivate is a singleton and does the watching
30 * for every KDirWatch instance in the application. 30 * for every KDirWatch instance in the application.
31 */ 31 */
32class KDirWatchPrivate : public QObject 32class KDirWatchPrivate : public QObject
33{ 33{
34 Q_OBJECT 34 Q_OBJECT
35public: 35public:
36 36
37 enum entryStatus { Normal = 0, NonExistent }; 37 enum entryStatus { Normal = 0, NonExistent };
38 enum entryMode { UnknownMode = 0, StatMode, DNotifyMode, FAMMode }; 38 enum entryMode { UnknownMode = 0, StatMode, DNotifyMode, FAMMode };
39 enum { NoChange=0, Changed=1, Created=2, Deleted=4 }; 39 enum { NoChange=0, Changed=1, Created=2, Deleted=4 };
40 40
41 struct Client { 41 struct Client {
42 KDirWatch* instance; 42 KDirWatch* instance;
43 int count; 43 int count;
44 // did the instance stop watching 44 // did the instance stop watching
45 bool watchingStopped; 45 bool watchingStopped;
46 // events blocked when stopped 46 // events blocked when stopped
47 int pending; 47 int pending;
48 }; 48 };
49 49
50 class Entry 50 class Entry
51 { 51 {
52 public: 52 public:
53 // the last observed modification time 53 // the last observed modification time
54 time_t m_ctime; 54 time_t m_ctime;
55 // the last observed link count 55 // the last observed link count
56 int m_nlink; 56 int m_nlink;
57 entryStatus m_status; 57 entryStatus m_status;
58 entryMode m_mode; 58 entryMode m_mode;
59 bool isDir; 59 bool isDir;
60 // instances interested in events 60 // instances interested in events
61 QPtrList<Client> m_clients; 61 Q3PtrList<Client> m_clients;
62 // nonexistent entries of this directory 62 // nonexistent entries of this directory
63 QPtrList<Entry> m_entries; 63 Q3PtrList<Entry> m_entries;
64 QString path; 64 QString path;
65 65
66 int msecLeft, freq; 66 int msecLeft, freq;
67 67
68 void addClient(KDirWatch*); 68 void addClient(KDirWatch*);
69 void removeClient(KDirWatch*); 69 void removeClient(KDirWatch*);
70 int clients(); 70 int clients();
71 bool isValid() { return m_clients.count() || m_entries.count(); } 71 bool isValid() { return m_clients.count() || m_entries.count(); }
72 72
73#ifdef HAVE_FAM 73#ifdef HAVE_FAM
74 FAMRequest fr; 74 FAMRequest fr;
75#endif 75#endif
76 76
77#ifdef HAVE_DNOTIFY 77#ifdef HAVE_DNOTIFY
78 int dn_fd; 78 int dn_fd;
79 bool dn_dirty; 79 bool dn_dirty;
80 void propagate_dirty(); 80 void propagate_dirty();
81#endif 81#endif
82 }; 82 };
83 83
84 typedef QMap<QString,Entry> EntryMap; 84 typedef QMap<QString,Entry> EntryMap;
85 85
86 KDirWatchPrivate(); 86 KDirWatchPrivate();
87 ~KDirWatchPrivate(); 87 ~KDirWatchPrivate();
88 88
89 void resetList (KDirWatch*,bool); 89 void resetList (KDirWatch*,bool);
90 void useFreq(Entry* e, int newFreq); 90 void useFreq(Entry* e, int newFreq);
91 void addEntry(KDirWatch*,const QString&, Entry*, bool); 91 void addEntry(KDirWatch*,const QString&, Entry*, bool);
92 void removeEntry(KDirWatch*,const QString&, Entry*); 92 void removeEntry(KDirWatch*,const QString&, Entry*);
93 bool stopEntryScan(KDirWatch*, Entry*); 93 bool stopEntryScan(KDirWatch*, Entry*);
94 bool restartEntryScan(KDirWatch*, Entry*, bool ); 94 bool restartEntryScan(KDirWatch*, Entry*, bool );
95 void stopScan(KDirWatch*); 95 void stopScan(KDirWatch*);
96 void startScan(KDirWatch*, bool, bool); 96 void startScan(KDirWatch*, bool, bool);
97 97
98 void removeEntries(KDirWatch*); 98 void removeEntries(KDirWatch*);
99 void statistics(); 99 void statistics();
100 100
101 Entry* entry(const QString&); 101 Entry* entry(const QString&);
102 int scanEntry(Entry* e); 102 int scanEntry(Entry* e);
103 void emitEvent(Entry* e, int event, const QString &fileName = QString::null); 103 void emitEvent(Entry* e, int event, const QString &fileName = QString::null);
104 104
105 // Memory management - delete when last KDirWatch gets deleted 105 // Memory management - delete when last KDirWatch gets deleted
106 void ref() { m_ref++; } 106 void ref() { m_ref++; }
107 bool deref() { return ( --m_ref == 0 ); } 107 bool deref() { return ( --m_ref == 0 ); }
108 108
109public slots: 109public slots:
110 void slotRescan(); 110 void slotRescan();
111 void famEventReceived(); // for FAM 111 void famEventReceived(); // for FAM
112 void slotActivated(); // for DNOTIFY 112 void slotActivated(); // for DNOTIFY
113 void slotRemoveDelayed(); 113 void slotRemoveDelayed();
114 114
115public: 115public:
116 QTimer *timer; 116 QTimer *timer;
117 EntryMap m_mapEntries; 117 EntryMap m_mapEntries;
118 118
119private: 119private:
120 int freq; 120 int freq;
121 int statEntries; 121 int statEntries;
122 int m_nfsPollInterval, m_PollInterval; 122 int m_nfsPollInterval, m_PollInterval;
123 int m_ref; 123 int m_ref;
124 bool useStat(Entry*); 124 bool useStat(Entry*);
125 125
126 bool delayRemove; 126 bool delayRemove;
127 QPtrList<Entry> removeList; 127 Q3PtrList<Entry> removeList;
128 128
129#ifdef HAVE_FAM 129#ifdef HAVE_FAM
130 QSocketNotifier *sn; 130 QSocketNotifier *sn;
131 FAMConnection fc; 131 FAMConnection fc;
132 bool use_fam; 132 bool use_fam;
133 133
134 void checkFAMEvent(FAMEvent*); 134 void checkFAMEvent(FAMEvent*);
135 bool useFAM(Entry*); 135 bool useFAM(Entry*);
136#endif 136#endif
137 137
138#ifdef HAVE_DNOTIFY 138#ifdef HAVE_DNOTIFY
139 bool supports_dnotify; 139 bool supports_dnotify;
140 bool rescan_all; 140 bool rescan_all;
141 int mPipe[2]; 141 int mPipe[2];
142 QTimer mTimer; 142 QTimer mTimer;
143 QSocketNotifier *mSn; 143 QSocketNotifier *mSn;
144 QIntDict<Entry> fd_Entry; 144 Q3IntDict<Entry> fd_Entry;
145 145
146 static void dnotify_handler(int, siginfo_t *si, void *); 146 static void dnotify_handler(int, siginfo_t *si, void *);
147 static void dnotify_sigio_handler(int, siginfo_t *si, void *); 147 static void dnotify_sigio_handler(int, siginfo_t *si, void *);
148 bool useDNotify(Entry*); 148 bool useDNotify(Entry*);
149#endif 149#endif
150}; 150};
151 151
152#endif // KDIRWATCH_P_H 152#endif // KDIRWATCH_P_H
153 153
diff --git a/microkde/klineedit.h b/microkde/klineedit.h
index 70c72d1..9eb749d 100644
--- a/microkde/klineedit.h
+++ b/microkde/klineedit.h
@@ -1,47 +1,49 @@
1#ifndef MINIKDE_KLINEEDIT_H 1#ifndef MINIKDE_KLINEEDIT_H
2#define MINIKDE_KLINEEDIT_H 2#define MINIKDE_KLINEEDIT_H
3 3
4#include <qlineedit.h> 4#include <qlineedit.h>
5//Added by qt3to4:
6#include <QKeyEvent>
5 7
6#ifndef DESKTOP_VERSION 8#ifndef DESKTOP_VERSION
7#include <qpe/qpeapplication.h> 9#include <qpe/qpeapplication.h>
8#endif 10#endif
9 11
10 12
11class KLineEdit : public QLineEdit 13class KLineEdit : public QLineEdit
12{ 14{
13 15
14 Q_OBJECT 16 Q_OBJECT
15 17
16 public: 18 public:
17 KLineEdit( QWidget *parent=0, const char *name=0 ) : 19 KLineEdit( QWidget *parent=0, const char *name=0 ) :
18 QLineEdit( parent, name ) 20 QLineEdit( parent, name )
19 { 21 {
20#ifndef DESKTOP_VERSION 22#ifndef DESKTOP_VERSION
21 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 23 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
22#endif 24#endif
23 } 25 }
24 void keyPressEvent ( QKeyEvent * e) 26 void keyPressEvent ( QKeyEvent * e)
25 { 27 {
26 switch ( e->key() ) { 28 switch ( e->key() ) {
27 case Qt::Key_Down: 29 case Qt::Key_Down:
28 emit scrollDOWN(); 30 emit scrollDOWN();
29 e->accept(); 31 e->accept();
30 break; 32 break;
31 case Qt::Key_Up: 33 case Qt::Key_Up:
32 emit scrollUP(); 34 emit scrollUP();
33 e->accept(); 35 e->accept();
34 break; 36 break;
35 default: 37 default:
36 QLineEdit::keyPressEvent ( e ); 38 QLineEdit::keyPressEvent ( e );
37 break; 39 break;
38 } 40 }
39 41
40 } 42 }
41 void setTrapReturnKey( bool ) {} 43 void setTrapReturnKey( bool ) {}
42 signals: 44 signals:
43 void scrollUP(); 45 void scrollUP();
44 void scrollDOWN(); 46 void scrollDOWN();
45}; 47};
46 48
47#endif 49#endif
diff --git a/microkde/klineeditdlg.h b/microkde/klineeditdlg.h
index 68e9252..d0004cd 100644
--- a/microkde/klineeditdlg.h
+++ b/microkde/klineeditdlg.h
@@ -1,34 +1,36 @@
1#ifndef MICROKDE_KLINEEDITDLG_H 1#ifndef MICROKDE_KLINEEDITDLG_H
2#define MICROKDE_KLINEEDITDLG_H 2#define MICROKDE_KLINEEDITDLG_H
3 3
4#include "kdialogbase.h" 4#include "kdialogbase.h"
5#include <klineedit.h> 5#include <klineedit.h>
6#include <qlayout.h> 6#include <qlayout.h>
7#include <qlabel.h> 7#include <qlabel.h>
8#include <qdialog.h> 8#include <qdialog.h>
9#include <qpushbutton.h> 9#include <qpushbutton.h>
10//Added by qt3to4:
11#include <Q3VBoxLayout>
10 12
11class KLineEditDlg : public QDialog 13class KLineEditDlg : public QDialog
12{ 14{
13 public: 15 public:
14 KLineEditDlg( const QString & text, const QString & editText, QWidget *parent ) : 16 KLineEditDlg( const QString & text, const QString & editText, QWidget *parent ) :
15 QDialog( parent,"lineedit", true ) { 17 QDialog( parent,"lineedit", true ) {
16 QLabel* lab = new QLabel( text, this ); 18 QLabel* lab = new QLabel( text, this );
17 mEdit = new KLineEdit( this ); 19 mEdit = new KLineEdit( this );
18 QVBoxLayout* vl = new QVBoxLayout( this ); 20 Q3VBoxLayout* vl = new Q3VBoxLayout( this );
19 vl->setSpacing(5); 21 vl->setSpacing(5);
20 vl->setMargin(7); 22 vl->setMargin(7);
21 vl->addWidget( lab ); 23 vl->addWidget( lab );
22 vl->addWidget( mEdit ); 24 vl->addWidget( mEdit );
23 mEdit->setText( editText ); 25 mEdit->setText( editText );
24 QPushButton * p = new QPushButton (" OK ", this ); 26 QPushButton * p = new QPushButton (" OK ", this );
25 vl->addWidget( p ); 27 vl->addWidget( p );
26 connect( p, SIGNAL ( clicked () ), this , SLOT (accept() ) ); 28 connect( p, SIGNAL ( clicked () ), this , SLOT (accept() ) );
27 } 29 }
28 30
29 QString text() { return mEdit->text(); } 31 QString text() { return mEdit->text(); }
30 private: 32 private:
31 KLineEdit* mEdit; 33 KLineEdit* mEdit;
32}; 34};
33 35
34#endif 36#endif
diff --git a/microkde/kresources/configdialog.cpp b/microkde/kresources/configdialog.cpp
index 55253c0..4820faf 100644
--- a/microkde/kresources/configdialog.cpp
+++ b/microkde/kresources/configdialog.cpp
@@ -1,179 +1,182 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <klocale.h> 24#include <klocale.h>
25#include <kglobal.h> 25#include <kglobal.h>
26#include <kmessagebox.h> 26#include <kmessagebox.h>
27 27
28#include <qgroupbox.h> 28#include <q3groupbox.h>
29#include <qlabel.h> 29#include <qlabel.h>
30#include <qlayout.h> 30#include <qlayout.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qvbox.h> 32#include <q3vbox.h>
33 33
34#include <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qscrollview.h> 35#include <q3scrollview.h>
36//Added by qt3to4:
37#include <Q3VBoxLayout>
38#include <Q3Frame>
36 39
37#include <kbuttonbox.h> 40#include <kbuttonbox.h>
38#include <kdialog.h> 41#include <kdialog.h>
39#include <klineedit.h> 42#include <klineedit.h>
40 43
41#include "factory.h" 44#include "factory.h"
42#include "configwidget.h" 45#include "configwidget.h"
43#include "configdialog.h" 46#include "configdialog.h"
44 47
45using namespace KRES; 48using namespace KRES;
46 49
47ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily, 50ConfigDialog::ConfigDialog( QWidget *parent, const QString& resourceFamily,
48 Resource* resource, const char *name ) 51 Resource* resource, const char *name )
49 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ), 52 : KDialogBase( parent, name, true, i18n( "Resource Configuration" ),
50 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false) 53 Ok|Cancel, Ok, true )/*, mConfig( config )*/, mResource( resource ), mPersistentReadOnly(false)
51{ 54{
52 55
53 Factory *factory = Factory::self( resourceFamily ); 56 Factory *factory = Factory::self( resourceFamily );
54 57
55//US resize( 250, 240 ); 58//US resize( 250, 240 );
56 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240)); 59 resize( KMIN(KGlobal::getDesktopWidth(), 250), KMIN(KGlobal::getDesktopHeight(), 240));
57 60
58 QFrame *main; 61 Q3Frame *main;
59 62
60 main = plainPage(); 63 main = plainPage();
61 64
62 QVBoxLayout *mainLayout = new QVBoxLayout( main, 0, spacingHint() ); 65 Q3VBoxLayout *mainLayout = new Q3VBoxLayout( main, 0, spacingHint() );
63 66
64 67
65 QGroupBox *generalGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 68 Q3GroupBox *generalGroupBox = new Q3GroupBox( 2, Qt::Horizontal, main );
66 generalGroupBox->layout()->setSpacing( spacingHint() ); 69 generalGroupBox->layout()->setSpacing( spacingHint() );
67 generalGroupBox->setTitle( i18n( "General Settings" ) ); 70 generalGroupBox->setTitle( i18n( "General Settings" ) );
68 71
69 new QLabel( i18n( "Name:" ), generalGroupBox ); 72 new QLabel( i18n( "Name:" ), generalGroupBox );
70 73
71 mName = new KLineEdit( generalGroupBox ); 74 mName = new KLineEdit( generalGroupBox );
72 75
73 new QLabel("", generalGroupBox ); 76 new QLabel("", generalGroupBox );
74 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox ); 77 mReadOnly = new QCheckBox( i18n( "Read-only" ), generalGroupBox );
75 mReadOnly->setChecked( mResource->readOnly() ); 78 mReadOnly->setChecked( mResource->readOnly() );
76 79
77 new QLabel("", generalGroupBox ); 80 new QLabel("", generalGroupBox );
78 mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox ); 81 mIncludeInSync = new QCheckBox( i18n( "Include in sync" ), generalGroupBox );
79 mIncludeInSync->setChecked( mResource->includeInSync() ); 82 mIncludeInSync->setChecked( mResource->includeInSync() );
80 83
81 mName->setText( mResource->resourceName() ); 84 mName->setText( mResource->resourceName() );
82 85
83 mainLayout->addWidget( generalGroupBox ); 86 mainLayout->addWidget( generalGroupBox );
84 87
85 QGroupBox *resourceGroupBox = new QGroupBox( 2, Qt::Horizontal, main ); 88 Q3GroupBox *resourceGroupBox = new Q3GroupBox( 2, Qt::Horizontal, main );
86 resourceGroupBox->layout()->setSpacing( spacingHint()); 89 resourceGroupBox->layout()->setSpacing( spacingHint());
87 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" ) 90 resourceGroupBox->setTitle( i18n( "%1 Resource Settings" )
88 .arg( factory->typeName( resource->type() ) ) ); 91 .arg( factory->typeName( resource->type() ) ) );
89 mainLayout->addWidget( resourceGroupBox ); 92 mainLayout->addWidget( resourceGroupBox );
90 93
91 mainLayout->addStretch(); 94 mainLayout->addStretch();
92 95
93 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox ); 96 mConfigWidget = factory->configWidget( resource->type(), resourceGroupBox );
94 if ( mConfigWidget ) { 97 if ( mConfigWidget ) {
95 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ), 98 connect( mConfigWidget, SIGNAL( setReadOnly( bool ) ),
96 SLOT( setReadOnly( bool ) ) ); 99 SLOT( setReadOnly( bool ) ) );
97 connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ), 100 connect( mConfigWidget, SIGNAL( setIncludeInSync( bool ) ),
98 SLOT( setIncludeInSync( bool ) ) ); 101 SLOT( setIncludeInSync( bool ) ) );
99 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ), 102 connect( mConfigWidget, SIGNAL( setPersistentReadOnly( bool ) ),
100 SLOT( setPersistentReadOnly( bool ) ) ); 103 SLOT( setPersistentReadOnly( bool ) ) );
101 mConfigWidget->setInEditMode( false ); 104 mConfigWidget->setInEditMode( false );
102 mConfigWidget->loadSettings( mResource ); 105 mConfigWidget->loadSettings( mResource );
103 mConfigWidget->show(); 106 mConfigWidget->show();
104 107
105 } 108 }
106 109
107 110
108 connect( mName, SIGNAL( textChanged(const QString &)), 111 connect( mName, SIGNAL( textChanged(const QString &)),
109 SLOT( slotNameChanged(const QString &))); 112 SLOT( slotNameChanged(const QString &)));
110 113
111 slotNameChanged( mName->text() ); 114 slotNameChanged( mName->text() );
112 115
113//US setMinimumSize( 400, 250 ); 116//US setMinimumSize( 400, 250 );
114 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250)); 117 setMinimumSize( KMIN(KGlobal::getDesktopWidth(), 400), KMIN(KGlobal::getDesktopHeight(), 250));
115 118
116} 119}
117 120
118void ConfigDialog::setInEditMode( bool value ) 121void ConfigDialog::setInEditMode( bool value )
119{ 122{
120 if ( mConfigWidget ) 123 if ( mConfigWidget )
121 mConfigWidget->setInEditMode( value ); 124 mConfigWidget->setInEditMode( value );
122} 125}
123 126
124void ConfigDialog::slotNameChanged( const QString &text) 127void ConfigDialog::slotNameChanged( const QString &text)
125{ 128{
126 enableButtonOK( !text.isEmpty() ); 129 enableButtonOK( !text.isEmpty() );
127} 130}
128 131
129void ConfigDialog::setReadOnly( bool value ) 132void ConfigDialog::setReadOnly( bool value )
130{ 133{
131 if (mPersistentReadOnly == false) 134 if (mPersistentReadOnly == false)
132 mReadOnly->setChecked( value ); 135 mReadOnly->setChecked( value );
133 else 136 else
134 mReadOnly->setChecked( true ); 137 mReadOnly->setChecked( true );
135} 138}
136 139
137void ConfigDialog::setIncludeInSync( bool value ) 140void ConfigDialog::setIncludeInSync( bool value )
138{ 141{
139 if (mPersistentReadOnly == false) 142 if (mPersistentReadOnly == false)
140 mIncludeInSync->setChecked( value ); 143 mIncludeInSync->setChecked( value );
141 else 144 else
142 mIncludeInSync->setChecked( false ); 145 mIncludeInSync->setChecked( false );
143} 146}
144 147
145void ConfigDialog::setPersistentReadOnly( bool value ) 148void ConfigDialog::setPersistentReadOnly( bool value )
146{ 149{
147 mPersistentReadOnly = value; 150 mPersistentReadOnly = value;
148 151
149 if (value == true) { 152 if (value == true) {
150 setReadOnly( true ); 153 setReadOnly( true );
151 setIncludeInSync( false ); 154 setIncludeInSync( false );
152 } 155 }
153 156
154 mReadOnly->setEnabled( !value ); 157 mReadOnly->setEnabled( !value );
155 mIncludeInSync->setEnabled (!value ); 158 mIncludeInSync->setEnabled (!value );
156} 159}
157 160
158 161
159void ConfigDialog::accept() 162void ConfigDialog::accept()
160{ 163{
161 if ( mName->text().isEmpty() ) { 164 if ( mName->text().isEmpty() ) {
162 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) ); 165 KMessageBox::sorry( this, i18n( "Please enter a resource name" ) );
163 return; 166 return;
164 } 167 }
165 168
166 mResource->setResourceName( mName->text() ); 169 mResource->setResourceName( mName->text() );
167 mResource->setReadOnly( mReadOnly->isChecked() ); 170 mResource->setReadOnly( mReadOnly->isChecked() );
168 mResource->setIncludeInSync( mIncludeInSync->isChecked() ); 171 mResource->setIncludeInSync( mIncludeInSync->isChecked() );
169 172
170 if ( mConfigWidget ) { 173 if ( mConfigWidget ) {
171 // First save generic information 174 // First save generic information
172 // Also save setting of specific resource type 175 // Also save setting of specific resource type
173 mConfigWidget->saveSettings( mResource ); 176 mConfigWidget->saveSettings( mResource );
174 } 177 }
175 178
176 KDialog::accept(); 179 KDialog::accept();
177} 180}
178 181
179//US #include "configdialog.moc" 182//US #include "configdialog.moc"
diff --git a/microkde/kresources/configpage.cpp b/microkde/kresources/configpage.cpp
index fc7a42e..1a9d063 100644
--- a/microkde/kresources/configpage.cpp
+++ b/microkde/kresources/configpage.cpp
@@ -1,534 +1,538 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qgroupbox.h> 31#include <q3groupbox.h>
32 32
33#ifdef DESKTOP_VERSION 33#ifdef DESKTOP_VERSION
34#include <qinputdialog.h> 34#include <qinputdialog.h>
35#else 35#else
36#include <qtcompat/qinputdialog.h> 36#include <qtcompat/qinputdialog.h>
37#endif 37#endif
38#include <qlabel.h> 38#include <qlabel.h>
39#include <qlayout.h> 39#include <qlayout.h>
40//Added by qt3to4:
41#include <Q3GridLayout>
42#include <Q3ValueList>
43#include <Q3VBoxLayout>
40#include <kapplication.h> 44#include <kapplication.h>
41#include <kcombobox.h> 45#include <kcombobox.h>
42#include <kdebug.h> 46#include <kdebug.h>
43#include <klocale.h> 47#include <klocale.h>
44#include <kmessagebox.h> 48#include <kmessagebox.h>
45#include <ksimpleconfig.h> 49#include <ksimpleconfig.h>
46#include <kstandarddirs.h> 50#include <kstandarddirs.h>
47#include <kurlrequester.h> 51#include <kurlrequester.h>
48#include <klistview.h> 52#include <klistview.h>
49#include <kbuttonbox.h> 53#include <kbuttonbox.h>
50//US #include <ktrader.h> 54//US #include <ktrader.h>
51 55
52#include "resource.h" 56#include "resource.h"
53#include "configdialog.h" 57#include "configdialog.h"
54 58
55#include "configpage.h" 59#include "configpage.h"
56 60
57//US 61//US
58#include <qpushbutton.h> 62#include <qpushbutton.h>
59#include <qfile.h> 63#include <qfile.h>
60#include <kglobal.h> 64#include <kglobal.h>
61 65
62using namespace KRES; 66using namespace KRES;
63 67
64class ConfigViewItem : public QCheckListItem 68class ConfigViewItem : public Q3CheckListItem
65{ 69{
66 public: 70 public:
67 ConfigViewItem( QListView *parent, Resource* resource ) : 71 ConfigViewItem( Q3ListView *parent, Resource* resource ) :
68 QCheckListItem( parent, resource->resourceName(), CheckBox ), 72 Q3CheckListItem( parent, resource->resourceName(), CheckBox ),
69 mResource( resource ), 73 mResource( resource ),
70 mIsStandard( false ) 74 mIsStandard( false )
71 { 75 {
72 setText( 1, mResource->type() ); 76 setText( 1, mResource->type() );
73 setOn( mResource->isActive() ); 77 setOn( mResource->isActive() );
74 } 78 }
75 79
76 void setStandard( bool value ) 80 void setStandard( bool value )
77 { 81 {
78 setText( 2, ( value ? i18n( "Yes" ) : QString::null ) ); 82 setText( 2, ( value ? i18n( "Yes" ) : QString::null ) );
79 mIsStandard = value; 83 mIsStandard = value;
80 } 84 }
81 85
82 bool standard() const { return mIsStandard; } 86 bool standard() const { return mIsStandard; }
83 bool readOnly() const { return mResource->readOnly(); } 87 bool readOnly() const { return mResource->readOnly(); }
84 88
85 Resource *resource() { return mResource; } 89 Resource *resource() { return mResource; }
86 90
87 private: 91 private:
88 Resource* mResource; 92 Resource* mResource;
89 93
90 bool mIsStandard; 94 bool mIsStandard;
91}; 95};
92 96
93ConfigPage::ConfigPage( QWidget *parent, const char *name ) 97ConfigPage::ConfigPage( QWidget *parent, const char *name )
94 : QWidget( parent, name ), 98 : QWidget( parent, name ),
95 mCurrentManager( 0 ), 99 mCurrentManager( 0 ),
96 mCurrentConfig( 0 ) 100 mCurrentConfig( 0 )
97{ 101{
98 setCaption( i18n( "Resource Configuration" ) ); 102 setCaption( i18n( "Resource Configuration" ) );
99 103
100 QVBoxLayout *mainLayout = new QVBoxLayout( this ); 104 Q3VBoxLayout *mainLayout = new Q3VBoxLayout( this );
101 105
102 QGroupBox *groupBox = new QGroupBox( i18n( "Resources" ), this ); 106 Q3GroupBox *groupBox = new Q3GroupBox( i18n( "Resources" ), this );
103 groupBox->setColumnLayout(0, Qt::Vertical ); 107 groupBox->setColumnLayout(0, Qt::Vertical );
104 groupBox->layout()->setSpacing( 3 ); 108 groupBox->layout()->setSpacing( 3 );
105 groupBox->layout()->setMargin( 5 ); 109 groupBox->layout()->setMargin( 5 );
106 QGridLayout *groupBoxLayout = new QGridLayout( groupBox->layout(), 4, 2 ); 110 Q3GridLayout *groupBoxLayout = new Q3GridLayout( groupBox->layout(), 4, 2 );
107 111
108//US mFamilyCombo = new KComboBox( false, groupBox ); 112//US mFamilyCombo = new KComboBox( false, groupBox );
109 mFamilyCombo = new KComboBox( groupBox ); 113 mFamilyCombo = new KComboBox( groupBox );
110 groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 ); 114 groupBoxLayout->addMultiCellWidget( mFamilyCombo, 0, 0, 0, 1 );
111 115
112 mListView = new KListView( groupBox ); 116 mListView = new KListView( groupBox );
113 mListView->setAllColumnsShowFocus( true ); 117 mListView->setAllColumnsShowFocus( true );
114 mListView->addColumn( i18n( "Name" ) ); 118 mListView->addColumn( i18n( "Name" ) );
115 mListView->addColumn( i18n( "Type" ) ); 119 mListView->addColumn( i18n( "Type" ) );
116 mListView->addColumn( i18n( "Standard" ) ); 120 mListView->addColumn( i18n( "Standard" ) );
117 121
118//US groupBoxLayout->addWidget( mListView, 1, 0 ); 122//US groupBoxLayout->addWidget( mListView, 1, 0 );
119 groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 ); 123 groupBoxLayout->addMultiCellWidget( mListView, 1, 1, 0, 1 );
120 124
121 125
122 mAddButton = new QPushButton( i18n( "&Add..." ), groupBox ); 126 mAddButton = new QPushButton( i18n( "&Add..." ), groupBox );
123 groupBoxLayout->addWidget( mAddButton, 2, 0 ); 127 groupBoxLayout->addWidget( mAddButton, 2, 0 );
124 mRemoveButton = new QPushButton( i18n( "&Remove" ), groupBox ); 128 mRemoveButton = new QPushButton( i18n( "&Remove" ), groupBox );
125 groupBoxLayout->addWidget( mRemoveButton, 2, 1 ); 129 groupBoxLayout->addWidget( mRemoveButton, 2, 1 );
126 mEditButton = new QPushButton( i18n( "&Edit..." ), groupBox ); 130 mEditButton = new QPushButton( i18n( "&Edit..." ), groupBox );
127 groupBoxLayout->addWidget( mEditButton, 3, 0 ); 131 groupBoxLayout->addWidget( mEditButton, 3, 0 );
128 mStandardButton = new QPushButton( i18n( "&Use as Standard" ), groupBox ); 132 mStandardButton = new QPushButton( i18n( "&Use as Standard" ), groupBox );
129 groupBoxLayout->addWidget( mStandardButton, 3, 1 ); 133 groupBoxLayout->addWidget( mStandardButton, 3, 1 );
130 134
131 mRemoveButton->setEnabled( false ); 135 mRemoveButton->setEnabled( false );
132 mEditButton->setEnabled( false ); 136 mEditButton->setEnabled( false );
133 mStandardButton->setEnabled( false ); 137 mStandardButton->setEnabled( false );
134 138
135 139
136 connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) ); 140 connect( mAddButton, SIGNAL( clicked() ), SLOT(slotAdd()) );
137 connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) ); 141 connect( mRemoveButton, SIGNAL( clicked() ), SLOT(slotRemove()) );
138 connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) ); 142 connect( mEditButton, SIGNAL( clicked() ), SLOT(slotEdit()) );
139 connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) ); 143 connect( mStandardButton, SIGNAL( clicked() ), SLOT(slotStandard()) );
140 144
141 145
142 mainLayout->addWidget( groupBox ); 146 mainLayout->addWidget( groupBox );
143 147
144 connect( mFamilyCombo, SIGNAL( activated( int ) ), 148 connect( mFamilyCombo, SIGNAL( activated( int ) ),
145 SLOT( slotFamilyChanged( int ) ) ); 149 SLOT( slotFamilyChanged( int ) ) );
146 connect( mListView, SIGNAL( selectionChanged() ), 150 connect( mListView, SIGNAL( selectionChanged() ),
147 SLOT( slotSelectionChanged() ) ); 151 SLOT( slotSelectionChanged() ) );
148 connect( mListView, SIGNAL( clicked( QListViewItem * ) ), 152 connect( mListView, SIGNAL( clicked( Q3ListViewItem * ) ),
149 SLOT( slotItemClicked( QListViewItem * ) ) ); 153 SLOT( slotItemClicked( Q3ListViewItem * ) ) );
150 154
151 mLastItem = 0; 155 mLastItem = 0;
152 156
153//US mConfig = new KConfig( "kcmkresourcesrc" ); 157//US mConfig = new KConfig( "kcmkresourcesrc" );
154 mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") ); 158 mConfig = new KConfig( locateLocal( "config", "kcmkresourcesrc") );
155 mConfig->setGroup( "General" ); 159 mConfig->setGroup( "General" );
156 160
157 load(); 161 load();
158} 162}
159 163
160ConfigPage::~ConfigPage() 164ConfigPage::~ConfigPage()
161{ 165{
162 QValueList<ResourcePageInfo>::Iterator it; 166 Q3ValueList<ResourcePageInfo>::Iterator it;
163 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) { 167 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) {
164 (*it).mManager->removeListener( this ); 168 (*it).mManager->removeListener( this );
165 delete (*it).mManager; 169 delete (*it).mManager;
166 delete (*it).mConfig; 170 delete (*it).mConfig;
167 } 171 }
168 172
169 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() ); 173 mConfig->writeEntry( "CurrentFamily", mFamilyCombo->currentItem() );
170 delete mConfig; 174 delete mConfig;
171 mConfig = 0; 175 mConfig = 0;
172} 176}
173 177
174void ConfigPage::load() 178void ConfigPage::load()
175{ 179{
176 kdDebug(5650) << "ConfigPage::load()" << endl; 180 kdDebug(5650) << "ConfigPage::load()" << endl;
177 181
178 mListView->clear(); 182 mListView->clear();
179 183
180//US we remove the dynamic pluginloader, and set the one family we need (contact) manually. 184//US we remove the dynamic pluginloader, and set the one family we need (contact) manually.
181 185
182//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" ); 186//US KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin" );
183//US KTrader::OfferList::ConstIterator it; 187//US KTrader::OfferList::ConstIterator it;
184//US for ( it = plugins.begin(); it != plugins.end(); ++it ) { 188//US for ( it = plugins.begin(); it != plugins.end(); ++it ) {
185//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" ); 189//US QVariant tmp = (*it)->property( "X-KDE-ResourceFamily" );
186//US QString family = tmp.toString(); 190//US QString family = tmp.toString();
187 QStringList families; 191 QStringList families;
188 families << "contact"; 192 families << "contact";
189 193
190 194
191 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) 195 for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it )
192 { 196 {
193 QString family = (*it); 197 QString family = (*it);
194 if ( !family.isEmpty() ) { 198 if ( !family.isEmpty() ) {
195 if ( !mFamilyMap.contains( family ) ) { 199 if ( !mFamilyMap.contains( family ) ) {
196 mCurrentManager = new Manager<Resource>( family ); 200 mCurrentManager = new Manager<Resource>( family );
197 if ( mCurrentManager ) { 201 if ( mCurrentManager ) {
198 mFamilyMap.append( family ); 202 mFamilyMap.append( family );
199 mCurrentManager->addListener( this ); 203 mCurrentManager->addListener( this );
200 204
201 ResourcePageInfo info; 205 ResourcePageInfo info;
202 info.mManager = mCurrentManager; 206 info.mManager = mCurrentManager;
203 QString configDir = KGlobal::dirs()->saveLocation( "config" ); 207 QString configDir = KGlobal::dirs()->saveLocation( "config" );
204 //QString configDir = KStandardDirs::appDir() + "/config"; 208 //QString configDir = KStandardDirs::appDir() + "/config";
205 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) { 209 if ( family == "contact" && QFile::exists( configDir + "/kabcrc" ) ) {
206 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) ); 210 info.mConfig = new KConfig( locateLocal( "config", "kabcrc" ) );
207 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) { 211 } else if ( family == "calendar" && QFile::exists( configDir + "/kcalrc" ) ) {
208 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) ); 212 info.mConfig = new KConfig( locateLocal( "config", "kcalrc" ) );
209 } else { 213 } else {
210 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) ); 214 QString configFile = locateLocal( "config", QString( "kresources/%1/stdrc" ).arg( family ) );
211 info.mConfig = new KConfig( configFile ); 215 info.mConfig = new KConfig( configFile );
212 } 216 }
213 info.mManager->readConfig( info.mConfig ); 217 info.mManager->readConfig( info.mConfig );
214 218
215 mInfoMap.append( info ); 219 mInfoMap.append( info );
216 } 220 }
217 } 221 }
218 } 222 }
219 } 223 }
220 mCurrentManager = 0; 224 mCurrentManager = 0;
221 225
222 mFamilyCombo->insertStringList( mFamilyMap ); 226 mFamilyCombo->insertStringList( mFamilyMap );
223 227
224 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 ); 228 int currentFamily = mConfig->readNumEntry( "CurrentFamily", 0 );
225 mFamilyCombo->setCurrentItem( currentFamily ); 229 mFamilyCombo->setCurrentItem( currentFamily );
226 slotFamilyChanged( currentFamily ); 230 slotFamilyChanged( currentFamily );
227} 231}
228 232
229void ConfigPage::save() 233void ConfigPage::save()
230{ 234{
231 saveResourceSettings(); 235 saveResourceSettings();
232 236
233 QValueList<ResourcePageInfo>::Iterator it; 237 Q3ValueList<ResourcePageInfo>::Iterator it;
234 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it ) 238 for ( it = mInfoMap.begin(); it != mInfoMap.end(); ++it )
235 (*it).mManager->writeConfig( (*it).mConfig ); 239 (*it).mManager->writeConfig( (*it).mConfig );
236 240
237 emit changed( false ); 241 emit changed( false );
238} 242}
239 243
240void ConfigPage::defaults() 244void ConfigPage::defaults()
241{ 245{
242} 246}
243 247
244void ConfigPage::slotFamilyChanged( int pos ) 248void ConfigPage::slotFamilyChanged( int pos )
245{ 249{
246 if ( pos < 0 || pos >= (int)mFamilyMap.count() ) 250 if ( pos < 0 || pos >= (int)mFamilyMap.count() )
247 return; 251 return;
248 252
249 saveResourceSettings(); 253 saveResourceSettings();
250 254
251 mFamily = mFamilyMap[ pos ]; 255 mFamily = mFamilyMap[ pos ];
252 256
253//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1()); 257//US qDebug("ConfigPage::slotFamilyChanged 4 family=%s", mFamily.latin1());
254 258
255 mCurrentManager = mInfoMap[ pos ].mManager; 259 mCurrentManager = mInfoMap[ pos ].mManager;
256 mCurrentConfig = mInfoMap[ pos ].mConfig; 260 mCurrentConfig = mInfoMap[ pos ].mConfig;
257 261
258 if ( !mCurrentManager ) 262 if ( !mCurrentManager )
259 kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl; 263 kdDebug(5650) << "ERROR: cannot create ResourceManager<Resource>( mFamily )" << endl;
260 264
261 mListView->clear(); 265 mListView->clear();
262 266
263 if ( mCurrentManager->isEmpty() ) { 267 if ( mCurrentManager->isEmpty() ) {
264//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager ); 268//US qDebug("ConfigPage::slotFamilyChanged 4.1 mCurrentManager=%ul", mCurrentManager );
265 269
266 defaults(); 270 defaults();
267 } 271 }
268 272
269 Resource *standardResource = mCurrentManager->standardResource(); 273 Resource *standardResource = mCurrentManager->standardResource();
270 274
271//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1()); 275//US qDebug("ConfigPage::slotFamilyChanged 4.4 resourcename=%s", standardResource->resourceName().latin1());
272 276
273 277
274 Manager<Resource>::Iterator it; 278 Manager<Resource>::Iterator it;
275 for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) { 279 for ( it = mCurrentManager->begin(); it != mCurrentManager->end(); ++it ) {
276 ConfigViewItem *item = new ConfigViewItem( mListView, *it ); 280 ConfigViewItem *item = new ConfigViewItem( mListView, *it );
277 if ( *it == standardResource ) 281 if ( *it == standardResource )
278 item->setStandard( true ); 282 item->setStandard( true );
279 } 283 }
280 284
281 if ( mListView->childCount() == 0 ) { 285 if ( mListView->childCount() == 0 ) {
282//US qDebug("ConfigPage::slotFamilyChanged 4.5 "); 286//US qDebug("ConfigPage::slotFamilyChanged 4.5 ");
283 287
284 defaults(); 288 defaults();
285 emit changed( true ); 289 emit changed( true );
286 mCurrentManager->writeConfig( mCurrentConfig ); 290 mCurrentManager->writeConfig( mCurrentConfig );
287 } else { 291 } else {
288//US qDebug("ConfigPage::slotFamilyChanged 4.6 "); 292//US qDebug("ConfigPage::slotFamilyChanged 4.6 ");
289 293
290 if ( !standardResource ) { 294 if ( !standardResource ) {
291 KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) ); 295 KMessageBox::sorry( this, i18n( "There is no standard resource!<br> Please select one." ) );
292 296
293//US qDebug("ConfigPage::slotFamilyChanged 4.7" ); 297//US qDebug("ConfigPage::slotFamilyChanged 4.7" );
294 298
295 } 299 }
296 300
297 emit changed( false ); 301 emit changed( false );
298 } 302 }
299} 303}
300 304
301void ConfigPage::slotAdd() 305void ConfigPage::slotAdd()
302{ 306{
303 if ( !mCurrentManager ) 307 if ( !mCurrentManager )
304 return; 308 return;
305 309
306 QStringList types = mCurrentManager->resourceTypeNames(); 310 QStringList types = mCurrentManager->resourceTypeNames();
307 QStringList descs = mCurrentManager->resourceTypeDescriptions(); 311 QStringList descs = mCurrentManager->resourceTypeDescriptions();
308 bool ok = false; 312 bool ok = false;
309 313
310 QString desc; 314 QString desc;
311 315
312 desc = QInputDialog::getItem( i18n( "Resource Configuration" ), 316 desc = QInputDialog::getItem( i18n( "Resource Configuration" ),
313 i18n( "Select type of the new resource:" ), descs, 0, 317 i18n( "Select type of the new resource:" ), descs, 0,
314 false, &ok, this ); 318 false, &ok, this );
315 319
316 if ( !ok ) 320 if ( !ok )
317 return; 321 return;
318 322
319 QString type = types[ descs.findIndex( desc ) ]; 323 QString type = types[ descs.findIndex( desc ) ];
320 324
321 // Create new resource 325 // Create new resource
322 Resource *resource = mCurrentManager->createResource( type ); 326 Resource *resource = mCurrentManager->createResource( type );
323 if ( !resource ) { 327 if ( !resource ) {
324 KMessageBox::error( this, i18n("Unable to create resource of type '%1'.") 328 KMessageBox::error( this, i18n("Unable to create resource of type '%1'.")
325 .arg( type ) ); 329 .arg( type ) );
326 return; 330 return;
327 } 331 }
328 332
329 resource->setResourceName( type + "-resource" ); 333 resource->setResourceName( type + "-resource" );
330 334
331 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); 335 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
332 336
333 if ( dlg.exec() ) { 337 if ( dlg.exec() ) {
334 mCurrentManager->add( resource ); 338 mCurrentManager->add( resource );
335 339
336 ConfigViewItem *item = new ConfigViewItem( mListView, resource ); 340 ConfigViewItem *item = new ConfigViewItem( mListView, resource );
337 341
338 mLastItem = item; 342 mLastItem = item;
339 343
340 // if there are only read-only resources we'll set this resource 344 // if there are only read-only resources we'll set this resource
341 // as standard resource 345 // as standard resource
342 if ( !resource->readOnly() ) { 346 if ( !resource->readOnly() ) {
343 bool onlyReadOnly = true; 347 bool onlyReadOnly = true;
344 QListViewItem *it = mListView->firstChild(); 348 Q3ListViewItem *it = mListView->firstChild();
345 while ( it != 0 ) { 349 while ( it != 0 ) {
346 ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it ); 350 ConfigViewItem *confIt = static_cast<ConfigViewItem*>( it );
347 if ( !confIt->readOnly() && confIt != item ) 351 if ( !confIt->readOnly() && confIt != item )
348 onlyReadOnly = false; 352 onlyReadOnly = false;
349 353
350 it = it->itemBelow(); 354 it = it->itemBelow();
351 } 355 }
352 356
353 if ( onlyReadOnly ) 357 if ( onlyReadOnly )
354 item->setStandard( true ); 358 item->setStandard( true );
355 } 359 }
356 360
357 emit changed( true ); 361 emit changed( true );
358 } else { 362 } else {
359 delete resource; 363 delete resource;
360 resource = 0; 364 resource = 0;
361 } 365 }
362} 366}
363 367
364void ConfigPage::slotRemove() 368void ConfigPage::slotRemove()
365{ 369{
366 if ( !mCurrentManager ) 370 if ( !mCurrentManager )
367 return; 371 return;
368 372
369 QListViewItem *item = mListView->currentItem(); 373 Q3ListViewItem *item = mListView->currentItem();
370 ConfigViewItem *confItem = static_cast<ConfigViewItem*>( item ); 374 ConfigViewItem *confItem = static_cast<ConfigViewItem*>( item );
371 375
372 if ( !confItem ) 376 if ( !confItem )
373 return; 377 return;
374 378
375 if ( confItem->standard() ) { 379 if ( confItem->standard() ) {
376 KMessageBox::sorry( this, i18n( "You cannot remove your standard resource!\n Please select a new standard resource first." ) ); 380 KMessageBox::sorry( this, i18n( "You cannot remove your standard resource!\n Please select a new standard resource first." ) );
377 return; 381 return;
378 } 382 }
379 383
380 mCurrentManager->remove( confItem->resource() ); 384 mCurrentManager->remove( confItem->resource() );
381 385
382 if ( item == mLastItem ) 386 if ( item == mLastItem )
383 mLastItem = 0; 387 mLastItem = 0;
384 388
385 mListView->takeItem( item ); 389 mListView->takeItem( item );
386 delete item; 390 delete item;
387 391
388 emit changed( true ); 392 emit changed( true );
389} 393}
390 394
391void ConfigPage::slotEdit() 395void ConfigPage::slotEdit()
392{ 396{
393 if ( !mCurrentManager ) 397 if ( !mCurrentManager )
394 return; 398 return;
395 399
396 QListViewItem *item = mListView->currentItem(); 400 Q3ListViewItem *item = mListView->currentItem();
397 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item ); 401 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item );
398 if ( !configItem ) 402 if ( !configItem )
399 return; 403 return;
400 404
401 Resource *resource = configItem->resource(); 405 Resource *resource = configItem->resource();
402 406
403 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" ); 407 ConfigDialog dlg( this, mFamily, resource, "KRES::ConfigDialog" );
404 408
405 if ( dlg.exec() ) { 409 if ( dlg.exec() ) {
406 configItem->setText( 0, resource->resourceName() ); 410 configItem->setText( 0, resource->resourceName() );
407 configItem->setText( 1, resource->type() ); 411 configItem->setText( 1, resource->type() );
408 412
409 if ( configItem->standard() && configItem->readOnly() ) { 413 if ( configItem->standard() && configItem->readOnly() ) {
410 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) ); 414 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br> resource as standard!" ) );
411 configItem->setStandard( false ); 415 configItem->setStandard( false );
412 } 416 }
413 417
414 mCurrentManager->resourceChanged( resource ); 418 mCurrentManager->resourceChanged( resource );
415 emit changed( true ); 419 emit changed( true );
416 } 420 }
417} 421}
418 422
419void ConfigPage::slotStandard() 423void ConfigPage::slotStandard()
420{ 424{
421 if ( !mCurrentManager ) 425 if ( !mCurrentManager )
422 return; 426 return;
423 427
424 ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() ); 428 ConfigViewItem *item = static_cast<ConfigViewItem*>( mListView->currentItem() );
425 if ( !item ) 429 if ( !item )
426 return; 430 return;
427 431
428 if ( item->readOnly() ) { 432 if ( item->readOnly() ) {
429 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br>resource as standard!" ) ); 433 KMessageBox::sorry( this, i18n( "You cannot use a read-only<br>resource as standard!" ) );
430 return; 434 return;
431 } 435 }
432 436
433 if ( !item->isOn() ) { 437 if ( !item->isOn() ) {
434 KMessageBox::sorry( this, i18n( "You cannot use an inactive<br>resource as standard!" ) ); 438 KMessageBox::sorry( this, i18n( "You cannot use an inactive<br>resource as standard!" ) );
435 return; 439 return;
436 } 440 }
437 441
438 QListViewItem *it = mListView->firstChild(); 442 Q3ListViewItem *it = mListView->firstChild();
439 while ( it != 0 ) { 443 while ( it != 0 ) {
440 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( it ); 444 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( it );
441 if ( configItem->standard() ) 445 if ( configItem->standard() )
442 configItem->setStandard( false ); 446 configItem->setStandard( false );
443 it = it->itemBelow(); 447 it = it->itemBelow();
444 } 448 }
445 449
446 item->setStandard( true ); 450 item->setStandard( true );
447 mCurrentManager->setStandardResource( item->resource() ); 451 mCurrentManager->setStandardResource( item->resource() );
448 emit changed( true ); 452 emit changed( true );
449 453
450} 454}
451 455
452void ConfigPage::slotSelectionChanged() 456void ConfigPage::slotSelectionChanged()
453{ 457{
454 bool state = ( mListView->currentItem() != 0 ); 458 bool state = ( mListView->currentItem() != 0 );
455 459
456 mRemoveButton->setEnabled( state ); 460 mRemoveButton->setEnabled( state );
457 mEditButton->setEnabled( state ); 461 mEditButton->setEnabled( state );
458 mStandardButton->setEnabled( state ); 462 mStandardButton->setEnabled( state );
459} 463}
460 464
461void ConfigPage::resourceAdded( Resource* resource ) 465void ConfigPage::resourceAdded( Resource* resource )
462{ 466{
463 qDebug("ConfigPage::resourceAdded : %s", resource->resourceName().latin1()); 467 qDebug("ConfigPage::resourceAdded : %s", resource->resourceName().latin1());
464 ConfigViewItem *item = new ConfigViewItem( mListView, resource ); 468 ConfigViewItem *item = new ConfigViewItem( mListView, resource );
465 469
466 // FIXME: this sucks. This should be in the config file, 470 // FIXME: this sucks. This should be in the config file,
467 // or application-dependent, in which case it's always Off 471 // or application-dependent, in which case it's always Off
468 item->setOn( false ); 472 item->setOn( false );
469 473
470 mLastItem = item; 474 mLastItem = item;
471 475
472 emit changed( true ); 476 emit changed( true );
473} 477}
474 478
475void ConfigPage::resourceModified( Resource* resource ) 479void ConfigPage::resourceModified( Resource* resource )
476{ 480{
477 qDebug("ConfigPage::resourceModified : %s", resource->resourceName().latin1()); 481 qDebug("ConfigPage::resourceModified : %s", resource->resourceName().latin1());
478} 482}
479 483
480void ConfigPage::resourceDeleted( Resource* resource ) 484void ConfigPage::resourceDeleted( Resource* resource )
481{ 485{
482 qDebug("ConfigPage::resourceDeleted : %s", resource->resourceName().latin1()); 486 qDebug("ConfigPage::resourceDeleted : %s", resource->resourceName().latin1());
483} 487}
484 488
485void ConfigPage::slotItemClicked( QListViewItem *item ) 489void ConfigPage::slotItemClicked( Q3ListViewItem *item )
486{ 490{
487 ConfigViewItem *configItem = static_cast<ConfigViewItem *>( item ); 491 ConfigViewItem *configItem = static_cast<ConfigViewItem *>( item );
488 if ( !configItem ) return; 492 if ( !configItem ) return;
489 493
490 if ( configItem->standard() && !configItem->isOn() ) { 494 if ( configItem->standard() && !configItem->isOn() ) {
491 KMessageBox::sorry( this, i18n( "You cannot deactivate the<br>standard resource. Choose<br>another standard resource first." ) ); 495 KMessageBox::sorry( this, i18n( "You cannot deactivate the<br>standard resource. Choose<br>another standard resource first." ) );
492 configItem->setOn( true ); 496 configItem->setOn( true );
493 return; 497 return;
494 } 498 }
495 499
496 if ( configItem->isOn() != configItem->resource()->isActive() ) { 500 if ( configItem->isOn() != configItem->resource()->isActive() ) {
497 emit changed( true ); 501 emit changed( true );
498 } 502 }
499} 503}
500 504
501void ConfigPage::saveResourceSettings() 505void ConfigPage::saveResourceSettings()
502{ 506{
503 //qDebug("ConfigPage::saveResourceSettings() begin"); 507 //qDebug("ConfigPage::saveResourceSettings() begin");
504 508
505 if ( mCurrentManager ) { 509 if ( mCurrentManager ) {
506 510
507 QListViewItem *item = mListView->firstChild(); 511 Q3ListViewItem *item = mListView->firstChild();
508 while ( item ) { 512 while ( item ) {
509 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item ); 513 ConfigViewItem *configItem = static_cast<ConfigViewItem*>( item );
510 514
511 // check if standard resource 515 // check if standard resource
512 if ( configItem->standard() && !configItem->readOnly() && 516 if ( configItem->standard() && !configItem->readOnly() &&
513 configItem->isOn() ) { 517 configItem->isOn() ) {
514 518
515 mCurrentManager->setStandardResource( configItem->resource() ); 519 mCurrentManager->setStandardResource( configItem->resource() );
516 } 520 }
517 521
518 // check if active or passive resource 522 // check if active or passive resource
519 configItem->resource()->setActive( configItem->isOn() ); 523 configItem->resource()->setActive( configItem->isOn() );
520 524
521 item = item->nextSibling(); 525 item = item->nextSibling();
522 } 526 }
523 mCurrentManager->writeConfig( mCurrentConfig ); 527 mCurrentManager->writeConfig( mCurrentConfig );
524 528
525 if ( !mCurrentManager->standardResource() ) 529 if ( !mCurrentManager->standardResource() )
526 KMessageBox::sorry( this, i18n( "There is no valid standard resource!<br>Please select one which is neither read-only nor inactive." ) ); 530 KMessageBox::sorry( this, i18n( "There is no valid standard resource!<br>Please select one which is neither read-only nor inactive." ) );
527 } 531 }
528 532
529 //qDebug("ConfigPage::saveResourceSettings() end"); 533 //qDebug("ConfigPage::saveResourceSettings() end");
530 534
531} 535}
532 536
533//US #include "configpage.moc" 537//US #include "configpage.moc"
534 538
diff --git a/microkde/kresources/configpage.h b/microkde/kresources/configpage.h
index be9239e..dc1aa50 100644
--- a/microkde/kresources/configpage.h
+++ b/microkde/kresources/configpage.h
@@ -1,104 +1,106 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 3 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 4 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22 22
23#ifndef KRESOURCES_CONFIGPAGE_H 23#ifndef KRESOURCES_CONFIGPAGE_H
24#define KRESOURCES_CONFIGPAGE_H 24#define KRESOURCES_CONFIGPAGE_H
25 25
26#include <qstringlist.h> 26#include <qstringlist.h>
27#include <qwidget.h> 27#include <qwidget.h>
28//Added by qt3to4:
29#include <Q3ValueList>
28 30
29#include "manager.h" 31#include "manager.h"
30 32
31class KComboBox; 33class KComboBox;
32class KListView; 34class KListView;
33 35
34class QListViewItem; 36class Q3ListViewItem;
35class QPushButton; 37class QPushButton;
36 38
37 39
38namespace KRES { 40namespace KRES {
39 41
40class ResourcePageInfo 42class ResourcePageInfo
41{ 43{
42 public: 44 public:
43 Manager<Resource> *mManager; 45 Manager<Resource> *mManager;
44 KConfig *mConfig; 46 KConfig *mConfig;
45}; 47};
46 48
47class Resource; 49class Resource;
48 50
49class ConfigPage : public QWidget, public ManagerListener<Resource> 51class ConfigPage : public QWidget, public ManagerListener<Resource>
50{ 52{
51 Q_OBJECT 53 Q_OBJECT
52 54
53 public: 55 public:
54 ConfigPage( QWidget *parent = 0, const char *name = 0 ); 56 ConfigPage( QWidget *parent = 0, const char *name = 0 );
55 virtual ~ConfigPage(); 57 virtual ~ConfigPage();
56 58
57 void load(); 59 void load();
58 void save(); 60 void save();
59 virtual void defaults(); 61 virtual void defaults();
60 62
61 public slots: 63 public slots:
62 void slotFamilyChanged( int ); 64 void slotFamilyChanged( int );
63 void slotAdd(); 65 void slotAdd();
64 void slotRemove(); 66 void slotRemove();
65 void slotEdit(); 67 void slotEdit();
66 void slotStandard(); 68 void slotStandard();
67 void slotSelectionChanged(); 69 void slotSelectionChanged();
68 70
69 // From ManagerListener<Resource> 71 // From ManagerListener<Resource>
70 public: 72 public:
71 virtual void resourceAdded( Resource* resource ); 73 virtual void resourceAdded( Resource* resource );
72 virtual void resourceModified( Resource* resource ); 74 virtual void resourceModified( Resource* resource );
73 virtual void resourceDeleted( Resource* resource ); 75 virtual void resourceDeleted( Resource* resource );
74 76
75 protected slots: 77 protected slots:
76 void slotItemClicked( QListViewItem * ); 78 void slotItemClicked( Q3ListViewItem * );
77 79
78 signals: 80 signals:
79 void changed( bool ); 81 void changed( bool );
80 82
81 private: 83 private:
82 void saveResourceSettings(); 84 void saveResourceSettings();
83 85
84 Manager<Resource>* mCurrentManager; 86 Manager<Resource>* mCurrentManager;
85 KConfig* mCurrentConfig; 87 KConfig* mCurrentConfig;
86 KConfig* mConfig; 88 KConfig* mConfig;
87 QString mFamily; 89 QString mFamily;
88 QStringList mFamilyMap; 90 QStringList mFamilyMap;
89 QValueList<ResourcePageInfo> mInfoMap; 91 Q3ValueList<ResourcePageInfo> mInfoMap;
90 92
91 KComboBox* mFamilyCombo; 93 KComboBox* mFamilyCombo;
92 KListView* mListView; 94 KListView* mListView;
93 QPushButton* mAddButton; 95 QPushButton* mAddButton;
94 QPushButton* mRemoveButton; 96 QPushButton* mRemoveButton;
95 QPushButton* mEditButton; 97 QPushButton* mEditButton;
96 QPushButton* mStandardButton; 98 QPushButton* mStandardButton;
97 99
98 QListViewItem* mLastItem; 100 Q3ListViewItem* mLastItem;
99 static const QString syncfamily; 101 static const QString syncfamily;
100}; 102};
101 103
102} 104}
103 105
104#endif 106#endif
diff --git a/microkde/kresources/factory.cpp b/microkde/kresources/factory.cpp
index 86b22b2..4f286d1 100644
--- a/microkde/kresources/factory.cpp
+++ b/microkde/kresources/factory.cpp
@@ -1,295 +1,295 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#include <kdebug.h> 24#include <kdebug.h>
25#include <klocale.h> 25#include <klocale.h>
26#include <ksimpleconfig.h> 26#include <ksimpleconfig.h>
27#include <kstandarddirs.h> 27#include <kstandarddirs.h>
28#include <kstaticdeleter.h> 28#include <kstaticdeleter.h>
29//#ifndef DESKTOP_VERSION 29//#ifndef DESKTOP_VERSION
30#include <klibloader.h> 30#include <klibloader.h>
31//#endif 31//#endif
32#include <qfile.h> 32#include <qfile.h>
33 33
34#include "resource.h" 34#include "resource.h"
35#include "factory.h" 35#include "factory.h"
36 36
37#ifdef STATIC_RESOURCES 37#ifdef STATIC_RESOURCES
38#include <file/resourcefile.h> 38#include <file/resourcefile.h>
39#include <dir/resourcedir.h> 39#include <dir/resourcedir.h>
40#include <qtopia/resourceqtopia.h> 40#include <qtopia/resourceqtopia.h>
41#endif 41#endif
42using namespace KRES; 42using namespace KRES;
43 43
44QDict<Factory> *Factory::mSelves = 0; 44Q3Dict<Factory> *Factory::mSelves = 0;
45static KStaticDeleter< QDict<Factory> > staticDeleter; 45static KStaticDeleter< Q3Dict<Factory> > staticDeleter;
46 46
47Factory *Factory::self( const QString& resourceFamily) 47Factory *Factory::self( const QString& resourceFamily)
48{ 48{
49 49
50 50
51 Factory *factory = 0; 51 Factory *factory = 0;
52 if ( !mSelves ) 52 if ( !mSelves )
53 { 53 {
54 mSelves = staticDeleter.setObject( new QDict<Factory> ); 54 mSelves = staticDeleter.setObject( new Q3Dict<Factory> );
55 } 55 }
56 56
57 factory = mSelves->find( resourceFamily ); 57 factory = mSelves->find( resourceFamily );
58 58
59 if ( !factory ) { 59 if ( !factory ) {
60 factory = new Factory( resourceFamily); 60 factory = new Factory( resourceFamily);
61 mSelves->insert( resourceFamily, factory ); 61 mSelves->insert( resourceFamily, factory );
62 } 62 }
63 63
64 return factory; 64 return factory;
65} 65}
66 66
67Factory::Factory( const QString& resourceFamily) : 67Factory::Factory( const QString& resourceFamily) :
68 mResourceFamily( resourceFamily ) 68 mResourceFamily( resourceFamily )
69{ 69{
70//US so far we have three types available for resourceFamily "contact" 70//US so far we have three types available for resourceFamily "contact"
71// and that are "file", "dir", "ldap" 71// and that are "file", "dir", "ldap"
72/*US 72/*US
73 73
74 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" ) 74 KTrader::OfferList plugins = KTrader::self()->query( "KResources/Plugin", QString( "[X-KDE-ResourceFamily] == '%1'" )
75 .arg( resourceFamily ) ); 75 .arg( resourceFamily ) );
76 KTrader::OfferList::ConstIterator it; 76 KTrader::OfferList::ConstIterator it;
77 for ( it = plugins.begin(); it != plugins.end(); ++it ) { 77 for ( it = plugins.begin(); it != plugins.end(); ++it ) {
78 QVariant type = (*it)->property( "X-KDE-ResourceType" ); 78 QVariant type = (*it)->property( "X-KDE-ResourceType" );
79 if ( !type.toString().isEmpty() ) 79 if ( !type.toString().isEmpty() )
80 mTypeMap.insert( type.toString(), *it ); 80 mTypeMap.insert( type.toString(), *it );
81 } 81 }
82*/ 82*/
83 83
84//US new 84//US new
85 PluginInfo* info = new PluginInfo; 85 PluginInfo* info = new PluginInfo;
86 info->library = "microkabc_file"; 86 info->library = "microkabc_file";
87 info->nameLabel = i18n( "file" ); 87 info->nameLabel = i18n( "file" );
88 info->descriptionLabel = i18n( "One file" ); 88 info->descriptionLabel = i18n( "One file" );
89 mTypeMap.insert( "file", info ); 89 mTypeMap.insert( "file", info );
90 90
91 info = new PluginInfo; 91 info = new PluginInfo;
92 info->library = "microkabc_dir"; 92 info->library = "microkabc_dir";
93 info->nameLabel = i18n( "dir" ); 93 info->nameLabel = i18n( "dir" );
94 info->descriptionLabel = i18n( "A directory with many files" ); 94 info->descriptionLabel = i18n( "A directory with many files" );
95 mTypeMap.insert( "dir", info ); 95 mTypeMap.insert( "dir", info );
96 96
97 info = new PluginInfo; 97 info = new PluginInfo;
98 info->library = "microkabc_ldap"; 98 info->library = "microkabc_ldap";
99 info->nameLabel = i18n( "ldap" ); 99 info->nameLabel = i18n( "ldap" );
100 info->descriptionLabel = i18n( "Connect to a directory server" ); 100 info->descriptionLabel = i18n( "Connect to a directory server" );
101 mTypeMap.insert( "ldap", info ); 101 mTypeMap.insert( "ldap", info );
102 102
103 //US add opie plugin only, if the library exists. 103 //US add opie plugin only, if the library exists.
104 /*US 104 /*US
105 QString libname = "microkabc_opie"; 105 QString libname = "microkabc_opie";
106 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 106 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
107 if ( !path.isEmpty() ) 107 if ( !path.isEmpty() )
108 { 108 {
109 info = new PluginInfo; 109 info = new PluginInfo;
110 info->library = libname; 110 info->library = libname;
111 info->nameLabel = i18n( "opie" ); 111 info->nameLabel = i18n( "opie" );
112 info->descriptionLabel = i18n( "Opie PIM Addressbook." ); 112 info->descriptionLabel = i18n( "Opie PIM Addressbook." );
113 mTypeMap.insert( "opie", info ); 113 mTypeMap.insert( "opie", info );
114 } 114 }
115 */ 115 */
116 //US add qtopia plugin only, if the library exists. 116 //US add qtopia plugin only, if the library exists.
117 QString libname = "microkabc_qtopia"; 117 QString libname = "microkabc_qtopia";
118 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 118 QString path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
119 if ( !path.isEmpty() ) 119 if ( !path.isEmpty() )
120 { 120 {
121 info = new PluginInfo; 121 info = new PluginInfo;
122 info->library = libname; 122 info->library = libname;
123 info->nameLabel = i18n( "qtopia" ); 123 info->nameLabel = i18n( "qtopia" );
124 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." ); 124 info->descriptionLabel = i18n( "Qtopia PIM Addressbook." );
125 mTypeMap.insert( "qtopia", info ); 125 mTypeMap.insert( "qtopia", info );
126 } 126 }
127 127
128 //US add sharp plugin only, if the library exists. 128 //US add sharp plugin only, if the library exists.
129 libname = "microkabc_sharpdtm"; 129 libname = "microkabc_sharpdtm";
130 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 130 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
131 if ( !path.isEmpty() ) 131 if ( !path.isEmpty() )
132 { 132 {
133 info = new PluginInfo; 133 info = new PluginInfo;
134 info->library = libname; 134 info->library = libname;
135 info->nameLabel = i18n( "sharp" ); 135 info->nameLabel = i18n( "sharp" );
136 info->descriptionLabel = i18n( "Sharp DTM Addressbook." ); 136 info->descriptionLabel = i18n( "Sharp DTM Addressbook." );
137 mTypeMap.insert( "sharp", info ); 137 mTypeMap.insert( "sharp", info );
138 } 138 }
139 139
140 140
141 //LR add ol plugin only, if the library exists. 141 //LR add ol plugin only, if the library exists.
142 libname = "microkabc_olaccess"; 142 libname = "microkabc_olaccess";
143 path = KLibLoader::findLibrary( QFile::encodeName( libname ) ); 143 path = KLibLoader::findLibrary( QFile::encodeName( libname ) );
144 if ( !path.isEmpty() ) 144 if ( !path.isEmpty() )
145 { 145 {
146 info = new PluginInfo; 146 info = new PluginInfo;
147 info->library = libname; 147 info->library = libname;
148 info->nameLabel = i18n( "olaccess" ); 148 info->nameLabel = i18n( "olaccess" );
149 info->descriptionLabel = i18n( "Outlook Addressbook." ); 149 info->descriptionLabel = i18n( "Outlook Addressbook." );
150 mTypeMap.insert( "olaccess", info ); 150 mTypeMap.insert( "olaccess", info );
151 } 151 }
152 152
153 153
154} 154}
155 155
156Factory::~Factory() 156Factory::~Factory()
157{ 157{
158} 158}
159 159
160QStringList Factory::typeNames() const 160QStringList Factory::typeNames() const
161{ 161{
162//US method QMap::keys() not available yet. SO collect the data manually 162//US method QMap::keys() not available yet. SO collect the data manually
163//US return mTypeMap.keys(); 163//US return mTypeMap.keys();
164 164
165 QStringList result; 165 QStringList result;
166 166
167 QMap<QString, PluginInfo*>::ConstIterator it; 167 QMap<QString, PluginInfo*>::ConstIterator it;
168 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) { 168 for( it = mTypeMap.begin(); it != mTypeMap.end(); ++it ) {
169 result << it.key().latin1(); 169 result << it.key().latin1();
170// qDebug("Factory::typeNames() : %s ", it.key().latin1()); 170// qDebug("Factory::typeNames() : %s ", it.key().latin1());
171 171
172 } 172 }
173 return result; 173 return result;
174} 174}
175 175
176ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent ) 176ConfigWidget *Factory::configWidget( const QString& type, QWidget *parent )
177{ 177{
178 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 178 if ( type.isEmpty() || !mTypeMap.contains( type ) )
179 return 0; 179 return 0;
180 180
181//US KService::Ptr ptr = mTypeMap[ type ]; 181//US KService::Ptr ptr = mTypeMap[ type ];
182//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 182//US KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
183 PluginInfo* pi = mTypeMap[ type ]; 183 PluginInfo* pi = mTypeMap[ type ];
184 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 184 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
185 if ( !factory ) { 185 if ( !factory ) {
186 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1()); 186 qDebug("KRES::Factory::configWidget(): Factory creation failed for library %s", pi->library.latin1());
187 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl; 187 kdDebug() << "KRES::Factory::configWidget(): Factory creation failed" << endl;
188 return 0; 188 return 0;
189 } 189 }
190 190
191 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 191 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
192 192
193 if ( !pluginFactory ) { 193 if ( !pluginFactory ) {
194 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1()); 194 qDebug("KRES::Factory::configWidget(): no plugin factory for library %s", pi->library.latin1());
195 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl; 195 kdDebug() << "KRES::Factory::configWidget(): no plugin factory." << endl;
196 return 0; 196 return 0;
197 } 197 }
198 198
199 ConfigWidget *wdg = pluginFactory->configWidget( parent ); 199 ConfigWidget *wdg = pluginFactory->configWidget( parent );
200 if ( !wdg ) { 200 if ( !wdg ) {
201//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 201//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
202 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 202 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
203 return 0; 203 return 0;
204 } 204 }
205 return wdg; 205 return wdg;
206 206
207} 207}
208 208
209QString Factory::typeName( const QString &type ) const 209QString Factory::typeName( const QString &type ) const
210{ 210{
211 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 211 if ( type.isEmpty() || !mTypeMap.contains( type ) )
212 return QString(); 212 return QString();
213 213
214 214
215//US KService::Ptr ptr = mTypeMap[ type ]; 215//US KService::Ptr ptr = mTypeMap[ type ];
216//US return ptr->name(); 216//US return ptr->name();
217 PluginInfo* pi = mTypeMap[ type ]; 217 PluginInfo* pi = mTypeMap[ type ];
218 return pi->nameLabel; 218 return pi->nameLabel;
219 219
220} 220}
221 221
222QString Factory::typeDescription( const QString &type ) const 222QString Factory::typeDescription( const QString &type ) const
223{ 223{
224 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 224 if ( type.isEmpty() || !mTypeMap.contains( type ) )
225 return QString(); 225 return QString();
226 226
227//US KService::Ptr ptr = mTypeMap[ type ]; 227//US KService::Ptr ptr = mTypeMap[ type ];
228//US return ptr->comment(); 228//US return ptr->comment();
229 PluginInfo* pi = mTypeMap[ type ]; 229 PluginInfo* pi = mTypeMap[ type ];
230 return pi->descriptionLabel; 230 return pi->descriptionLabel;
231} 231}
232 232
233Resource *Factory::resource( const QString& type, const KConfig *config ) 233Resource *Factory::resource( const QString& type, const KConfig *config )
234{ 234{
235 235
236 236
237 if ( type.isEmpty() || !mTypeMap.contains( type ) ) 237 if ( type.isEmpty() || !mTypeMap.contains( type ) )
238 return 0; 238 return 0;
239 239
240#ifdef STATIC_RESOURCES 240#ifdef STATIC_RESOURCES
241 qDebug("NEW STATIC RESOURCE %s", type.latin1()); 241 qDebug("NEW STATIC RESOURCE %s", type.latin1());
242 Resource *resource = 0; 242 Resource *resource = 0;
243 if ( type == "file" ) { 243 if ( type == "file" ) {
244 resource = (Resource *) new KABC::ResourceFile( config ); 244 resource = (Resource *) new KABC::ResourceFile( config );
245 } else if ( type == "dir" ) { 245 } else if ( type == "dir" ) {
246 resource = new KABC::ResourceDir( config ); 246 resource = new KABC::ResourceDir( config );
247 } else if ( type == "qtopia" ) { 247 } else if ( type == "qtopia" ) {
248 resource = new KABC::ResourceQtopia( config ); 248 resource = new KABC::ResourceQtopia( config );
249 } 249 }
250 if ( !resource) 250 if ( !resource)
251 qDebug("Factory::resource:: resources are statically linked. resource type %s is not supported ",type.latin1() ); 251 qDebug("Factory::resource:: resources are statically linked. resource type %s is not supported ",type.latin1() );
252 else 252 else
253 resource->setType( type ); 253 resource->setType( type );
254 return resource; 254 return resource;
255#else 255#else
256 256
257 257
258 258
259/*US load the lib not dynamicly. !! 259/*US load the lib not dynamicly. !!
260 KService::Ptr ptr = mTypeMap[ type ]; 260 KService::Ptr ptr = mTypeMap[ type ];
261 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() ); 261 KLibFactory *factory = KLibLoader::self()->factory( ptr->library().latin1() );
262 if ( !factory ) { 262 if ( !factory ) {
263 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 263 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
264 return 0; 264 return 0;
265 } 265 }
266*/ 266*/
267 PluginInfo* pi = mTypeMap[ type ]; 267 PluginInfo* pi = mTypeMap[ type ];
268 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() ); 268 KLibFactory *factory = (KLibFactory *)KLibLoader::self()->factory( pi->library.latin1() );
269 if ( !factory ) { 269 if ( !factory ) {
270 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1()); 270 qDebug("KRES::Factory::resource(): Factory creation failed for library %s", pi->library.latin1());
271 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl; 271 kdDebug() << "KRES::Factory::resource(): Factory creation failed" << endl;
272 return 0; 272 return 0;
273 } 273 }
274 274
275 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory ); 275 PluginFactoryBase *pluginFactory = static_cast<PluginFactoryBase *>( factory );
276 276
277 if ( !pluginFactory ) { 277 if ( !pluginFactory ) {
278 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1()); 278 qDebug("KRES::Factory::resource(): no plugin factory for library %s", pi->library.latin1());
279 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl; 279 kdDebug() << "KRES::Factory::resource(): no plugin factory." << endl;
280 return 0; 280 return 0;
281 } 281 }
282 282
283 Resource *resource = pluginFactory->resource( config ); 283 Resource *resource = pluginFactory->resource( config );
284 if ( !resource ) { 284 if ( !resource ) {
285//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl; 285//US kdDebug() << "'" << ptr->library() << "' is not a " + mResourceFamily + " plugin." << endl;
286 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1()); 286 qDebug("%s is not a %s plugin.", pi->library.latin1(), mResourceFamily.latin1());
287 return 0; 287 return 0;
288 } 288 }
289 289
290 resource->setType( type ); 290 resource->setType( type );
291 291
292 return resource; 292 return resource;
293 293
294#endif 294#endif
295} 295}
diff --git a/microkde/kresources/factory.h b/microkde/kresources/factory.h
index ea01b23..709fde0 100644
--- a/microkde/kresources/factory.h
+++ b/microkde/kresources/factory.h
@@ -1,126 +1,126 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#ifndef KRESOURCES_FACTORY_H 24#ifndef KRESOURCES_FACTORY_H
25#define KRESOURCES_FACTORY_H 25#define KRESOURCES_FACTORY_H
26 26
27#include <qdict.h> 27#include <q3dict.h>
28#include <qstring.h> 28#include <qstring.h>
29 29
30#include <kconfig.h> 30#include <kconfig.h>
31 31
32 32
33#include "resource.h" 33#include "resource.h"
34 34
35namespace KRES { 35namespace KRES {
36 36
37class ConfigWidget; 37class ConfigWidget;
38 38
39//US 39//US
40struct PluginInfo 40struct PluginInfo
41{ 41{
42 QString library; 42 QString library;
43 QString nameLabel; 43 QString nameLabel;
44 QString descriptionLabel; 44 QString descriptionLabel;
45}; 45};
46 46
47 47
48/** 48/**
49 * Class for loading resource plugins. 49 * Class for loading resource plugins.
50 * Do not use this class directly. Use ResourceManager instead 50 * Do not use this class directly. Use ResourceManager instead
51 * 51 *
52 * Example: 52 * Example:
53 * 53 *
54 * <pre> 54 * <pre>
55 * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self(); 55 * KABC::Factory<Calendar> *factory = KABC::Factory<Calendar>::self();
56 * 56 *
57 * QStringList list = factory->resources(); 57 * QStringList list = factory->resources();
58 * QStringList::Iterator it; 58 * QStringList::Iterator it;
59 * for ( it = list.begin(); it != list.end(); ++it ) { 59 * for ( it = list.begin(); it != list.end(); ++it ) {
60 * Resource<Calendar> *resource = factory->resource( (*it), 60 * Resource<Calendar> *resource = factory->resource( (*it),
61 * KABC::StdAddressBook::self(), 0 ); 61 * KABC::StdAddressBook::self(), 0 );
62 * // do something with resource 62 * // do something with resource
63 * } 63 * }
64 * </pre> 64 * </pre>
65 */ 65 */
66class Factory 66class Factory
67{ 67{
68 public: 68 public:
69 69
70 70
71 /** 71 /**
72 * Returns the global resource factory. 72 * Returns the global resource factory.
73 */ 73 */
74 static Factory *self( const QString& resourceFamily ); 74 static Factory *self( const QString& resourceFamily );
75 75
76 ~Factory(); 76 ~Factory();
77 77
78 /** 78 /**
79 * Returns the config widget for the given resource type, 79 * Returns the config widget for the given resource type,
80 * or a null pointer if resource type doesn't exist. 80 * or a null pointer if resource type doesn't exist.
81 * 81 *
82 * @param type The type of the resource, returned by @ref resources() 82 * @param type The type of the resource, returned by @ref resources()
83 * @param resource The resource to be editted. 83 * @param resource The resource to be editted.
84 * @param parent The parent widget 84 * @param parent The parent widget
85 */ 85 */
86 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ); 86 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 );
87 87
88 /** 88 /**
89 * Returns a pointer to a resource object or a null pointer 89 * Returns a pointer to a resource object or a null pointer
90 * if resource type doesn't exist. 90 * if resource type doesn't exist.
91 * 91 *
92 * @param type The type of the resource, returned by @ref resources() 92 * @param type The type of the resource, returned by @ref resources()
93 * @param ab The address book, the resource should belong to 93 * @param ab The address book, the resource should belong to
94 * @param config The config object where the resource get it settings from, or 0 if a new resource should be created. 94 * @param config The config object where the resource get it settings from, or 0 if a new resource should be created.
95 */ 95 */
96 Resource *resource( const QString& type, const KConfig *config); 96 Resource *resource( const QString& type, const KConfig *config);
97 97
98 /** 98 /**
99 * Returns a list of all available resource types. 99 * Returns a list of all available resource types.
100 */ 100 */
101 QStringList typeNames() const; 101 QStringList typeNames() const;
102 102
103 /** 103 /**
104 * Returns the name for a special type. 104 * Returns the name for a special type.
105 */ 105 */
106 QString typeName( const QString &type ) const; 106 QString typeName( const QString &type ) const;
107 107
108 /** 108 /**
109 * Returns the description for a special type. 109 * Returns the description for a special type.
110 */ 110 */
111 QString typeDescription( const QString &type ) const; 111 QString typeDescription( const QString &type ) const;
112 112
113 protected: 113 protected:
114 Factory( const QString& resourceFamily); 114 Factory( const QString& resourceFamily);
115 115
116 private: 116 private:
117 static QDict<Factory> *mSelves; 117 static Q3Dict<Factory> *mSelves;
118 118
119 QString mResourceFamily; 119 QString mResourceFamily;
120//US QMap<QString, KService::Ptr> mTypeMap; 120//US QMap<QString, KService::Ptr> mTypeMap;
121//US lets store the pluginfo struct as value instead of a KService 121//US lets store the pluginfo struct as value instead of a KService
122 QMap<QString, PluginInfo*> mTypeMap; 122 QMap<QString, PluginInfo*> mTypeMap;
123}; 123};
124 124
125} 125}
126#endif 126#endif
diff --git a/microkde/kresources/kcmkresources.cpp b/microkde/kresources/kcmkresources.cpp
index d600a31..f5eb826 100644
--- a/microkde/kresources/kcmkresources.cpp
+++ b/microkde/kresources/kcmkresources.cpp
@@ -1,89 +1,92 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2003 Tobias Koenig <tokoe@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qlayout.h> 22#include <qlayout.h>
23//Added by qt3to4:
24#include <Q3VBoxLayout>
25#include <Q3Frame>
23 26
24//US #include <kaboutdata.h> 27//US #include <kaboutdata.h>
25//US #include <kgenericfactory.h> 28//US #include <kgenericfactory.h>
26#include <klocale.h> 29#include <klocale.h>
27 30
28#include "configpage.h" 31#include "configpage.h"
29 32
30#include "kcmkresources.h" 33#include "kcmkresources.h"
31 34
32using namespace KRES; 35using namespace KRES;
33 36
34//US typedef KGenericFactory<KCMKResources, QWidget> ResourcesFactory; 37//US typedef KGenericFactory<KCMKResources, QWidget> ResourcesFactory;
35//US K_EXPORT_COMPONENT_FACTORY( kcm_kresources, ResourcesFactory( "kcmkresources" ) ); 38//US K_EXPORT_COMPONENT_FACTORY( kcm_kresources, ResourcesFactory( "kcmkresources" ) );
36 39
37//US KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& ) 40//US KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& )
38//US : KCModule( ResourcesFactory::instance(), parent, name ) 41//US : KCModule( ResourcesFactory::instance(), parent, name )
39KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& ) 42KCMKResources::KCMKResources( QWidget *parent, const char *name, const QStringList& )
40 : KDialogBase( parent, name, true, i18n( "Configure Resources" ), 43 : KDialogBase( parent, name, true, i18n( "Configure Resources" ),
41 Ok|Cancel, Ok, true ) 44 Ok|Cancel, Ok, true )
42{ 45{
43 QFrame *main = plainPage(); 46 Q3Frame *main = plainPage();
44 47
45 QVBoxLayout *layout = new QVBoxLayout( main ); 48 Q3VBoxLayout *layout = new Q3VBoxLayout( main );
46 mConfigPage = new KRES::ConfigPage( main ); 49 mConfigPage = new KRES::ConfigPage( main );
47 layout->addWidget( mConfigPage ); 50 layout->addWidget( mConfigPage );
48 51
49 52
50 connect( mConfigPage, SIGNAL( changed( bool ) ), SLOT( changed( bool ) ) ); 53 connect( mConfigPage, SIGNAL( changed( bool ) ), SLOT( changed( bool ) ) );
51#ifndef DESKTOP_VERSION 54#ifndef DESKTOP_VERSION
52 showMaximized(); 55 showMaximized();
53#endif 56#endif
54} 57}
55 58
56void KCMKResources::changed( bool changed) 59void KCMKResources::changed( bool changed)
57{ 60{
58 modified = changed; 61 modified = changed;
59} 62}
60 63
61void KCMKResources::slotOk() 64void KCMKResources::slotOk()
62{ 65{
63 if (modified) { 66 if (modified) {
64 mConfigPage->save(); 67 mConfigPage->save();
65 modified = false; 68 modified = false;
66 } 69 }
67 70
68 KDialogBase::slotOk(); 71 KDialogBase::slotOk();
69} 72}
70 73
71void KCMKResources::load() 74void KCMKResources::load()
72{ 75{
73 qDebug("KCMKResources::load" ); 76 qDebug("KCMKResources::load" );
74 mConfigPage->load(); 77 mConfigPage->load();
75} 78}
76 79
77void KCMKResources::save() 80void KCMKResources::save()
78{ 81{
79 qDebug("KCMKResources::save" ); 82 qDebug("KCMKResources::save" );
80 mConfigPage->save(); 83 mConfigPage->save();
81} 84}
82 85
83void KCMKResources::defaults() 86void KCMKResources::defaults()
84{ 87{
85 qDebug("KCMKResources::defaults" ); 88 qDebug("KCMKResources::defaults" );
86 mConfigPage->defaults(); 89 mConfigPage->defaults();
87} 90}
88 91
89//US #include "kcmkresources.moc" 92//US #include "kcmkresources.moc"
diff --git a/microkde/kresources/manager.h b/microkde/kresources/manager.h
index 69062da..88705d4 100644
--- a/microkde/kresources/manager.h
+++ b/microkde/kresources/manager.h
@@ -1,338 +1,340 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 Copyright (c) 2004 Ulf Schenk 7 Copyright (c) 2004 Ulf Schenk
8 8
9 This library is free software; you can redistribute it and/or 9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Library General Public 10 modify it under the terms of the GNU Library General Public
11 License as published by the Free Software Foundation; either 11 License as published by the Free Software Foundation; either
12 version 2 of the License, or (at your option) any later version. 12 version 2 of the License, or (at your option) any later version.
13 13
14 This library is distributed in the hope that it will be useful, 14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Library General Public License for more details. 17 Library General Public License for more details.
18 18
19 You should have received a copy of the GNU Library General Public License 19 You should have received a copy of the GNU Library General Public License
20 along with this library; see the file COPYING.LIB. If not, write to 20 along with this library; see the file COPYING.LIB. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. 22 Boston, MA 02111-1307, USA.
23*/ 23*/
24 24
25/* 25/*
26Enhanced Version of the file for platform independent KDE tools. 26Enhanced Version of the file for platform independent KDE tools.
27Copyright (c) 2004 Ulf Schenk 27Copyright (c) 2004 Ulf Schenk
28 28
29$Id$ 29$Id$
30*/ 30*/
31 31
32#ifndef KRESOURCES_MANAGER_H 32#ifndef KRESOURCES_MANAGER_H
33#define KRESOURCES_MANAGER_H 33#define KRESOURCES_MANAGER_H
34 34
35#include <qdict.h> 35#include <q3dict.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37//Added by qt3to4:
38#include <Q3PtrList>
37 39
38#include "factory.h" 40#include "factory.h"
39#include "managerimpl.h" 41#include "managerimpl.h"
40 42
41namespace KRES { 43namespace KRES {
42 44
43class Resource; 45class Resource;
44 46
45template<class T> 47template<class T>
46class ManagerListener 48class ManagerListener
47{ 49{
48 public: 50 public:
49 virtual void resourceAdded( T *resource ) = 0; 51 virtual void resourceAdded( T *resource ) = 0;
50 virtual void resourceModified( T *resource ) = 0; 52 virtual void resourceModified( T *resource ) = 0;
51 virtual void resourceDeleted( T *resource ) = 0; 53 virtual void resourceDeleted( T *resource ) = 0;
52}; 54};
53 55
54// TODO: 56// TODO:
55// The resource manager should provide some signals 57// The resource manager should provide some signals
56// to warn applications that resources have been added, 58// to warn applications that resources have been added,
57// removed or modified. 59// removed or modified.
58// 60//
59// The manager should also keep track of which (or at least 61// The manager should also keep track of which (or at least
60// how many) applications hve opened a resource, so that it 62// how many) applications hve opened a resource, so that it
61// is only closed if none of them is using it any more 63// is only closed if none of them is using it any more
62 64
63template<class T> 65template<class T>
64class Manager : private ManagerImplListener 66class Manager : private ManagerImplListener
65{ 67{
66 public: 68 public:
67 class Iterator 69 class Iterator
68 { 70 {
69 friend class Manager; 71 friend class Manager;
70 public: 72 public:
71 Iterator() {}; 73 Iterator() {};
72 Iterator( const Iterator &it ) { mIt = it.mIt; } 74 Iterator( const Iterator &it ) { mIt = it.mIt; }
73 75
74 T *operator*() { return static_cast<T *>( *mIt ); } 76 T *operator*() { return static_cast<T *>( *mIt ); }
75 Iterator &operator++() { mIt++; return *this; } 77 Iterator &operator++() { mIt++; return *this; }
76 Iterator &operator++(int) { mIt++; return *this; } 78 Iterator &operator++(int) { mIt++; return *this; }
77 Iterator &operator--() { mIt--; return *this; } 79 Iterator &operator--() { mIt--; return *this; }
78 Iterator &operator--(int) { mIt--; return *this; } 80 Iterator &operator--(int) { mIt--; return *this; }
79 bool operator==( const Iterator &it ) { return mIt == it.mIt; } 81 bool operator==( const Iterator &it ) { return mIt == it.mIt; }
80 bool operator!=( const Iterator &it ) { return mIt != it.mIt; } 82 bool operator!=( const Iterator &it ) { return mIt != it.mIt; }
81 83
82 private: 84 private:
83 Resource::List::Iterator mIt; 85 Resource::List::Iterator mIt;
84 }; 86 };
85 87
86 Iterator begin() 88 Iterator begin()
87 { 89 {
88 Iterator it; 90 Iterator it;
89 it.mIt = mImpl->resourceList()->begin(); 91 it.mIt = mImpl->resourceList()->begin();
90 return it; 92 return it;
91 } 93 }
92 94
93 Iterator end() 95 Iterator end()
94 { 96 {
95 Iterator it; 97 Iterator it;
96 it.mIt = mImpl->resourceList()->end(); 98 it.mIt = mImpl->resourceList()->end();
97 return it; 99 return it;
98 } 100 }
99 101
100 class ActiveIterator 102 class ActiveIterator
101 { 103 {
102 friend class Manager; 104 friend class Manager;
103 public: 105 public:
104 ActiveIterator() : mList( 0 ) {}; 106 ActiveIterator() : mList( 0 ) {};
105 ActiveIterator( const ActiveIterator &it ) 107 ActiveIterator( const ActiveIterator &it )
106 { 108 {
107 mIt = it.mIt; 109 mIt = it.mIt;
108 mList = it.mList; 110 mList = it.mList;
109 } 111 }
110 112
111 T *operator*() { return static_cast<T *>( *mIt ); } 113 T *operator*() { return static_cast<T *>( *mIt ); }
112 ActiveIterator &operator++() 114 ActiveIterator &operator++()
113 { 115 {
114 do { mIt++; } while ( checkActive() ); 116 do { mIt++; } while ( checkActive() );
115 return *this; 117 return *this;
116 } 118 }
117 ActiveIterator &operator++(int) 119 ActiveIterator &operator++(int)
118 { 120 {
119 do { mIt++; } while ( checkActive() ); 121 do { mIt++; } while ( checkActive() );
120 return *this; 122 return *this;
121 } 123 }
122 ActiveIterator &operator--() 124 ActiveIterator &operator--()
123 { 125 {
124 do { mIt--; } while ( checkActive() ); 126 do { mIt--; } while ( checkActive() );
125 return *this; 127 return *this;
126 } 128 }
127 ActiveIterator &operator--(int) 129 ActiveIterator &operator--(int)
128 { 130 {
129 do { mIt--; } while ( checkActive() ); 131 do { mIt--; } while ( checkActive() );
130 return *this; 132 return *this;
131 } 133 }
132 bool operator==( const ActiveIterator &it ) { return mIt == it.mIt; } 134 bool operator==( const ActiveIterator &it ) { return mIt == it.mIt; }
133 bool operator!=( const ActiveIterator &it ) { return mIt != it.mIt; } 135 bool operator!=( const ActiveIterator &it ) { return mIt != it.mIt; }
134 136
135 private: 137 private:
136 /** 138 /**
137 Check if iterator needs to be advanced once more. 139 Check if iterator needs to be advanced once more.
138 */ 140 */
139 bool checkActive() 141 bool checkActive()
140 { 142 {
141 if ( !mList || mIt == mList->end() ) return false; 143 if ( !mList || mIt == mList->end() ) return false;
142 return !(*mIt)->isActive(); 144 return !(*mIt)->isActive();
143 } 145 }
144 146
145 Resource::List::Iterator mIt; 147 Resource::List::Iterator mIt;
146 Resource::List *mList; 148 Resource::List *mList;
147 }; 149 };
148 150
149 ActiveIterator activeBegin() 151 ActiveIterator activeBegin()
150 { 152 {
151 ActiveIterator it; 153 ActiveIterator it;
152 it.mIt = mImpl->resourceList()->begin(); 154 it.mIt = mImpl->resourceList()->begin();
153 it.mList = mImpl->resourceList(); 155 it.mList = mImpl->resourceList();
154 if ( it.mIt != mImpl->resourceList()->end() ) { 156 if ( it.mIt != mImpl->resourceList()->end() ) {
155 if ( !(*it)->isActive() ) it++; 157 if ( !(*it)->isActive() ) it++;
156 } 158 }
157 return it; 159 return it;
158 } 160 }
159 161
160 ActiveIterator activeEnd() 162 ActiveIterator activeEnd()
161 { 163 {
162 ActiveIterator it; 164 ActiveIterator it;
163 it.mIt = mImpl->resourceList()->end(); 165 it.mIt = mImpl->resourceList()->end();
164 it.mList = mImpl->resourceList(); 166 it.mList = mImpl->resourceList();
165 return it; 167 return it;
166 } 168 }
167 169
168 bool isEmpty() const { return mImpl->resourceList()->isEmpty(); } 170 bool isEmpty() const { return mImpl->resourceList()->isEmpty(); }
169 171
170 Manager( const QString &family ) 172 Manager( const QString &family )
171 { 173 {
172 mFactory = Factory::self( family ); 174 mFactory = Factory::self( family );
173 // The managerimpl will use the same Factory object as the manager 175 // The managerimpl will use the same Factory object as the manager
174 // because of the Factory::self() pattern 176 // because of the Factory::self() pattern
175 mImpl = new ManagerImpl( family ); 177 mImpl = new ManagerImpl( family );
176 mImpl->setListener( this ); 178 mImpl->setListener( this );
177 179
178 mListeners = new QPtrList<ManagerListener<T> >; 180 mListeners = new Q3PtrList<ManagerListener<T> >;
179 } 181 }
180 182
181 virtual ~Manager() 183 virtual ~Manager()
182 { 184 {
183 mImpl->setListener( 0 ); 185 mImpl->setListener( 0 );
184 delete mListeners; 186 delete mListeners;
185 delete mImpl; 187 delete mImpl;
186 } 188 }
187 189
188 /** 190 /**
189 Recreate Resource objects from configuration file. If cfg is 0, read standard 191 Recreate Resource objects from configuration file. If cfg is 0, read standard
190 configuration file. 192 configuration file.
191 */ 193 */
192 void readConfig( KConfig *cfg = 0 ) 194 void readConfig( KConfig *cfg = 0 )
193 { 195 {
194 mImpl->readConfig( cfg ); 196 mImpl->readConfig( cfg );
195 } 197 }
196 198
197 /** 199 /**
198 Write configuration of Resource objects to configuration file. If cfg is 0, write 200 Write configuration of Resource objects to configuration file. If cfg is 0, write
199 to standard configuration file. 201 to standard configuration file.
200 */ 202 */
201 void writeConfig( KConfig *cfg = 0 ) 203 void writeConfig( KConfig *cfg = 0 )
202 { 204 {
203 mImpl->writeConfig( cfg ); 205 mImpl->writeConfig( cfg );
204 } 206 }
205 207
206 /** 208 /**
207 Add resource to manager. This passes ownership of the Resource object 209 Add resource to manager. This passes ownership of the Resource object
208 to the manager. 210 to the manager.
209 */ 211 */
210 void add( Resource *resource ) 212 void add( Resource *resource )
211 { 213 {
212 if ( resource ) mImpl->add( resource ); 214 if ( resource ) mImpl->add( resource );
213 } 215 }
214 216
215 void remove( Resource *resource ) 217 void remove( Resource *resource )
216 { 218 {
217 if ( resource ) mImpl->remove( resource ); 219 if ( resource ) mImpl->remove( resource );
218 } 220 }
219 221
220 T* standardResource() 222 T* standardResource()
221 { 223 {
222 return static_cast<T *>( mImpl->standardResource() ); 224 return static_cast<T *>( mImpl->standardResource() );
223 } 225 }
224 226
225 void setStandardResource( T *resource ) 227 void setStandardResource( T *resource )
226 { 228 {
227 if ( resource ) mImpl->setStandardResource( resource ); 229 if ( resource ) mImpl->setStandardResource( resource );
228 } 230 }
229 231
230 void setActive( Resource *resource, bool active ) 232 void setActive( Resource *resource, bool active )
231 { 233 {
232 if ( resource ) mImpl->setActive( resource, active ); 234 if ( resource ) mImpl->setActive( resource, active );
233 } 235 }
234 236
235 /** 237 /**
236 Returns a list of the names of the reources managed by the 238 Returns a list of the names of the reources managed by the
237 Manager for this family. 239 Manager for this family.
238 */ 240 */
239 QStringList resourceNames() const 241 QStringList resourceNames() const
240 { 242 {
241 return mImpl->resourceNames(); 243 return mImpl->resourceNames();
242 } 244 }
243 245
244 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 ) 246 ConfigWidget *configWidget( const QString& type, QWidget *parent = 0 )
245 { 247 {
246 return mFactory->configWidget( type, parent ); 248 return mFactory->configWidget( type, parent );
247 } 249 }
248 250
249 /** 251 /**
250 Creates a new resource of type @param type, with default 252 Creates a new resource of type @param type, with default
251 settings. The resource is 253 settings. The resource is
252 not added to the manager, the application has to do that. 254 not added to the manager, the application has to do that.
253 Returns a pointer to a resource object or a null pointer 255 Returns a pointer to a resource object or a null pointer
254 if resource type doesn't exist. 256 if resource type doesn't exist.
255 257
256 @param type The type of the resource, one of those returned 258 @param type The type of the resource, one of those returned
257 by @ref resourceTypeNames() 259 by @ref resourceTypeNames()
258 */ 260 */
259 T *createResource( const QString& type ) 261 T *createResource( const QString& type )
260 { 262 {
261 return (T *)( mFactory->resource( type, 0 ) ); 263 return (T *)( mFactory->resource( type, 0 ) );
262 } 264 }
263 265
264 /** 266 /**
265 Returns a list of the names of all available resource types. 267 Returns a list of the names of all available resource types.
266 */ 268 */
267 QStringList resourceTypeNames() const 269 QStringList resourceTypeNames() const
268 { 270 {
269 return mFactory->typeNames(); 271 return mFactory->typeNames();
270 } 272 }
271 273
272 QStringList resourceTypeDescriptions() const 274 QStringList resourceTypeDescriptions() const
273 { 275 {
274 QStringList typeDescs; 276 QStringList typeDescs;
275 QStringList types = mFactory->typeNames(); 277 QStringList types = mFactory->typeNames();
276 278
277 for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) { 279 for ( QStringList::ConstIterator it = types.begin(); it != types.end(); ++it ) {
278 QString desc = mFactory->typeName( *it ); 280 QString desc = mFactory->typeName( *it );
279 if ( !mFactory->typeDescription( *it ).isEmpty() ) 281 if ( !mFactory->typeDescription( *it ).isEmpty() )
280 desc += " (" + mFactory->typeDescription( *it ) + ")"; 282 desc += " (" + mFactory->typeDescription( *it ) + ")";
281 283
282 typeDescs.append( desc ); 284 typeDescs.append( desc );
283 } 285 }
284 286
285 return typeDescs; 287 return typeDescs;
286 } 288 }
287 289
288 void resourceChanged( T *resource ) 290 void resourceChanged( T *resource )
289 { 291 {
290 mImpl->resourceChanged( resource ); 292 mImpl->resourceChanged( resource );
291 } 293 }
292 294
293 void addListener( ManagerListener<T> *listener ) 295 void addListener( ManagerListener<T> *listener )
294 { 296 {
295 mListeners->append( listener ); 297 mListeners->append( listener );
296 } 298 }
297 299
298 void removeListener( ManagerListener<T> *listener ) 300 void removeListener( ManagerListener<T> *listener )
299 { 301 {
300 mListeners->remove( listener ); 302 mListeners->remove( listener );
301 } 303 }
302 304
303 virtual void resourceAdded( Resource *res ) 305 virtual void resourceAdded( Resource *res )
304 { 306 {
305 T* resource = (T *)( res ); 307 T* resource = (T *)( res );
306 ManagerListener<T> *listener; 308 ManagerListener<T> *listener;
307 for ( listener = mListeners->first(); listener; listener = mListeners->next() ) 309 for ( listener = mListeners->first(); listener; listener = mListeners->next() )
308 listener->resourceAdded( resource ); 310 listener->resourceAdded( resource );
309 } 311 }
310 312
311 virtual void resourceModified( Resource *res ) 313 virtual void resourceModified( Resource *res )
312 { 314 {
313 315
314 T* resource = (T *)( res ); 316 T* resource = (T *)( res );
315 ManagerListener<T> *listener; 317 ManagerListener<T> *listener;
316 for ( listener = mListeners->first(); listener; listener = mListeners->next() ) 318 for ( listener = mListeners->first(); listener; listener = mListeners->next() )
317 listener->resourceModified( resource ); 319 listener->resourceModified( resource );
318 } 320 }
319 321
320 virtual void resourceDeleted( Resource *res ) 322 virtual void resourceDeleted( Resource *res )
321 { 323 {
322 324
323 T* resource = (T *)( res ); 325 T* resource = (T *)( res );
324 ManagerListener<T> *listener; 326 ManagerListener<T> *listener;
325 for ( listener = mListeners->first(); listener; listener = mListeners->next() ) { 327 for ( listener = mListeners->first(); listener; listener = mListeners->next() ) {
326 listener->resourceDeleted( resource ); 328 listener->resourceDeleted( resource );
327 } 329 }
328 } 330 }
329 331
330 private: 332 private:
331 ManagerImpl *mImpl; 333 ManagerImpl *mImpl;
332 Factory *mFactory; 334 Factory *mFactory;
333 QPtrList<ManagerListener<T> > *mListeners; 335 Q3PtrList<ManagerListener<T> > *mListeners;
334}; 336};
335 337
336} 338}
337 339
338#endif 340#endif
diff --git a/microkde/kresources/managerimpl.cpp b/microkde/kresources/managerimpl.cpp
index a6d2007..4c0751c 100644
--- a/microkde/kresources/managerimpl.cpp
+++ b/microkde/kresources/managerimpl.cpp
@@ -1,376 +1,378 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <kglobal.h> 31#include <kglobal.h>
32 32
33#include <kapplication.h> 33#include <kapplication.h>
34#include <kdebug.h> 34#include <kdebug.h>
35#include <kconfig.h> 35#include <kconfig.h>
36#include <kstandarddirs.h> 36#include <kstandarddirs.h>
37#include <qfile.h> 37#include <qfile.h>
38//Added by qt3to4:
39#include <Q3PtrList>
38 40
39#include "resource.h" 41#include "resource.h"
40#include "factory.h" 42#include "factory.h"
41#include "managerimpl.h" 43#include "managerimpl.h"
42 44
43 45
44 46
45using namespace KRES; 47using namespace KRES;
46 48
47ManagerImpl::ManagerImpl( const QString &family ) 49ManagerImpl::ManagerImpl( const QString &family )
48 : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ), 50 : mFamily( family ), mConfig( 0 ), mStdConfig( 0 ), mStandard( 0 ),
49 mFactory( 0 ) 51 mFactory( 0 )
50 52
51{ 53{
52 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl; 54 kdDebug(5650) << "ManagerImpl::ManagerImpl()" << endl;
53 55
54 56
55} 57}
56 58
57ManagerImpl::~ManagerImpl() 59ManagerImpl::~ManagerImpl()
58{ 60{
59 kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl; 61 kdDebug(5650) << "ManagerImpl::~ManagerImpl()" << endl;
60 62
61 Resource::List::ConstIterator it; 63 Resource::List::ConstIterator it;
62 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 64 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
63 delete *it; 65 delete *it;
64 } 66 }
65 67
66 delete mStdConfig; 68 delete mStdConfig;
67} 69}
68 70
69void ManagerImpl::createStandardConfig() 71void ManagerImpl::createStandardConfig()
70{ 72{
71 if ( !mStdConfig ) { 73 if ( !mStdConfig ) {
72 QString file = locateLocal( "data", KGlobal::getAppName() 74 QString file = locateLocal( "data", KGlobal::getAppName()
73 + "/kresources/" + mFamily + "rc" ); 75 + "/kresources/" + mFamily + "rc" );
74 if ( mFamily == "tmpcontact" ) { 76 if ( mFamily == "tmpcontact" ) {
75 if (QFile::exists ( file ) ){ 77 if (QFile::exists ( file ) ){
76 QFile::remove ( file ); 78 QFile::remove ( file );
77 qDebug("removed tmp rc file: %s ", file.latin1()); 79 qDebug("removed tmp rc file: %s ", file.latin1());
78 } 80 }
79 } 81 }
80 mStdConfig = new KConfig( file ); 82 mStdConfig = new KConfig( file );
81 } 83 }
82 84
83 mConfig = mStdConfig; 85 mConfig = mStdConfig;
84} 86}
85 87
86void ManagerImpl::readConfig( KConfig *cfg ) 88void ManagerImpl::readConfig( KConfig *cfg )
87{ 89{
88 kdDebug(5650) << "ManagerImpl::readConfig()" << endl; 90 kdDebug(5650) << "ManagerImpl::readConfig()" << endl;
89 91
90 delete mFactory; 92 delete mFactory;
91 mFactory = Factory::self( mFamily ); 93 mFactory = Factory::self( mFamily );
92 94
93 if ( !cfg ) { 95 if ( !cfg ) {
94 createStandardConfig(); 96 createStandardConfig();
95 } else { 97 } else {
96 mConfig = cfg; 98 mConfig = cfg;
97 } 99 }
98 100
99 mStandard = 0; 101 mStandard = 0;
100 102
101 mConfig->setGroup( "General" ); 103 mConfig->setGroup( "General" );
102 104
103 QStringList keys = mConfig->readListEntry( "ResourceKeys" ); 105 QStringList keys = mConfig->readListEntry( "ResourceKeys" );
104 keys += mConfig->readListEntry( "PassiveResourceKeys" ); 106 keys += mConfig->readListEntry( "PassiveResourceKeys" );
105 107
106 QString standardKey = mConfig->readEntry( "Standard" ); 108 QString standardKey = mConfig->readEntry( "Standard" );
107 109
108 for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) { 110 for ( QStringList::Iterator it = keys.begin(); it != keys.end(); ++it ) {
109 readResourceConfig( *it, false ); 111 readResourceConfig( *it, false );
110 } 112 }
111 113
112} 114}
113 115
114void ManagerImpl::writeConfig( KConfig *cfg ) 116void ManagerImpl::writeConfig( KConfig *cfg )
115{ 117{
116//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg); 118//USqDebug("ManagerImpl::writeConfig begin this= %ul cfg=%ul", this, cfg);
117 119
118 120
119 kdDebug(5650) << "ManagerImpl::writeConfig()" << endl; 121 kdDebug(5650) << "ManagerImpl::writeConfig()" << endl;
120 122
121 if ( !cfg ) { 123 if ( !cfg ) {
122 createStandardConfig(); 124 createStandardConfig();
123 } else { 125 } else {
124 mConfig = cfg; 126 mConfig = cfg;
125 } 127 }
126 128
127 QStringList activeKeys; 129 QStringList activeKeys;
128 QStringList passiveKeys; 130 QStringList passiveKeys;
129 131
130 // First write all keys, collect active and passive keys on the way 132 // First write all keys, collect active and passive keys on the way
131 Resource::List::Iterator it; 133 Resource::List::Iterator it;
132 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 134 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
133 writeResourceConfig( *it, false ); 135 writeResourceConfig( *it, false );
134 136
135 QString key = (*it)->identifier(); 137 QString key = (*it)->identifier();
136 if( (*it)->isActive() ) 138 if( (*it)->isActive() )
137 activeKeys.append( key ); 139 activeKeys.append( key );
138 else 140 else
139 passiveKeys.append( key ); 141 passiveKeys.append( key );
140 } 142 }
141 143
142 // And then the general group 144 // And then the general group
143 145
144 kdDebug(5650) << "Saving general info" << endl; 146 kdDebug(5650) << "Saving general info" << endl;
145 mConfig->setGroup( "General" ); 147 mConfig->setGroup( "General" );
146 mConfig->writeEntry( "ResourceKeys", activeKeys ); 148 mConfig->writeEntry( "ResourceKeys", activeKeys );
147 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); 149 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys );
148 if ( mStandard ) 150 if ( mStandard )
149 mConfig->writeEntry( "Standard", mStandard->identifier() ); 151 mConfig->writeEntry( "Standard", mStandard->identifier() );
150 else 152 else
151 mConfig->writeEntry( "Standard", "" ); 153 mConfig->writeEntry( "Standard", "" );
152 154
153 mConfig->sync(); 155 mConfig->sync();
154 kdDebug(5650) << "ManagerImpl::save() finished" << endl; 156 kdDebug(5650) << "ManagerImpl::save() finished" << endl;
155 157
156//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg); 158//US qDebug("ManagerImpl::writeConfig end this= %ul cfg=%ul", this, cfg);
157 159
158} 160}
159 161
160void ManagerImpl::add( Resource *resource, bool useDCOP ) 162void ManagerImpl::add( Resource *resource, bool useDCOP )
161{ 163{
162 //qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource); 164 //qDebug("ManagerImpl::add begin this= %ul resource=%ul", this, resource);
163 165
164 resource->setActive( true ); 166 resource->setActive( true );
165 167
166 if ( mResources.isEmpty() ) { 168 if ( mResources.isEmpty() ) {
167 mStandard = resource; 169 mStandard = resource;
168 } 170 }
169 171
170 mResources.append( resource ); 172 mResources.append( resource );
171 173
172 writeResourceConfig( resource, true ); 174 writeResourceConfig( resource, true );
173 175
174 //qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource); 176 //qDebug("ManagerImpl::add end this= %ul resource=%ul", this, resource);
175 177
176} 178}
177 179
178void ManagerImpl::remove( Resource *resource, bool useDCOP ) 180void ManagerImpl::remove( Resource *resource, bool useDCOP )
179{ 181{
180 if ( mStandard == resource ) mStandard = 0; 182 if ( mStandard == resource ) mStandard = 0;
181 removeResource( resource ); 183 removeResource( resource );
182 184
183 mResources.remove( resource ); 185 mResources.remove( resource );
184 186
185 delete resource; 187 delete resource;
186 188
187 kdDebug(5650) << "Finished ManagerImpl::remove()" << endl; 189 kdDebug(5650) << "Finished ManagerImpl::remove()" << endl;
188} 190}
189 191
190void ManagerImpl::setActive( Resource *resource, bool active ) 192void ManagerImpl::setActive( Resource *resource, bool active )
191{ 193{
192 if ( resource && resource->isActive() != active ) { 194 if ( resource && resource->isActive() != active ) {
193 resource->setActive( active ); 195 resource->setActive( active );
194 } 196 }
195} 197}
196 198
197Resource *ManagerImpl::standardResource() 199Resource *ManagerImpl::standardResource()
198{ 200{
199 return mStandard; 201 return mStandard;
200} 202}
201 203
202void ManagerImpl::setStandardResource( Resource *resource ) 204void ManagerImpl::setStandardResource( Resource *resource )
203{ 205{
204 mStandard = resource; 206 mStandard = resource;
205} 207}
206 208
207void ManagerImpl::resourceChanged( Resource *resource ) 209void ManagerImpl::resourceChanged( Resource *resource )
208{ 210{
209 writeResourceConfig( resource, true ); 211 writeResourceConfig( resource, true );
210 212
211 213
212// ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() ); 214// ManagerIface_stub allManagers( "*", "ManagerIface_" + mFamily.utf8() );
213// allManagers.dcopResourceModified( resource->identifier() ); 215// allManagers.dcopResourceModified( resource->identifier() );
214} 216}
215 217
216// DCOP asynchronous functions 218// DCOP asynchronous functions
217//US since we work from inside the application, we call the methods directly. 219//US since we work from inside the application, we call the methods directly.
218 220
219QStringList ManagerImpl::resourceNames() 221QStringList ManagerImpl::resourceNames()
220{ 222{
221 QStringList result; 223 QStringList result;
222 224
223 Resource::List::ConstIterator it; 225 Resource::List::ConstIterator it;
224 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 226 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
225 result.append( (*it)->resourceName() ); 227 result.append( (*it)->resourceName() );
226 } 228 }
227 return result; 229 return result;
228} 230}
229 231
230Resource::List *ManagerImpl::resourceList() 232Resource::List *ManagerImpl::resourceList()
231{ 233{
232 return &mResources; 234 return &mResources;
233} 235}
234 236
235QPtrList<Resource> ManagerImpl::resources() 237Q3PtrList<Resource> ManagerImpl::resources()
236{ 238{
237 QPtrList<Resource> result; 239 Q3PtrList<Resource> result;
238 240
239 Resource::List::ConstIterator it; 241 Resource::List::ConstIterator it;
240 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 242 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
241 result.append( *it ); 243 result.append( *it );
242 } 244 }
243 return result; 245 return result;
244} 246}
245 247
246QPtrList<Resource> ManagerImpl::resources( bool active ) 248Q3PtrList<Resource> ManagerImpl::resources( bool active )
247{ 249{
248 QPtrList<Resource> result; 250 Q3PtrList<Resource> result;
249 251
250 Resource::List::ConstIterator it; 252 Resource::List::ConstIterator it;
251 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 253 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
252 if ( (*it)->isActive() == active ) { 254 if ( (*it)->isActive() == active ) {
253 result.append( *it ); 255 result.append( *it );
254 } 256 }
255 } 257 }
256 return result; 258 return result;
257} 259}
258 260
259void ManagerImpl::setListener( ManagerImplListener *listener ) 261void ManagerImpl::setListener( ManagerImplListener *listener )
260{ 262{
261 mListener = listener; 263 mListener = listener;
262} 264}
263 265
264Resource* ManagerImpl::readResourceConfig( const QString& identifier, 266Resource* ManagerImpl::readResourceConfig( const QString& identifier,
265 bool checkActive ) 267 bool checkActive )
266{ 268{
267 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl; 269 kdDebug() << "ManagerImpl::readResourceConfig() " << identifier << endl;
268 270
269// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1()); 271// qDebug("ManagerImpl::readResourceConfig() %s", identifier.latin1());
270 272
271 mConfig->setGroup( "Resource_" + identifier ); 273 mConfig->setGroup( "Resource_" + identifier );
272#ifdef _WIN32_ 274#ifdef _WIN32_
273 // we use plugins on win32. the group is stored in a static variable 275 // we use plugins on win32. the group is stored in a static variable
274 // such that gourp info not avail on win32 plugins 276 // such that gourp info not avail on win32 plugins
275 // to fix that, it would be a looooot of work 277 // to fix that, it would be a looooot of work
276 mConfig->setTempGroup( "Resource_" + identifier ); 278 mConfig->setTempGroup( "Resource_" + identifier );
277#endif 279#endif
278 QString type = mConfig->readEntry( "ResourceType" ); 280 QString type = mConfig->readEntry( "ResourceType" );
279 QString name = mConfig->readEntry( "ResourceName" ); 281 QString name = mConfig->readEntry( "ResourceName" );
280 Resource *resource = mFactory->resource( type, mConfig ); 282 Resource *resource = mFactory->resource( type, mConfig );
281 if ( !resource ) { 283 if ( !resource ) {
282 qDebug("Failed to create resource with id %s ",identifier.latin1() ); 284 qDebug("Failed to create resource with id %s ",identifier.latin1() );
283 return 0; 285 return 0;
284 } 286 }
285 287
286 if ( resource->identifier().isEmpty() ) 288 if ( resource->identifier().isEmpty() )
287 resource->setIdentifier( identifier ); 289 resource->setIdentifier( identifier );
288 290
289 mConfig->setGroup( "General" ); 291 mConfig->setGroup( "General" );
290 292
291 QString standardKey = mConfig->readEntry( "Standard" ); 293 QString standardKey = mConfig->readEntry( "Standard" );
292 if ( standardKey == identifier ) { 294 if ( standardKey == identifier ) {
293 mStandard = resource; 295 mStandard = resource;
294 } 296 }
295 297
296 if ( checkActive ) { 298 if ( checkActive ) {
297 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 299 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
298 resource->setActive( activeKeys.contains( identifier ) ); 300 resource->setActive( activeKeys.contains( identifier ) );
299 } 301 }
300 mResources.append( resource ); 302 mResources.append( resource );
301 303
302 return resource; 304 return resource;
303} 305}
304 306
305void ManagerImpl::writeResourceConfig( Resource *resource, 307void ManagerImpl::writeResourceConfig( Resource *resource,
306 bool checkActive ) 308 bool checkActive )
307{ 309{
308 QString key = resource->identifier(); 310 QString key = resource->identifier();
309 311
310 kdDebug(5650) << "Saving resource " << key << endl; 312 kdDebug(5650) << "Saving resource " << key << endl;
311 313
312 if ( !mConfig ) createStandardConfig(); 314 if ( !mConfig ) createStandardConfig();
313 315
314 mConfig->setGroup( "Resource_" + key ); 316 mConfig->setGroup( "Resource_" + key );
315 resource->writeConfig( mConfig ); 317 resource->writeConfig( mConfig );
316 318
317 mConfig->setGroup( "General" ); 319 mConfig->setGroup( "General" );
318 QString standardKey = mConfig->readEntry( "Standard" ); 320 QString standardKey = mConfig->readEntry( "Standard" );
319 321
320 if ( resource == mStandard && standardKey != key ) 322 if ( resource == mStandard && standardKey != key )
321 mConfig->writeEntry( "Standard", resource->identifier() ); 323 mConfig->writeEntry( "Standard", resource->identifier() );
322 else if ( resource != mStandard && standardKey == key ) 324 else if ( resource != mStandard && standardKey == key )
323 mConfig->writeEntry( "Standard", "" ); 325 mConfig->writeEntry( "Standard", "" );
324 326
325 if ( checkActive ) { 327 if ( checkActive ) {
326 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 328 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
327 if ( resource->isActive() && !activeKeys.contains( key ) ) { 329 if ( resource->isActive() && !activeKeys.contains( key ) ) {
328 activeKeys.append( resource->identifier() ); 330 activeKeys.append( resource->identifier() );
329 mConfig->writeEntry( "ResourceKeys", activeKeys ); 331 mConfig->writeEntry( "ResourceKeys", activeKeys );
330 } else if ( !resource->isActive() && activeKeys.contains( key ) ) { 332 } else if ( !resource->isActive() && activeKeys.contains( key ) ) {
331 activeKeys.remove( key ); 333 activeKeys.remove( key );
332 mConfig->writeEntry( "ResourceKeys", activeKeys ); 334 mConfig->writeEntry( "ResourceKeys", activeKeys );
333 } 335 }
334 } 336 }
335 337
336 mConfig->sync(); 338 mConfig->sync();
337} 339}
338 340
339void ManagerImpl::removeResource( Resource *resource ) 341void ManagerImpl::removeResource( Resource *resource )
340{ 342{
341 QString key = resource->identifier(); 343 QString key = resource->identifier();
342 344
343 if ( !mConfig ) createStandardConfig(); 345 if ( !mConfig ) createStandardConfig();
344 346
345 mConfig->setGroup( "General" ); 347 mConfig->setGroup( "General" );
346 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" ); 348 QStringList activeKeys = mConfig->readListEntry( "ResourceKeys" );
347 if ( activeKeys.contains( key ) ) { 349 if ( activeKeys.contains( key ) ) {
348 activeKeys.remove( key ); 350 activeKeys.remove( key );
349 mConfig->writeEntry( "ResourceKeys", activeKeys ); 351 mConfig->writeEntry( "ResourceKeys", activeKeys );
350 } else { 352 } else {
351 QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" ); 353 QStringList passiveKeys = mConfig->readListEntry( "PassiveResourceKeys" );
352 passiveKeys.remove( key ); 354 passiveKeys.remove( key );
353 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys ); 355 mConfig->writeEntry( "PassiveResourceKeys", passiveKeys );
354 } 356 }
355 357
356 QString standardKey = mConfig->readEntry( "Standard" ); 358 QString standardKey = mConfig->readEntry( "Standard" );
357 if ( standardKey == key ) { 359 if ( standardKey == key ) {
358 mConfig->writeEntry( "Standard", "" ); 360 mConfig->writeEntry( "Standard", "" );
359 } 361 }
360 362
361 mConfig->deleteGroup( "Resource_" + resource->identifier() ); 363 mConfig->deleteGroup( "Resource_" + resource->identifier() );
362 364
363 mConfig->sync(); 365 mConfig->sync();
364} 366}
365 367
366Resource* ManagerImpl::getResource( const QString& identifier ) 368Resource* ManagerImpl::getResource( const QString& identifier )
367{ 369{
368 Resource::List::ConstIterator it; 370 Resource::List::ConstIterator it;
369 for ( it = mResources.begin(); it != mResources.end(); ++it ) { 371 for ( it = mResources.begin(); it != mResources.end(); ++it ) {
370 if ( (*it)->identifier() == identifier ) 372 if ( (*it)->identifier() == identifier )
371 return *it; 373 return *it;
372 } 374 }
373 return 0; 375 return 0;
374} 376}
375 377
376 378
diff --git a/microkde/kresources/managerimpl.h b/microkde/kresources/managerimpl.h
index 56a2db6..1f728e5 100644
--- a/microkde/kresources/managerimpl.h
+++ b/microkde/kresources/managerimpl.h
@@ -1,120 +1,120 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KRESOURCES_MANAGERIMPL_H 31#ifndef KRESOURCES_MANAGERIMPL_H
32#define KRESOURCES_MANAGERIMPL_H 32#define KRESOURCES_MANAGERIMPL_H
33 33
34#include <qstring.h> 34#include <qstring.h>
35#include <qptrlist.h> 35#include <q3ptrlist.h>
36#include <qdict.h> 36#include <q3dict.h>
37//US 37//US
38#include <qobject.h> 38#include <qobject.h>
39 39
40#include "resource.h" 40#include "resource.h"
41 41
42 42
43class KConfig; 43class KConfig;
44 44
45namespace KRES { 45namespace KRES {
46 46
47class Resource; 47class Resource;
48class Factory; 48class Factory;
49 49
50class ManagerImplListener 50class ManagerImplListener
51{ 51{
52 public: 52 public:
53 virtual void resourceAdded( Resource *resource ) = 0; 53 virtual void resourceAdded( Resource *resource ) = 0;
54 virtual void resourceModified( Resource *resource ) = 0; 54 virtual void resourceModified( Resource *resource ) = 0;
55 virtual void resourceDeleted( Resource *resource ) = 0; 55 virtual void resourceDeleted( Resource *resource ) = 0;
56}; 56};
57 57
58 58
59/** 59/**
60 @internal 60 @internal
61 61
62 Do not use this class directly. Use ResourceManager instead 62 Do not use this class directly. Use ResourceManager instead
63*/ 63*/
64class ManagerImpl : public QObject 64class ManagerImpl : public QObject
65{ 65{
66 Q_OBJECT 66 Q_OBJECT
67 public: 67 public:
68 ManagerImpl( const QString &family); 68 ManagerImpl( const QString &family);
69 ~ManagerImpl(); 69 ~ManagerImpl();
70 70
71 void readConfig( KConfig * ); 71 void readConfig( KConfig * );
72 void writeConfig( KConfig * ); 72 void writeConfig( KConfig * );
73 73
74 void add( Resource *resource, bool useDCOP = true ); 74 void add( Resource *resource, bool useDCOP = true );
75 void remove( Resource *resource, bool useDCOP = true ); 75 void remove( Resource *resource, bool useDCOP = true );
76 76
77 Resource *standardResource(); 77 Resource *standardResource();
78 void setStandardResource( Resource *resource ); 78 void setStandardResource( Resource *resource );
79 79
80 void setActive( Resource *resource, bool active ); 80 void setActive( Resource *resource, bool active );
81 81
82 Resource::List *resourceList(); 82 Resource::List *resourceList();
83 83
84 QPtrList<Resource> resources(); 84 Q3PtrList<Resource> resources();
85 85
86 // Get only active or passive resources 86 // Get only active or passive resources
87 QPtrList<Resource> resources( bool active ); 87 Q3PtrList<Resource> resources( bool active );
88 88
89 QStringList resourceNames(); 89 QStringList resourceNames();
90 90
91 void setListener( ManagerImplListener *listener ); 91 void setListener( ManagerImplListener *listener );
92 92
93 public slots: 93 public slots:
94 void resourceChanged( Resource *resource ); 94 void resourceChanged( Resource *resource );
95 95
96 private: 96 private:
97 // dcop calls 97 // dcop calls
98 98
99 private: 99 private:
100 void createStandardConfig(); 100 void createStandardConfig();
101 101
102 Resource *readResourceConfig( const QString& identifier, bool checkActive ); 102 Resource *readResourceConfig( const QString& identifier, bool checkActive );
103 void writeResourceConfig( Resource *resource, bool checkActive ); 103 void writeResourceConfig( Resource *resource, bool checkActive );
104 104
105 void removeResource( Resource *resource ); 105 void removeResource( Resource *resource );
106 Resource *getResource( Resource *resource ); 106 Resource *getResource( Resource *resource );
107 Resource *getResource( const QString& identifier ); 107 Resource *getResource( const QString& identifier );
108 108
109 QString mFamily; 109 QString mFamily;
110 KConfig *mConfig; 110 KConfig *mConfig;
111 KConfig *mStdConfig; 111 KConfig *mStdConfig;
112 Resource *mStandard; 112 Resource *mStandard;
113 Factory *mFactory; 113 Factory *mFactory;
114 Resource::List mResources; 114 Resource::List mResources;
115 ManagerImplListener *mListener; 115 ManagerImplListener *mListener;
116}; 116};
117 117
118} 118}
119 119
120#endif 120#endif
diff --git a/microkde/kresources/resource.h b/microkde/kresources/resource.h
index ed5af96..1f9527c 100644
--- a/microkde/kresources/resource.h
+++ b/microkde/kresources/resource.h
@@ -1,404 +1,404 @@
1/* 1/*
2 This file is part of libkresources 2 This file is part of libkresources
3 3
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 6
7 This library is free software; you can redistribute it and/or 7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public 8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either 9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version. 10 version 2 of the License, or (at your option) any later version.
11 11
12 This library is distributed in the hope that it will be useful, 12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details. 15 Library General Public License for more details.
16 16
17 You should have received a copy of the GNU Library General Public License 17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to 18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. 20 Boston, MA 02111-1307, USA.
21*/ 21*/
22 22
23#ifndef KRESOURCES_RESOURCE_H 23#ifndef KRESOURCES_RESOURCE_H
24#define KRESOURCES_RESOURCE_H 24#define KRESOURCES_RESOURCE_H
25 25
26//US 26//US
27#ifdef QT_THREAD_SUPPORT 27#ifdef QT_THREAD_SUPPORT
28#include <qmutex.h> 28#include <qmutex.h>
29#endif //QT_THREAD_SUPPORT 29#endif //QT_THREAD_SUPPORT
30 30
31#include <qvaluelist.h> 31#include <q3valuelist.h>
32#include <qwidget.h> 32#include <qwidget.h>
33 33
34#include <qobject.h> 34#include <qobject.h>
35 35
36#include <klibloader.h> 36#include <klibloader.h>
37 37
38class KConfig; 38class KConfig;
39 39
40namespace KRES { 40namespace KRES {
41 41
42class ConfigWidget; 42class ConfigWidget;
43 43
44/** 44/**
45 * @internal 45 * @internal
46 * @libdoc The KDE Resource library 46 * @libdoc The KDE Resource library
47 * 47 *
48 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this 48 * NOTE: this library is NOT (YET?) PUBLIC. Do not publish this
49 * interface, it is in constant flux. 49 * interface, it is in constant flux.
50 * 50 *
51 * The KDE Resource framework can be used to manage resources of 51 * The KDE Resource framework can be used to manage resources of
52 * different types, organized in families. The Resource framework 52 * different types, organized in families. The Resource framework
53 * is currently used for addressbook resources in libkabc and for 53 * is currently used for addressbook resources in libkabc and for
54 * calendar resources in libkcal. 54 * calendar resources in libkcal.
55 * 55 *
56 * When you want to use the framework for a new family, you need to 56 * When you want to use the framework for a new family, you need to
57 * <ul><li>Define a name for your resource family</li> 57 * <ul><li>Define a name for your resource family</li>
58 * <li>subclass Resource and add the fields and method that are needed 58 * <li>subclass Resource and add the fields and method that are needed
59 * in your application</li> 59 * in your application</li>
60 * <li>If needed, override the doOpen() and doClose() methods. 60 * <li>If needed, override the doOpen() and doClose() methods.
61 * <li> Provide a configuration possibility for resources in your 61 * <li> Provide a configuration possibility for resources in your
62 * new family. You can use @ref ResourcesConfigPage to easily create a 62 * new family. You can use @ref ResourcesConfigPage to easily create a
63 * KControl applet</li> 63 * KControl applet</li>
64 * <li>In your application, you can use @ref ResourceManager to keep track 64 * <li>In your application, you can use @ref ResourceManager to keep track
65 * of the resources in your family, and you can use @ref ResourceSelectDialog 65 * of the resources in your family, and you can use @ref ResourceSelectDialog
66 * to let the user select a single resource.</li> 66 * to let the user select a single resource.</li>
67 * </ul> 67 * </ul>
68 * 68 *
69 * When you want to add a new resource type to an existing resource family, 69 * When you want to add a new resource type to an existing resource family,
70 * you need to 70 * you need to
71 * <ul><li>Further subclass the family-specific Resource to implement 71 * <ul><li>Further subclass the family-specific Resource to implement
72 * resource type-specific operation</li> 72 * resource type-specific operation</li>
73 * <li>Subclass ResourceConfigWidget to provide a configuration widget 73 * <li>Subclass ResourceConfigWidget to provide a configuration widget
74 * for your new resource type</li> 74 * for your new resource type</li>
75 * <li>Provide a .desktop file so that the new resource type can be found 75 * <li>Provide a .desktop file so that the new resource type can be found
76 * automatically by the ResourceManager</li> 76 * automatically by the ResourceManager</li>
77 * </ul> 77 * </ul>
78 * 78 *
79 * Example: 79 * Example:
80 * 80 *
81<B>resourceexample.h</B>: 81<B>resourceexample.h</B>:
82<pre> 82<pre>
83#include <kconfig.h> 83#include <kconfig.h>
84#include <kresources/resource.h> 84#include <kresources/resource.h>
85 85
86class ResourceExample : public KRES::ResourceExample 86class ResourceExample : public KRES::ResourceExample
87{ 87{
88public: 88public:
89 ResourceExample( const KConfig * ); 89 ResourceExample( const KConfig * );
90 ~ResourceCalendarExchange(); 90 ~ResourceCalendarExchange();
91 void writeConfig( KConfig *config ); 91 void writeConfig( KConfig *config );
92private: 92private:
93 QString mLocation; 93 QString mLocation;
94 QString mPassword; 94 QString mPassword;
95} 95}
96</pre> 96</pre>
97<B>resourceexample.cpp</B>: 97<B>resourceexample.cpp</B>:
98<pre> 98<pre>
99#include <kconfig.h> 99#include <kconfig.h>
100 100
101#include "resourceexample.h" 101#include "resourceexample.h"
102 102
103ResourceExample::ResourceExample( const KConfig *config ) 103ResourceExample::ResourceExample( const KConfig *config )
104 : Resource( config ) 104 : Resource( config )
105{ 105{
106 if ( config ) { 106 if ( config ) {
107 mLocation = config->readEntry( "Location" ); 107 mLocation = config->readEntry( "Location" );
108 mPassword = KStringHandler::obscure( config->readEntry( "Password" ) ); 108 mPassword = KStringHandler::obscure( config->readEntry( "Password" ) );
109 } else { 109 } else {
110 mLocation = ""; // Or some sensible default 110 mLocation = ""; // Or some sensible default
111 mPassword = ""; 111 mPassword = "";
112 } 112 }
113} 113}
114 114
115void ResourceExample::writeConfig( KConfig *config ) 115void ResourceExample::writeConfig( KConfig *config )
116{ 116{
117 KRES::Resource::writeConfig( config ); 117 KRES::Resource::writeConfig( config );
118 config->writeEntry( "Location", mLocation ); 118 config->writeEntry( "Location", mLocation );
119 config->writeEntry( "Password", KStringHandler::obscure( mPassword ) ); 119 config->writeEntry( "Password", KStringHandler::obscure( mPassword ) );
120} 120}
121 121
122extern "C" 122extern "C"
123{ 123{
124 KRES::ResourceExample *config_widget( QWidget *parent ) { 124 KRES::ResourceExample *config_widget( QWidget *parent ) {
125 return new ResourceExampleConfig( parent, "Configure Example Resource" ); 125 return new ResourceExampleConfig( parent, "Configure Example Resource" );
126 } 126 }
127 127
128 KRES::Resource *resource( const KConfig *config ) { 128 KRES::Resource *resource( const KConfig *config ) {
129 return new ResourceExample( config ); 129 return new ResourceExample( config );
130 } 130 }
131} 131}
132</pre> 132</pre>
133* <B>resourceexampleconfig.h</B>: 133* <B>resourceexampleconfig.h</B>:
134<pre> 134<pre>
135#include <klineedit.h> 135#include <klineedit.h>
136#include <kresources/resourceconfigwidget.h> 136#include <kresources/resourceconfigwidget.h>
137 137
138#include "resourceexample.h" 138#include "resourceexample.h"
139 139
140class ResourceExampleConfig : public KRES::ResourceConfigWidget 140class ResourceExampleConfig : public KRES::ResourceConfigWidget
141{ 141{
142 Q_OBJECT 142 Q_OBJECT
143 143
144public: 144public:
145 ResourceExampleConfig( QWidget* parent = 0, const char* name = 0 ); 145 ResourceExampleConfig( QWidget* parent = 0, const char* name = 0 );
146 146
147public slots: 147public slots:
148 virtual void loadSettings( KRES::Resource *resource); 148 virtual void loadSettings( KRES::Resource *resource);
149 virtual void saveSettings( KRES::Resource *resource ); 149 virtual void saveSettings( KRES::Resource *resource );
150 150
151private: 151private:
152 KLineEdit* mLocationEdit; 152 KLineEdit* mLocationEdit;
153 KLineEdit* mPasswordEdit; 153 KLineEdit* mPasswordEdit;
154}; 154};
155</pre> 155</pre>
156* <B>resourceexampleconfig.cpp</B>: 156* <B>resourceexampleconfig.cpp</B>:
157<pre> 157<pre>
158#include <qlayout.h> 158#include <qlayout.h>
159#include <qlabel.h" 159#include <qlabel.h"
160#include <kresources/resourceconfigwidget.h> 160#include <kresources/resourceconfigwidget.h>
161#include "resourceexample.h" 161#include "resourceexample.h"
162#include "resourceexampleconfig.h" 162#include "resourceexampleconfig.h"
163 163
164ResourceExampleConfig::ResourceExampleConfig( QWidget* parent, const char* name ) 164ResourceExampleConfig::ResourceExampleConfig( QWidget* parent, const char* name )
165 : KRES::ResourceConfigWidget( parent, name ) 165 : KRES::ResourceConfigWidget( parent, name )
166{ 166{
167 resize( 245, 115 ); 167 resize( 245, 115 );
168 QGridLayout *mainLayout = new QGridLayout( this, 2, 2 ); 168 QGridLayout *mainLayout = new QGridLayout( this, 2, 2 );
169 169
170 QLabel *label = new QLabel( i18n( "Location:" ), this ); 170 QLabel *label = new QLabel( i18n( "Location:" ), this );
171 mHostEdit = new KLineEdit( this ); 171 mHostEdit = new KLineEdit( this );
172 mainLayout->addWidget( label, 1, 0 ); 172 mainLayout->addWidget( label, 1, 0 );
173 mainLayout->addWidget( mHostEdit, 1, 1 ); 173 mainLayout->addWidget( mHostEdit, 1, 1 );
174 174
175 label = new QLabel( i18n( "Password:" ), this ); 175 label = new QLabel( i18n( "Password:" ), this );
176 mPasswordEdit = new KLineEdit( this ); 176 mPasswordEdit = new KLineEdit( this );
177 mPasswordEdit->setEchoMode( QLineEdit::Password ); 177 mPasswordEdit->setEchoMode( QLineEdit::Password );
178 mainLayout->addWidget( label, 2, 0 ); 178 mainLayout->addWidget( label, 2, 0 );
179 mainLayout->addWidget( mPasswordEdit, 2, 1 ); 179 mainLayout->addWidget( mPasswordEdit, 2, 1 );
180} 180}
181 181
182void ResourceExampleConfig::loadSettings( KRES::Resource *resource ) 182void ResourceExampleConfig::loadSettings( KRES::Resource *resource )
183{ 183{
184 ResourceExample* res = dynamic_cast<ResourceExample *>( resource ); 184 ResourceExample* res = dynamic_cast<ResourceExample *>( resource );
185 if (res) { 185 if (res) {
186 mHostEdit->setText( res->host() ); 186 mHostEdit->setText( res->host() );
187 mPasswordEdit->setText( res->password() ); 187 mPasswordEdit->setText( res->password() );
188 } else 188 } else
189 kdDebug(5700) << "ERROR: ResourceExampleConfig::loadSettings(): no ResourceExample, cast failed" << endl; 189 kdDebug(5700) << "ERROR: ResourceExampleConfig::loadSettings(): no ResourceExample, cast failed" << endl;
190} 190}
191 191
192void ResourceExampleConfig::saveSettings( KRES::Resource *resource ) 192void ResourceExampleConfig::saveSettings( KRES::Resource *resource )
193{ 193{
194 ResourceExample* res = dynamic_cast<ResourceExample *>( resource ); 194 ResourceExample* res = dynamic_cast<ResourceExample *>( resource );
195 if (res) { 195 if (res) {
196 res->setHost(mHostEdit->text()); 196 res->setHost(mHostEdit->text());
197 res->setPassword(mPasswordEdit->text()); 197 res->setPassword(mPasswordEdit->text());
198 } else 198 } else
199 kdDebug(5700) << "ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed" << endl; 199 kdDebug(5700) << "ERROR: ResourceExampleConfig::saveSettings(): no ResourceExample, cast failed" << endl;
200} 200}
201</pre> 201</pre>
202* <B>resourceexample.desktop</B>: 202* <B>resourceexample.desktop</B>:
203<pre> 203<pre>
204[Desktop Entry] 204[Desktop Entry]
205Type=Service 205Type=Service
206 206
207[Misc] 207[Misc]
208Encoding=UTF-8 208Encoding=UTF-8
209Name=Example Resource 209Name=Example Resource
210 210
211[Plugin] 211[Plugin]
212Type=exchange 212Type=exchange
213X-KDE-Library=resourceexample 213X-KDE-Library=resourceexample
214</pre> 214</pre>
215* <B>Makefile.am</B> 215* <B>Makefile.am</B>
216<pre> 216<pre>
217kde_module_LTLIBRARIES = resourceexample.la 217kde_module_LTLIBRARIES = resourceexample.la
218 218
219resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp 219resourceexample_la_SOURCES = resourceexample.cpp resourceexampleconfig.cpp
220resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN) 220resourceexample_la_LDFLAGS= $(all_libraries) -module $(KDE_PLUGIN)
221resourceexample_la_LIBADD= -lkderesources 221resourceexample_la_LIBADD= -lkderesources
222 222
223linkdir= $(kde_datadir)/resources/family 223linkdir= $(kde_datadir)/resources/family
224link_DATA= resourceexample.desktop 224link_DATA= resourceexample.desktop
225</pre> 225</pre>
226 * 226 *
227 * 227 *
228 */ 228 */
229 229
230/** 230/**
231 * A @ref Resource is a ... 231 * A @ref Resource is a ...
232 * 232 *
233 * A subclass should reimplement at least the constructor and the 233 * A subclass should reimplement at least the constructor and the
234k * @ref writeConfig method. 234k * @ref writeConfig method.
235 * 235 *
236 */ 236 */
237class Resource : public QObject 237class Resource : public QObject
238{ 238{
239 Q_OBJECT 239 Q_OBJECT
240 240
241 public: 241 public:
242 typedef QValueList<Resource *> List; 242 typedef Q3ValueList<Resource *> List;
243 243
244 /** 244 /**
245 * Constructor. Construct resource from config. 245 * Constructor. Construct resource from config.
246 * @param config Configuration to read persistence information from. 246 * @param config Configuration to read persistence information from.
247 * If config==0, create object using default settings. 247 * If config==0, create object using default settings.
248 */ 248 */
249 Resource( const KConfig* config ); 249 Resource( const KConfig* config );
250 250
251 /** 251 /**
252 * Destructor. 252 * Destructor.
253 */ 253 */
254 virtual ~Resource(); 254 virtual ~Resource();
255 255
256 /** 256 /**
257 * Write configuration information for this resource to a configuration 257 * Write configuration information for this resource to a configuration
258 * file. If you override this method, remember to call Resource::writeConfig 258 * file. If you override this method, remember to call Resource::writeConfig
259 * or Terrible Things(TM) will happen. 259 * or Terrible Things(TM) will happen.
260 * @param config Configuration to write persistence information to. 260 * @param config Configuration to write persistence information to.
261 */ 261 */
262 virtual void writeConfig( KConfig* config ); 262 virtual void writeConfig( KConfig* config );
263 263
264 /** 264 /**
265 * Open this resource, if it not already open. Increase the open 265 * Open this resource, if it not already open. Increase the open
266 * count of this object, and open the resource by calling @ref doOpen(). 266 * count of this object, and open the resource by calling @ref doOpen().
267 * This method may block while another thread is concurrently opening 267 * This method may block while another thread is concurrently opening
268 * or closing the resource. 268 * or closing the resource.
269 * 269 *
270 * Returns true if the resource was already opened or if it was opened 270 * Returns true if the resource was already opened or if it was opened
271 * successfully; returns false if the resource was not opened successfully. 271 * successfully; returns false if the resource was not opened successfully.
272 */ 272 */
273 bool open(); 273 bool open();
274 274
275 /** 275 /**
276 * Decrease the open count of this object, and if the count reaches 276 * Decrease the open count of this object, and if the count reaches
277 * zero, close this resource by calling @ref doClose(). 277 * zero, close this resource by calling @ref doClose().
278 * This method may block while another thread is concurrently closing 278 * This method may block while another thread is concurrently closing
279 * or opening the resource. 279 * or opening the resource.
280 */ 280 */
281 void close(); 281 void close();
282 282
283 /** 283 /**
284 * Returns whether the resource is open or not. 284 * Returns whether the resource is open or not.
285 */ 285 */
286 bool isOpen() const; 286 bool isOpen() const;
287 287
288 /** 288 /**
289 * Returns a unique identifier. The identifier is unique for this resource. 289 * Returns a unique identifier. The identifier is unique for this resource.
290 * It is created when the resource is first created, and it is retained 290 * It is created when the resource is first created, and it is retained
291 * in the resource family configuration file for this resource. 291 * in the resource family configuration file for this resource.
292 * @return This resource's identifier 292 * @return This resource's identifier
293 */ 293 */
294 QString identifier() const; 294 QString identifier() const;
295 295
296 /** 296 /**
297 * Returns the type of this resource. 297 * Returns the type of this resource.
298 */ 298 */
299 QString type() const; 299 QString type() const;
300 300
301 /** 301 /**
302 * Mark the resource as read-only. You can override this method, 302 * Mark the resource as read-only. You can override this method,
303 * but also remember to call Resource::setReadOnly(). 303 * but also remember to call Resource::setReadOnly().
304 */ 304 */
305 virtual void setReadOnly( bool value ); 305 virtual void setReadOnly( bool value );
306 306
307 /** 307 /**
308 * Returns, if the resource is read-only. 308 * Returns, if the resource is read-only.
309 */ 309 */
310 virtual bool readOnly() const; 310 virtual bool readOnly() const;
311 311
312 void setIncludeInSync( bool value ); 312 void setIncludeInSync( bool value );
313 bool includeInSync() const; 313 bool includeInSync() const;
314 /** 314 /**
315 * Set the name of resource.You can override this method, 315 * Set the name of resource.You can override this method,
316 * but also remember to call Resource::setResourceName(). 316 * but also remember to call Resource::setResourceName().
317 */ 317 */
318 virtual void setResourceName( const QString &name ); 318 virtual void setResourceName( const QString &name );
319 319
320 /** 320 /**
321 * Returns the name of resource. 321 * Returns the name of resource.
322 */ 322 */
323 virtual QString resourceName() const; 323 virtual QString resourceName() const;
324 324
325 /** 325 /**
326 Sets, if the resource is active. 326 Sets, if the resource is active.
327 */ 327 */
328 void setActive( bool active ); 328 void setActive( bool active );
329 329
330 /** 330 /**
331 Return true, if the resource is active. 331 Return true, if the resource is active.
332 */ 332 */
333 bool isActive() const; 333 bool isActive() const;
334 334
335 friend class Factory; 335 friend class Factory;
336 friend class ManagerImpl; 336 friend class ManagerImpl;
337 337
338 /** 338 /**
339 Print resource information as debug output. 339 Print resource information as debug output.
340 */ 340 */
341 virtual void dump() const; 341 virtual void dump() const;
342 342
343 343
344 protected: 344 protected:
345 /** 345 /**
346 * Open this resource. When called, the resource must be in 346 * Open this resource. When called, the resource must be in
347 * a closed state. 347 * a closed state.
348 * 348 *
349 * Returns true if the resource was opened successfully; 349 * Returns true if the resource was opened successfully;
350 * returns false if the resource was not opened successfully. 350 * returns false if the resource was not opened successfully.
351 * 351 *
352 * The result of this call can be accessed later by @ref isOpen() 352 * The result of this call can be accessed later by @ref isOpen()
353 */ 353 */
354 virtual bool doOpen() { return true; } 354 virtual bool doOpen() { return true; }
355 355
356 /** 356 /**
357 * Close this resource. Pre-condition: resource is open. 357 * Close this resource. Pre-condition: resource is open.
358 * Post-condition: resource is closed. 358 * Post-condition: resource is closed.
359 */ 359 */
360 virtual void doClose() {} 360 virtual void doClose() {}
361 361
362 void setIdentifier( const QString& identifier ); 362 void setIdentifier( const QString& identifier );
363 void setType( const QString& type ); 363 void setType( const QString& type );
364 364
365 private: 365 private:
366 class ResourcePrivate; 366 class ResourcePrivate;
367 ResourcePrivate *d; 367 ResourcePrivate *d;
368}; 368};
369 369
370class PluginFactoryBase : public KLibFactory 370class PluginFactoryBase : public KLibFactory
371{ 371{
372 public: 372 public:
373 virtual Resource *resource( const KConfig *config) = 0; 373 virtual Resource *resource( const KConfig *config) = 0;
374 374
375 virtual ConfigWidget *configWidget( QWidget *parent ) = 0; 375 virtual ConfigWidget *configWidget( QWidget *parent ) = 0;
376 376
377 protected: 377 protected:
378 virtual QObject* createObject( QObject*, const char*, const char*, 378 virtual QObject* createObject( QObject*, const char*, const char*,
379 const QStringList & ) 379 const QStringList & )
380 { 380 {
381 return 0; 381 return 0;
382 } 382 }
383}; 383};
384 384
385template<class TR,class TC> 385template<class TR,class TC>
386class PluginFactory : public PluginFactoryBase 386class PluginFactory : public PluginFactoryBase
387{ 387{
388 public: 388 public:
389 Resource *resource( const KConfig *config) 389 Resource *resource( const KConfig *config)
390 { 390 {
391 return new TR( config ); 391 return new TR( config );
392 } 392 }
393 393
394 ConfigWidget *configWidget( QWidget *parent ) 394 ConfigWidget *configWidget( QWidget *parent )
395 { 395 {
396 return new TC( parent ); 396 return new TC( parent );
397 } 397 }
398}; 398};
399 399
400 400
401 401
402} 402}
403 403
404#endif 404#endif
diff --git a/microkde/kresources/selectdialog.cpp b/microkde/kresources/selectdialog.cpp
index fba8648..d5b83e9 100644
--- a/microkde/kresources/selectdialog.cpp
+++ b/microkde/kresources/selectdialog.cpp
@@ -1,154 +1,158 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24/*US 24/*US
25#include <kbuttonbox.h> 25#include <kbuttonbox.h>
26#include <klistbox.h> 26#include <klistbox.h>
27#include <klocale.h> 27#include <klocale.h>
28#include <kmessagebox.h> 28#include <kmessagebox.h>
29 29
30*/ 30*/
31#include <klocale.h> 31#include <klocale.h>
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33 33
34//US 34//US
35#include <kglobal.h> 35#include <kglobal.h>
36 36
37#include <qlistbox.h> 37#include <q3listbox.h>
38#include <qlayout.h> 38#include <qlayout.h>
39#include <qgroupbox.h> 39#include <q3groupbox.h>
40//Added by qt3to4:
41#include <Q3VBoxLayout>
42#include <Q3Frame>
43#include <Q3PtrList>
40 44
41#include "resource.h" 45#include "resource.h"
42 46
43#include "selectdialog.h" 47#include "selectdialog.h"
44 48
45using namespace KRES; 49using namespace KRES;
46 50
47//US I am using KBaseDialog instead of KDialog 51//US I am using KBaseDialog instead of KDialog
48//US : KDialog( parent, name, true ) 52//US : KDialog( parent, name, true )
49SelectDialog::SelectDialog( QPtrList<Resource> list, QWidget *parent, 53SelectDialog::SelectDialog( Q3PtrList<Resource> list, QWidget *parent,
50 const char *name ) 54 const char *name )
51 : KDialogBase( parent, name, true, i18n( "Resource Selection" ), Help | Ok | Cancel, 55 : KDialogBase( parent, name, true, i18n( "Resource Selection" ), Help | Ok | Cancel,
52 Ok, true) 56 Ok, true)
53 57
54{ 58{
55//US setCaption( i18n( "Resource Selection" ) ); 59//US setCaption( i18n( "Resource Selection" ) );
56//US resize( 300, 200 ); 60//US resize( 300, 200 );
57 resize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 200) ); 61 resize( KMIN(KGlobal::getDesktopWidth(), 300), KMIN(KGlobal::getDesktopHeight(), 200) );
58 62
59//US 63//US
60 QFrame *main = plainPage(); 64 Q3Frame *main = plainPage();
61/*US 65/*US
62 QVBoxLayout *layout = new QVBoxLayout( main ); 66 QVBoxLayout *layout = new QVBoxLayout( main );
63 mConfigPage = new KRES::ConfigPage( main ); 67 mConfigPage = new KRES::ConfigPage( main );
64 layout->addWidget( mConfigPage ); 68 layout->addWidget( mConfigPage );
65*/ 69*/
66 70
67//US QVBoxLayout *mainLayout = new QVBoxLayout( this ); 71//US QVBoxLayout *mainLayout = new QVBoxLayout( this );
68 QVBoxLayout *mainLayout = new QVBoxLayout( main ); 72 Q3VBoxLayout *mainLayout = new Q3VBoxLayout( main );
69 mainLayout->setMargin( marginHint() ); 73 mainLayout->setMargin( marginHint() );
70 74
71//US QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, this ); 75//US QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, this );
72 QGroupBox *groupBox = new QGroupBox( 2, Qt::Horizontal, main ); 76 Q3GroupBox *groupBox = new Q3GroupBox( 2, Qt::Horizontal, main );
73 groupBox->setTitle( i18n( "Resources" ) ); 77 groupBox->setTitle( i18n( "Resources" ) );
74 78
75//US mResourceId = new KListBox( groupBox ); 79//US mResourceId = new KListBox( groupBox );
76 mResourceId = new QListBox( groupBox ); 80 mResourceId = new Q3ListBox( groupBox );
77 81
78 mainLayout->addWidget( groupBox ); 82 mainLayout->addWidget( groupBox );
79 83
80 mainLayout->addSpacing( 40 ); 84 mainLayout->addSpacing( 40 );
81 85
82/*US 86/*US
83 KButtonBox *buttonBox = new KButtonBox( this ); 87 KButtonBox *buttonBox = new KButtonBox( this );
84 88
85 buttonBox->addStretch(); 89 buttonBox->addStretch();
86 buttonBox->addButton( i18n( "&OK" ), this, SLOT( accept() ) ); 90 buttonBox->addButton( i18n( "&OK" ), this, SLOT( accept() ) );
87 buttonBox->addButton( i18n( "&Cancel" ), this, SLOT( reject() ) ); 91 buttonBox->addButton( i18n( "&Cancel" ), this, SLOT( reject() ) );
88 buttonBox->layout(); 92 buttonBox->layout();
89 93
90 mainLayout->addWidget( buttonBox ); 94 mainLayout->addWidget( buttonBox );
91*/ 95*/
92 // setup listbox 96 // setup listbox
93 uint counter = 0; 97 uint counter = 0;
94 for ( uint i = 0; i < list.count(); ++i ) { 98 for ( uint i = 0; i < list.count(); ++i ) {
95 Resource *resource = list.at( i ); 99 Resource *resource = list.at( i );
96 if ( resource && !resource->readOnly() ) { 100 if ( resource && !resource->readOnly() ) {
97 mResourceMap.insert( counter, resource ); 101 mResourceMap.insert( counter, resource );
98 mResourceId->insertItem( resource->resourceName() ); 102 mResourceId->insertItem( resource->resourceName() );
99 counter++; 103 counter++;
100 } 104 }
101 } 105 }
102 106
103 mResourceId->setCurrentItem( 0 ); 107 mResourceId->setCurrentItem( 0 );
104 connect( mResourceId, SIGNAL(returnPressed(QListBoxItem*)), 108 connect( mResourceId, SIGNAL(returnPressed(Q3ListBoxItem*)),
105 SLOT(accept()) ); 109 SLOT(accept()) );
106} 110}
107 111
108Resource *SelectDialog::resource() 112Resource *SelectDialog::resource()
109{ 113{
110 if ( mResourceId->currentItem() != -1 ) 114 if ( mResourceId->currentItem() != -1 )
111 return mResourceMap[ mResourceId->currentItem() ]; 115 return mResourceMap[ mResourceId->currentItem() ];
112 else 116 else
113 return 0; 117 return 0;
114} 118}
115 119
116Resource *SelectDialog::getResource( QPtrList<Resource> list, QWidget *parent ) 120Resource *SelectDialog::getResource( Q3PtrList<Resource> list, QWidget *parent )
117{ 121{
118 if ( list.count() == 0 ) { 122 if ( list.count() == 0 ) {
119 KMessageBox::error( parent, i18n( "There is no resource available!" ) ); 123 KMessageBox::error( parent, i18n( "There is no resource available!" ) );
120 return 0; 124 return 0;
121 } 125 }
122 126
123 if ( list.count() == 1 ) return list.first(); 127 if ( list.count() == 1 ) return list.first();
124 128
125 // the following lines will return a writeable resource if only _one_ writeable 129 // the following lines will return a writeable resource if only _one_ writeable
126 // resource exists 130 // resource exists
127 Resource *found = 0; 131 Resource *found = 0;
128 Resource *it = list.first(); 132 Resource *it = list.first();
129 while ( it ) { 133 while ( it ) {
130 if ( !it->readOnly() ) { 134 if ( !it->readOnly() ) {
131 if ( found ) { 135 if ( found ) {
132 found = 0; 136 found = 0;
133 break; 137 break;
134 } else 138 } else
135 found = it; 139 found = it;
136 } 140 }
137 it = list.next(); 141 it = list.next();
138 } 142 }
139 143
140 if ( found ) 144 if ( found )
141 return found; 145 return found;
142 146
143 SelectDialog dlg( list, parent); 147 SelectDialog dlg( list, parent);
144//US if ( dlg.exec() == KDialog::Accepted ) 148//US if ( dlg.exec() == KDialog::Accepted )
145 if ( dlg.exec() ) 149 if ( dlg.exec() )
146 return dlg.resource(); 150 return dlg.resource();
147 else 151 else
148 return 0; 152 return 0;
149} 153}
150 154
151/*US 155/*US
152#include "selectdialog.moc" 156#include "selectdialog.moc"
153*/ 157*/
154 158
diff --git a/microkde/kresources/selectdialog.h b/microkde/kresources/selectdialog.h
index 7026212..be5152b 100644
--- a/microkde/kresources/selectdialog.h
+++ b/microkde/kresources/selectdialog.h
@@ -1,92 +1,92 @@
1/* 1/*
2 This file is part of libkresources. 2 This file is part of libkresources.
3 3
4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org> 4 Copyright (c) 2002 Tobias Koenig <tokoe@kde.org>
5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org> 5 Copyright (c) 2002 Jan-Pascal van Best <janpascal@vanbest.org>
6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> 6 Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
11 version 2 of the License, or (at your option) any later version. 11 version 2 of the License, or (at your option) any later version.
12 12
13 This library is distributed in the hope that it will be useful, 13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Library General Public License for more details. 16 Library General Public License for more details.
17 17
18 You should have received a copy of the GNU Library General Public License 18 You should have received a copy of the GNU Library General Public License
19 along with this library; see the file COPYING.LIB. If not, write to 19 along with this library; see the file COPYING.LIB. If not, write to
20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 20 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 Boston, MA 02111-1307, USA. 21 Boston, MA 02111-1307, USA.
22*/ 22*/
23 23
24#ifndef KRESOURCES_SELECTDIALOG_H 24#ifndef KRESOURCES_SELECTDIALOG_H
25#define KRESOURCES_SELECTDIALOG_H 25#define KRESOURCES_SELECTDIALOG_H
26 26
27#include <qobject.h> 27#include <qobject.h>
28#include <qptrlist.h> 28#include <q3ptrlist.h>
29#include <qmap.h> 29#include <qmap.h>
30 30
31#include <kdialogbase.h> 31#include <kdialogbase.h>
32 32
33//US class KListBox; 33//US class KListBox;
34class QListBox; 34class Q3ListBox;
35 35
36namespace KRES { 36namespace KRES {
37 37
38class Resource; 38class Resource;
39 39
40/** 40/**
41 * Dialog for selecting a resource. 41 * Dialog for selecting a resource.
42 * 42 *
43 * Example: 43 * Example:
44 * 44 *
45 * <pre> 45 * <pre>
46 * KABC::Resource *res = KABC::SelectDialog::getResource(); 46 * KABC::Resource *res = KABC::SelectDialog::getResource();
47 * if ( !( res ) ) { 47 * if ( !( res ) ) {
48 * // no resource selected 48 * // no resource selected
49 * } else { 49 * } else {
50 * // do something with resource 50 * // do something with resource
51 * } 51 * }
52 * </pre> 52 * </pre>
53 */ 53 */
54//US class SelectDialog : KDialog 54//US class SelectDialog : KDialog
55class SelectDialog : KDialogBase 55class SelectDialog : KDialogBase
56{ 56{
57 // Q_OBJECT 57 // Q_OBJECT
58 public: 58 public:
59 /** 59 /**
60 * Constructor. 60 * Constructor.
61 * @param ab The address book you want to select the resource from 61 * @param ab The address book you want to select the resource from
62 * @param parent The parent widget 62 * @param parent The parent widget
63 * @param name The name of the dialog 63 * @param name The name of the dialog
64 */ 64 */
65 SelectDialog( QPtrList<Resource> list, QWidget *parent = 0, 65 SelectDialog( Q3PtrList<Resource> list, QWidget *parent = 0,
66 const char *name = 0); 66 const char *name = 0);
67 67
68 // ~SelectDialog(); 68 // ~SelectDialog();
69 69
70 /** 70 /**
71 * Return selected resource. 71 * Return selected resource.
72 */ 72 */
73 Resource *resource(); 73 Resource *resource();
74 74
75 /** 75 /**
76 * Open a dialog showing the available resources and return the resource the 76 * Open a dialog showing the available resources and return the resource the
77 * user has selected. Returns 0, if the dialog was canceled. 77 * user has selected. Returns 0, if the dialog was canceled.
78 */ 78 */
79 static Resource *getResource( QPtrList<Resource> list, QWidget *parent = 0 ); 79 static Resource *getResource( Q3PtrList<Resource> list, QWidget *parent = 0 );
80 80
81 private: 81 private:
82//US KListBox *mResourceId; 82//US KListBox *mResourceId;
83 QListBox *mResourceId; 83 Q3ListBox *mResourceId;
84 84
85 QMap<int, Resource*> mResourceMap; 85 QMap<int, Resource*> mResourceMap;
86}; 86};
87 87
88 88
89 89
90} 90}
91 91
92#endif 92#endif
diff --git a/microkde/ksystemtray.cpp b/microkde/ksystemtray.cpp
index 4f81d02..0d0045f 100644
--- a/microkde/ksystemtray.cpp
+++ b/microkde/ksystemtray.cpp
@@ -1,11 +1,14 @@
1#include "ksystemtray.h" 1#include "ksystemtray.h"
2//Added by qt3to4:
3#include <QMouseEvent>
4#include <QLabel>
2 5
3void KSystemTray::mousePressEvent( QMouseEvent *) 6void KSystemTray::mousePressEvent( QMouseEvent *)
4{ 7{
5 ; //qDebug("hallo"); 8 ; //qDebug("hallo");
6} 9}
7 10
8KSystemTray::KSystemTray( QWidget *parent ) : QLabel( parent ) 11KSystemTray::KSystemTray( QWidget *parent ) : QLabel( parent )
9{ 12{
10 13
11} 14}
diff --git a/microkde/ksystemtray.h b/microkde/ksystemtray.h
index f3e4f6a..6708c86 100644
--- a/microkde/ksystemtray.h
+++ b/microkde/ksystemtray.h
@@ -1,14 +1,16 @@
1#ifndef MICROKDE_KSYSTEMTRAY_H 1#ifndef MICROKDE_KSYSTEMTRAY_H
2#define MICROKDE_KSYSTEMTRAY_H 2#define MICROKDE_KSYSTEMTRAY_H
3 3
4#include <qlabel.h> 4#include <qlabel.h>
5//Added by qt3to4:
6#include <QMouseEvent>
5 7
6class KSystemTray : public QLabel 8class KSystemTray : public QLabel
7{ 9{
8 Q_OBJECT 10 Q_OBJECT
9 public: 11 public:
10 KSystemTray( QWidget *parent = 0 ); 12 KSystemTray( QWidget *parent = 0 );
11 void mousePressEvent( QMouseEvent *); 13 void mousePressEvent( QMouseEvent *);
12}; 14};
13 15
14#endif 16#endif
diff --git a/microkde/ktempfile.cpp b/microkde/ktempfile.cpp
index b9166bd..d61d22e 100644
--- a/microkde/ktempfile.cpp
+++ b/microkde/ktempfile.cpp
@@ -1,25 +1,25 @@
1#include <qtextstream.h> 1#include <q3textstream.h>
2 2
3#include "ktempfile.h" 3#include "ktempfile.h"
4 4
5KTempFile::KTempFile() 5KTempFile::KTempFile()
6{ 6{
7} 7}
8 8
9KTempFile::KTempFile( const QString &filename, const QString &extension ) 9KTempFile::KTempFile( const QString &filename, const QString &extension )
10{ 10{
11} 11}
12 12
13void KTempFile::setAutoDelete( bool ) 13void KTempFile::setAutoDelete( bool )
14{ 14{
15} 15}
16 16
17QString KTempFile::name() 17QString KTempFile::name()
18{ 18{
19 return QString::null; 19 return QString::null;
20} 20}
21 21
22QTextStream *KTempFile::textStream() 22Q3TextStream *KTempFile::textStream()
23{ 23{
24 return 0; 24 return 0;
25} 25}
diff --git a/microkde/ktempfile.h b/microkde/ktempfile.h
index 20dfa82..1ac7258 100644
--- a/microkde/ktempfile.h
+++ b/microkde/ktempfile.h
@@ -1,20 +1,20 @@
1#ifndef MINIKDE_KTEMPFILE_H 1#ifndef MINIKDE_KTEMPFILE_H
2#define MINIKDE_KTEMPFILE_H 2#define MINIKDE_KTEMPFILE_H
3 3
4#include <qstring.h> 4#include <qstring.h>
5 5
6class QTextStream; 6class Q3TextStream;
7 7
8class KTempFile 8class KTempFile
9{ 9{
10 public: 10 public:
11 KTempFile(); 11 KTempFile();
12 KTempFile( const QString &filename, const QString &extension ); 12 KTempFile( const QString &filename, const QString &extension );
13 13
14 void setAutoDelete( bool ); 14 void setAutoDelete( bool );
15 QString name(); 15 QString name();
16 16
17 QTextStream *textStream(); 17 Q3TextStream *textStream();
18}; 18};
19 19
20#endif 20#endif
diff --git a/microkde/ktextedit.cpp b/microkde/ktextedit.cpp
index 4dd6875..d74706b 100644
--- a/microkde/ktextedit.cpp
+++ b/microkde/ktextedit.cpp
@@ -1,53 +1,55 @@
1 1
2#include <ktextedit.h> 2#include <ktextedit.h>
3#ifndef DESKTOP_VERSION 3#ifndef DESKTOP_VERSION
4#include <qpe/qpeapplication.h> 4#include <qpe/qpeapplication.h>
5//Added by qt3to4:
6#include <QMouseEvent>
5#endif 7#endif
6 8
7 9
8KTextEdit::KTextEdit ( QWidget *parent ) : QMultiLineEdit( parent ) 10KTextEdit::KTextEdit ( QWidget *parent ) : Q3MultiLineEdit( parent )
9{ 11{
10 mAllowPopupMenu = false; 12 mAllowPopupMenu = false;
11 mMouseDown = false; 13 mMouseDown = false;
12 mIgnoreMark = false; 14 mIgnoreMark = false;
13#ifndef DESKTOP_VERSION 15#ifndef DESKTOP_VERSION
14 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold ); 16 QPEApplication::setStylusOperation( this, QPEApplication::RightOnHold );
15#endif 17#endif
16} 18}
17 19
18void KTextEdit::mousePressEvent(QMouseEvent *e) 20void KTextEdit::mousePressEvent(QMouseEvent *e)
19{ 21{
20 if ( e->button() == LeftButton ) { 22 if ( e->button() == Qt::LeftButton ) {
21 mAllowPopupMenu = true; 23 mAllowPopupMenu = true;
22 mYMousePos = mapToGlobal( (e->pos())).y(); 24 mYMousePos = mapToGlobal( (e->pos())).y();
23 mXMousePos = mapToGlobal( (e->pos())).x(); 25 mXMousePos = mapToGlobal( (e->pos())).x();
24 } 26 }
25 if ( e->button() == RightButton && !mAllowPopupMenu ) 27 if ( e->button() == Qt::RightButton && !mAllowPopupMenu )
26 return; 28 return;
27 if ( e->button() == LeftButton ) { 29 if ( e->button() == Qt::LeftButton ) {
28 if ( hasMarkedText () ) 30 if ( hasMarkedText () )
29 mIgnoreMark = !mIgnoreMark; 31 mIgnoreMark = !mIgnoreMark;
30 if ( mIgnoreMark && hasMarkedText () ) { 32 if ( mIgnoreMark && hasMarkedText () ) {
31 mMouseDown = false; 33 mMouseDown = false;
32 return ; 34 return ;
33 } 35 }
34 } 36 }
35 QMultiLineEdit::mousePressEvent( e ); 37 Q3MultiLineEdit::mousePressEvent( e );
36} 38}
37 39
38void KTextEdit::mouseReleaseEvent(QMouseEvent *e) 40void KTextEdit::mouseReleaseEvent(QMouseEvent *e)
39{ 41{
40 QMultiLineEdit::mouseReleaseEvent(e); 42 Q3MultiLineEdit::mouseReleaseEvent(e);
41} 43}
42 44
43void KTextEdit::mouseMoveEvent(QMouseEvent *e) 45void KTextEdit::mouseMoveEvent(QMouseEvent *e)
44{ 46{
45 int diff = mYMousePos - mapToGlobal( (e->pos())).y(); 47 int diff = mYMousePos - mapToGlobal( (e->pos())).y();
46 if ( diff < 0 ) diff = -diff; 48 if ( diff < 0 ) diff = -diff;
47 int diff2 = mXMousePos - mapToGlobal( (e->pos())).x(); 49 int diff2 = mXMousePos - mapToGlobal( (e->pos())).x();
48 if ( diff2 < 0 ) diff2 = -diff2; 50 if ( diff2 < 0 ) diff2 = -diff2;
49 if ( diff+ diff2 > 20 ) 51 if ( diff+ diff2 > 20 )
50 mAllowPopupMenu = false; 52 mAllowPopupMenu = false;
51 QMultiLineEdit::mouseMoveEvent(e); 53 Q3MultiLineEdit::mouseMoveEvent(e);
52} 54}
53 55
diff --git a/microkde/ktextedit.h b/microkde/ktextedit.h
index 87c0602..b7c8924 100644
--- a/microkde/ktextedit.h
+++ b/microkde/ktextedit.h
@@ -1,23 +1,25 @@
1#ifndef MICROKDE_KTEXTEDIT_H 1#ifndef MICROKDE_KTEXTEDIT_H
2#define MICROKDE_KTEXTEDIT_H 2#define MICROKDE_KTEXTEDIT_H
3 3
4#include <qmultilineedit.h> 4#include <q3multilineedit.h>
5//Added by qt3to4:
6#include <QMouseEvent>
5 7
6class KTextEdit : public QMultiLineEdit 8class KTextEdit : public Q3MultiLineEdit
7{ 9{
8 public: 10 public:
9 KTextEdit( QWidget *parent ) ; 11 KTextEdit( QWidget *parent ) ;
10 void setIgnoreMark( bool b ) { mIgnoreMark = b; } 12 void setIgnoreMark( bool b ) { mIgnoreMark = b; }
11 13
12 private: 14 private:
13 bool mAllowPopupMenu; 15 bool mAllowPopupMenu;
14 bool mMouseDown; 16 bool mMouseDown;
15 bool mIgnoreMark; 17 bool mIgnoreMark;
16 int mYMousePos; 18 int mYMousePos;
17 int mXMousePos; 19 int mXMousePos;
18 void mousePressEvent(QMouseEvent *e); 20 void mousePressEvent(QMouseEvent *e);
19 void mouseReleaseEvent(QMouseEvent *e); 21 void mouseReleaseEvent(QMouseEvent *e);
20 void mouseMoveEvent(QMouseEvent *e); 22 void mouseMoveEvent(QMouseEvent *e);
21}; 23};
22 24
23#endif 25#endif
diff --git a/microkde/kurl.cpp b/microkde/kurl.cpp
index 2574e25..122ad71 100644
--- a/microkde/kurl.cpp
+++ b/microkde/kurl.cpp
@@ -1,1805 +1,1807 @@
1/* 1/*
2 Copyright (C) 1999 Torben Weis <weis@kde.org> 2 Copyright (C) 1999 Torben Weis <weis@kde.org>
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include "kurl.h" 20#include "kurl.h"
21 21
22#ifndef KDE_QT_ONLY 22#ifndef KDE_QT_ONLY
23#include <kdebug.h> 23#include <kdebug.h>
24#include <kglobal.h> 24#include <kglobal.h>
25//US#include <kidna.h> 25//US#include <kidna.h>
26#endif 26#endif
27 27
28#include <stdio.h> 28#include <stdio.h>
29#include <assert.h> 29#include <assert.h>
30#include <ctype.h> 30#include <ctype.h>
31#include <stdlib.h> 31#include <stdlib.h>
32#ifdef _WIN32_ 32#ifdef _WIN32_
33 33
34#else 34#else
35#include <unistd.h> 35#include <unistd.h>
36#endif 36#endif
37#include <qurl.h> 37#include <q3url.h>
38#include <qdir.h> 38#include <qdir.h>
39#include <qstringlist.h> 39#include <qstringlist.h>
40#include <qregexp.h> 40#include <qregexp.h>
41//US#include <qstylesheet.h> 41//US#include <qstylesheet.h>
42#include <qmap.h> 42#include <qmap.h>
43#include <qtextcodec.h> 43#include <qtextcodec.h>
44//Added by qt3to4:
45#include <Q3CString>
44 46
45static const QString fileProt = "file"; 47static const QString fileProt = "file";
46 48
47static QTextCodec * codecForHint( int encoding_hint /* not 0 ! */ ) 49static QTextCodec * codecForHint( int encoding_hint /* not 0 ! */ )
48{ 50{
49 return QTextCodec::codecForMib( encoding_hint ); 51 return QTextCodec::codecForMib( encoding_hint );
50} 52}
51 53
52static QString encode( const QString& segment, bool encode_slash, int encoding_hint ) 54static QString encode( const QString& segment, bool encode_slash, int encoding_hint )
53{ 55{
54 const char *encode_string; 56 const char *encode_string;
55 if (encode_slash) 57 if (encode_slash)
56 encode_string = "<>#@\"&%?={}|^~[]\'`\\:+/"; 58 encode_string = "<>#@\"&%?={}|^~[]\'`\\:+/";
57 else 59 else
58 encode_string = "<>#@\"&%?={}|^~[]\'`\\:+"; 60 encode_string = "<>#@\"&%?={}|^~[]\'`\\:+";
59 61
60 QCString local; 62 Q3CString local;
61 if (encoding_hint==0) 63 if (encoding_hint==0)
62 local = segment.local8Bit(); 64 local = segment.local8Bit();
63 else 65 else
64 { 66 {
65 QTextCodec * textCodec = codecForHint( encoding_hint ); 67 QTextCodec * textCodec = codecForHint( encoding_hint );
66 if (!textCodec) 68 if (!textCodec)
67 local = segment.local8Bit(); 69 local = segment.local8Bit();
68 else 70 else
69 local = textCodec->fromUnicode( segment ); 71 local = textCodec->fromUnicode( segment );
70 } 72 }
71 73
72 int old_length = local.length(); 74 int old_length = local.length();
73 75
74 if ( !old_length ) 76 if ( !old_length )
75 return segment.isNull() ? QString::null : QString(""); // differenciate null and empty 77 return segment.isNull() ? QString::null : QString(""); // differenciate null and empty
76 78
77 // a worst case approximation 79 // a worst case approximation
78 QChar *new_segment = new QChar[ old_length * 3 + 1 ]; 80 QChar *new_segment = new QChar[ old_length * 3 + 1 ];
79 int new_length = 0; 81 int new_length = 0;
80 82
81 for ( int i = 0; i < old_length; i++ ) 83 for ( int i = 0; i < old_length; i++ )
82 { 84 {
83 // 'unsave' and 'reserved' characters 85 // 'unsave' and 'reserved' characters
84 // according to RFC 1738, 86 // according to RFC 1738,
85 // 2.2. URL Character Encoding Issues (pp. 3-4) 87 // 2.2. URL Character Encoding Issues (pp. 3-4)
86 // WABA: Added non-ascii 88 // WABA: Added non-ascii
87 unsigned char character = local[i]; 89 unsigned char character = local[i];
88 if ( (character <= 32) || (character >= 127) || 90 if ( (character <= 32) || (character >= 127) ||
89 strchr(encode_string, character) ) 91 strchr(encode_string, character) )
90 { 92 {
91 new_segment[ new_length++ ] = '%'; 93 new_segment[ new_length++ ] = '%';
92 94
93 unsigned int c = character / 16; 95 unsigned int c = character / 16;
94 c += (c > 9) ? ('A' - 10) : '0'; 96 c += (c > 9) ? ('A' - 10) : '0';
95 new_segment[ new_length++ ] = c; 97 new_segment[ new_length++ ] = c;
96 98
97 c = character % 16; 99 c = character % 16;
98 c += (c > 9) ? ('A' - 10) : '0'; 100 c += (c > 9) ? ('A' - 10) : '0';
99 new_segment[ new_length++ ] = c; 101 new_segment[ new_length++ ] = c;
100 102
101 } 103 }
102 else 104 else
103 new_segment[ new_length++ ] = local[i]; 105 new_segment[ new_length++ ] = character;
104 } 106 }
105 107
106 QString result = QString(new_segment, new_length); 108 QString result = QString(new_segment, new_length);
107 delete [] new_segment; 109 delete [] new_segment;
108 return result; 110 return result;
109} 111}
110 112
111static QString encodeHost( const QString& segment, bool encode_slash, int encoding_hint ) 113static QString encodeHost( const QString& segment, bool encode_slash, int encoding_hint )
112{ 114{
113 // Hostnames are encoded differently 115 // Hostnames are encoded differently
114 // we use the IDNA transformation instead 116 // we use the IDNA transformation instead
115 117
116 // Note: when merging qt-addon, use QResolver::domainToAscii here 118 // Note: when merging qt-addon, use QResolver::domainToAscii here
117#ifndef KDE_QT_ONLY 119#ifndef KDE_QT_ONLY
118 Q_UNUSED( encode_slash ); 120 Q_UNUSED( encode_slash );
119 Q_UNUSED( encoding_hint ); 121 Q_UNUSED( encoding_hint );
120 return KIDNA::toAscii(segment); 122 return KIDNA::toAscii(segment);
121#else 123#else
122 return encode(segment, encode_slash, encoding_hint); 124 return encode(segment, encode_slash, encoding_hint);
123#endif 125#endif
124} 126}
125 127
126static int hex2int( unsigned int _char ) 128static int hex2int( unsigned int _char )
127{ 129{
128 if ( _char >= 'A' && _char <='F') 130 if ( _char >= 'A' && _char <='F')
129 return _char - 'A' + 10; 131 return _char - 'A' + 10;
130 if ( _char >= 'a' && _char <='f') 132 if ( _char >= 'a' && _char <='f')
131 return _char - 'a' + 10; 133 return _char - 'a' + 10;
132 if ( _char >= '0' && _char <='9') 134 if ( _char >= '0' && _char <='9')
133 return _char - '0'; 135 return _char - '0';
134 return -1; 136 return -1;
135} 137}
136 138
137// WABA: The result of lazy_encode isn't usable for a URL which 139// WABA: The result of lazy_encode isn't usable for a URL which
138// needs to satisfies RFC requirements. However, the following 140// needs to satisfies RFC requirements. However, the following
139// operation will make it usable again: 141// operation will make it usable again:
140// encode(decode(...)) 142// encode(decode(...))
141// 143//
142// As a result one can see that url.prettyURL() does not result in 144// As a result one can see that url.prettyURL() does not result in
143// a RFC compliant URL but that the following sequence does: 145// a RFC compliant URL but that the following sequence does:
144// KURL(url.prettyURL()).url() 146// KURL(url.prettyURL()).url()
145 147
146 148
147static QString lazy_encode( const QString& segment ) 149static QString lazy_encode( const QString& segment )
148{ 150{
149 int old_length = segment.length(); 151 int old_length = segment.length();
150 152
151 if ( !old_length ) 153 if ( !old_length )
152 return QString::null; 154 return QString::null;
153 155
154 // a worst case approximation 156 // a worst case approximation
155 QChar *new_segment = new QChar[ old_length * 3 + 1 ]; 157 QChar *new_segment = new QChar[ old_length * 3 + 1 ];
156 int new_length = 0; 158 int new_length = 0;
157 159
158 for ( int i = 0; i < old_length; i++ ) 160 for ( int i = 0; i < old_length; i++ )
159 { 161 {
160 unsigned int character = segment[i].unicode(); // Don't use latin1() 162 unsigned int character = segment[i].unicode(); // Don't use latin1()
161 // It returns 0 for non-latin1 values 163 // It returns 0 for non-latin1 values
162 // Small set of really ambiguous chars 164 // Small set of really ambiguous chars
163 if ((character < 32) || // Low ASCII 165 if ((character < 32) || // Low ASCII
164 ((character == '%') && // The escape character itself 166 ((character == '%') && // The escape character itself
165 (i+2 < old_length) && // But only if part of a valid escape sequence! 167 (i+2 < old_length) && // But only if part of a valid escape sequence!
166 (hex2int(segment[i+1].unicode())!= -1) && 168 (hex2int(segment[i+1].unicode())!= -1) &&
167 (hex2int(segment[i+2].unicode())!= -1)) || 169 (hex2int(segment[i+2].unicode())!= -1)) ||
168 (character == '?') || // Start of query delimiter 170 (character == '?') || // Start of query delimiter
169 (character == '@') || // Username delimiter 171 (character == '@') || // Username delimiter
170 (character == '#') || // Start of reference delimiter 172 (character == '#') || // Start of reference delimiter
171 ((character == 32) && (i+1 == old_length))) // A trailing space 173 ((character == 32) && (i+1 == old_length))) // A trailing space
172 { 174 {
173 new_segment[ new_length++ ] = '%'; 175 new_segment[ new_length++ ] = '%';
174 176
175 unsigned int c = character / 16; 177 unsigned int c = character / 16;
176 c += (c > 9) ? ('A' - 10) : '0'; 178 c += (c > 9) ? ('A' - 10) : '0';
177 new_segment[ new_length++ ] = c; 179 new_segment[ new_length++ ] = c;
178 180
179 c = character % 16; 181 c = character % 16;
180 c += (c > 9) ? ('A' - 10) : '0'; 182 c += (c > 9) ? ('A' - 10) : '0';
181 new_segment[ new_length++ ] = c; 183 new_segment[ new_length++ ] = c;
182 } 184 }
183 else 185 else
184 new_segment[ new_length++ ] = segment[i]; 186 new_segment[ new_length++ ] = segment[i];
185 } 187 }
186 188
187 QString result = QString(new_segment, new_length); 189 QString result = QString(new_segment, new_length);
188 delete [] new_segment; 190 delete [] new_segment;
189 return result; 191 return result;
190} 192}
191 193
192static void decode( const QString& segment, QString &decoded, QString &encoded, int encoding_hint=0, bool updateDecoded = true ) 194static void decode( const QString& segment, QString &decoded, QString &encoded, int encoding_hint=0, bool updateDecoded = true )
193{ 195{
194 decoded = QString::null; 196 decoded = QString::null;
195 encoded = segment; 197 encoded = segment;
196 198
197 int old_length = segment.length(); 199 int old_length = segment.length();
198 if ( !old_length ) 200 if ( !old_length )
199 return; 201 return;
200 202
201 QTextCodec *textCodec = 0; 203 QTextCodec *textCodec = 0;
202 if (encoding_hint) 204 if (encoding_hint)
203 textCodec = codecForHint( encoding_hint ); 205 textCodec = codecForHint( encoding_hint );
204 206
205 if (!textCodec) 207 if (!textCodec)
206 textCodec = QTextCodec::codecForLocale(); 208 textCodec = QTextCodec::codecForLocale();
207 209
208 QCString csegment = textCodec->fromUnicode(segment); 210 Q3CString csegment = textCodec->fromUnicode(segment);
209 // Check if everything went ok 211 // Check if everything went ok
210 if (textCodec->toUnicode(csegment) != segment) 212 if (textCodec->toUnicode(csegment) != segment)
211 { 213 {
212 // Uh oh 214 // Uh oh
213 textCodec = codecForHint( 106 ); // Fall back to utf-8 215 textCodec = codecForHint( 106 ); // Fall back to utf-8
214 csegment = textCodec->fromUnicode(segment); 216 csegment = textCodec->fromUnicode(segment);
215 } 217 }
216 old_length = csegment.length(); 218 old_length = csegment.length();
217 219
218 int new_length = 0; 220 int new_length = 0;
219 int new_length2 = 0; 221 int new_length2 = 0;
220 222
221 // make a copy of the old one 223 // make a copy of the old one
222 char *new_segment = new char[ old_length + 1 ]; 224 char *new_segment = new char[ old_length + 1 ];
223 QChar *new_usegment = new QChar[ old_length * 3 + 1 ]; 225 QChar *new_usegment = new QChar[ old_length * 3 + 1 ];
224 226
225 int i = 0; 227 int i = 0;
226 while( i < old_length ) 228 while( i < old_length )
227 { 229 {
228 bool bReencode = false; 230 bool bReencode = false;
229 unsigned char character = csegment[ i++ ]; 231 unsigned char character = csegment[ i++ ];
230 if ((character <= ' ') || (character > 127)) 232 if ((character <= ' ') || (character > 127))
231 bReencode = true; 233 bReencode = true;
232 234
233 new_usegment [ new_length2++ ] = character; 235 new_usegment [ new_length2++ ] = character;
234 if (character == '%' ) 236 if (character == '%' )
235 { 237 {
236 int a = i+1 < old_length ? hex2int( csegment[i] ) : -1; 238 int a = i+1 < old_length ? hex2int( csegment[i] ) : -1;
237 int b = i+1 < old_length ? hex2int( csegment[i+1] ) : -1; 239 int b = i+1 < old_length ? hex2int( csegment[i+1] ) : -1;
238 if ((a == -1) || (b == -1)) // Only replace if sequence is valid 240 if ((a == -1) || (b == -1)) // Only replace if sequence is valid
239 { 241 {
240 // Contains stray %, make sure to re-encode! 242 // Contains stray %, make sure to re-encode!
241 bReencode = true; 243 bReencode = true;
242 } 244 }
243 else 245 else
244 { 246 {
245 // Valid %xx sequence 247 // Valid %xx sequence
246 character = a * 16 + b; // Replace with value of %dd 248 character = a * 16 + b; // Replace with value of %dd
247 if (!character && updateDecoded) 249 if (!character && updateDecoded)
248 break; // Stop at %00 250 break; // Stop at %00
249 251
250 new_usegment [ new_length2++ ] = (unsigned char) csegment[i++]; 252 new_usegment [ new_length2++ ] = (unsigned char) csegment[i++];
251 new_usegment [ new_length2++ ] = (unsigned char) csegment[i++]; 253 new_usegment [ new_length2++ ] = (unsigned char) csegment[i++];
252 } 254 }
253 } 255 }
254 if (bReencode) 256 if (bReencode)
255 { 257 {
256 new_length2--; 258 new_length2--;
257 new_usegment [ new_length2++ ] = '%'; 259 new_usegment [ new_length2++ ] = '%';
258 260
259 unsigned int c = character / 16; 261 unsigned int c = character / 16;
260 c += (c > 9) ? ('A' - 10) : '0'; 262 c += (c > 9) ? ('A' - 10) : '0';
261 new_usegment[ new_length2++ ] = c; 263 new_usegment[ new_length2++ ] = c;
262 264
263 c = character % 16; 265 c = character % 16;
264 c += (c > 9) ? ('A' - 10) : '0'; 266 c += (c > 9) ? ('A' - 10) : '0';
265 new_usegment[ new_length2++ ] = c; 267 new_usegment[ new_length2++ ] = c;
266 } 268 }
267 269
268 new_segment [ new_length++ ] = character; 270 new_segment [ new_length++ ] = character;
269 } 271 }
270 new_segment [ new_length ] = 0; 272 new_segment [ new_length ] = 0;
271 273
272 encoded = QString( new_usegment, new_length2); 274 encoded = QString( new_usegment, new_length2);
273 275
274 // Encoding specified 276 // Encoding specified
275 if (updateDecoded) 277 if (updateDecoded)
276 { 278 {
277 QByteArray array; 279 QByteArray array;
278 array.setRawData(new_segment, new_length); 280 array.setRawData(new_segment, new_length);
279 decoded = textCodec->toUnicode( array, new_length ); 281 decoded = textCodec->toUnicode( array, new_length );
280 array.resetRawData(new_segment, new_length); 282 array.resetRawData(new_segment, new_length);
281 QCString validate = textCodec->fromUnicode(decoded); 283 Q3CString validate = textCodec->fromUnicode(decoded);
282 284
283 if (strcmp(validate.data(), new_segment) != 0) 285 if (strcmp(validate.data(), new_segment) != 0)
284 { 286 {
285 decoded = QString::fromLocal8Bit(new_segment, new_length); 287 decoded = QString::fromLocal8Bit(new_segment, new_length);
286 } 288 }
287 } 289 }
288 290
289 delete [] new_segment; 291 delete [] new_segment;
290 delete [] new_usegment; 292 delete [] new_usegment;
291} 293}
292 294
293static QString decode(const QString &segment, int encoding_hint = 0) 295static QString decode(const QString &segment, int encoding_hint = 0)
294{ 296{
295 QString result; 297 QString result;
296 QString tmp; 298 QString tmp;
297 decode(segment, result, tmp, encoding_hint); 299 decode(segment, result, tmp, encoding_hint);
298 return result; 300 return result;
299} 301}
300 302
301static QString cleanpath(const QString &path, bool cleanDirSeparator=true) 303static QString cleanpath(const QString &path, bool cleanDirSeparator=true)
302{ 304{
303 if (path.isEmpty()) return QString::null; 305 if (path.isEmpty()) return QString::null;
304 int len = path.length(); 306 int len = path.length();
305 bool slash = (len && path[len-1] == '/') || 307 bool slash = (len && path[len-1] == '/') ||
306 (len > 1 && path[len-2] == '/' && path[len-1] == '.'); 308 (len > 1 && path[len-2] == '/' && path[len-1] == '.');
307 309
308 // The following code cleans up directory path much like 310 // The following code cleans up directory path much like
309 // QDir::cleanDirPath() except it can be made to ignore multiple 311 // QDir::cleanDirPath() except it can be made to ignore multiple
310 // directory separators by setting the flag to false. That fixes 312 // directory separators by setting the flag to false. That fixes
311 // bug# 15044, mail.altavista.com and other similar brain-dead server 313 // bug# 15044, mail.altavista.com and other similar brain-dead server
312 // implementations that do not follow what has been specified in 314 // implementations that do not follow what has been specified in
313 // RFC 2396!! (dA) 315 // RFC 2396!! (dA)
314 QString result; 316 QString result;
315 int cdUp, orig_pos, pos; 317 int cdUp, orig_pos, pos;
316 318
317 cdUp = 0; 319 cdUp = 0;
318 pos = orig_pos = len; 320 pos = orig_pos = len;
319 while ( pos && (pos = path.findRev('/',--pos)) != -1 ) 321 while ( pos && (pos = path.findRev('/',--pos)) != -1 )
320 { 322 {
321 len = orig_pos - pos - 1; 323 len = orig_pos - pos - 1;
322 if ( len == 2 && path[pos+1] == '.' && path[pos+2] == '.' ) 324 if ( len == 2 && path[pos+1] == '.' && path[pos+2] == '.' )
323 cdUp++; 325 cdUp++;
324 else 326 else
325 { 327 {
326 // Ignore any occurances of '.' 328 // Ignore any occurances of '.'
327 // This includes entries that simply do not make sense like /..../ 329 // This includes entries that simply do not make sense like /..../
328 if ( (len || !cleanDirSeparator) && 330 if ( (len || !cleanDirSeparator) &&
329 (len != 1 || path[pos+1] != '.' ) ) 331 (len != 1 || path[pos+1] != '.' ) )
330 { 332 {
331 if ( !cdUp ) 333 if ( !cdUp )
332 result.prepend(path.mid(pos, len+1)); 334 result.prepend(path.mid(pos, len+1));
333 else 335 else
334 cdUp--; 336 cdUp--;
335 } 337 }
336 } 338 }
337 orig_pos = pos; 339 orig_pos = pos;
338 } 340 }
339 341
340 if ( result.isEmpty() ) 342 if ( result.isEmpty() )
341 result = "/"; 343 result = "/";
342 else if ( slash && result.at(result.length()-1) != '/' ) 344 else if ( slash && result.at(result.length()-1) != '/' )
343 result.append('/'); 345 result.append('/');
344 346
345 return result; 347 return result;
346} 348}
347 349
348bool KURL::isRelativeURL(const QString &_url) 350bool KURL::isRelativeURL(const QString &_url)
349{ 351{
350 int len = _url.length(); 352 int len = _url.length();
351 if (!len) return true; // Very short relative URL. 353 if (!len) return true; // Very short relative URL.
352 const QChar *str = _url.unicode(); 354 const QChar *str = _url.unicode();
353 355
354 // Absolute URL must start with alpha-character 356 // Absolute URL must start with alpha-character
355 if (!isalpha(str[0].latin1())) 357 if (!isalpha(str[0].latin1()))
356 return true; // Relative URL 358 return true; // Relative URL
357 359
358 for(int i = 1; i < len; i++) 360 for(int i = 1; i < len; i++)
359 { 361 {
360 char c = str[i].latin1(); // Note: non-latin1 chars return 0! 362 char c = str[i].latin1(); // Note: non-latin1 chars return 0!
361 if (c == ':') 363 if (c == ':')
362 return false; // Absolute URL 364 return false; // Absolute URL
363 365
364 // Protocol part may only contain alpha, digit, + or - 366 // Protocol part may only contain alpha, digit, + or -
365 if (!isalpha(c) && !isdigit(c) && (c != '+') && (c != '-')) 367 if (!isalpha(c) && !isdigit(c) && (c != '+') && (c != '-'))
366 return true; // Relative URL 368 return true; // Relative URL
367 } 369 }
368 // URL did not contain ':' 370 // URL did not contain ':'
369 return true; // Relative URL 371 return true; // Relative URL
370} 372}
371 373
372KURL::List::List(const KURL &url) 374KURL::List::List(const KURL &url)
373{ 375{
374 append( url ); 376 append( url );
375} 377}
376 378
377KURL::List::List(const QStringList &list) 379KURL::List::List(const QStringList &list)
378{ 380{
379 for (QStringList::ConstIterator it = list.begin(); 381 for (QStringList::ConstIterator it = list.begin();
380 it != list.end(); 382 it != list.end();
381 it++) 383 it++)
382 { 384 {
383 append( KURL(*it) ); 385 append( KURL(*it) );
384 } 386 }
385} 387}
386 388
387QStringList KURL::List::toStringList() const 389QStringList KURL::List::toStringList() const
388{ 390{
389 QStringList lst; 391 QStringList lst;
390 for( KURL::List::ConstIterator it = begin(); 392 for( KURL::List::ConstIterator it = begin();
391 it != end(); 393 it != end();
392 it++) 394 it++)
393 { 395 {
394 lst.append( (*it).url() ); 396 lst.append( (*it).url() );
395 } 397 }
396 return lst; 398 return lst;
397} 399}
398 400
399 401
400KURL::KURL() 402KURL::KURL()
401{ 403{
402 reset(); 404 reset();
403} 405}
404 406
405KURL::~KURL() 407KURL::~KURL()
406{ 408{
407} 409}
408 410
409 411
410KURL::KURL( const QString &url, int encoding_hint ) 412KURL::KURL( const QString &url, int encoding_hint )
411{ 413{
412 reset(); 414 reset();
413 parse( url, encoding_hint ); 415 parse( url, encoding_hint );
414} 416}
415 417
416KURL::KURL( const char * url, int encoding_hint ) 418KURL::KURL( const char * url, int encoding_hint )
417{ 419{
418 reset(); 420 reset();
419 parse( QString::fromLatin1(url), encoding_hint ); 421 parse( QString::fromLatin1(url), encoding_hint );
420} 422}
421 423
422KURL::KURL( const QCString& url, int encoding_hint ) 424KURL::KURL( const Q3CString& url, int encoding_hint )
423{ 425{
424 reset(); 426 reset();
425 parse( QString::fromLatin1(url), encoding_hint ); 427 parse( QString::fromLatin1(url), encoding_hint );
426} 428}
427 429
428KURL::KURL( const KURL& _u ) 430KURL::KURL( const KURL& _u )
429{ 431{
430 *this = _u; 432 *this = _u;
431} 433}
432 434
433QDataStream & operator<< (QDataStream & s, const KURL & a) 435QDataStream & operator<< (QDataStream & s, const KURL & a)
434{ 436{
435 QString QueryForWire=a.m_strQuery_encoded; 437 QString QueryForWire=a.m_strQuery_encoded;
436 if (!a.m_strQuery_encoded.isNull()) 438 if (!a.m_strQuery_encoded.isNull())
437 QueryForWire.prepend("?"); 439 QueryForWire.prepend("?");
438 440
439 s << a.m_strProtocol << a.m_strUser << a.m_strPass << a.m_strHost 441 s << a.m_strProtocol << a.m_strUser << a.m_strPass << a.m_strHost
440 << a.m_strPath << a.m_strPath_encoded << QueryForWire << a.m_strRef_encoded 442 << a.m_strPath << a.m_strPath_encoded << QueryForWire << a.m_strRef_encoded
441 << Q_INT8(a.m_bIsMalformed ? 1 : 0) << a.m_iPort; 443 << Q_INT8(a.m_bIsMalformed ? 1 : 0) << a.m_iPort;
442 return s; 444 return s;
443} 445}
444 446
445QDataStream & operator>> (QDataStream & s, KURL & a) 447QDataStream & operator>> (QDataStream & s, KURL & a)
446{ 448{
447 Q_INT8 malf; 449 Q_INT8 malf;
448 QString QueryFromWire; 450 QString QueryFromWire;
449 s >> a.m_strProtocol >> a.m_strUser >> a.m_strPass >> a.m_strHost 451 s >> a.m_strProtocol >> a.m_strUser >> a.m_strPass >> a.m_strHost
450 >> a.m_strPath >> a.m_strPath_encoded >> QueryFromWire >> a.m_strRef_encoded 452 >> a.m_strPath >> a.m_strPath_encoded >> QueryFromWire >> a.m_strRef_encoded
451 >> malf >> a.m_iPort; 453 >> malf >> a.m_iPort;
452 a.m_bIsMalformed = (malf != 0); 454 a.m_bIsMalformed = (malf != 0);
453 455
454 if ( QueryFromWire.isEmpty() ) 456 if ( QueryFromWire.isEmpty() )
455 a.m_strQuery_encoded = QString::null; 457 a.m_strQuery_encoded = QString::null;
456 else 458 else
457 a.m_strQuery_encoded = QueryFromWire.mid(1); 459 a.m_strQuery_encoded = QueryFromWire.mid(1);
458 460
459 return s; 461 return s;
460} 462}
461 463
462#ifndef QT_NO_NETWORKPROTOCOL 464#ifndef QT_NO_NETWORKPROTOCOL
463KURL::KURL( const QUrl &u ) 465KURL::KURL( const Q3Url &u )
464{ 466{
465 *this = u; 467 *this = u;
466} 468}
467#endif 469#endif
468 470
469KURL::KURL( const KURL& _u, const QString& _rel_url, int encoding_hint ) 471KURL::KURL( const KURL& _u, const QString& _rel_url, int encoding_hint )
470{ 472{
471 // WORKAROUND THE RFC 1606 LOOPHOLE THAT ALLOWS 473 // WORKAROUND THE RFC 1606 LOOPHOLE THAT ALLOWS
472 // http:/index.html AS A VALID SYNTAX FOR RELATIVE 474 // http:/index.html AS A VALID SYNTAX FOR RELATIVE
473 // URLS. ( RFC 2396 section 5.2 item # 3 ) 475 // URLS. ( RFC 2396 section 5.2 item # 3 )
474 QString rUrl = _rel_url; 476 QString rUrl = _rel_url;
475 int len = _u.m_strProtocol.length(); 477 int len = _u.m_strProtocol.length();
476 if ( !_u.m_strHost.isEmpty() && !rUrl.isEmpty() && 478 if ( !_u.m_strHost.isEmpty() && !rUrl.isEmpty() &&
477 rUrl.find( _u.m_strProtocol, 0, false ) == 0 && 479 rUrl.find( _u.m_strProtocol, 0, false ) == 0 &&
478 rUrl[len] == ':' && (rUrl[len+1] != '/' || 480 rUrl[len] == ':' && (rUrl[len+1] != '/' ||
479 (rUrl[len+1] == '/' && rUrl[len+2] != '/')) ) 481 (rUrl[len+1] == '/' && rUrl[len+2] != '/')) )
480 { 482 {
481 rUrl.remove( 0, rUrl.find( ':' ) + 1 ); 483 rUrl.remove( 0, rUrl.find( ':' ) + 1 );
482 } 484 }
483 485
484 if ( rUrl.isEmpty() ) 486 if ( rUrl.isEmpty() )
485 { 487 {
486 *this = _u; 488 *this = _u;
487 } 489 }
488 else if ( rUrl[0] == '#' ) 490 else if ( rUrl[0] == '#' )
489 { 491 {
490 *this = _u; 492 *this = _u;
491 QString ref = decode(rUrl.mid(1), encoding_hint); 493 QString ref = decode(rUrl.mid(1), encoding_hint);
492 if ( ref.isNull() ) 494 if ( ref.isNull() )
493 ref = ""; // we know there was an (empty) html ref, we saw the '#' 495 ref = ""; // we know there was an (empty) html ref, we saw the '#'
494 setHTMLRef( ref ); 496 setHTMLRef( ref );
495 } 497 }
496 else if ( isRelativeURL( rUrl) ) 498 else if ( isRelativeURL( rUrl) )
497 { 499 {
498 *this = _u; 500 *this = _u;
499 m_strQuery_encoded = QString::null; 501 m_strQuery_encoded = QString::null;
500 m_strRef_encoded = QString::null; 502 m_strRef_encoded = QString::null;
501 if ( rUrl[0] == '/') 503 if ( rUrl[0] == '/')
502 { 504 {
503 if ((rUrl.length() > 1) && (rUrl[1] == '/')) 505 if ((rUrl.length() > 1) && (rUrl[1] == '/'))
504 { 506 {
505 m_strHost = QString::null; 507 m_strHost = QString::null;
506 } 508 }
507 m_strPath = QString::null; 509 m_strPath = QString::null;
508 m_strPath_encoded = QString::null; 510 m_strPath_encoded = QString::null;
509 } 511 }
510 else if ( rUrl[0] != '?' ) 512 else if ( rUrl[0] != '?' )
511 { 513 {
512 int pos = m_strPath.findRev( '/' ); 514 int pos = m_strPath.findRev( '/' );
513 if (pos >= 0) 515 if (pos >= 0)
514 m_strPath.truncate(pos); 516 m_strPath.truncate(pos);
515 m_strPath += '/'; 517 m_strPath += '/';
516 if (!m_strPath_encoded.isEmpty()) 518 if (!m_strPath_encoded.isEmpty())
517 { 519 {
518 pos = m_strPath_encoded.findRev( '/' ); 520 pos = m_strPath_encoded.findRev( '/' );
519 if (pos >= 0) 521 if (pos >= 0)
520 m_strPath_encoded.truncate(pos); 522 m_strPath_encoded.truncate(pos);
521 m_strPath_encoded += '/'; 523 m_strPath_encoded += '/';
522 } 524 }
523 } 525 }
524 else 526 else
525 { 527 {
526 if ( m_strPath.isEmpty() ) 528 if ( m_strPath.isEmpty() )
527 m_strPath = '/'; 529 m_strPath = '/';
528 } 530 }
529 KURL tmp( url() + rUrl, encoding_hint); 531 KURL tmp( url() + rUrl, encoding_hint);
530 *this = tmp; 532 *this = tmp;
531 cleanPath(false); 533 cleanPath(false);
532 } 534 }
533 else 535 else
534 { 536 {
535 KURL tmp( rUrl, encoding_hint); 537 KURL tmp( rUrl, encoding_hint);
536 *this = tmp; 538 *this = tmp;
537 // Preserve userinfo if applicable. 539 // Preserve userinfo if applicable.
538 if (!_u.m_strUser.isEmpty() && m_strUser.isEmpty() && (_u.m_strHost == m_strHost) && (_u.m_strProtocol == m_strProtocol)) 540 if (!_u.m_strUser.isEmpty() && m_strUser.isEmpty() && (_u.m_strHost == m_strHost) && (_u.m_strProtocol == m_strProtocol))
539 { 541 {
540 m_strUser = _u.m_strUser; 542 m_strUser = _u.m_strUser;
541 m_strPass = _u.m_strPass; 543 m_strPass = _u.m_strPass;
542 } 544 }
543 } 545 }
544} 546}
545 547
546void KURL::reset() 548void KURL::reset()
547{ 549{
548 m_strProtocol = QString::null; 550 m_strProtocol = QString::null;
549 m_strUser = QString::null; 551 m_strUser = QString::null;
550 m_strPass = QString::null; 552 m_strPass = QString::null;
551 m_strHost = QString::null; 553 m_strHost = QString::null;
552 m_strPath = QString::null; 554 m_strPath = QString::null;
553 m_strPath_encoded = QString::null; 555 m_strPath_encoded = QString::null;
554 m_strQuery_encoded = QString::null; 556 m_strQuery_encoded = QString::null;
555 m_strRef_encoded = QString::null; 557 m_strRef_encoded = QString::null;
556 m_bIsMalformed = true; 558 m_bIsMalformed = true;
557 m_iPort = 0; 559 m_iPort = 0;
558} 560}
559 561
560bool KURL::isEmpty() const 562bool KURL::isEmpty() const
561{ 563{
562 return (m_strPath.isEmpty() && m_strProtocol.isEmpty()); 564 return (m_strPath.isEmpty() && m_strProtocol.isEmpty());
563} 565}
564 566
565void KURL::parse( const QString& _url, int encoding_hint ) 567void KURL::parse( const QString& _url, int encoding_hint )
566{ 568{
567 //kdDebug(126) << "parse " << _url << endl; 569 //kdDebug(126) << "parse " << _url << endl;
568 // Return immediately whenever the given url 570 // Return immediately whenever the given url
569 // is empty or null. 571 // is empty or null.
570 if ( _url.isEmpty() ) 572 if ( _url.isEmpty() )
571 { 573 {
572 m_strProtocol = _url; 574 m_strProtocol = _url;
573 return; 575 return;
574 } 576 }
575 577
576 QString port; 578 QString port;
577 bool badHostName = false; 579 bool badHostName = false;
578 int start = 0; 580 int start = 0;
579 uint len = _url.length(); 581 uint len = _url.length();
580 const QChar* buf = _url.unicode(); 582 const QChar* buf = _url.unicode();
581 const QChar* orig = buf; 583 const QChar* orig = buf;
582 584
583 QChar delim; 585 QChar delim;
584 QString tmp; 586 QString tmp;
585 587
586 uint pos = 0; 588 uint pos = 0;
587 589
588 // Node 1: Accept alpha or slash 590 // Node 1: Accept alpha or slash
589 QChar x = buf[pos++]; 591 QChar x = buf[pos++];
590 if ( x == '/' ) 592 if ( x == '/' )
591 goto Node9; 593 goto Node9;
592 if ( !isalpha( (int)x ) ) 594 if ( !x.isLetter() )
593 goto NodeErr; 595 goto NodeErr;
594 596
595 // Node 2: Accept any amount of (alpha|digit|'+'|'-') 597 // Node 2: Accept any amount of (alpha|digit|'+'|'-')
596 // '.' is not currently accepted, because current KURL may be confused. 598 // '.' is not currently accepted, because current KURL may be confused.
597 // Proceed with :// :/ or : 599 // Proceed with :// :/ or :
598 while( pos < len && (isalpha((int)buf[pos]) || isdigit((int)buf[pos]) || 600 while( pos < len && ( buf[pos].isLetter() || buf[pos].isDigit() ||
599 buf[pos] == '+' || buf[pos] == '-')) pos++; 601 buf[pos] == '+' || buf[pos] == '-')) pos++;
600 602
601 if ( pos+2 < len && buf[pos] == ':' && buf[pos+1] == '/' && buf[pos+2] == '/' ) 603 if ( pos+2 < len && buf[pos] == ':' && buf[pos+1] == '/' && buf[pos+2] == '/' )
602 { 604 {
603 m_strProtocol = QString( orig, pos ).lower(); 605 m_strProtocol = QString( orig, pos ).lower();
604 pos += 3; 606 pos += 3;
605 } 607 }
606 else if (pos+1 < len && buf[pos] == ':' ) // Need to always compare length()-1 otherwise KURL passes "http:" as legal!! 608 else if (pos+1 < len && buf[pos] == ':' ) // Need to always compare length()-1 otherwise KURL passes "http:" as legal!!
607 { 609 {
608 m_strProtocol = QString( orig, pos ).lower(); 610 m_strProtocol = QString( orig, pos ).lower();
609 //kdDebug(126)<<"setting protocol to "<<m_strProtocol<<endl; 611 //kdDebug(126)<<"setting protocol to "<<m_strProtocol<<endl;
610 pos++; 612 pos++;
611 start = pos; 613 start = pos;
612 goto Node9; 614 goto Node9;
613 } 615 }
614 else 616 else
615 goto NodeErr; 617 goto NodeErr;
616 618
617 //Node 3: We need at least one character here 619 //Node 3: We need at least one character here
618 if ( pos == len ) 620 if ( pos == len )
619 goto NodeErr; 621 goto NodeErr;
620 start = pos; 622 start = pos;
621 623
622 // Node 4: Accept any amount of characters. 624 // Node 4: Accept any amount of characters.
623 if (buf[pos] == '[') // An IPv6 host follows. 625 if (buf[pos] == '[') // An IPv6 host follows.
624 goto Node8; 626 goto Node8;
625 // Terminate on / or @ or ? or # or " or ; or < 627 // Terminate on / or @ or ? or # or " or ; or <
626 x = buf[pos]; 628 x = buf[pos];
627 while( (x != ':') && (x != '@') && (x != '/') && (x != '?') && (x != '#') ) 629 while( (x != ':') && (x != '@') && (x != '/') && (x != '?') && (x != '#') )
628 { 630 {
629 if ((x == '\"') || (x == ';') || (x == '<')) 631 if ((x == '\"') || (x == ';') || (x == '<'))
630 badHostName = true; 632 badHostName = true;
631 if (++pos == len) 633 if (++pos == len)
632 break; 634 break;
633 x = buf[pos]; 635 x = buf[pos];
634 } 636 }
635 if ( pos == len ) 637 if ( pos == len )
636 { 638 {
637 if (badHostName) 639 if (badHostName)
638 goto NodeErr; 640 goto NodeErr;
639 641
640 setHost(decode(QString( buf + start, pos - start ), encoding_hint)); 642 setHost(decode(QString( buf + start, pos - start ), encoding_hint));
641 goto NodeOk; 643 goto NodeOk;
642 } 644 }
643 if ( x == '@' ) 645 if ( x == '@' )
644 { 646 {
645 m_strUser = decode(QString( buf + start, pos - start ), encoding_hint); 647 m_strUser = decode(QString( buf + start, pos - start ), encoding_hint);
646 pos++; 648 pos++;
647 goto Node7; 649 goto Node7;
648 } 650 }
649 else if ( (x == '/') || (x == '?') || (x == '#')) 651 else if ( (x == '/') || (x == '?') || (x == '#'))
650 { 652 {
651 if (badHostName) 653 if (badHostName)
652 goto NodeErr; 654 goto NodeErr;
653 655
654 setHost(decode(QString( buf + start, pos - start ), encoding_hint)); 656 setHost(decode(QString( buf + start, pos - start ), encoding_hint));
655 start = pos; 657 start = pos;
656 goto Node9; 658 goto Node9;
657 } 659 }
658 else if ( x != ':' ) 660 else if ( x != ':' )
659 goto NodeErr; 661 goto NodeErr;
660 m_strUser = decode(QString( buf + start, pos - start ), encoding_hint); 662 m_strUser = decode(QString( buf + start, pos - start ), encoding_hint);
661 pos++; 663 pos++;
662 664
663 // Node 5: We need at least one character 665 // Node 5: We need at least one character
664 if ( pos == len ) 666 if ( pos == len )
665 goto NodeErr; 667 goto NodeErr;
666 start = pos++; 668 start = pos++;
667 669
668 // Node 6: Read everything until @, /, ? or # 670 // Node 6: Read everything until @, /, ? or #
669 while( (pos < len) && 671 while( (pos < len) &&
670 (buf[pos] != '@') && 672 (buf[pos] != '@') &&
671 (buf[pos] != '/') && 673 (buf[pos] != '/') &&
672 (buf[pos] != '?') && 674 (buf[pos] != '?') &&
673 (buf[pos] != '#')) pos++; 675 (buf[pos] != '#')) pos++;
674 // If we now have a '@' the ':' seperates user and password. 676 // If we now have a '@' the ':' seperates user and password.
675 // Otherwise it seperates host and port. 677 // Otherwise it seperates host and port.
676 if ( (pos == len) || (buf[pos] != '@') ) 678 if ( (pos == len) || (buf[pos] != '@') )
677 { 679 {
678 // Ok the : was used to separate host and port 680 // Ok the : was used to separate host and port
679 if (badHostName) 681 if (badHostName)
680 goto NodeErr; 682 goto NodeErr;
681 setHost(m_strUser); 683 setHost(m_strUser);
682 m_strUser = QString::null; 684 m_strUser = QString::null;
683 QString tmp( buf + start, pos - start ); 685 QString tmp( buf + start, pos - start );
684 char *endptr; 686 char *endptr;
685 m_iPort = (unsigned short int)strtol(tmp.ascii(), &endptr, 10); 687 m_iPort = (unsigned short int)strtol(tmp.ascii(), &endptr, 10);
686 if ((pos == len) && (strlen(endptr) == 0)) 688 if ((pos == len) && (strlen(endptr) == 0))
687 goto NodeOk; 689 goto NodeOk;
688 // there is more after the digits 690 // there is more after the digits
689 pos -= strlen(endptr); 691 pos -= strlen(endptr);
690 start = pos++; 692 start = pos++;
691 goto Node9; 693 goto Node9;
692 } 694 }
693 m_strPass = decode(QString( buf + start, pos - start), encoding_hint); 695 m_strPass = decode(QString( buf + start, pos - start), encoding_hint);
694 pos++; 696 pos++;
695 697
696 // Node 7: We need at least one character 698 // Node 7: We need at least one character
697 Node7: 699 Node7:
698 if ( pos == len ) 700 if ( pos == len )
699 goto NodeErr; 701 goto NodeErr;
700 702
701 Node8: 703 Node8:
702 if (buf[pos] == '[') 704 if (buf[pos] == '[')
703 { 705 {
704 // IPv6 address 706 // IPv6 address
705 start = ++pos; // Skip '[' 707 start = ++pos; // Skip '['
706 708
707 if (pos == len) 709 if (pos == len)
708 { 710 {
709 badHostName = true; 711 badHostName = true;
710 goto NodeErr; 712 goto NodeErr;
711 } 713 }
712 // Node 8b: Read everything until ] or terminate 714 // Node 8b: Read everything until ] or terminate
713 badHostName = false; 715 badHostName = false;
714 x = buf[pos]; 716 x = buf[pos];
715 while( (x != ']') ) 717 while( (x != ']') )
716 { 718 {
717 if ((x == '\"') || (x == ';') || (x == '<')) 719 if ((x == '\"') || (x == ';') || (x == '<'))
718 badHostName = true; 720 badHostName = true;
719 if (++pos == len) 721 if (++pos == len)
720 { 722 {
721 badHostName = true; 723 badHostName = true;
722 break; 724 break;
723 } 725 }
724 x = buf[pos]; 726 x = buf[pos];
725 } 727 }
726 if (badHostName) 728 if (badHostName)
727 goto NodeErr; 729 goto NodeErr;
728 setHost(decode(QString( buf + start, pos - start ), encoding_hint)); 730 setHost(decode(QString( buf + start, pos - start ), encoding_hint));
729 if (pos < len) pos++; // Skip ']' 731 if (pos < len) pos++; // Skip ']'
730 if (pos == len) 732 if (pos == len)
731 goto NodeOk; 733 goto NodeOk;
732 } 734 }
733 else 735 else
734 { 736 {
735 // Non IPv6 address 737 // Non IPv6 address
736 start = pos; 738 start = pos;
737 739
738 // Node 8b: Read everything until / : or terminate 740 // Node 8b: Read everything until / : or terminate
739 badHostName = false; 741 badHostName = false;
740 x = buf[pos]; 742 x = buf[pos];
741 while( (x != ':') && (x != '@') && (x != '/') && (x != '?') && (x != '#') ) 743 while( (x != ':') && (x != '@') && (x != '/') && (x != '?') && (x != '#') )
742 { 744 {
743 if ((x == '\"') || (x == ';') || (x == '<')) 745 if ((x == '\"') || (x == ';') || (x == '<'))
744 badHostName = true; 746 badHostName = true;
745 if (++pos == len) 747 if (++pos == len)
746 break; 748 break;
747 x = buf[pos]; 749 x = buf[pos];
748 } 750 }
749 if (badHostName) 751 if (badHostName)
750 goto NodeErr; 752 goto NodeErr;
751 if ( pos == len ) 753 if ( pos == len )
752 { 754 {
753 setHost(decode(QString( buf + start, pos - start ), encoding_hint)); 755 setHost(decode(QString( buf + start, pos - start ), encoding_hint));
754 goto NodeOk; 756 goto NodeOk;
755 } 757 }
756 setHost(decode(QString( buf + start, pos - start ), encoding_hint)); 758 setHost(decode(QString( buf + start, pos - start ), encoding_hint));
757 } 759 }
758 x = buf[pos]; 760 x = buf[pos];
759 if ( x == '/' ) 761 if ( x == '/' )
760 { 762 {
761 start = pos++; 763 start = pos++;
762 goto Node9; 764 goto Node9;
763 } 765 }
764 else if ( x != ':' ) 766 else if ( x != ':' )
765 goto NodeErr; 767 goto NodeErr;
766 pos++; 768 pos++;
767 769
768 // Node 8a: Accept at least one digit 770 // Node 8a: Accept at least one digit
769 if ( pos == len ) 771 if ( pos == len )
770 goto NodeErr; 772 goto NodeErr;
771 start = pos; 773 start = pos;
772 if ( !isdigit( buf[pos++] ) ) 774 if ( !buf[pos++].isDigit() )
773 goto NodeErr; 775 goto NodeErr;
774 776
775 // Node 8b: Accept any amount of digits 777 // Node 8b: Accept any amount of digits
776 while( pos < len && isdigit( buf[pos] ) ) pos++; 778 while( pos < len && buf[pos].isDigit() ) pos++;
777 port = QString( buf + start, pos - start ); 779 port = QString( buf + start, pos - start );
778 m_iPort = port.toUShort(); 780 m_iPort = port.toUShort();
779 if ( pos == len ) 781 if ( pos == len )
780 goto NodeOk; 782 goto NodeOk;
781 start = pos++; 783 start = pos++;
782 784
783 Node9: // parse path until query or reference reached 785 Node9: // parse path until query or reference reached
784 786
785 while( pos < len && buf[pos] != '#' && buf[pos]!='?' ) pos++; 787 while( pos < len && buf[pos] != '#' && buf[pos]!='?' ) pos++;
786 788
787 tmp = QString( buf + start, pos - start ); 789 tmp = QString( buf + start, pos - start );
788 //kdDebug(126)<<" setting encoded path&query to:"<<tmp<<endl; 790 //kdDebug(126)<<" setting encoded path&query to:"<<tmp<<endl;
789 setEncodedPath( tmp, encoding_hint ); 791 setEncodedPath( tmp, encoding_hint );
790 792
791 if ( pos == len ) 793 if ( pos == len )
792 goto NodeOk; 794 goto NodeOk;
793 795
794 //Node10: // parse query or reference depending on what comes first 796 //Node10: // parse query or reference depending on what comes first
795 delim = (buf[pos++]=='#'?'?':'#'); 797 delim = (buf[pos++]=='#'?'?':'#');
796 798
797 start = pos; 799 start = pos;
798 800
799 while(pos < len && buf[pos]!=delim ) pos++; 801 while(pos < len && buf[pos]!=delim ) pos++;
800 802
801 tmp = QString(buf + start, pos - start); 803 tmp = QString(buf + start, pos - start);
802 if (delim=='#') 804 if (delim=='#')
803 setQuery(tmp, encoding_hint); 805 setQuery(tmp, encoding_hint);
804 else 806 else
805 m_strRef_encoded = tmp; 807 m_strRef_encoded = tmp;
806 808
807 if (pos == len) 809 if (pos == len)
808 goto NodeOk; 810 goto NodeOk;
809 811
810 //Node11: // feed the rest into the remaining variable 812 //Node11: // feed the rest into the remaining variable
811 tmp = QString( buf + pos + 1, len - pos - 1); 813 tmp = QString( buf + pos + 1, len - pos - 1);
812 if (delim == '#') 814 if (delim == '#')
813 m_strRef_encoded = tmp; 815 m_strRef_encoded = tmp;
814 else 816 else
815 setQuery(tmp, encoding_hint); 817 setQuery(tmp, encoding_hint);
816 818
817 NodeOk: 819 NodeOk:
818 //kdDebug(126)<<"parsing finished. m_strProtocol="<<m_strProtocol<<" m_strHost="<<m_strHost<<" m_strPath="<<m_strPath<<endl; 820 //kdDebug(126)<<"parsing finished. m_strProtocol="<<m_strProtocol<<" m_strHost="<<m_strHost<<" m_strPath="<<m_strPath<<endl;
819 m_bIsMalformed = false; // Valid URL 821 m_bIsMalformed = false; // Valid URL
820 822
821 //kdDebug()<<"Prot="<<m_strProtocol<<"\nUser="<<m_strUser<<"\nPass="<<m_strPass<<"\nHost="<<m_strHost<<"\nPath="<<m_strPath<<"\nQuery="<<m_strQuery_encoded<<"\nRef="<<m_strRef_encoded<<"\nPort="<<m_iPort<<endl; 823 //kdDebug()<<"Prot="<<m_strProtocol<<"\nUser="<<m_strUser<<"\nPass="<<m_strPass<<"\nHost="<<m_strHost<<"\nPath="<<m_strPath<<"\nQuery="<<m_strQuery_encoded<<"\nRef="<<m_strRef_encoded<<"\nPort="<<m_iPort<<endl;
822 if (m_strProtocol.isEmpty()) 824 if (m_strProtocol.isEmpty())
823 { 825 {
824 m_strProtocol = fileProt; 826 m_strProtocol = fileProt;
825 } 827 }
826 return; 828 return;
827 829
828 NodeErr: 830 NodeErr:
829// kdDebug(126) << "KURL couldn't parse URL \"" << _url << "\"" << endl; 831// kdDebug(126) << "KURL couldn't parse URL \"" << _url << "\"" << endl;
830 reset(); 832 reset();
831 m_strProtocol = _url; 833 m_strProtocol = _url;
832} 834}
833 835
834KURL& KURL::operator=( const QString& _url ) 836KURL& KURL::operator=( const QString& _url )
835{ 837{
836 reset(); 838 reset();
837 parse( _url ); 839 parse( _url );
838 840
839 return *this; 841 return *this;
840} 842}
841 843
842KURL& KURL::operator=( const char * _url ) 844KURL& KURL::operator=( const char * _url )
843{ 845{
844 reset(); 846 reset();
845 parse( QString::fromLatin1(_url) ); 847 parse( QString::fromLatin1(_url) );
846 848
847 return *this; 849 return *this;
848} 850}
849 851
850#ifndef QT_NO_NETWORKPROTOCOL 852#ifndef QT_NO_NETWORKPROTOCOL
851KURL& KURL::operator=( const QUrl & u ) 853KURL& KURL::operator=( const Q3Url & u )
852{ 854{
853 m_strProtocol = u.protocol(); 855 m_strProtocol = u.protocol();
854 m_strUser = u.user(); 856 m_strUser = u.user();
855 m_strPass = u.password(); 857 m_strPass = u.password();
856 m_strHost = u.host(); 858 m_strHost = u.host();
857 m_strPath = u.path( FALSE ); 859 m_strPath = u.path( FALSE );
858 m_strPath_encoded = QString::null; 860 m_strPath_encoded = QString::null;
859 m_strQuery_encoded = u.query(); 861 m_strQuery_encoded = u.query();
860 m_strRef_encoded = u.ref(); 862 m_strRef_encoded = u.ref();
861 m_bIsMalformed = !u.isValid(); 863 m_bIsMalformed = !u.isValid();
862 m_iPort = u.port(); 864 m_iPort = u.port();
863 865
864 return *this; 866 return *this;
865} 867}
866#endif 868#endif
867 869
868KURL& KURL::operator=( const KURL& _u ) 870KURL& KURL::operator=( const KURL& _u )
869{ 871{
870 m_strProtocol = _u.m_strProtocol; 872 m_strProtocol = _u.m_strProtocol;
871 m_strUser = _u.m_strUser; 873 m_strUser = _u.m_strUser;
872 m_strPass = _u.m_strPass; 874 m_strPass = _u.m_strPass;
873 m_strHost = _u.m_strHost; 875 m_strHost = _u.m_strHost;
874 m_strPath = _u.m_strPath; 876 m_strPath = _u.m_strPath;
875 m_strPath_encoded = _u.m_strPath_encoded; 877 m_strPath_encoded = _u.m_strPath_encoded;
876 m_strQuery_encoded = _u.m_strQuery_encoded; 878 m_strQuery_encoded = _u.m_strQuery_encoded;
877 m_strRef_encoded = _u.m_strRef_encoded; 879 m_strRef_encoded = _u.m_strRef_encoded;
878 m_bIsMalformed = _u.m_bIsMalformed; 880 m_bIsMalformed = _u.m_bIsMalformed;
879 m_iPort = _u.m_iPort; 881 m_iPort = _u.m_iPort;
880 882
881 return *this; 883 return *this;
882} 884}
883 885
884bool KURL::operator==( const KURL& _u ) const 886bool KURL::operator==( const KURL& _u ) const
885{ 887{
886 if ( isMalformed() || _u.isMalformed() ) 888 if ( isMalformed() || _u.isMalformed() )
887 return false; 889 return false;
888 890
889 if ( m_strProtocol == _u.m_strProtocol && 891 if ( m_strProtocol == _u.m_strProtocol &&
890 m_strUser == _u.m_strUser && 892 m_strUser == _u.m_strUser &&
891 m_strPass == _u.m_strPass && 893 m_strPass == _u.m_strPass &&
892 m_strHost == _u.m_strHost && 894 m_strHost == _u.m_strHost &&
893 m_strPath == _u.m_strPath && 895 m_strPath == _u.m_strPath &&
894 // The encoded path may be null, but the URLs are still equal (David) 896 // The encoded path may be null, but the URLs are still equal (David)
895 ( m_strPath_encoded.isNull() || _u.m_strPath_encoded.isNull() || 897 ( m_strPath_encoded.isNull() || _u.m_strPath_encoded.isNull() ||
896 m_strPath_encoded == _u.m_strPath_encoded ) && 898 m_strPath_encoded == _u.m_strPath_encoded ) &&
897 m_strQuery_encoded == _u.m_strQuery_encoded && 899 m_strQuery_encoded == _u.m_strQuery_encoded &&
898 m_strRef_encoded == _u.m_strRef_encoded && 900 m_strRef_encoded == _u.m_strRef_encoded &&
899 m_iPort == _u.m_iPort ) 901 m_iPort == _u.m_iPort )
900 { 902 {
901 return true; 903 return true;
902 } 904 }
903 905
904 return false; 906 return false;
905} 907}
906 908
907bool KURL::operator==( const QString& _u ) const 909bool KURL::operator==( const QString& _u ) const
908{ 910{
909 KURL u( _u ); 911 KURL u( _u );
910 return ( *this == u ); 912 return ( *this == u );
911} 913}
912 914
913bool KURL::cmp( const KURL &u, bool ignore_trailing ) const 915bool KURL::cmp( const KURL &u, bool ignore_trailing ) const
914{ 916{
915 return equals( u, ignore_trailing ); 917 return equals( u, ignore_trailing );
916} 918}
917 919
918bool KURL::equals( const KURL &_u, bool ignore_trailing ) const 920bool KURL::equals( const KURL &_u, bool ignore_trailing ) const
919{ 921{
920 if ( isMalformed() || _u.isMalformed() ) 922 if ( isMalformed() || _u.isMalformed() )
921 return false; 923 return false;
922 924
923 if ( ignore_trailing ) 925 if ( ignore_trailing )
924 { 926 {
925 QString path1 = path(1); 927 QString path1 = path(1);
926 QString path2 = _u.path(1); 928 QString path2 = _u.path(1);
927 if ( path1 != path2 ) 929 if ( path1 != path2 )
928 return false; 930 return false;
929 931
930 if ( m_strProtocol == _u.m_strProtocol && 932 if ( m_strProtocol == _u.m_strProtocol &&
931 m_strUser == _u.m_strUser && 933 m_strUser == _u.m_strUser &&
932 m_strPass == _u.m_strPass && 934 m_strPass == _u.m_strPass &&
933 m_strHost == _u.m_strHost && 935 m_strHost == _u.m_strHost &&
934 m_strQuery_encoded == _u.m_strQuery_encoded && 936 m_strQuery_encoded == _u.m_strQuery_encoded &&
935 m_strRef_encoded == _u.m_strRef_encoded && 937 m_strRef_encoded == _u.m_strRef_encoded &&
936 m_iPort == _u.m_iPort ) 938 m_iPort == _u.m_iPort )
937 return true; 939 return true;
938 940
939 return false; 941 return false;
940 } 942 }
941 943
942 return ( *this == _u ); 944 return ( *this == _u );
943} 945}
944 946
945bool KURL::isParentOf( const KURL& _u ) const 947bool KURL::isParentOf( const KURL& _u ) const
946{ 948{
947 if ( isMalformed() || _u.isMalformed() ) 949 if ( isMalformed() || _u.isMalformed() )
948 return false; 950 return false;
949 951
950 if ( m_strProtocol == _u.m_strProtocol && 952 if ( m_strProtocol == _u.m_strProtocol &&
951 m_strUser == _u.m_strUser && 953 m_strUser == _u.m_strUser &&
952 m_strPass == _u.m_strPass && 954 m_strPass == _u.m_strPass &&
953 m_strHost == _u.m_strHost && 955 m_strHost == _u.m_strHost &&
954 m_strQuery_encoded == _u.m_strQuery_encoded && 956 m_strQuery_encoded == _u.m_strQuery_encoded &&
955 m_strRef_encoded == _u.m_strRef_encoded && 957 m_strRef_encoded == _u.m_strRef_encoded &&
956 m_iPort == _u.m_iPort ) 958 m_iPort == _u.m_iPort )
957 { 959 {
958 if ( path().isEmpty() || _u.path().isEmpty() ) 960 if ( path().isEmpty() || _u.path().isEmpty() )
959 return false; // can't work with implicit paths 961 return false; // can't work with implicit paths
960 962
961 QString p1( cleanpath( path() ) ); 963 QString p1( cleanpath( path() ) );
962 if ( p1.at(p1.length()-1) != '/' ) 964 if ( p1.at(p1.length()-1) != '/' )
963 p1 += '/'; 965 p1 += '/';
964 QString p2( cleanpath( _u.path() ) ); 966 QString p2( cleanpath( _u.path() ) );
965 if ( p2.at(p2.length()-1) != '/' ) 967 if ( p2.at(p2.length()-1) != '/' )
966 p2 += '/'; 968 p2 += '/';
967 969
968 //kdDebug(126) << "p1=" << p1 << endl; 970 //kdDebug(126) << "p1=" << p1 << endl;
969 //kdDebug(126) << "p2=" << p2 << endl; 971 //kdDebug(126) << "p2=" << p2 << endl;
970 //kdDebug(126) << "p1.length()=" << p1.length() << endl; 972 //kdDebug(126) << "p1.length()=" << p1.length() << endl;
971 //kdDebug(126) << "p2.left(!$)=" << p2.left( p1.length() ) << endl; 973 //kdDebug(126) << "p2.left(!$)=" << p2.left( p1.length() ) << endl;
972 return p2.startsWith( p1 ); 974 return p2.startsWith( p1 );
973 } 975 }
974 return false; 976 return false;
975} 977}
976 978
977void KURL::setFileName( const QString& _txt ) 979void KURL::setFileName( const QString& _txt )
978{ 980{
979 m_strRef_encoded = QString::null; 981 m_strRef_encoded = QString::null;
980 int i = 0; 982 int i = 0;
981 while( _txt[i] == '/' ) ++i; 983 while( _txt[i] == '/' ) ++i;
982 QString tmp; 984 QString tmp;
983 if ( i ) 985 if ( i )
984 tmp = _txt.mid( i ); 986 tmp = _txt.mid( i );
985 else 987 else
986 tmp = _txt; 988 tmp = _txt;
987 989
988 QString path = m_strPath_encoded.isEmpty() ? m_strPath : m_strPath_encoded; 990 QString path = m_strPath_encoded.isEmpty() ? m_strPath : m_strPath_encoded;
989 if ( path.isEmpty() ) 991 if ( path.isEmpty() )
990 path = "/"; 992 path = "/";
991 else 993 else
992 { 994 {
993 int lastSlash = path.findRev( '/' ); 995 int lastSlash = path.findRev( '/' );
994 if ( lastSlash == -1) 996 if ( lastSlash == -1)
995 { 997 {
996 // The first character is not a '/' ??? 998 // The first character is not a '/' ???
997 // This looks strange ... 999 // This looks strange ...
998 path = "/"; 1000 path = "/";
999 } 1001 }
1000 else if ( path.right(1) != "/" ) 1002 else if ( path.right(1) != "/" )
1001 path.truncate( lastSlash+1 ); // keep the "/" 1003 path.truncate( lastSlash+1 ); // keep the "/"
1002 } 1004 }
1003 if (m_strPath_encoded.isEmpty()) 1005 if (m_strPath_encoded.isEmpty())
1004 { 1006 {
1005 path += tmp; 1007 path += tmp;
1006 setPath( path ); 1008 setPath( path );
1007 } 1009 }
1008 else 1010 else
1009 { 1011 {
1010 path += encode_string(tmp); 1012 path += encode_string(tmp);
1011 setEncodedPath( path ); 1013 setEncodedPath( path );
1012 } 1014 }
1013 cleanPath(); 1015 cleanPath();
1014} 1016}
1015 1017
1016void KURL::cleanPath( bool cleanDirSeparator ) // taken from the old KURL 1018void KURL::cleanPath( bool cleanDirSeparator ) // taken from the old KURL
1017{ 1019{
1018 m_strPath = cleanpath(m_strPath, cleanDirSeparator); 1020 m_strPath = cleanpath(m_strPath, cleanDirSeparator);
1019 // WABA: Is this safe when "/../" is encoded with %? 1021 // WABA: Is this safe when "/../" is encoded with %?
1020 m_strPath_encoded = cleanpath(m_strPath_encoded, cleanDirSeparator); 1022 m_strPath_encoded = cleanpath(m_strPath_encoded, cleanDirSeparator);
1021} 1023}
1022 1024
1023static QString trailingSlash( int _trailing, const QString &path ) 1025static QString trailingSlash( int _trailing, const QString &path )
1024{ 1026{
1025 QString result = path; 1027 QString result = path;
1026 1028
1027 if ( _trailing == 0 ) 1029 if ( _trailing == 0 )
1028 return result; 1030 return result;
1029 else if ( _trailing == 1 ) 1031 else if ( _trailing == 1 )
1030 { 1032 {
1031 int len = result.length(); 1033 int len = result.length();
1032 if ( len == 0 ) 1034 if ( len == 0 )
1033 result = QString::null; 1035 result = QString::null;
1034 else if ( result[ len - 1 ] != '/' ) 1036 else if ( result[ len - 1 ] != '/' )
1035 result += "/"; 1037 result += "/";
1036 return result; 1038 return result;
1037 } 1039 }
1038 else if ( _trailing == -1 ) 1040 else if ( _trailing == -1 )
1039 { 1041 {
1040 if ( result == "/" ) 1042 if ( result == "/" )
1041 return result; 1043 return result;
1042 int len = result.length(); 1044 int len = result.length();
1043 if ( len != 0 && result[ len - 1 ] == '/' ) 1045 if ( len != 0 && result[ len - 1 ] == '/' )
1044 result.truncate( len - 1 ); 1046 result.truncate( len - 1 );
1045 return result; 1047 return result;
1046 } 1048 }
1047 else { 1049 else {
1048 assert( 0 ); 1050 assert( 0 );
1049 return QString::null; 1051 return QString::null;
1050 } 1052 }
1051} 1053}
1052 1054
1053void KURL::adjustPath( int _trailing ) 1055void KURL::adjustPath( int _trailing )
1054{ 1056{
1055 if (!m_strPath_encoded.isEmpty()) 1057 if (!m_strPath_encoded.isEmpty())
1056 { 1058 {
1057 m_strPath_encoded = trailingSlash( _trailing, m_strPath_encoded ); 1059 m_strPath_encoded = trailingSlash( _trailing, m_strPath_encoded );
1058 } 1060 }
1059 m_strPath = trailingSlash( _trailing, m_strPath ); 1061 m_strPath = trailingSlash( _trailing, m_strPath );
1060} 1062}
1061 1063
1062 1064
1063QString KURL::encodedPathAndQuery( int _trailing, bool _no_empty_path, int encoding_hint ) const 1065QString KURL::encodedPathAndQuery( int _trailing, bool _no_empty_path, int encoding_hint ) const
1064{ 1066{
1065 QString tmp; 1067 QString tmp;
1066 if (!m_strPath_encoded.isEmpty() && encoding_hint == 0) 1068 if (!m_strPath_encoded.isEmpty() && encoding_hint == 0)
1067 { 1069 {
1068 tmp = trailingSlash( _trailing, m_strPath_encoded ); 1070 tmp = trailingSlash( _trailing, m_strPath_encoded );
1069 } 1071 }
1070 else 1072 else
1071 { 1073 {
1072 tmp = path( _trailing ); 1074 tmp = path( _trailing );
1073 if ( _no_empty_path && tmp.isEmpty() ) 1075 if ( _no_empty_path && tmp.isEmpty() )
1074 tmp = "/"; 1076 tmp = "/";
1075 tmp = encode( tmp, false, encoding_hint ); 1077 tmp = encode( tmp, false, encoding_hint );
1076 } 1078 }
1077 1079
1078 // TODO apply encoding_hint to the query 1080 // TODO apply encoding_hint to the query
1079 if (!m_strQuery_encoded.isNull()) 1081 if (!m_strQuery_encoded.isNull())
1080 tmp += '?' + m_strQuery_encoded; 1082 tmp += '?' + m_strQuery_encoded;
1081 return tmp; 1083 return tmp;
1082} 1084}
1083 1085
1084void KURL::setEncodedPath( const QString& _txt, int encoding_hint ) 1086void KURL::setEncodedPath( const QString& _txt, int encoding_hint )
1085{ 1087{
1086 m_strPath_encoded = _txt; 1088 m_strPath_encoded = _txt;
1087 1089
1088 decode( m_strPath_encoded, m_strPath, m_strPath_encoded, encoding_hint ); 1090 decode( m_strPath_encoded, m_strPath, m_strPath_encoded, encoding_hint );
1089 // Throw away encoding for local files, makes file-operations faster. 1091 // Throw away encoding for local files, makes file-operations faster.
1090 if (m_strProtocol == fileProt) 1092 if (m_strProtocol == fileProt)
1091 m_strPath_encoded = QString::null; 1093 m_strPath_encoded = QString::null;
1092} 1094}
1093 1095
1094 1096
1095void KURL::setEncodedPathAndQuery( const QString& _txt, int encoding_hint ) 1097void KURL::setEncodedPathAndQuery( const QString& _txt, int encoding_hint )
1096{ 1098{
1097 int pos = _txt.find( '?' ); 1099 int pos = _txt.find( '?' );
1098 if ( pos == -1 ) 1100 if ( pos == -1 )
1099 { 1101 {
1100 setEncodedPath(_txt, encoding_hint); 1102 setEncodedPath(_txt, encoding_hint);
1101 m_strQuery_encoded = QString::null; 1103 m_strQuery_encoded = QString::null;
1102 } 1104 }
1103 else 1105 else
1104 { 1106 {
1105 setEncodedPath(_txt.left( pos ), encoding_hint); 1107 setEncodedPath(_txt.left( pos ), encoding_hint);
1106 setQuery(_txt.right(_txt.length() - pos - 1), encoding_hint); 1108 setQuery(_txt.right(_txt.length() - pos - 1), encoding_hint);
1107 } 1109 }
1108} 1110}
1109 1111
1110QString KURL::path( int _trailing ) const 1112QString KURL::path( int _trailing ) const
1111{ 1113{
1112 return trailingSlash( _trailing, path() ); 1114 return trailingSlash( _trailing, path() );
1113} 1115}
1114 1116
1115bool KURL::isLocalFile() const 1117bool KURL::isLocalFile() const
1116{ 1118{
1117 if ( (m_strProtocol != fileProt ) || hasSubURL() ) 1119 if ( (m_strProtocol != fileProt ) || hasSubURL() )
1118 return false; 1120 return false;
1119 1121
1120 if (m_strHost.isEmpty() || (m_strHost == "localhost")) 1122 if (m_strHost.isEmpty() || (m_strHost == "localhost"))
1121 return true; 1123 return true;
1122 1124
1123 char hostname[ 256 ]; 1125 char hostname[ 256 ];
1124 hostname[ 0 ] = '\0'; 1126 hostname[ 0 ] = '\0';
1125#ifdef _WIN32_ 1127#ifdef _WIN32_
1126 // pending LR fixme 1128 // pending LR fixme
1127 //hostname = "localhost"; 1129 //hostname = "localhost";
1128#else 1130#else
1129 if (!gethostname( hostname, 255 )) 1131 if (!gethostname( hostname, 255 ))
1130 hostname[sizeof(hostname)-1] = '\0'; 1132 hostname[sizeof(hostname)-1] = '\0';
1131#endif 1133#endif
1132 for(char *p = hostname; *p; p++) 1134 for(char *p = hostname; *p; p++)
1133 *p = tolower(*p); 1135 *p = tolower(*p);
1134 1136
1135 return (m_strHost == hostname); 1137 return (m_strHost == hostname);
1136} 1138}
1137 1139
1138void KURL::setFileEncoding(const QString &encoding) 1140void KURL::setFileEncoding(const QString &encoding)
1139{ 1141{
1140 if (!isLocalFile()) 1142 if (!isLocalFile())
1141 return; 1143 return;
1142 1144
1143 QString q = query(); 1145 QString q = query();
1144 1146
1145 if (!q.isEmpty() && (q[0] == '?')) 1147 if (!q.isEmpty() && (q[0] == '?'))
1146 q = q.mid(1); 1148 q = q.mid(1);
1147 1149
1148 QStringList args = QStringList::split('&', q); 1150 QStringList args = QStringList::split('&', q);
1149 for(QStringList::Iterator it = args.begin(); 1151 for(QStringList::Iterator it = args.begin();
1150 it != args.end();) 1152 it != args.end();)
1151 { 1153 {
1152 QString s = decode_string(*it); 1154 QString s = decode_string(*it);
1153 if (s.startsWith("charset=")) 1155 if (s.startsWith("charset="))
1154//US changed erase into remove ??? 1156//US changed erase into remove ???
1155 it = args.remove(it); 1157 it = args.remove(it);
1156 else 1158 else
1157 ++it; 1159 ++it;
1158 } 1160 }
1159 if (!encoding.isEmpty()) 1161 if (!encoding.isEmpty())
1160 args.append("charset="+encode_string(encoding)); 1162 args.append("charset="+encode_string(encoding));
1161 1163
1162 if (args.isEmpty()) 1164 if (args.isEmpty())
1163 setQuery(QString::null); 1165 setQuery(QString::null);
1164 else 1166 else
1165 setQuery(args.join("&")); 1167 setQuery(args.join("&"));
1166} 1168}
1167 1169
1168QString KURL::fileEncoding() const 1170QString KURL::fileEncoding() const
1169{ 1171{
1170 if (!isLocalFile()) 1172 if (!isLocalFile())
1171 return QString::null; 1173 return QString::null;
1172 1174
1173 QString q = query(); 1175 QString q = query();
1174 1176
1175 if (q.isEmpty()) 1177 if (q.isEmpty())
1176 return QString::null; 1178 return QString::null;
1177 1179
1178 if (q[0] == '?') 1180 if (q[0] == '?')
1179 q = q.mid(1); 1181 q = q.mid(1);
1180 1182
1181 QStringList args = QStringList::split('&', q); 1183 QStringList args = QStringList::split('&', q);
1182 for(QStringList::ConstIterator it = args.begin(); 1184 for(QStringList::ConstIterator it = args.begin();
1183 it != args.end(); 1185 it != args.end();
1184 ++it) 1186 ++it)
1185 { 1187 {
1186 QString s = decode_string(*it); 1188 QString s = decode_string(*it);
1187 if (s.startsWith("charset=")) 1189 if (s.startsWith("charset="))
1188 return s.mid(8); 1190 return s.mid(8);
1189 } 1191 }
1190 return QString::null; 1192 return QString::null;
1191} 1193}
1192 1194
1193bool KURL::hasSubURL() const 1195bool KURL::hasSubURL() const
1194{ 1196{
1195 if ( m_strProtocol.isEmpty() || m_bIsMalformed ) 1197 if ( m_strProtocol.isEmpty() || m_bIsMalformed )
1196 return false; 1198 return false;
1197 if (m_strRef_encoded.isEmpty()) 1199 if (m_strRef_encoded.isEmpty())
1198 return false; 1200 return false;
1199 if (m_strRef_encoded.startsWith("gzip:")) 1201 if (m_strRef_encoded.startsWith("gzip:"))
1200 return true; 1202 return true;
1201 if (m_strRef_encoded.startsWith("bzip:")) 1203 if (m_strRef_encoded.startsWith("bzip:"))
1202 return true; 1204 return true;
1203 if (m_strRef_encoded.startsWith("bzip2:")) 1205 if (m_strRef_encoded.startsWith("bzip2:"))
1204 return true; 1206 return true;
1205 if (m_strRef_encoded.startsWith("tar:")) 1207 if (m_strRef_encoded.startsWith("tar:"))
1206 return true; 1208 return true;
1207 if ( m_strProtocol == "error" ) // anything that starts with error: has suburls 1209 if ( m_strProtocol == "error" ) // anything that starts with error: has suburls
1208 return true; 1210 return true;
1209 return false; 1211 return false;
1210} 1212}
1211 1213
1212QString KURL::url( int _trailing, int encoding_hint ) const 1214QString KURL::url( int _trailing, int encoding_hint ) const
1213{ 1215{
1214 if( m_bIsMalformed ) 1216 if( m_bIsMalformed )
1215 { 1217 {
1216 // Return the whole url even when the url is 1218 // Return the whole url even when the url is
1217 // malformed. Under such conditions the url 1219 // malformed. Under such conditions the url
1218 // is stored in m_strProtocol. 1220 // is stored in m_strProtocol.
1219 return m_strProtocol; 1221 return m_strProtocol;
1220 } 1222 }
1221 1223
1222 QString u = m_strProtocol; 1224 QString u = m_strProtocol;
1223 if (!u.isEmpty()) 1225 if (!u.isEmpty())
1224 u += ":"; 1226 u += ":";
1225 1227
1226 if ( hasHost() ) 1228 if ( hasHost() )
1227 { 1229 {
1228 u += "//"; 1230 u += "//";
1229 if ( hasUser() ) 1231 if ( hasUser() )
1230 { 1232 {
1231 u += encode(m_strUser, true, encoding_hint); 1233 u += encode(m_strUser, true, encoding_hint);
1232 if ( hasPass() ) 1234 if ( hasPass() )
1233 { 1235 {
1234 u += ":"; 1236 u += ":";
1235 u += encode(m_strPass, true, encoding_hint); 1237 u += encode(m_strPass, true, encoding_hint);
1236 } 1238 }
1237 u += "@"; 1239 u += "@";
1238 } 1240 }
1239 bool IPv6 = (m_strHost.find(':') != -1); 1241 bool IPv6 = (m_strHost.find(':') != -1);
1240 if (IPv6) 1242 if (IPv6)
1241 u += '[' + m_strHost + ']'; 1243 u += '[' + m_strHost + ']';
1242 else 1244 else
1243 u += encodeHost(m_strHost, true, encoding_hint); 1245 u += encodeHost(m_strHost, true, encoding_hint);
1244 if ( m_iPort != 0 ) { 1246 if ( m_iPort != 0 ) {
1245 QString buffer; 1247 QString buffer;
1246 buffer.sprintf( ":%u", m_iPort ); 1248 buffer.sprintf( ":%u", m_iPort );
1247 u += buffer; 1249 u += buffer;
1248 } 1250 }
1249 } 1251 }
1250 1252
1251 u += encodedPathAndQuery( _trailing, false, encoding_hint ); 1253 u += encodedPathAndQuery( _trailing, false, encoding_hint );
1252 1254
1253 if ( hasRef() ) 1255 if ( hasRef() )
1254 { 1256 {
1255 u += "#"; 1257 u += "#";
1256 u += m_strRef_encoded; 1258 u += m_strRef_encoded;
1257 } 1259 }
1258 1260
1259 return u; 1261 return u;
1260} 1262}
1261 1263
1262QString KURL::prettyURL( int _trailing ) const 1264QString KURL::prettyURL( int _trailing ) const
1263{ 1265{
1264 if( m_bIsMalformed ) 1266 if( m_bIsMalformed )
1265 { 1267 {
1266 // Return the whole url even when the url is 1268 // Return the whole url even when the url is
1267 // malformed. Under such conditions the url 1269 // malformed. Under such conditions the url
1268 // is stored in m_strProtocol. 1270 // is stored in m_strProtocol.
1269 return m_strProtocol; 1271 return m_strProtocol;
1270 } 1272 }
1271 1273
1272 QString u = m_strProtocol; 1274 QString u = m_strProtocol;
1273 if (!u.isEmpty()) 1275 if (!u.isEmpty())
1274 u += ":"; 1276 u += ":";
1275 1277
1276 if ( hasHost() ) 1278 if ( hasHost() )
1277 { 1279 {
1278 u += "//"; 1280 u += "//";
1279 if ( hasUser() ) 1281 if ( hasUser() )
1280 { 1282 {
1281 u += lazy_encode(m_strUser); 1283 u += lazy_encode(m_strUser);
1282 // Don't show password! 1284 // Don't show password!
1283 u += "@"; 1285 u += "@";
1284 } 1286 }
1285 bool IPv6 = (m_strHost.find(':') != -1); 1287 bool IPv6 = (m_strHost.find(':') != -1);
1286 if (IPv6) 1288 if (IPv6)
1287 { 1289 {
1288 u += '[' + m_strHost + ']'; 1290 u += '[' + m_strHost + ']';
1289 } 1291 }
1290 else 1292 else
1291 { 1293 {
1292 u += lazy_encode(m_strHost); 1294 u += lazy_encode(m_strHost);
1293 } 1295 }
1294 if ( m_iPort != 0 ) { 1296 if ( m_iPort != 0 ) {
1295 QString buffer; 1297 QString buffer;
1296 buffer.sprintf( ":%u", m_iPort ); 1298 buffer.sprintf( ":%u", m_iPort );
1297 u += buffer; 1299 u += buffer;
1298 } 1300 }
1299 } 1301 }
1300 1302
1301 u += trailingSlash( _trailing, lazy_encode( m_strPath ) ); 1303 u += trailingSlash( _trailing, lazy_encode( m_strPath ) );
1302 if (!m_strQuery_encoded.isNull()) 1304 if (!m_strQuery_encoded.isNull())
1303 u += '?' + m_strQuery_encoded; 1305 u += '?' + m_strQuery_encoded;
1304 1306
1305 if ( hasRef() ) 1307 if ( hasRef() )
1306 { 1308 {
1307 u += "#"; 1309 u += "#";
1308 u += m_strRef_encoded; 1310 u += m_strRef_encoded;
1309 } 1311 }
1310 1312
1311 return u; 1313 return u;
1312} 1314}
1313 1315
1314QString KURL::prettyURL( int _trailing, AdjustementFlags _flags) const 1316QString KURL::prettyURL( int _trailing, AdjustementFlags _flags) const
1315{ 1317{
1316 QString u = prettyURL(_trailing); 1318 QString u = prettyURL(_trailing);
1317 if (_flags & StripFileProtocol && u.startsWith("file:")) 1319 if (_flags & StripFileProtocol && u.startsWith("file:"))
1318 u.remove(0, 5); 1320 u.remove(0, 5);
1319 return u; 1321 return u;
1320} 1322}
1321 1323
1322QString KURL::htmlURL() const 1324QString KURL::htmlURL() const
1323{ 1325{
1324//US QStyleSheet::escape was not in my Qt distribution. Why ??? 1326//US QStyleSheet::escape was not in my Qt distribution. Why ???
1325//US return QStyleSheet::escape(prettyURL()); 1327//US return QStyleSheet::escape(prettyURL());
1326 return prettyURL(); 1328 return prettyURL();
1327} 1329}
1328 1330
1329KURL::List KURL::split( const KURL& _url ) 1331KURL::List KURL::split( const KURL& _url )
1330{ 1332{
1331 QString ref; 1333 QString ref;
1332 KURL::List lst; 1334 KURL::List lst;
1333 KURL url = _url; 1335 KURL url = _url;
1334 1336
1335 while(true) 1337 while(true)
1336 { 1338 {
1337 KURL u = url; 1339 KURL u = url;
1338 u.m_strRef_encoded = QString::null; 1340 u.m_strRef_encoded = QString::null;
1339 lst.append(u); 1341 lst.append(u);
1340 if (url.hasSubURL()) 1342 if (url.hasSubURL())
1341 { 1343 {
1342 url = KURL(url.m_strRef_encoded); 1344 url = KURL(url.m_strRef_encoded);
1343 } 1345 }
1344 else 1346 else
1345 { 1347 {
1346 ref = url.m_strRef_encoded; 1348 ref = url.m_strRef_encoded;
1347 break; 1349 break;
1348 } 1350 }
1349 } 1351 }
1350 1352
1351 // Set HTML ref in all URLs. 1353 // Set HTML ref in all URLs.
1352 KURL::List::Iterator it; 1354 KURL::List::Iterator it;
1353 for( it = lst.begin() ; it != lst.end(); ++it ) 1355 for( it = lst.begin() ; it != lst.end(); ++it )
1354 { 1356 {
1355 (*it).m_strRef_encoded = ref; 1357 (*it).m_strRef_encoded = ref;
1356 } 1358 }
1357 1359
1358 return lst; 1360 return lst;
1359} 1361}
1360 1362
1361KURL::List KURL::split( const QString& _url ) 1363KURL::List KURL::split( const QString& _url )
1362{ 1364{
1363 return split(KURL(_url)); 1365 return split(KURL(_url));
1364} 1366}
1365 1367
1366KURL KURL::join( const KURL::List & lst ) 1368KURL KURL::join( const KURL::List & lst )
1367{ 1369{
1368 if (lst.isEmpty()) return KURL(); 1370 if (lst.isEmpty()) return KURL();
1369 KURL tmp; 1371 KURL tmp;
1370 1372
1371 KURL::List::ConstIterator first = lst.fromLast(); 1373 KURL::List::ConstIterator first = lst.fromLast();
1372 for( KURL::List::ConstIterator it = first; it != lst.end(); --it ) 1374 for( KURL::List::ConstIterator it = first; it != lst.end(); --it )
1373 { 1375 {
1374 KURL u(*it); 1376 KURL u(*it);
1375 if (it != first) 1377 if (it != first)
1376 { 1378 {
1377 if (!u.m_strRef_encoded) u.m_strRef_encoded = tmp.url(); 1379 if (u.m_strRef_encoded.isEmpty()) u.m_strRef_encoded = tmp.url();
1378 else u.m_strRef_encoded += "#" + tmp.url(); // Support more than one suburl thingy 1380 else u.m_strRef_encoded += "#" + tmp.url(); // Support more than one suburl thingy
1379 } 1381 }
1380 tmp = u; 1382 tmp = u;
1381 } 1383 }
1382 1384
1383 return tmp; 1385 return tmp;
1384} 1386}
1385 1387
1386QString KURL::fileName( bool _strip_trailing_slash ) const 1388QString KURL::fileName( bool _strip_trailing_slash ) const
1387{ 1389{
1388 QString fname; 1390 QString fname;
1389 if (hasSubURL()) { // If we have a suburl, then return the filename from there 1391 if (hasSubURL()) { // If we have a suburl, then return the filename from there
1390 KURL::List list = KURL::split(*this); 1392 KURL::List list = KURL::split(*this);
1391 KURL::List::Iterator it = list.fromLast(); 1393 KURL::List::Iterator it = list.fromLast();
1392 return (*it).fileName(_strip_trailing_slash); 1394 return (*it).fileName(_strip_trailing_slash);
1393 } 1395 }
1394 const QString &path = m_strPath; 1396 const QString &path = m_strPath;
1395 1397
1396 int len = path.length(); 1398 int len = path.length();
1397 if ( len == 0 ) 1399 if ( len == 0 )
1398 return fname; 1400 return fname;
1399 1401
1400 if ( _strip_trailing_slash ) 1402 if ( _strip_trailing_slash )
1401 { 1403 {
1402 while ( len >= 1 && path[ len - 1 ] == '/' ) 1404 while ( len >= 1 && path[ len - 1 ] == '/' )
1403 len--; 1405 len--;
1404 } 1406 }
1405 else if ( path[ len - 1 ] == '/' ) 1407 else if ( path[ len - 1 ] == '/' )
1406 return fname; 1408 return fname;
1407 1409
1408 // Does the path only consist of '/' characters ? 1410 // Does the path only consist of '/' characters ?
1409 if ( len == 1 && path[ 0 ] == '/' ) 1411 if ( len == 1 && path[ 0 ] == '/' )
1410 return fname; 1412 return fname;
1411 1413
1412 // Skip last n slashes 1414 // Skip last n slashes
1413 int n = 1; 1415 int n = 1;
1414 if (!m_strPath_encoded.isEmpty()) 1416 if (!m_strPath_encoded.isEmpty())
1415 { 1417 {
1416 // This is hairy, we need the last unencoded slash. 1418 // This is hairy, we need the last unencoded slash.
1417 // Count in the encoded string how many encoded slashes follow the last 1419 // Count in the encoded string how many encoded slashes follow the last
1418 // unencoded one. 1420 // unencoded one.
1419 int i = m_strPath_encoded.findRev( '/', len - 1 ); 1421 int i = m_strPath_encoded.findRev( '/', len - 1 );
1420 QString fileName_encoded = m_strPath_encoded.mid(i+1); 1422 QString fileName_encoded = m_strPath_encoded.mid(i+1);
1421 n += fileName_encoded.contains("%2f", false); 1423 n += fileName_encoded.count("%2f", Qt::CaseInsensitive);
1422 } 1424 }
1423 int i = len; 1425 int i = len;
1424 do { 1426 do {
1425 i = path.findRev( '/', i - 1 ); 1427 i = path.findRev( '/', i - 1 );
1426 } 1428 }
1427 while (--n && (i > 0)); 1429 while (--n && (i > 0));
1428 1430
1429 // If ( i == -1 ) => the first character is not a '/' 1431 // If ( i == -1 ) => the first character is not a '/'
1430 // So it's some URL like file:blah.tgz, return the whole path 1432 // So it's some URL like file:blah.tgz, return the whole path
1431 if ( i == -1 ) { 1433 if ( i == -1 ) {
1432 if ( len == (int)path.length() ) 1434 if ( len == (int)path.length() )
1433 fname = path; 1435 fname = path;
1434 else 1436 else
1435 // Might get here if _strip_trailing_slash is true 1437 // Might get here if _strip_trailing_slash is true
1436 fname = path.left( len ); 1438 fname = path.left( len );
1437 } 1439 }
1438 else 1440 else
1439 { 1441 {
1440 fname = path.mid( i + 1, len - i - 1 ); // TO CHECK 1442 fname = path.mid( i + 1, len - i - 1 ); // TO CHECK
1441 } 1443 }
1442 return fname; 1444 return fname;
1443} 1445}
1444 1446
1445void KURL::addPath( const QString& _txt ) 1447void KURL::addPath( const QString& _txt )
1446{ 1448{
1447 if (hasSubURL()) 1449 if (hasSubURL())
1448 { 1450 {
1449 KURL::List lst = split( *this ); 1451 KURL::List lst = split( *this );
1450 KURL &u = lst.last(); 1452 KURL &u = lst.last();
1451 u.addPath(_txt); 1453 u.addPath(_txt);
1452 *this = join( lst ); 1454 *this = join( lst );
1453 return; 1455 return;
1454 } 1456 }
1455 1457
1456 m_strPath_encoded = QString::null; 1458 m_strPath_encoded = QString::null;
1457 1459
1458 if ( _txt.isEmpty() ) 1460 if ( _txt.isEmpty() )
1459 return; 1461 return;
1460 1462
1461 int i = 0; 1463 int i = 0;
1462 int len = m_strPath.length(); 1464 int len = m_strPath.length();
1463 // NB: avoid three '/' when building a new path from nothing 1465 // NB: avoid three '/' when building a new path from nothing
1464 if ( len == 0 ) { 1466 if ( len == 0 ) {
1465 while( _txt[i] == '/' ) ++i; 1467 while( _txt[i] == '/' ) ++i;
1466 } 1468 }
1467 // Add the trailing '/' if it is missing 1469 // Add the trailing '/' if it is missing
1468 else if ( _txt[0] != '/' && ( len == 0 || m_strPath[ len - 1 ] != '/' ) ) 1470 else if ( _txt[0] != '/' && ( len == 0 || m_strPath[ len - 1 ] != '/' ) )
1469 m_strPath += "/"; 1471 m_strPath += "/";
1470 1472
1471 // No double '/' characters 1473 // No double '/' characters
1472 i = 0; 1474 i = 0;
1473 if ( len != 0 && m_strPath[ len - 1 ] == '/' ) 1475 if ( len != 0 && m_strPath[ len - 1 ] == '/' )
1474 { 1476 {
1475 while( _txt[i] == '/' ) 1477 while( _txt[i] == '/' )
1476 ++i; 1478 ++i;
1477 } 1479 }
1478 1480
1479 m_strPath += _txt.mid( i ); 1481 m_strPath += _txt.mid( i );
1480} 1482}
1481 1483
1482QString KURL::directory( bool _strip_trailing_slash_from_result, 1484QString KURL::directory( bool _strip_trailing_slash_from_result,
1483 bool _ignore_trailing_slash_in_path ) const 1485 bool _ignore_trailing_slash_in_path ) const
1484{ 1486{
1485 QString result = m_strPath_encoded.isEmpty() ? m_strPath : m_strPath_encoded; 1487 QString result = m_strPath_encoded.isEmpty() ? m_strPath : m_strPath_encoded;
1486 if ( _ignore_trailing_slash_in_path ) 1488 if ( _ignore_trailing_slash_in_path )
1487 result = trailingSlash( -1, result ); 1489 result = trailingSlash( -1, result );
1488 1490
1489 if ( result.isEmpty() || result == "/" ) 1491 if ( result.isEmpty() || result == "/" )
1490 return result; 1492 return result;
1491 1493
1492 int i = result.findRev( "/" ); 1494 int i = result.findRev( "/" );
1493 // If ( i == -1 ) => the first character is not a '/' 1495 // If ( i == -1 ) => the first character is not a '/'
1494 // So it's some URL like file:blah.tgz, with no path 1496 // So it's some URL like file:blah.tgz, with no path
1495 if ( i == -1 ) 1497 if ( i == -1 )
1496 return QString::null; 1498 return QString::null;
1497 1499
1498 if ( i == 0 ) 1500 if ( i == 0 )
1499 { 1501 {
1500 result = "/"; 1502 result = "/";
1501 return result; 1503 return result;
1502 } 1504 }
1503 1505
1504 if ( _strip_trailing_slash_from_result ) 1506 if ( _strip_trailing_slash_from_result )
1505 result = result.left( i ); 1507 result = result.left( i );
1506 else 1508 else
1507 result = result.left( i + 1 ); 1509 result = result.left( i + 1 );
1508 1510
1509 if (!m_strPath_encoded.isEmpty()) 1511 if (!m_strPath_encoded.isEmpty())
1510 result = decode(result); 1512 result = decode(result);
1511 1513
1512 return result; 1514 return result;
1513} 1515}
1514 1516
1515 1517
1516bool KURL::cd( const QString& _dir ) 1518bool KURL::cd( const QString& _dir )
1517{ 1519{
1518 if ( _dir.isEmpty() || m_bIsMalformed ) 1520 if ( _dir.isEmpty() || m_bIsMalformed )
1519 return false; 1521 return false;
1520 1522
1521 if (hasSubURL()) 1523 if (hasSubURL())
1522 { 1524 {
1523 KURL::List lst = split( *this ); 1525 KURL::List lst = split( *this );
1524 KURL &u = lst.last(); 1526 KURL &u = lst.last();
1525 u.cd(_dir); 1527 u.cd(_dir);
1526 *this = join( lst ); 1528 *this = join( lst );
1527 return true; 1529 return true;
1528 } 1530 }
1529 1531
1530 // absolute path ? 1532 // absolute path ?
1531 if ( _dir[0] == '/' ) 1533 if ( _dir[0] == '/' )
1532 { 1534 {
1533 m_strPath_encoded = QString::null; 1535 m_strPath_encoded = QString::null;
1534 m_strPath = _dir; 1536 m_strPath = _dir;
1535 setHTMLRef( QString::null ); 1537 setHTMLRef( QString::null );
1536 m_strQuery_encoded = QString::null; 1538 m_strQuery_encoded = QString::null;
1537 return true; 1539 return true;
1538 } 1540 }
1539 1541
1540 // Users home directory on the local disk ? 1542 // Users home directory on the local disk ?
1541 if ( ( _dir[0] == '~' ) && ( m_strProtocol == fileProt )) 1543 if ( ( _dir[0] == '~' ) && ( m_strProtocol == fileProt ))
1542 { 1544 {
1543 m_strPath_encoded = QString::null; 1545 m_strPath_encoded = QString::null;
1544 m_strPath = QDir::homeDirPath(); 1546 m_strPath = QDir::homeDirPath();
1545 m_strPath += "/"; 1547 m_strPath += "/";
1546 m_strPath += _dir.right(m_strPath.length() - 1); 1548 m_strPath += _dir.right(m_strPath.length() - 1);
1547 setHTMLRef( QString::null ); 1549 setHTMLRef( QString::null );
1548 m_strQuery_encoded = QString::null; 1550 m_strQuery_encoded = QString::null;
1549 return true; 1551 return true;
1550 } 1552 }
1551 1553
1552 // relative path 1554 // relative path
1553 // we always work on the past of the first url. 1555 // we always work on the past of the first url.
1554 // Sub URLs are not touched. 1556 // Sub URLs are not touched.
1555 1557
1556 // append '/' if necessary 1558 // append '/' if necessary
1557 QString p = path(1); 1559 QString p = path(1);
1558 p += _dir; 1560 p += _dir;
1559 p = cleanpath( p ); 1561 p = cleanpath( p );
1560 setPath( p ); 1562 setPath( p );
1561 1563
1562 setHTMLRef( QString::null ); 1564 setHTMLRef( QString::null );
1563 m_strQuery_encoded = QString::null; 1565 m_strQuery_encoded = QString::null;
1564 1566
1565 return true; 1567 return true;
1566} 1568}
1567 1569
1568KURL KURL::upURL( ) const 1570KURL KURL::upURL( ) const
1569{ 1571{
1570 if (!query().isEmpty()) 1572 if (!query().isEmpty())
1571 { 1573 {
1572 KURL u(*this); 1574 KURL u(*this);
1573 u.setQuery(QString::null); 1575 u.setQuery(QString::null);
1574 return u; 1576 return u;
1575 }; 1577 };
1576 1578
1577 if (!hasSubURL()) 1579 if (!hasSubURL())
1578 { 1580 {
1579 KURL u(*this); 1581 KURL u(*this);
1580 u.cd("../"); 1582 u.cd("../");
1581 return u; 1583 return u;
1582 } 1584 }
1583 1585
1584 // We have a subURL. 1586 // We have a subURL.
1585 KURL::List lst = split( *this ); 1587 KURL::List lst = split( *this );
1586 if (lst.isEmpty()) 1588 if (lst.isEmpty())
1587 return KURL(); // Huh? 1589 return KURL(); // Huh?
1588 while (true) 1590 while (true)
1589 { 1591 {
1590 KURL &u = lst.last(); 1592 KURL &u = lst.last();
1591 QString old = u.path(); 1593 QString old = u.path();
1592 u.cd("../"); 1594 u.cd("../");
1593 if (u.path() != old) 1595 if (u.path() != old)
1594 break; // Finshed. 1596 break; // Finshed.
1595 if (lst.count() == 1) 1597 if (lst.count() == 1)
1596 break; // Finished. 1598 break; // Finished.
1597 lst.remove(lst.fromLast()); 1599 lst.remove(lst.fromLast());
1598 } 1600 }
1599 return join( lst ); 1601 return join( lst );
1600} 1602}
1601 1603
1602QString KURL::htmlRef() const 1604QString KURL::htmlRef() const
1603{ 1605{
1604 if ( !hasSubURL() ) 1606 if ( !hasSubURL() )
1605 { 1607 {
1606 return decode( ref() ); 1608 return decode( ref() );
1607 } 1609 }
1608 1610
1609 List lst = split( *this ); 1611 List lst = split( *this );
1610 return decode( (*lst.begin()).ref() ); 1612 return decode( (*lst.begin()).ref() );
1611} 1613}
1612 1614
1613QString KURL::encodedHtmlRef() const 1615QString KURL::encodedHtmlRef() const
1614{ 1616{
1615 if ( !hasSubURL() ) 1617 if ( !hasSubURL() )
1616 { 1618 {
1617 return ref(); 1619 return ref();
1618 } 1620 }
1619 1621
1620 List lst = split( *this ); 1622 List lst = split( *this );
1621 return (*lst.begin()).ref(); 1623 return (*lst.begin()).ref();
1622} 1624}
1623 1625
1624void KURL::setHTMLRef( const QString& _ref ) 1626void KURL::setHTMLRef( const QString& _ref )
1625{ 1627{
1626 if ( !hasSubURL() ) 1628 if ( !hasSubURL() )
1627 { 1629 {
1628 m_strRef_encoded = encode( _ref, true, 0 /*?*/); 1630 m_strRef_encoded = encode( _ref, true, 0 /*?*/);
1629 return; 1631 return;
1630 } 1632 }
1631 1633
1632 List lst = split( *this ); 1634 List lst = split( *this );
1633 1635
1634 (*lst.begin()).setRef( encode( _ref, true, 0 /*?*/) ); 1636 (*lst.begin()).setRef( encode( _ref, true, 0 /*?*/) );
1635 1637
1636 *this = join( lst ); 1638 *this = join( lst );
1637} 1639}
1638 1640
1639bool KURL::hasHTMLRef() const 1641bool KURL::hasHTMLRef() const
1640{ 1642{
1641 if ( !hasSubURL() ) 1643 if ( !hasSubURL() )
1642 { 1644 {
1643 return hasRef(); 1645 return hasRef();
1644 } 1646 }
1645 1647
1646 List lst = split( *this ); 1648 List lst = split( *this );
1647 return (*lst.begin()).hasRef(); 1649 return (*lst.begin()).hasRef();
1648} 1650}
1649 1651
1650void 1652void
1651KURL::setProtocol( const QString& _txt ) 1653KURL::setProtocol( const QString& _txt )
1652{ 1654{
1653 m_strProtocol = _txt; 1655 m_strProtocol = _txt;
1654 m_bIsMalformed = false; 1656 m_bIsMalformed = false;
1655} 1657}
1656 1658
1657void 1659void
1658KURL::setUser( const QString& _txt ) 1660KURL::setUser( const QString& _txt )
1659{ 1661{
1660 m_strUser = _txt; 1662 m_strUser = _txt;
1661} 1663}
1662 1664
1663void 1665void
1664KURL::setPass( const QString& _txt ) 1666KURL::setPass( const QString& _txt )
1665{ 1667{
1666 m_strPass = _txt; 1668 m_strPass = _txt;
1667} 1669}
1668 1670
1669void 1671void
1670KURL::setHost( const QString& _txt ) 1672KURL::setHost( const QString& _txt )
1671{ 1673{
1672#ifndef KDE_QT_ONLY 1674#ifndef KDE_QT_ONLY
1673 m_strHost = KIDNA::toUnicode(_txt); 1675 m_strHost = KIDNA::toUnicode(_txt);
1674 if (m_strHost.isEmpty()) 1676 if (m_strHost.isEmpty())
1675 m_strHost = _txt.lower(); // Probably an invalid hostname, but... 1677 m_strHost = _txt.lower(); // Probably an invalid hostname, but...
1676#else 1678#else
1677 m_strHost = _txt.lower(); 1679 m_strHost = _txt.lower();
1678#endif 1680#endif
1679} 1681}
1680 1682
1681void 1683void
1682KURL::setPort( unsigned short int _p ) 1684KURL::setPort( unsigned short int _p )
1683{ 1685{
1684 m_iPort = _p; 1686 m_iPort = _p;
1685} 1687}
1686 1688
1687void KURL::setPath( const QString & path ) 1689void KURL::setPath( const QString & path )
1688{ 1690{
1689 if (isEmpty()) 1691 if (isEmpty())
1690 m_bIsMalformed = false; 1692 m_bIsMalformed = false;
1691 if (m_strProtocol.isEmpty()) 1693 if (m_strProtocol.isEmpty())
1692 { 1694 {
1693 m_strProtocol = fileProt; 1695 m_strProtocol = fileProt;
1694 } 1696 }
1695 m_strPath = path; 1697 m_strPath = path;
1696 m_strPath_encoded = QString::null; 1698 m_strPath_encoded = QString::null;
1697} 1699}
1698 1700
1699void KURL::setDirectory( const QString &dir) 1701void KURL::setDirectory( const QString &dir)
1700{ 1702{
1701//US this has to be fixed. endsWith is not available in my distribution 1703//US this has to be fixed. endsWith is not available in my distribution
1702//US if ( dir.endsWith("/")) 1704//US if ( dir.endsWith("/"))
1703//US setPath(dir); 1705//US setPath(dir);
1704//US else 1706//US else
1705 setPath(dir+"/"); 1707 setPath(dir+"/");
1706} 1708}
1707 1709
1708void KURL::setQuery( const QString &_txt, int encoding_hint) 1710void KURL::setQuery( const QString &_txt, int encoding_hint)
1709{ 1711{
1710 if (!_txt.length()) 1712 if (!_txt.length())
1711 { 1713 {
1712 m_strQuery_encoded = _txt; 1714 m_strQuery_encoded = _txt;
1713 return; 1715 return;
1714 } 1716 }
1715 if (_txt[0] =='?') 1717 if (_txt[0] =='?')
1716 m_strQuery_encoded = _txt.mid(1); 1718 m_strQuery_encoded = _txt.mid(1);
1717 else 1719 else
1718 m_strQuery_encoded = _txt; 1720 m_strQuery_encoded = _txt;
1719 1721
1720 int l = m_strQuery_encoded.length(); 1722 int l = m_strQuery_encoded.length();
1721 int i = 0; 1723 int i = 0;
1722 QString result; 1724 QString result;
1723 while (i < l) 1725 while (i < l)
1724 { 1726 {
1725 int s = i; 1727 int s = i;
1726 // Re-encode. Break encoded string up according to the reserved 1728 // Re-encode. Break encoded string up according to the reserved
1727 // characters '&:;=/?' and re-encode part by part. 1729 // characters '&:;=/?' and re-encode part by part.
1728 while(i < l) 1730 while(i < l)
1729 { 1731 {
1730 char c = m_strQuery_encoded[i].latin1(); 1732 char c = m_strQuery_encoded[i].latin1();
1731 if ((c == '&') || (c == ':') || (c == ';') || 1733 if ((c == '&') || (c == ':') || (c == ';') ||
1732 (c == '=') || (c == '/') || (c == '?')) 1734 (c == '=') || (c == '/') || (c == '?'))
1733 break; 1735 break;
1734 i++; 1736 i++;
1735 } 1737 }
1736 if (i > s) 1738 if (i > s)
1737 { 1739 {
1738 QString tmp = m_strQuery_encoded.mid(s, i-s); 1740 QString tmp = m_strQuery_encoded.mid(s, i-s);
1739 QString newTmp; 1741 QString newTmp;
1740 decode( tmp, newTmp, tmp, encoding_hint, false ); 1742 decode( tmp, newTmp, tmp, encoding_hint, false );
1741 result += tmp; 1743 result += tmp;
1742 } 1744 }
1743 if (i < l) 1745 if (i < l)
1744 { 1746 {
1745 result += m_strQuery_encoded[i]; 1747 result += m_strQuery_encoded[i];
1746 i++; 1748 i++;
1747 } 1749 }
1748 } 1750 }
1749 m_strQuery_encoded = result; 1751 m_strQuery_encoded = result;
1750} 1752}
1751 1753
1752QString KURL::query() const 1754QString KURL::query() const
1753{ 1755{
1754 if (m_strQuery_encoded.isNull()) 1756 if (m_strQuery_encoded.isNull())
1755 return QString::null; 1757 return QString::null;
1756 return '?'+m_strQuery_encoded; 1758 return '?'+m_strQuery_encoded;
1757} 1759}
1758 1760
1759QString KURL::decode_string(const QString &str, int encoding_hint) 1761QString KURL::decode_string(const QString &str, int encoding_hint)
1760{ 1762{
1761 return decode(str, encoding_hint); 1763 return decode(str, encoding_hint);
1762} 1764}
1763 1765
1764QString KURL::encode_string(const QString &str, int encoding_hint) 1766QString KURL::encode_string(const QString &str, int encoding_hint)
1765{ 1767{
1766 return encode(str, false, encoding_hint); 1768 return encode(str, false, encoding_hint);
1767} 1769}
1768 1770
1769QString KURL::encode_string_no_slash(const QString &str, int encoding_hint) 1771QString KURL::encode_string_no_slash(const QString &str, int encoding_hint)
1770{ 1772{
1771 return encode(str, true, encoding_hint); 1773 return encode(str, true, encoding_hint);
1772} 1774}
1773 1775
1774bool urlcmp( const QString& _url1, const QString& _url2 ) 1776bool urlcmp( const QString& _url1, const QString& _url2 )
1775{ 1777{
1776 // Both empty ? 1778 // Both empty ?
1777 if ( _url1.isEmpty() && _url2.isEmpty() ) 1779 if ( _url1.isEmpty() && _url2.isEmpty() )
1778 return true; 1780 return true;
1779 // Only one empty ? 1781 // Only one empty ?
1780 if ( _url1.isEmpty() || _url2.isEmpty() ) 1782 if ( _url1.isEmpty() || _url2.isEmpty() )
1781 return false; 1783 return false;
1782 1784
1783 KURL::List list1 = KURL::split( _url1 ); 1785 KURL::List list1 = KURL::split( _url1 );
1784 KURL::List list2 = KURL::split( _url2 ); 1786 KURL::List list2 = KURL::split( _url2 );
1785 1787
1786 // Malformed ? 1788 // Malformed ?
1787 if ( list1.isEmpty() || list2.isEmpty() ) 1789 if ( list1.isEmpty() || list2.isEmpty() )
1788 return false; 1790 return false;
1789 1791
1790 return ( list1 == list2 ); 1792 return ( list1 == list2 );
1791} 1793}
1792 1794
1793bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref ) 1795bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref )
1794{ 1796{
1795 // Both empty ? 1797 // Both empty ?
1796 if ( _url1.isEmpty() && _url2.isEmpty() ) 1798 if ( _url1.isEmpty() && _url2.isEmpty() )
1797 return true; 1799 return true;
1798 // Only one empty ? 1800 // Only one empty ?
1799 if ( _url1.isEmpty() || _url2.isEmpty() ) 1801 if ( _url1.isEmpty() || _url2.isEmpty() )
1800 return false; 1802 return false;
1801 1803
1802 KURL::List list1 = KURL::split( _url1 ); 1804 KURL::List list1 = KURL::split( _url1 );
1803 KURL::List list2 = KURL::split( _url2 ); 1805 KURL::List list2 = KURL::split( _url2 );
1804 1806
1805 // Malformed ? 1807 // Malformed ?
diff --git a/microkde/kurl.h b/microkde/kurl.h
index cd65a1c..016eb24 100644
--- a/microkde/kurl.h
+++ b/microkde/kurl.h
@@ -1,853 +1,855 @@
1/* This file is part of the KDE libraries 1/* This file is part of the KDE libraries
2 * Copyright (C) 1999 Torben Weis <weis@kde.org> 2 * Copyright (C) 1999 Torben Weis <weis@kde.org>
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA. 17 * Boston, MA 02111-1307, USA.
18 **/ 18 **/
19 19
20#ifndef __kurl_h__ 20#ifndef __kurl_h__
21#define __kurl_h__ "$Id$" 21#define __kurl_h__ "$Id$"
22 22
23#include <qstring.h> 23#include <qstring.h>
24#include <qvaluelist.h> 24#include <q3valuelist.h>
25//Added by qt3to4:
26#include <Q3CString>
25 27
26class QUrl; 28class Q3Url;
27class QStringList; 29class QStringList;
28template <typename K, typename V> class QMap; 30template <typename K, typename V> class QMap;
29 31
30class KURLPrivate; 32class KURLPrivate;
31/** 33/**
32 * Represents and parses a URL. 34 * Represents and parses a URL.
33 * 35 *
34 * A prototypical URL looks like: 36 * A prototypical URL looks like:
35 * <pre> 37 * <pre>
36 * protocol:/user:password\@hostname:port/path/to/file.ext#reference 38 * protocol:/user:password\@hostname:port/path/to/file.ext#reference
37 * </pre> 39 * </pre>
38 * 40 *
39 * KURL has some restrictions regarding the path 41 * KURL has some restrictions regarding the path
40 * encoding. KURL works internally with the decoded path and 42 * encoding. KURL works internally with the decoded path and
41 * and encoded query. For example, 43 * and encoded query. For example,
42 * <pre> 44 * <pre>
43 * http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you 45 * http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you
44 * </pre> 46 * </pre>
45 * would result in a decoded path "/cgi-bin/test me.pl" 47 * would result in a decoded path "/cgi-bin/test me.pl"
46 * and in the encoded query "?cmd=Hello%20you". 48 * and in the encoded query "?cmd=Hello%20you".
47 * Since path is internally always encoded you may @em not use 49 * Since path is internally always encoded you may @em not use
48 * "%00" in the path, although this is OK for the query. 50 * "%00" in the path, although this is OK for the query.
49 * 51 *
50 * @author Torben Weis <weis@kde.org> 52 * @author Torben Weis <weis@kde.org>
51 */ 53 */
52class KURL 54class KURL
53{ 55{
54public: 56public:
55 enum AdjustementFlags 57 enum AdjustementFlags
56 { 58 {
57 NoAdjustements = 0, 59 NoAdjustements = 0,
58 StripFileProtocol = 1 60 StripFileProtocol = 1
59 }; 61 };
60 62
61 /** 63 /**
62 * KURL::List is a QValueList that contains KURLs with a few 64 * KURL::List is a QValueList that contains KURLs with a few
63 * convenience methods. 65 * convenience methods.
64 * @see KURL 66 * @see KURL
65 * @see QValueList 67 * @see QValueList
66 */ 68 */
67 class List : public QValueList<KURL> 69 class List : public Q3ValueList<KURL>
68 { 70 {
69 public: 71 public:
70 /** 72 /**
71 * Creates an empty List. 73 * Creates an empty List.
72 */ 74 */
73 List() { } 75 List() { }
74 /** 76 /**
75 * Creates a list that contains the given URL as only 77 * Creates a list that contains the given URL as only
76 * item. 78 * item.
77 * @param url the url to add. 79 * @param url the url to add.
78 */ 80 */
79 List(const KURL &url); 81 List(const KURL &url);
80 /** 82 /**
81 * Creates a list that contains the URLs from the given 83 * Creates a list that contains the URLs from the given
82 * list. 84 * list.
83 * @param list the list containing the URLs as strings 85 * @param list the list containing the URLs as strings
84 */ 86 */
85 List(const QStringList &list); 87 List(const QStringList &list);
86 /** 88 /**
87 * Converts the URLs of this list to a list of strings. 89 * Converts the URLs of this list to a list of strings.
88 * @return the list of strings 90 * @return the list of strings
89 */ 91 */
90 QStringList toStringList() const; 92 QStringList toStringList() const;
91 }; 93 };
92 /** 94 /**
93 * Constructs an empty URL. 95 * Constructs an empty URL.
94 */ 96 */
95 KURL(); 97 KURL();
96 98
97 /** 99 /**
98 * Destructs the KURL object. 100 * Destructs the KURL object.
99 */ 101 */
100 ~KURL(); 102 ~KURL();
101 103
102 /** 104 /**
103 * Usual constructor, to construct from a string. 105 * Usual constructor, to construct from a string.
104 * @param url A URL, not a filename. If the URL does not have a protocol 106 * @param url A URL, not a filename. If the URL does not have a protocol
105 * part, "file:" is assumed. 107 * part, "file:" is assumed.
106 * It is dangerous to feed unix filenames into this function, 108 * It is dangerous to feed unix filenames into this function,
107 * this will work most of the time but not always. 109 * this will work most of the time but not always.
108 * For example "/home/Torben%20Weis" will be considered a URL 110 * For example "/home/Torben%20Weis" will be considered a URL
109 * pointing to the file "/home/Torben Weis" instead of to the 111 * pointing to the file "/home/Torben Weis" instead of to the
110 * file "/home/Torben%20Weis". 112 * file "/home/Torben%20Weis".
111 * This means that if you have a usual UNIX like path you 113 * This means that if you have a usual UNIX like path you
112 * should not use this constructor. 114 * should not use this constructor.
113 * Instead create an empty url and set the path by using 115 * Instead create an empty url and set the path by using
114 * @ref setPath(). 116 * @ref setPath().
115 * @param encoding_hint MIB of original encoding of URL. 117 * @param encoding_hint MIB of original encoding of URL.
116 * @see QTextCodec::mibEnum() 118 * @see QTextCodec::mibEnum()
117 */ 119 */
118 KURL( const QString& url, int encoding_hint = 0 ); 120 KURL( const QString& url, int encoding_hint = 0 );
119 /** 121 /**
120 * Constructor taking a char * @p url, which is an _encoded_ representation 122 * Constructor taking a char * @p url, which is an _encoded_ representation
121 * of the URL, exactly like the usual constructor. This is useful when 123 * of the URL, exactly like the usual constructor. This is useful when
122 * then URL, in its encoded form, is strictly ascii. 124 * then URL, in its encoded form, is strictly ascii.
123 * @param url A encoded URL. If the URL does not have a protocol part, 125 * @param url A encoded URL. If the URL does not have a protocol part,
124 * "file:" is assumed. 126 * "file:" is assumed.
125 * @param encoding_hint MIB of original encoding of URL. 127 * @param encoding_hint MIB of original encoding of URL.
126 * @see QTextCodec::mibEnum() 128 * @see QTextCodec::mibEnum()
127 */ 129 */
128 KURL( const char * url, int encoding_hint = 0 ); 130 KURL( const char * url, int encoding_hint = 0 );
129 /** 131 /**
130 * Constructor taking a QCString @p url, which is an _encoded_ representation 132 * Constructor taking a QCString @p url, which is an _encoded_ representation
131 * of the URL, exactly like the usual constructor. This is useful when 133 * of the URL, exactly like the usual constructor. This is useful when
132 * then URL, in its encoded form, is strictly ascii. 134 * then URL, in its encoded form, is strictly ascii.
133 * @param url A encoded URL. If the URL does not have a protocol part, 135 * @param url A encoded URL. If the URL does not have a protocol part,
134 * "file:" is assumed. 136 * "file:" is assumed.
135 * @param encoding_hint MIB of original encoding of URL. 137 * @param encoding_hint MIB of original encoding of URL.
136 * @see QTextCodec::mibEnum() 138 * @see QTextCodec::mibEnum()
137 */ 139 */
138 KURL( const QCString& url, int encoding_hint = 0 ); 140 KURL( const Q3CString& url, int encoding_hint = 0 );
139 /** 141 /**
140 * Copy constructor. 142 * Copy constructor.
141 * @param u the KURL to copy 143 * @param u the KURL to copy
142 */ 144 */
143 KURL( const KURL& u ); 145 KURL( const KURL& u );
144 /** 146 /**
145 * Converts from a @ref QUrl. 147 * Converts from a @ref QUrl.
146 * @param u the QUrl 148 * @param u the QUrl
147 */ 149 */
148 KURL( const QUrl &u ); 150 KURL( const Q3Url &u );
149 /** 151 /**
150 * Constructor allowing relative URLs. 152 * Constructor allowing relative URLs.
151 * 153 *
152 * @param _baseurl The base url. 154 * @param _baseurl The base url.
153 * @param _rel_url A relative or absolute URL. 155 * @param _rel_url A relative or absolute URL.
154 * If this is an absolute URL then @p _baseurl will be ignored. 156 * If this is an absolute URL then @p _baseurl will be ignored.
155 * If this is a relative URL it will be combined with @p _baseurl. 157 * If this is a relative URL it will be combined with @p _baseurl.
156 * Note that _rel_url should be encoded too, in any case. 158 * Note that _rel_url should be encoded too, in any case.
157 * So do NOT pass a path here (use setPath or addPath instead). 159 * So do NOT pass a path here (use setPath or addPath instead).
158 * @param encoding_hint MIB of original encoding of URL. 160 * @param encoding_hint MIB of original encoding of URL.
159 * @see QTextCodec::mibEnum() 161 * @see QTextCodec::mibEnum()
160 */ 162 */
161 KURL( const KURL& _baseurl, const QString& _rel_url, int encoding_hint=0 ); 163 KURL( const KURL& _baseurl, const QString& _rel_url, int encoding_hint=0 );
162 164
163 /** 165 /**
164 * Returns the protocol for the URL (i.e., file, http, etc.). 166 * Returns the protocol for the URL (i.e., file, http, etc.).
165 * @return the protocol of the URL, does not include the colon. If the 167 * @return the protocol of the URL, does not include the colon. If the
166 * URL is malformed, QString::null will be returned. 168 * URL is malformed, QString::null will be returned.
167 **/ 169 **/
168 QString protocol() const { return m_bIsMalformed ? QString::null : m_strProtocol; } 170 QString protocol() const { return m_bIsMalformed ? QString::null : m_strProtocol; }
169 /** 171 /**
170 * Sets the protocol for the URL (i.e., file, http, etc.) 172 * Sets the protocol for the URL (i.e., file, http, etc.)
171 * @param _txt the new protocol of the URL (without colon) 173 * @param _txt the new protocol of the URL (without colon)
172 **/ 174 **/
173 void setProtocol( const QString& _txt ); 175 void setProtocol( const QString& _txt );
174 176
175 /** 177 /**
176 * Returns the decoded user name (login, user id, ...) included in the URL. 178 * Returns the decoded user name (login, user id, ...) included in the URL.
177 * @return the user name or QString::null if there is no user name 179 * @return the user name or QString::null if there is no user name
178 **/ 180 **/
179 QString user() const { return m_strUser; } 181 QString user() const { return m_strUser; }
180 /** 182 /**
181 * Sets the user name (login, user id, ...) included in the URL. 183 * Sets the user name (login, user id, ...) included in the URL.
182 * 184 *
183 * Special characters in the user name will appear encoded in the URL. 185 * Special characters in the user name will appear encoded in the URL.
184 * @param _txt the name of the user or QString::null to remove the user 186 * @param _txt the name of the user or QString::null to remove the user
185 **/ 187 **/
186 void setUser( const QString& _txt ); 188 void setUser( const QString& _txt );
187 /** 189 /**
188 * Test to see if this URL has a user name included in it. 190 * Test to see if this URL has a user name included in it.
189 * @return true if the URL has an non-empty user name 191 * @return true if the URL has an non-empty user name
190 **/ 192 **/
191 bool hasUser() const { return !m_strUser.isEmpty(); } 193 bool hasUser() const { return !m_strUser.isEmpty(); }
192 194
193 /** 195 /**
194 * Returns the decoded password (corresponding to \ref user()) included in the URL. 196 * Returns the decoded password (corresponding to \ref user()) included in the URL.
195 * @return the password or QString::null if it does not exist 197 * @return the password or QString::null if it does not exist
196 **/ 198 **/
197 QString pass() const { return m_strPass; } 199 QString pass() const { return m_strPass; }
198 /** 200 /**
199 * Sets the password (corresponding to @ref user()) included in the URL. 201 * Sets the password (corresponding to @ref user()) included in the URL.
200 * 202 *
201 * Special characters in the password will appear encoded in the URL. 203 * Special characters in the password will appear encoded in the URL.
202 * Note that a password can only appear in a URL string if you also set 204 * Note that a password can only appear in a URL string if you also set
203 * a user. 205 * a user.
204 * @param _txt the password to set or QString::null to remove the password 206 * @param _txt the password to set or QString::null to remove the password
205 * @see #setUser 207 * @see #setUser
206 * @see #hasUser 208 * @see #hasUser
207 **/ 209 **/
208 void setPass( const QString& _txt ); 210 void setPass( const QString& _txt );
209 /** 211 /**
210 * Test to see if this URL has a password included in it. 212 * Test to see if this URL has a password included in it.
211 * @return true if there is a non-empty password set 213 * @return true if there is a non-empty password set
212 **/ 214 **/
213 bool hasPass() const { return !m_strPass.isEmpty(); } 215 bool hasPass() const { return !m_strPass.isEmpty(); }
214 216
215 /** 217 /**
216 * Returns the decoded hostname included in the URL. 218 * Returns the decoded hostname included in the URL.
217 * @return the name of the host or QString::null if no host is set 219 * @return the name of the host or QString::null if no host is set
218 **/ 220 **/
219 QString host() const { return m_strHost; } 221 QString host() const { return m_strHost; }
220 222
221 /** 223 /**
222 * Sets the hostname included in the URL. 224 * Sets the hostname included in the URL.
223 * 225 *
224 * Special characters in the hostname will appear encoded in the URL. 226 * Special characters in the hostname will appear encoded in the URL.
225 * @param _txt the new name of the host or QString::null to remove the host 227 * @param _txt the new name of the host or QString::null to remove the host
226 **/ 228 **/
227 void setHost( const QString& _txt ); 229 void setHost( const QString& _txt );
228 /** 230 /**
229 * Test to see if this URL has a hostname included in it. 231 * Test to see if this URL has a hostname included in it.
230 * @return true if the URL has a host 232 * @return true if the URL has a host
231 **/ 233 **/
232 bool hasHost() const { return !m_strHost.isEmpty(); } 234 bool hasHost() const { return !m_strHost.isEmpty(); }
233 235
234 /** 236 /**
235 * Returns the port number included in the URL. 237 * Returns the port number included in the URL.
236 * @return the port number. If there is no port number specified in the 238 * @return the port number. If there is no port number specified in the
237 * URL, returns 0. 239 * URL, returns 0.
238 **/ 240 **/
239 unsigned short int port() const { return m_iPort; } 241 unsigned short int port() const { return m_iPort; }
240 /** 242 /**
241 * Sets the port number included in the URL. 243 * Sets the port number included in the URL.
242 * @param _p the new port number or 0 to have no port number 244 * @param _p the new port number or 0 to have no port number
243 **/ 245 **/
244 void setPort( unsigned short int _p ); 246 void setPort( unsigned short int _p );
245 247
246 /** 248 /**
247 * Returns the current decoded path. This does @em not include the query. 249 * Returns the current decoded path. This does @em not include the query.
248 * @return the path of the URL (without query), or QString::null if no 250 * @return the path of the URL (without query), or QString::null if no
249 * path set. 251 * path set.
250 */ 252 */
251 QString path() const { return m_strPath; } 253 QString path() const { return m_strPath; }
252 254
253 /** 255 /**
254 * @param _trailing May be ( -1, 0 +1 ). -1 strips a trailing '/', +1 adds 256 * @param _trailing May be ( -1, 0 +1 ). -1 strips a trailing '/', +1 adds
255 * a trailing '/' if there is none yet and 0 returns the 257 * a trailing '/' if there is none yet and 0 returns the
256 * path unchanged. If the URL has no path, then no '/' is added 258 * path unchanged. If the URL has no path, then no '/' is added
257 * anyway. And on the other side: If the path is "/", then this 259 * anyway. And on the other side: If the path is "/", then this
258 * character won't be stripped. Reason: "ftp://weis\@host" means something 260 * character won't be stripped. Reason: "ftp://weis\@host" means something
259 * completely different than "ftp://weis\@host/". So adding or stripping 261 * completely different than "ftp://weis\@host/". So adding or stripping
260 * the '/' would really alter the URL, while "ftp://host/path" and 262 * the '/' would really alter the URL, while "ftp://host/path" and
261 * "ftp://host/path/" mean the same directory. 263 * "ftp://host/path/" mean the same directory.
262 * 264 *
263 * @return The current decoded path. This does not include the query. Can 265 * @return The current decoded path. This does not include the query. Can
264 * be QString::null if no path is set. 266 * be QString::null if no path is set.
265 */ 267 */
266 QString path( int _trailing ) const; 268 QString path( int _trailing ) const;
267 269
268 /** 270 /**
269 * Sets the path of the URL. The query is not changed by this function. 271 * Sets the path of the URL. The query is not changed by this function.
270 * 272 *
271 * @param path The new path. This is considered to be decoded. This 273 * @param path The new path. This is considered to be decoded. This
272 * means: %3f does not become decoded 274 * means: %3f does not become decoded
273 * and the ? does not indicate the start of the query part. 275 * and the ? does not indicate the start of the query part.
274 * Can be QString::null to delete the path. 276 * Can be QString::null to delete the path.
275 */ 277 */
276 void setPath( const QString& path ); 278 void setPath( const QString& path );
277 279
278 /** 280 /**
279 * Test to see if this URL has a path is included in it. 281 * Test to see if this URL has a path is included in it.
280 * @return true if there is a path 282 * @return true if there is a path
281 **/ 283 **/
282 bool hasPath() const { return !m_strPath.isEmpty(); } 284 bool hasPath() const { return !m_strPath.isEmpty(); }
283 285
284 /** 286 /**
285 * Resolves "." and ".." components in path. 287 * Resolves "." and ".." components in path.
286 * Some servers seem not to like the removal of extra '/' 288 * Some servers seem not to like the removal of extra '/'
287 * even though it is against the specification in RFC 2396. 289 * even though it is against the specification in RFC 2396.
288 * 290 *
289 * @param cleanDirSeparator if true, occurrances of consecutive 291 * @param cleanDirSeparator if true, occurrances of consecutive
290 * directory separators (e.g. /foo//bar) are cleaned up as well. 292 * directory separators (e.g. /foo//bar) are cleaned up as well.
291 */ 293 */
292 void cleanPath(bool cleanDirSeparator = true); 294 void cleanPath(bool cleanDirSeparator = true);
293 295
294 /** 296 /**
295 * Add or remove a trailing slash to/from the path. 297 * Add or remove a trailing slash to/from the path.
296 * @param _trailing May be ( -1, 0 +1 ). -1 strips a trailing '/', +1 adds 298 * @param _trailing May be ( -1, 0 +1 ). -1 strips a trailing '/', +1 adds
297 * a trailing '/' if there is none yet and 0 returns the 299 * a trailing '/' if there is none yet and 0 returns the
298 * path unchanged. If the URL has no path, then no '/' is added 300 * path unchanged. If the URL has no path, then no '/' is added
299 * anyway. And on the other side: If the path is "/", then this 301 * anyway. And on the other side: If the path is "/", then this
300 * character won't be stripped. Reason: "ftp://weis\@host" means something 302 * character won't be stripped. Reason: "ftp://weis\@host" means something
301 * completely different than "ftp://weis\@host/". So adding or stripping 303 * completely different than "ftp://weis\@host/". So adding or stripping
302 * the '/' would really alter the URL, while "ftp://host/path" and 304 * the '/' would really alter the URL, while "ftp://host/path" and
303 * "ftp://host/path/" mean the same directory. 305 * "ftp://host/path/" mean the same directory.
304 */ 306 */
305 void adjustPath(int _trailing); 307 void adjustPath(int _trailing);
306 308
307 /** 309 /**
308 * This is useful for HTTP. It looks first for '?' and decodes then. 310 * This is useful for HTTP. It looks first for '?' and decodes then.
309 * The encoded path is the concatenation of the current path and the query. 311 * The encoded path is the concatenation of the current path and the query.
310 * @param _txt the new path and query. 312 * @param _txt the new path and query.
311 * @param encoding_hint MIB of original encoding of @p _txt . 313 * @param encoding_hint MIB of original encoding of @p _txt .
312 * @see QTextCodec::mibEnum() 314 * @see QTextCodec::mibEnum()
313 */ 315 */
314 void setEncodedPathAndQuery( const QString& _txt, int encoding_hint = 0 ); 316 void setEncodedPathAndQuery( const QString& _txt, int encoding_hint = 0 );
315 317
316 /** 318 /**
317 * Sets the (already encoded) path 319 * Sets the (already encoded) path
318 * @param _txt the new path 320 * @param _txt the new path
319 * @param encoding_hint MIB of original encoding of @p _txt . 321 * @param encoding_hint MIB of original encoding of @p _txt .
320 * @see QTextCodec::mibEnum() 322 * @see QTextCodec::mibEnum()
321 */ 323 */
322 void setEncodedPath(const QString& _txt, int encoding_hint = 0 ); 324 void setEncodedPath(const QString& _txt, int encoding_hint = 0 );
323 325
324 /** 326 /**
325 * Returns the encoded path and the query. 327 * Returns the encoded path and the query.
326 * 328 *
327 * @param _trailing May be ( -1, 0 +1 ). -1 strips a trailing '/', +1 adds 329 * @param _trailing May be ( -1, 0 +1 ). -1 strips a trailing '/', +1 adds
328 * a trailing '/' if there is none yet and 0 returns the 330 * a trailing '/' if there is none yet and 0 returns the
329 * path unchanged. If the URL has no path, then no '/' is added 331 * path unchanged. If the URL has no path, then no '/' is added
330 * anyway. And on the other side: If the path is "/", then this 332 * anyway. And on the other side: If the path is "/", then this
331 * character won't be stripped. Reason: "ftp://weis\@host" means something 333 * character won't be stripped. Reason: "ftp://weis\@host" means something
332 * completely different than "ftp://weis\@host/". So adding or stripping 334 * completely different than "ftp://weis\@host/". So adding or stripping
333 * the '/' would really alter the URL, while "ftp://host/path" and 335 * the '/' would really alter the URL, while "ftp://host/path" and
334 * "ftp://host/path/" mean the same directory. 336 * "ftp://host/path/" mean the same directory.
335 * @param _no_empty_path If set to true then an empty path is substituted by "/". 337 * @param _no_empty_path If set to true then an empty path is substituted by "/".
336 * @param encoding_hint MIB of desired encoding of URL. 338 * @param encoding_hint MIB of desired encoding of URL.
337 * @see QTextCodec::mibEnum() 339 * @see QTextCodec::mibEnum()
338 * @return The concatenation if the encoded path , '?' and the encoded query. 340 * @return The concatenation if the encoded path , '?' and the encoded query.
339 * 341 *
340 */ 342 */
341 QString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const; 343 QString encodedPathAndQuery( int _trailing = 0, bool _no_empty_path = false, int encoding_hint = 0) const;
342 344
343 /** 345 /**
344 * @param _txt This is considered to be encoded. This has a good reason: 346 * @param _txt This is considered to be encoded. This has a good reason:
345 * The query may contain the 0 character. 347 * The query may contain the 0 character.
346 * 348 *
347 * The query should start with a '?'. If it doesn't '?' is prepended. 349 * The query should start with a '?'. If it doesn't '?' is prepended.
348 * @param encoding_hint Reserved, should be 0. 350 * @param encoding_hint Reserved, should be 0.
349 * @see QTextCodec::mibEnum() 351 * @see QTextCodec::mibEnum()
350 */ 352 */
351 void setQuery( const QString& _txt, int encoding_hint = 0); 353 void setQuery( const QString& _txt, int encoding_hint = 0);
352 354
353 /** 355 /**
354 * Returns the query of the URL. 356 * Returns the query of the URL.
355 * The query may contain the 0 character. 357 * The query may contain the 0 character.
356 * If a query is present it always starts with a '?'. 358 * If a query is present it always starts with a '?'.
357 * A single '?' means an empty query. 359 * A single '?' means an empty query.
358 * An empty string means no query. 360 * An empty string means no query.
359 * @return The encoded query, or QString::null if there is none. 361 * @return The encoded query, or QString::null if there is none.
360 */ 362 */
361 QString query() const; 363 QString query() const;
362 364
363 /** 365 /**
364 * The reference is @em never decoded automatically. 366 * The reference is @em never decoded automatically.
365 * @return the undecoded reference, or QString::null if there is none 367 * @return the undecoded reference, or QString::null if there is none
366 */ 368 */
367 QString ref() const { return m_strRef_encoded; } 369 QString ref() const { return m_strRef_encoded; }
368 370
369 /** 371 /**
370 * Sets the reference part (everything after '#'). 372 * Sets the reference part (everything after '#').
371 * @param _txt The encoded reference (or QString::null to remove it). 373 * @param _txt The encoded reference (or QString::null to remove it).
372 */ 374 */
373 void setRef( const QString& _txt ) { m_strRef_encoded = _txt; } 375 void setRef( const QString& _txt ) { m_strRef_encoded = _txt; }
374 376
375 /** 377 /**
376 * Checks whether the URL has a reference part. 378 * Checks whether the URL has a reference part.
377 * @return true if the URL has a reference part. In a URL like 379 * @return true if the URL has a reference part. In a URL like
378 * http://www.kde.org/kdebase.tar#tar:/README it would 380 * http://www.kde.org/kdebase.tar#tar:/README it would
379 * return true, too. 381 * return true, too.
380 */ 382 */
381 bool hasRef() const { return !m_strRef_encoded.isNull(); } 383 bool hasRef() const { return !m_strRef_encoded.isNull(); }
382 384
383 /** 385 /**
384 * Returns the HTML reference (the part of the URL after "#"). 386 * Returns the HTML reference (the part of the URL after "#").
385 * @return The HTML-style reference. 387 * @return The HTML-style reference.
386 * @see #split 388 * @see #split
387 * @see #hasSubURL 389 * @see #hasSubURL
388 * @see #encodedHtmlRef 390 * @see #encodedHtmlRef
389 */ 391 */
390 QString htmlRef() const; 392 QString htmlRef() const;
391 393
392 /** 394 /**
393 * Returns the HTML reference (the part of the URL after "#") in 395 * Returns the HTML reference (the part of the URL after "#") in
394 * encoded form. 396 * encoded form.
395 * @return The HTML-style reference in its original form. 397 * @return The HTML-style reference in its original form.
396 */ 398 */
397 QString encodedHtmlRef() const; 399 QString encodedHtmlRef() const;
398 400
399 /** 401 /**
400 * Sets the HTML-style reference. 402 * Sets the HTML-style reference.
401 * 403 *
402 * @param _ref The new reference. This is considered to be @em not encoded in 404 * @param _ref The new reference. This is considered to be @em not encoded in
403 * contrast to @ref setRef(). Use QString::null to remove it. 405 * contrast to @ref setRef(). Use QString::null to remove it.
404 * @see htmlRef() 406 * @see htmlRef()
405 */ 407 */
406 void setHTMLRef( const QString& _ref ); 408 void setHTMLRef( const QString& _ref );
407 409
408 /** 410 /**
409 * Checks whether there is a HTML reference. 411 * Checks whether there is a HTML reference.
410 * @return true if the URL has an HTML-style reference. 412 * @return true if the URL has an HTML-style reference.
411 * @see htmlRef() 413 * @see htmlRef()
412 */ 414 */
413 bool hasHTMLRef() const; 415 bool hasHTMLRef() const;
414 416
415 /** 417 /**
416 * Checks whether the URL is well formed. 418 * Checks whether the URL is well formed.
417 * @return false if the URL is malformed. This function does @em not test 419 * @return false if the URL is malformed. This function does @em not test
418 * whether sub URLs are well-formed, too. 420 * whether sub URLs are well-formed, too.
419 */ 421 */
420 bool isValid() const { return !m_bIsMalformed; } 422 bool isValid() const { return !m_bIsMalformed; }
421 /** 423 /**
422 * @deprecated 424 * @deprecated
423 */ 425 */
424 bool isMalformed() const { return !isValid(); } 426 bool isMalformed() const { return !isValid(); }
425 427
426 /** 428 /**
427 * Checks whether the file is local. 429 * Checks whether the file is local.
428 * @return true if the file is a plain local file and has no filter protocols 430 * @return true if the file is a plain local file and has no filter protocols
429 * attached to it. 431 * attached to it.
430 */ 432 */
431 bool isLocalFile() const; 433 bool isLocalFile() const;
432 434
433 /** 435 /**
434 * Adds encoding information to url by adding a "charset" parameter. If there 436 * Adds encoding information to url by adding a "charset" parameter. If there
435 * is already a charset parameter, it will be replaced. 437 * is already a charset parameter, it will be replaced.
436 * @param encoding the encoding to add or QString::null to remove the 438 * @param encoding the encoding to add or QString::null to remove the
437 * encoding. 439 * encoding.
438 */ 440 */
439 void setFileEncoding(const QString &encoding); 441 void setFileEncoding(const QString &encoding);
440 442
441 /** 443 /**
442 * Returns encoding information from url, the content of the "charset" 444 * Returns encoding information from url, the content of the "charset"
443 * parameter. 445 * parameter.
444 * @return An encoding suitable for QTextCodec::codecForName() 446 * @return An encoding suitable for QTextCodec::codecForName()
445 * or QString::null if not encoding was specified. 447 * or QString::null if not encoding was specified.
446 */ 448 */
447 QString fileEncoding() const; 449 QString fileEncoding() const;
448 450
449 /** 451 /**
450 * Checks whether the URL has any sub URLs. See @ref #split() 452 * Checks whether the URL has any sub URLs. See @ref #split()
451 * for examples for sub URLs. 453 * for examples for sub URLs.
452 * @return true if the file has at least one sub URL. 454 * @return true if the file has at least one sub URL.
453 * @see #split 455 * @see #split
454 */ 456 */
455 bool hasSubURL() const; 457 bool hasSubURL() const;
456 458
457 /** 459 /**
458 * Adds to the current path. 460 * Adds to the current path.
459 * Assumes that the current path is a directory. @p _txt is appended to the 461 * Assumes that the current path is a directory. @p _txt is appended to the
460 * current path. The function adds '/' if needed while concatenating. 462 * current path. The function adds '/' if needed while concatenating.
461 * This means it does not matter whether the current path has a trailing 463 * This means it does not matter whether the current path has a trailing
462 * '/' or not. If there is none, it becomes appended. If @p _txt 464 * '/' or not. If there is none, it becomes appended. If @p _txt
463 * has a leading '/' then this one is stripped. 465 * has a leading '/' then this one is stripped.
464 * 466 *
465 * @param _txt The text to add. It is considered to be decoded. 467 * @param _txt The text to add. It is considered to be decoded.
466 */ 468 */
467 void addPath( const QString& _txt ); 469 void addPath( const QString& _txt );
468 470
469 /** 471 /**
470 * Returns the value of a certain query item. 472 * Returns the value of a certain query item.
471 * 473 *
472 * @param _item Item whose value we want 474 * @param _item Item whose value we want
473 * @param encoding_hint MIB of encoding of query. 475 * @param encoding_hint MIB of encoding of query.
474 * 476 *
475 * @return the value of the given query item name or QString::null if the 477 * @return the value of the given query item name or QString::null if the
476 * specified item does not exist. 478 * specified item does not exist.
477 */ 479 */
478/*US we do not need this functions 480/*US we do not need this functions
479 QString queryItem( const QString& _item ) const; 481 QString queryItem( const QString& _item ) const;
480 QString queryItem( const QString& _item, int encoding_hint ) const; 482 QString queryItem( const QString& _item, int encoding_hint ) const;
481*/ 483*/
482 /** 484 /**
483 * Options for @ref #queryItems. Currently, only one option is 485 * Options for @ref #queryItems. Currently, only one option is
484 * defined: 486 * defined:
485 * 487 *
486 * @param CaseInsensitiveKeys normalize query keys to lowercase. 488 * @param CaseInsensitiveKeys normalize query keys to lowercase.
487 * 489 *
488 * @since 3.1 490 * @since 3.1
489 **/ 491 **/
490 enum QueryItemsOptions { CaseInsensitiveKeys = 1 }; 492 enum QueryItemsOptions { CaseInsensitiveKeys = 1 };
491 493
492 /** 494 /**
493 * Returns the list of query items as a map mapping keys to values. 495 * Returns the list of query items as a map mapping keys to values.
494 * 496 *
495 * @param options any of @ref QueryItemsOptions <em>or</or>ed together. 497 * @param options any of @ref QueryItemsOptions <em>or</or>ed together.
496 * @param encoding_hint MIB of encoding of query. 498 * @param encoding_hint MIB of encoding of query.
497 * 499 *
498 * @return the map of query items or the empty map if the url has no 500 * @return the map of query items or the empty map if the url has no
499 * query items. 501 * query items.
500 * 502 *
501 * @since 3.1 503 * @since 3.1
502 */ 504 */
503 QMap< QString, QString > queryItems( int options=0 ) const; 505 QMap< QString, QString > queryItems( int options=0 ) const;
504 QMap< QString, QString > queryItems( int options, int encoding_hint ) const; 506 QMap< QString, QString > queryItems( int options, int encoding_hint ) const;
505 507
506 /** 508 /**
507 * Add an additional query item. 509 * Add an additional query item.
508 * To replace an existing query item, the item should first be 510 * To replace an existing query item, the item should first be
509 * removed with @ref removeQueryItem() 511 * removed with @ref removeQueryItem()
510 * 512 *
511 * @param _item Name of item to add 513 * @param _item Name of item to add
512 * @param _value Value of item to add 514 * @param _value Value of item to add
513 * @param encoding_hint MIB of encoding to use for _value. 515 * @param encoding_hint MIB of encoding to use for _value.
514 * @see QTextCodec::mibEnum() 516 * @see QTextCodec::mibEnum()
515 */ 517 */
516 void addQueryItem( const QString& _item, const QString& _value, int encoding_hint = 0 ); 518 void addQueryItem( const QString& _item, const QString& _value, int encoding_hint = 0 );
517 519
518 /** 520 /**
519 * Remove an item from the query. 521 * Remove an item from the query.
520 * 522 *
521 * @param _item Item to be removed 523 * @param _item Item to be removed
522 */ 524 */
523 void removeQueryItem( const QString& _item ); 525 void removeQueryItem( const QString& _item );
524 526
525 /** 527 /**
526 * Sets the filename of the path. 528 * Sets the filename of the path.
527 * In comparison to @ref addPath() this function does not assume that the current 529 * In comparison to @ref addPath() this function does not assume that the current
528 * path is a directory. This is only assumed if the current path ends with '/'. 530 * path is a directory. This is only assumed if the current path ends with '/'.
529 * 531 *
530 * Any reference is reset. 532 * Any reference is reset.
531 * 533 *
532 * @param _txt The filename to be set. It is considered to be decoded. If the 534 * @param _txt The filename to be set. It is considered to be decoded. If the
533 * current path ends with '/' then @p _txt int just appended, otherwise 535 * current path ends with '/' then @p _txt int just appended, otherwise
534 * all text behind the last '/' in the current path is erased and 536 * all text behind the last '/' in the current path is erased and
535 * @p _txt is appended then. It does not matter whether @p _txt starts 537 * @p _txt is appended then. It does not matter whether @p _txt starts
536 * with '/' or not. 538 * with '/' or not.
537 */ 539 */
538 void setFileName( const QString&_txt ); 540 void setFileName( const QString&_txt );
539 541
540 /** 542 /**
541 * Returns the filename of the path. 543 * Returns the filename of the path.
542 * @param _ignore_trailing_slash_in_path This tells whether a trailing '/' should 544 * @param _ignore_trailing_slash_in_path This tells whether a trailing '/' should
543 * be ignored. This means that the function would return "torben" for 545 * be ignored. This means that the function would return "torben" for
544 * <tt>file:/hallo/torben/</tt> and <tt>file:/hallo/torben</tt>. 546 * <tt>file:/hallo/torben/</tt> and <tt>file:/hallo/torben</tt>.
545 * If the flag is set to false, then everything behind the last '/' 547 * If the flag is set to false, then everything behind the last '/'
546 * is considered to be the filename. 548 * is considered to be the filename.
547 * @return The filename of the current path. The returned string is decoded. Null 549 * @return The filename of the current path. The returned string is decoded. Null
548 * if there is no file (and thus no path). 550 * if there is no file (and thus no path).
549 */ 551 */
550 QString fileName( bool _ignore_trailing_slash_in_path = true ) const; 552 QString fileName( bool _ignore_trailing_slash_in_path = true ) const;
551 553
552 /** 554 /**
553 * Returns the directory of the path. 555 * Returns the directory of the path.
554 * @param _strip_trailing_slash_from_result tells whether the returned result should end with '/' or not. 556 * @param _strip_trailing_slash_from_result tells whether the returned result should end with '/' or not.
555 * If the path is empty or just "/" then this flag has no effect. 557 * If the path is empty or just "/" then this flag has no effect.
556 * @param _ignore_trailing_slash_in_path means that <tt>file:/hallo/torben</tt> and 558 * @param _ignore_trailing_slash_in_path means that <tt>file:/hallo/torben</tt> and
557 * <tt>file:/hallo/torben/"</tt> would both return <tt>/hallo/</tt> 559 * <tt>file:/hallo/torben/"</tt> would both return <tt>/hallo/</tt>
558 * or <tt>/hallo</tt> depending on the other flag 560 * or <tt>/hallo</tt> depending on the other flag
559 * @return The directory part of the current path. Everything between the last and the second last '/' 561 * @return The directory part of the current path. Everything between the last and the second last '/'
560 * is returned. For example <tt>file:/hallo/torben/</tt> would return "/hallo/torben/" while 562 * is returned. For example <tt>file:/hallo/torben/</tt> would return "/hallo/torben/" while
561 * <tt>file:/hallo/torben</tt> would return "hallo/". The returned string is decoded. QString::null is returned when there is no path. 563 * <tt>file:/hallo/torben</tt> would return "hallo/". The returned string is decoded. QString::null is returned when there is no path.
562 */ 564 */
563 QString directory( bool _strip_trailing_slash_from_result = true, 565 QString directory( bool _strip_trailing_slash_from_result = true,
564 bool _ignore_trailing_slash_in_path = true ) const; 566 bool _ignore_trailing_slash_in_path = true ) const;
565 567
566 /** 568 /**
567 * Set the directory to @p dir, leaving the filename empty. 569 * Set the directory to @p dir, leaving the filename empty.
568 */ 570 */
569 void setDirectory(const QString &dir); 571 void setDirectory(const QString &dir);
570 572
571 /** 573 /**
572 * Changes the directory by descending into the given directory. 574 * Changes the directory by descending into the given directory.
573 * It is assumed the current URL represents a directory. 575 * It is assumed the current URL represents a directory.
574 * If @p dir starts with a "/" the 576 * If @p dir starts with a "/" the
575 * current URL will be "protocol://host/dir" otherwise @p _dir will 577 * current URL will be "protocol://host/dir" otherwise @p _dir will
576 * be appended to the path. @p _dir can be ".." 578 * be appended to the path. @p _dir can be ".."
577 * This function won't strip protocols. That means that when you are in 579 * This function won't strip protocols. That means that when you are in
578 * file:/dir/dir2/my.tgz#tar:/ and you do cd("..") you will 580 * file:/dir/dir2/my.tgz#tar:/ and you do cd("..") you will
579 * still be in file:/dir/dir2/my.tgz#tar:/ 581 * still be in file:/dir/dir2/my.tgz#tar:/
580 * 582 *
581 * @param _dir the directory to change to 583 * @param _dir the directory to change to
582 * @return true if successful 584 * @return true if successful
583 */ 585 */
584 bool cd( const QString& _dir ); 586 bool cd( const QString& _dir );
585 587
586 /** 588 /**
587 * Returns the URL as string, with all escape sequences intact, 589 * Returns the URL as string, with all escape sequences intact,
588 * encoded in a given charset. 590 * encoded in a given charset.
589 * This is used in particular for encoding URLs in UTF-8 before using them 591 * This is used in particular for encoding URLs in UTF-8 before using them
590 * in a drag and drop operation. 592 * in a drag and drop operation.
591 * Please note that the string returned by @ref url() will include 593 * Please note that the string returned by @ref url() will include
592 * the password of the URL. If you want to show the URL to the 594 * the password of the URL. If you want to show the URL to the
593 * user, use @ref prettyURL(). 595 * user, use @ref prettyURL().
594 * 596 *
595 * @param _trailing This may be ( -1, 0 +1 ). -1 strips a trailing '/' from the path, +1 adds 597 * @param _trailing This may be ( -1, 0 +1 ). -1 strips a trailing '/' from the path, +1 adds
596 * a trailing '/' if there is none yet and 0 returns the 598 * a trailing '/' if there is none yet and 0 returns the
597 * path unchanged. 599 * path unchanged.
598 * @param encoding_hint MIB of encoding to use. 600 * @param encoding_hint MIB of encoding to use.
599 * @return The complete URL, with all escape sequences intact, encoded 601 * @return The complete URL, with all escape sequences intact, encoded
600 * in a given charset. 602 * in a given charset.
601 * @see QTextCodec::mibEnum() 603 * @see QTextCodec::mibEnum()
602 * @see prettyURL() 604 * @see prettyURL()
603 */ 605 */
604 QString url( int _trailing = 0, int encoding_hint = 0) const; 606 QString url( int _trailing = 0, int encoding_hint = 0) const;
605 607
606 /** 608 /**
607 * Returns the URL as string in human-friendly format. 609 * Returns the URL as string in human-friendly format.
608 * Example: 610 * Example:
609 * <pre> 611 * <pre>
610 * http://localhost:8080/test.cgi?test=hello world&name=fred 612 * http://localhost:8080/test.cgi?test=hello world&name=fred
611 * </pre> 613 * </pre>
612 * @param _trailing -1 to strip a trailing '/' from the path, +1 adds 614 * @param _trailing -1 to strip a trailing '/' from the path, +1 adds
613 * a trailing '/' if there is none yet and 0 returns the 615 * a trailing '/' if there is none yet and 0 returns the
614 * path unchanged. 616 * path unchanged.
615 * @return A human readable URL, with no non-necessary encodings/escaped 617 * @return A human readable URL, with no non-necessary encodings/escaped
616 * characters. Password will not be shown. 618 * characters. Password will not be shown.
617 * @see url() 619 * @see url()
618 */ 620 */
619 QString prettyURL( int _trailing = 0) const; 621 QString prettyURL( int _trailing = 0) const;
620 622
621 623
622 /** 624 /**
623 * Returns the URL as string, escaped for HTML. 625 * Returns the URL as string, escaped for HTML.
624 * @return A human readable URL, with no non-necessary encodings/escaped 626 * @return A human readable URL, with no non-necessary encodings/escaped
625 * characters which is html encoded for safe inclusion in html or 627 * characters which is html encoded for safe inclusion in html or
626 * rich text. Password will not be shown. 628 * rich text. Password will not be shown.
627 */ 629 */
628 QString htmlURL() const; 630 QString htmlURL() const;
629 631
630 /** 632 /**
631 * Returns the URL as string, escaped for HTML. 633 * Returns the URL as string, escaped for HTML.
632 * Example: 634 * Example:
633 * <pre> 635 * <pre>
634 * http://localhost:8080/test.cgi?test=hello world&name=fred 636 * http://localhost:8080/test.cgi?test=hello world&name=fred
635 * </pre> 637 * </pre>
636 * @return A human readable URL, with no non-necessary encodings/escaped 638 * @return A human readable URL, with no non-necessary encodings/escaped
637 * characters. Password will not be shown. 639 * characters. Password will not be shown.
638 */ 640 */
639 QString prettyURL( int _trailing, AdjustementFlags _flags) const; 641 QString prettyURL( int _trailing, AdjustementFlags _flags) const;
640 // ### BIC: Merge the two above 642 // ### BIC: Merge the two above
641 643
642 /** 644 /**
643 * Test to see if the KURL is empty. 645 * Test to see if the KURL is empty.
644 * @return true if the URL is empty 646 * @return true if the URL is empty
645 **/ 647 **/
646 bool isEmpty() const; 648 bool isEmpty() const;
647 649
648 /** 650 /**
649 * This function is useful to implement the "Up" button in a file manager for example. 651 * This function is useful to implement the "Up" button in a file manager for example.
650 * @ref cd() never strips a sub-protocol. That means that if you are in 652 * @ref cd() never strips a sub-protocol. That means that if you are in
651 * file:/home/x.tgz#gzip:/#tar:/ and hit the up button you expect to see 653 * file:/home/x.tgz#gzip:/#tar:/ and hit the up button you expect to see
652 * file:/home. The algorithm tries to go up on the right-most URL. If that is not 654 * file:/home. The algorithm tries to go up on the right-most URL. If that is not
653 * possible it strips the right most URL. It continues stripping URLs. 655 * possible it strips the right most URL. It continues stripping URLs.
654 * @return a URL that is a level higher 656 * @return a URL that is a level higher
655 */ 657 */
656 KURL upURL( ) const; 658 KURL upURL( ) const;
657 659
658 KURL& operator=( const KURL& _u ); 660 KURL& operator=( const KURL& _u );
659 KURL& operator=( const QString& _url ); 661 KURL& operator=( const QString& _url );
660 KURL& operator=( const char * _url ); 662 KURL& operator=( const char * _url );
661 KURL& operator=( const QUrl & u ); 663 KURL& operator=( const Q3Url & u );
662 664
663 bool operator==( const KURL& _u ) const; 665 bool operator==( const KURL& _u ) const;
664 bool operator==( const QString& _u ) const; 666 bool operator==( const QString& _u ) const;
665 bool operator!=( const KURL& _u ) const { return !( *this == _u ); } 667 bool operator!=( const KURL& _u ) const { return !( *this == _u ); }
666 bool operator!=( const QString& _u ) const { return !( *this == _u ); } 668 bool operator!=( const QString& _u ) const { return !( *this == _u ); }
667 669
668 /** 670 /**
669 * The same as equals(), just with a less obvious name. 671 * The same as equals(), just with a less obvious name.
670 * Compares this url with @p u. 672 * Compares this url with @p u.
671 * @param ignore_trailing set to true to ignore trailing '/' characters. 673 * @param ignore_trailing set to true to ignore trailing '/' characters.
672 * @return true if both urls are the same 674 * @return true if both urls are the same
673 * @see operator==. This function should be used if you want to 675 * @see operator==. This function should be used if you want to
674 * ignore trailing '/' characters. 676 * ignore trailing '/' characters.
675 * @deprecated 677 * @deprecated
676 */ 678 */
677 bool cmp( const KURL &u, bool ignore_trailing = false ) const; 679 bool cmp( const KURL &u, bool ignore_trailing = false ) const;
678 680
679 /** 681 /**
680 * Compares this url with @p u. 682 * Compares this url with @p u.
681 * @param ignore_trailing set to true to ignore trailing '/' characters. 683 * @param ignore_trailing set to true to ignore trailing '/' characters.
682 * @return true if both urls are the same 684 * @return true if both urls are the same
683 * @see operator==. This function should be used if you want to 685 * @see operator==. This function should be used if you want to
684 * ignore trailing '/' characters. 686 * ignore trailing '/' characters.
685 * @since 3.1 687 * @since 3.1
686 */ 688 */
687 bool equals( const KURL &u, bool ignore_trailing = false ) const; 689 bool equals( const KURL &u, bool ignore_trailing = false ) const;
688 690
689 /** 691 /**
690 * Checks whether the given URL is parent of this URL. 692 * Checks whether the given URL is parent of this URL.
691 * For instance, ftp://host/dir/ is a parent of ftp://host/dir/subdir/subsubdir/. 693 * For instance, ftp://host/dir/ is a parent of ftp://host/dir/subdir/subsubdir/.
692 * @return true if this url is a parent of @p u (or the same URL as @p u) 694 * @return true if this url is a parent of @p u (or the same URL as @p u)
693 */ 695 */
694 bool isParentOf( const KURL& u ) const; 696 bool isParentOf( const KURL& u ) const;
695 697
696 /** 698 /**
697 * Splits nested URLs like file:/home/weis/kde.tgz#gzip:/#tar:/kdebase 699 * Splits nested URLs like file:/home/weis/kde.tgz#gzip:/#tar:/kdebase
698 * A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in 700 * A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in
699 * http://www.kde.org and tar:/kde/README.html#ref1. 701 * http://www.kde.org and tar:/kde/README.html#ref1.
700 * That means in turn that "#ref1" is an HTML-style reference and not a new sub URL. 702 * That means in turn that "#ref1" is an HTML-style reference and not a new sub URL.
701 * Since HTML-style references mark 703 * Since HTML-style references mark
702 * a certain position in a document this reference is appended to every URL. 704 * a certain position in a document this reference is appended to every URL.
703 * The idea behind this is that browsers, for example, only look at the first URL while 705 * The idea behind this is that browsers, for example, only look at the first URL while
704 * the rest is not of interest to them. 706 * the rest is not of interest to them.
705 * 707 *
706 * 708 *
707 * @param _url The URL that has to be split. 709 * @param _url The URL that has to be split.
708 * @return An empty list on error or the list of split URLs. 710 * @return An empty list on error or the list of split URLs.
709 * @see #hasSubURL 711 * @see #hasSubURL
710 */ 712 */
711 static List split( const QString& _url ); 713 static List split( const QString& _url );
712 714
713 /** 715 /**
714 * Splits nested URLs like file:/home/weis/kde.tgz#gzip:/#tar:/kdebase 716 * Splits nested URLs like file:/home/weis/kde.tgz#gzip:/#tar:/kdebase
715 * A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in 717 * A URL like http://www.kde.org#tar:/kde/README.hml#ref1 will be split in
716 * http://www.kde.org and tar:/kde/README.html#ref1. 718 * http://www.kde.org and tar:/kde/README.html#ref1.
717 * That means in turn that "#ref1" is an HTML-style reference and not a new sub URL. 719 * That means in turn that "#ref1" is an HTML-style reference and not a new sub URL.
718 * Since HTML-style references mark 720 * Since HTML-style references mark
719 * a certain position in a document this reference is appended to every URL. 721 * a certain position in a document this reference is appended to every URL.
720 * The idea behind this is that browsers, for example, only look at the first URL while 722 * The idea behind this is that browsers, for example, only look at the first URL while
721 * the rest is not of interest to them. 723 * the rest is not of interest to them.
722 * 724 *
723 * @return An empty list on error or the list of split URLs. 725 * @return An empty list on error or the list of split URLs.
724 * 726 *
725 * @param _url The URL that has to be split. 727 * @param _url The URL that has to be split.
726 * @see #hasSubURL 728 * @see #hasSubURL
727 */ 729 */
728 static List split( const KURL& _url ); 730 static List split( const KURL& _url );
729 731
730 /** 732 /**
731 * Reverses @ref #split(). Only the first URL may have a reference. This reference 733 * Reverses @ref #split(). Only the first URL may have a reference. This reference
732 * is considered to be HTML-like and is appended at the end of the resulting 734 * is considered to be HTML-like and is appended at the end of the resulting
733 * joined URL. 735 * joined URL.
734 * @param _list the list to join 736 * @param _list the list to join
735 * @return the joined URL 737 * @return the joined URL
736 */ 738 */
737 static KURL join( const List& _list ); 739 static KURL join( const List& _list );
738 740
739 /** 741 /**
740 * Creates a KURL object from a QString representing either an absolute path 742 * Creates a KURL object from a QString representing either an absolute path
741 * or a real URL. Use this method instead of 743 * or a real URL. Use this method instead of
742 * <pre> 744 * <pre>
743 * QString someDir = ... 745 * QString someDir = ...
744 * KURL url = someDir; 746 * KURL url = someDir;
745 * </pre> 747 * </pre>
746 * 748 *
747 * Otherwise some characters (e.g. the '#') won't be encoded properly. 749 * Otherwise some characters (e.g. the '#') won't be encoded properly.
748 * @param text the string representation of the URL to convert 750 * @param text the string representation of the URL to convert
749 * @return the new KURL 751 * @return the new KURL
750 * @since 3.1 752 * @since 3.1
751 */ 753 */
752 static KURL fromPathOrURL( const QString& text ); 754 static KURL fromPathOrURL( const QString& text );
753 755
754/** 756/**
755 * Convenience function. 757 * Convenience function.
756 * 758 *
757 * Convert unicoded string to local encoding and use %-style 759 * Convert unicoded string to local encoding and use %-style
758 * encoding for all common delimiters / non-ascii characters. 760 * encoding for all common delimiters / non-ascii characters.
759 * @param str String to encode (can be QString::null). 761 * @param str String to encode (can be QString::null).
760 * @param encoding_hint MIB of encoding to use. 762 * @param encoding_hint MIB of encoding to use.
761 * @see QTextCodec::mibEnum() 763 * @see QTextCodec::mibEnum()
762 * @return the encoded string 764 * @return the encoded string
763 **/ 765 **/
764 static QString encode_string(const QString &str, int encoding_hint = 0); 766 static QString encode_string(const QString &str, int encoding_hint = 0);
765 767
766 /** 768 /**
767 * Convenience function. 769 * Convenience function.
768 * 770 *
769 * Convert unicoded string to local encoding and use %-style 771 * Convert unicoded string to local encoding and use %-style
770 * encoding for all common delimiters / non-ascii characters 772 * encoding for all common delimiters / non-ascii characters
771 * as well as the slash '/'. 773 * as well as the slash '/'.
772 * @param str String to encode 774 * @param str String to encode
773 * @param encoding_hint MIB of encoding to use. 775 * @param encoding_hint MIB of encoding to use.
774 * @see QTextCodec::mibEnum() 776 * @see QTextCodec::mibEnum()
775 **/ 777 **/
776 static QString encode_string_no_slash(const QString &str, int encoding_hint = 0); 778 static QString encode_string_no_slash(const QString &str, int encoding_hint = 0);
777 779
778 /** 780 /**
779 * Convenience function. 781 * Convenience function.
780 * 782 *
781 * Decode %-style encoding and convert from local encoding to unicode. 783 * Decode %-style encoding and convert from local encoding to unicode.
782 * 784 *
783 * Reverse of encode_string() 785 * Reverse of encode_string()
784 * @param str String to decode (can be QString::null). 786 * @param str String to decode (can be QString::null).
785 * @param encoding_hint MIB of original encoding of @p str . 787 * @param encoding_hint MIB of original encoding of @p str .
786 * @see QTextCodec::mibEnum() 788 * @see QTextCodec::mibEnum()
787 **/ 789 **/
788 static QString decode_string(const QString &str, int encoding_hint = 0); 790 static QString decode_string(const QString &str, int encoding_hint = 0);
789 791
790 /** 792 /**
791 * Convenience function. 793 * Convenience function.
792 * 794 *
793 * Returns whether '_url' is likely to be a "relative" URL instead of 795 * Returns whether '_url' is likely to be a "relative" URL instead of
794 * an "absolute" URL. 796 * an "absolute" URL.
795 * @param _url URL to examine 797 * @param _url URL to examine
796 * @return true when the URL is likely to be "relative", false otherwise. 798 * @return true when the URL is likely to be "relative", false otherwise.
797 */ 799 */
798 static bool isRelativeURL(const QString &_url); 800 static bool isRelativeURL(const QString &_url);
799 801
800#ifdef KDE_NO_COMPAT 802#ifdef KDE_NO_COMPAT
801private: 803private:
802#endif 804#endif
803 QString filename( bool _ignore_trailing_slash_in_path = true ) const 805 QString filename( bool _ignore_trailing_slash_in_path = true ) const
804 { 806 {
805 return fileName(_ignore_trailing_slash_in_path); 807 return fileName(_ignore_trailing_slash_in_path);
806 } 808 }
807 809
808protected: 810protected:
809 void reset(); 811 void reset();
810 void parse( const QString& _url, int encoding_hint = 0); 812 void parse( const QString& _url, int encoding_hint = 0);
811 813
812private: 814private:
813 QString m_strProtocol; 815 QString m_strProtocol;
814 QString m_strUser; 816 QString m_strUser;
815 QString m_strPass; 817 QString m_strPass;
816 QString m_strHost; 818 QString m_strHost;
817 QString m_strPath; 819 QString m_strPath;
818 QString m_strRef_encoded; 820 QString m_strRef_encoded;
819 QString m_strQuery_encoded; 821 QString m_strQuery_encoded;
820 bool m_bIsMalformed : 1; 822 bool m_bIsMalformed : 1;
821 int freeForUse : 7; 823 int freeForUse : 7;
822 unsigned short int m_iPort; 824 unsigned short int m_iPort;
823 QString m_strPath_encoded; 825 QString m_strPath_encoded;
824 826
825 friend QDataStream & operator<< (QDataStream & s, const KURL & a); 827 friend QDataStream & operator<< (QDataStream & s, const KURL & a);
826 friend QDataStream & operator>> (QDataStream & s, KURL & a); 828 friend QDataStream & operator>> (QDataStream & s, KURL & a);
827private: 829private:
828 KURLPrivate* d; 830 KURLPrivate* d;
829}; 831};
830 832
831/** 833/**
832 * Compares URLs. They are parsed, split and compared. 834 * Compares URLs. They are parsed, split and compared.
833 * Two malformed URLs with the same string representation 835 * Two malformed URLs with the same string representation
834 * are nevertheless considered to be unequal. 836 * are nevertheless considered to be unequal.
835 * That means no malformed URL equals anything else. 837 * That means no malformed URL equals anything else.
836 */ 838 */
837bool urlcmp( const QString& _url1, const QString& _url2 ); 839bool urlcmp( const QString& _url1, const QString& _url2 );
838 840
839/** 841/**
840 * Compares URLs. They are parsed, split and compared. 842 * Compares URLs. They are parsed, split and compared.
841 * Two malformed URLs with the same string representation 843 * Two malformed URLs with the same string representation
842 * are nevertheless considered to be unequal. 844 * are nevertheless considered to be unequal.
843 * That means no malformed URL equals anything else. 845 * That means no malformed URL equals anything else.
844 * 846 *
845 * @param _ignore_trailing Described in @ref KURL::cmp 847 * @param _ignore_trailing Described in @ref KURL::cmp
846 * @param _ignore_ref If true, disables comparison of HTML-style references. 848 * @param _ignore_ref If true, disables comparison of HTML-style references.
847 */ 849 */
848bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref ); 850bool urlcmp( const QString& _url1, const QString& _url2, bool _ignore_trailing, bool _ignore_ref );
849 851
850QDataStream & operator<< (QDataStream & s, const KURL & a); 852QDataStream & operator<< (QDataStream & s, const KURL & a);
851QDataStream & operator>> (QDataStream & s, KURL & a); 853QDataStream & operator>> (QDataStream & s, KURL & a);
852 854
853#endif 855#endif
diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp
index 9c87682..88f17e5 100644
--- a/microkde/kutils/kcmultidialog.cpp
+++ b/microkde/kutils/kcmultidialog.cpp
@@ -1,229 +1,231 @@
1/* 1/*
2 Copyright (c) 2000 Matthias Elter <elter@kde.org> 2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> 3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20*/ 20*/
21 21
22#include <qhbox.h> 22#include <q3hbox.h>
23#include <qvbox.h> 23#include <q3vbox.h>
24#include <qcursor.h> 24#include <qcursor.h>
25#include <qlayout.h> 25#include <qlayout.h>
26//Added by qt3to4:
27#include <QPixmap>
26 28
27#include <klocale.h> 29#include <klocale.h>
28#include <kglobal.h> 30#include <kglobal.h>
29#include <kdebug.h> 31#include <kdebug.h>
30#include <kiconloader.h> 32#include <kiconloader.h>
31#include <kmessagebox.h> 33#include <kmessagebox.h>
32//US #include <klibloader.h> 34//US #include <klibloader.h>
33#include <krun.h> 35#include <krun.h>
34#include <kprocess.h> 36#include <kprocess.h>
35#include <kglobalsettings.h> 37#include <kglobalsettings.h>
36 38
37#include "kcmultidialog.h" 39#include "kcmultidialog.h"
38//US #include "kcmultidialog.moc" 40//US #include "kcmultidialog.moc"
39//US #include "kcmoduleloader.h" 41//US #include "kcmoduleloader.h"
40 42
41KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal) 43KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal)
42 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok, 44 : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok,
43 parent, name, modal, true), d(0L) 45 parent, name, modal, true), d(0L)
44{ 46{
45 setFont( KGlobalSettings::generalMaxFont() ); 47 setFont( KGlobalSettings::generalMaxFont() );
46 enableButton(Apply, false); 48 enableButton(Apply, false);
47 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); 49 //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *)));
48 50
49 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) ); 51 connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) );
50 52
51 _baseGroup = baseGroup; 53 _baseGroup = baseGroup;
52 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); 54 mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed );
53 setMainWidget(mMainWidget ); 55 setMainWidget(mMainWidget );
54#ifdef DESKTOP_VERSION 56#ifdef DESKTOP_VERSION
55 resize(640,480); 57 resize(640,480);
56#else 58#else
57 //resize(640,480); 59 //resize(640,480);
58 //setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480)); 60 //setMaximumSize( KMIN(KGlobal::getDesktopWidth()-5, 640), KMIN(KGlobal::getDesktopHeight()-20, 480));
59 resize(800,800); 61 resize(800,800);
60 setMaximumSize( 800, 800 ); 62 setMaximumSize( 800, 800 );
61 //showMaximized(); 63 //showMaximized();
62#endif 64#endif
63 65
64} 66}
65 67
66KCMultiDialog::~KCMultiDialog() 68KCMultiDialog::~KCMultiDialog()
67{ 69{
68//US moduleDict.setAutoDelete(true); 70//US moduleDict.setAutoDelete(true);
69} 71}
70 72
71void KCMultiDialog::slotDefault() 73void KCMultiDialog::slotDefault()
72{ 74{
73 75
74 int curPageIndex = activePageIndex(); 76 int curPageIndex = activePageIndex();
75 77
76 QPtrListIterator<KCModule> it(modules); 78 Q3PtrListIterator<KCModule> it(modules);
77 for (; it.current(); ++it) 79 for (; it.current(); ++it)
78 { 80 {
79 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex) 81 if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex)
80 { 82 {
81 (*it)->defaults(); 83 (*it)->defaults();
82 clientChanged(true); 84 clientChanged(true);
83 return; 85 return;
84 } 86 }
85 } 87 }
86 88
87} 89}
88void KCMultiDialog::accept() 90void KCMultiDialog::accept()
89{ 91{
90 slotOk(); 92 slotOk();
91} 93}
92void KCMultiDialog::slotApply() 94void KCMultiDialog::slotApply()
93{ 95{
94 QPtrListIterator<KCModule> it(modules); 96 Q3PtrListIterator<KCModule> it(modules);
95 for (; it.current(); ++it) 97 for (; it.current(); ++it)
96 (*it)->save(); 98 (*it)->save();
97 clientChanged(false); 99 clientChanged(false);
98 100
99 emit applyClicked(); 101 emit applyClicked();
100 102
101} 103}
102 104
103 105
104void KCMultiDialog::slotOk() 106void KCMultiDialog::slotOk()
105{ 107{
106qDebug("KCMultiDialog::slotOk clicked"); 108qDebug("KCMultiDialog::slotOk clicked");
107 109
108 QPtrListIterator<KCModule> it(modules); 110 Q3PtrListIterator<KCModule> it(modules);
109 for (; it.current(); ++it) 111 for (; it.current(); ++it)
110 (*it)->save(); 112 (*it)->save();
111 QDialog::accept(); 113 QDialog::accept();
112 114
113 emit okClicked(); 115 emit okClicked();
114} 116}
115 117
116void KCMultiDialog::slotHelp() 118void KCMultiDialog::slotHelp()
117{ 119{
118/*US 120/*US
119 KURL url( KURL("help:/"), _docPath ); 121 KURL url( KURL("help:/"), _docPath );
120 122
121 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") { 123 if (url.protocol() == "help" || url.protocol() == "man" || url.protocol() == "info") {
122 KProcess process; 124 KProcess process;
123 process << "khelpcenter" 125 process << "khelpcenter"
124 << url.url(); 126 << url.url();
125 process.start(KProcess::DontCare); 127 process.start(KProcess::DontCare);
126 process.detach(); 128 process.detach();
127 } else { 129 } else {
128 new KRun(url); 130 new KRun(url);
129 } 131 }
130*/ 132*/
131} 133}
132 134
133void KCMultiDialog::clientChanged(bool state) 135void KCMultiDialog::clientChanged(bool state)
134{ 136{
135 enableButton(Apply, state); 137 enableButton(Apply, state);
136} 138}
137 139
138/*US 140/*US
139void KCMultiDialog::addModule(const QString& path, bool withfallback) 141void KCMultiDialog::addModule(const QString& path, bool withfallback)
140{ 142{
141 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl; 143 kdDebug(1208) << "KCMultiDialog::addModule " << path << endl;
142 144
143 KCModuleInfo info(path, _baseGroup); 145 KCModuleInfo info(path, _baseGroup);
144 146
145 QHBox* page = addHBoxPage(info.moduleName(), info.comment(), 147 QHBox* page = addHBoxPage(info.moduleName(), info.comment(),
146 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium)); 148 KGlobal::iconLoader()->loadIcon(info.icon(), KIcon::Desktop, KIcon::SizeMedium));
147 if(!page) { 149 if(!page) {
148 KCModuleLoader::unloadModule(info); 150 KCModuleLoader::unloadModule(info);
149 return; 151 return;
150 } 152 }
151 moduleDict.insert(page, new LoadInfo(path, withfallback)); 153 moduleDict.insert(page, new LoadInfo(path, withfallback));
152 if (modules.isEmpty()) 154 if (modules.isEmpty())
153 slotAboutToShow(page); 155 slotAboutToShow(page);
154} 156}
155*/ 157*/
156QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename ) 158Q3VBox * KCMultiDialog::getNewVBoxPage( const QString & modulename )
157{ 159{
158 QVBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() ); 160 Q3VBox *page = mMainWidget->addVBoxPage(modulename , QString::null,QPixmap() );
159 return page; 161 return page;
160 162
161} 163}
162//US special method for microkde. We dop noty want to load everything dynamically. 164//US special method for microkde. We dop noty want to load everything dynamically.
163void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname) 165void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname)
164{ 166{
165 167
166 modules.append(module); 168 modules.append(module);
167 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 169 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
168//US 170//US
169 module->load(); 171 module->load();
170 172
171 173
172} 174}
173 175
174void KCMultiDialog::slotAboutToShow(QWidget *page) 176void KCMultiDialog::slotAboutToShow(QWidget *page)
175{ 177{
176/*US 178/*US
177 LoadInfo *loadInfo = moduleDict[page]; 179 LoadInfo *loadInfo = moduleDict[page];
178 if (!loadInfo) 180 if (!loadInfo)
179 return; 181 return;
180 182
181 QApplication::setOverrideCursor(Qt::WaitCursor); 183 QApplication::setOverrideCursor(Qt::WaitCursor);
182 184
183 moduleDict.remove(page); 185 moduleDict.remove(page);
184 186
185 KCModuleInfo info(loadInfo->path, _baseGroup); 187 KCModuleInfo info(loadInfo->path, _baseGroup);
186 188
187 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback); 189 KCModule *module = KCModuleLoader::loadModule(info, loadInfo->withfallback);
188 190
189 if (!module) 191 if (!module)
190 { 192 {
191 QApplication::restoreOverrideCursor(); 193 QApplication::restoreOverrideCursor();
192 KCModuleLoader::showLastLoaderError(this); 194 KCModuleLoader::showLastLoaderError(this);
193 delete loadInfo; 195 delete loadInfo;
194 return; 196 return;
195 } 197 }
196 198
197 module->reparent(page,0,QPoint(0,0),true); 199 module->reparent(page,0,QPoint(0,0),true);
198 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); 200 connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool)));
199 //setHelp( docpath, QString::null ); 201 //setHelp( docpath, QString::null );
200 _docPath = info.docPath(); 202 _docPath = info.docPath();
201 modules.append(module); 203 modules.append(module);
202 204
203 //KCGlobal::repairAccels( topLevelWidget() ); 205 //KCGlobal::repairAccels( topLevelWidget() );
204 206
205 delete loadInfo; 207 delete loadInfo;
206 208
207 QApplication::restoreOverrideCursor(); 209 QApplication::restoreOverrideCursor();
208*/ 210*/
209 211
210qDebug("KCMultiDialog::slotAboutToShow not implemented"); 212qDebug("KCMultiDialog::slotAboutToShow not implemented");
211} 213}
212 214
213 215
214bool KCMultiDialog::showPage( int index ) 216bool KCMultiDialog::showPage( int index )
215{ 217{
216 return(mMainWidget->showPage(index) ); 218 return(mMainWidget->showPage(index) );
217} 219}
218 220
219 221
220int KCMultiDialog::activePageIndex() const 222int KCMultiDialog::activePageIndex() const
221{ 223{
222 return( mMainWidget->activePageIndex() ); 224 return( mMainWidget->activePageIndex() );
223} 225}
224 226
225 227
226int KCMultiDialog::pageIndex( QWidget *widget ) const 228int KCMultiDialog::pageIndex( QWidget *widget ) const
227{ 229{
228 return( mMainWidget->pageIndex( widget) ); 230 return( mMainWidget->pageIndex( widget) );
229} 231}
diff --git a/microkde/kutils/kcmultidialog.h b/microkde/kutils/kcmultidialog.h
index 66412ac..78f8a00 100644
--- a/microkde/kutils/kcmultidialog.h
+++ b/microkde/kutils/kcmultidialog.h
@@ -1,151 +1,151 @@
1/* 1/*
2 Copyright (c) 2000 Matthias Elter <elter@kde.org> 2 Copyright (c) 2000 Matthias Elter <elter@kde.org>
3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org> 3 Copyright (c) 2003 Daniel Molkentin <molkentin@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20*/ 20*/
21 21
22#ifndef KCMULTIDIALOG_H 22#ifndef KCMULTIDIALOG_H
23#define KCMULTIDIALOG_H 23#define KCMULTIDIALOG_H
24 24
25#include <qptrlist.h> 25#include <q3ptrlist.h>
26#include <qptrdict.h> 26#include <q3ptrdict.h>
27 27
28#include <kdialogbase.h> 28#include <kdialogbase.h>
29#include <kjanuswidget.h> 29#include <kjanuswidget.h>
30#include <kcmodule.h> 30#include <kcmodule.h>
31 31
32/** 32/**
33 * A class that offers a @ref KDialogBase containing arbitrary KControl Modules 33 * A class that offers a @ref KDialogBase containing arbitrary KControl Modules
34 * 34 *
35 * @short A method that offers a @ref KDialogBase containing arbitrary 35 * @short A method that offers a @ref KDialogBase containing arbitrary
36 * KControl Modules. 36 * KControl Modules.
37 * 37 *
38 * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org> 38 * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org>
39 * @since 3.2 39 * @since 3.2
40 */ 40 */
41class KCMultiDialog : public KDialogBase 41class KCMultiDialog : public KDialogBase
42{ 42{
43 Q_OBJECT 43 Q_OBJECT
44 44
45public: 45public:
46 /** 46 /**
47 * Constructs a new KCMultiDialog 47 * Constructs a new KCMultiDialog
48 * 48 *
49 * @param parent The parent Widget 49 * @param parent The parent Widget
50 * @param name The widget name 50 * @param name The widget name
51 * @param baseGroup The baseGroup, if you want to call a module out of 51 * @param baseGroup The baseGroup, if you want to call a module out of
52 * kcontrol, just keep "settings" 52 * kcontrol, just keep "settings"
53 * @param modal If you pass true here, the dialog will be modal 53 * @param modal If you pass true here, the dialog will be modal
54 **/ 54 **/
55 KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"), 55 KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"),
56 QWidget *parent=0, const char *name=0, 56 QWidget *parent=0, const char *name=0,
57 bool modal=false); 57 bool modal=false);
58 58
59 /** 59 /**
60 * Destructor 60 * Destructor
61 **/ 61 **/
62 virtual ~KCMultiDialog(); 62 virtual ~KCMultiDialog();
63 63
64 /** 64 /**
65 * Add a module. 65 * Add a module.
66 * 66 *
67 * @param module Specify the name of the module that is to be added 67 * @param module Specify the name of the module that is to be added
68 * to the list of modules the dialog will show. 68 * to the list of modules the dialog will show.
69 * 69 *
70 * @param withfallback Try harder to load the module. Might result 70 * @param withfallback Try harder to load the module. Might result
71 * in the module appearing outside the dialog. 71 * in the module appearing outside the dialog.
72 **/ 72 **/
73//US void addModule(const QString& module, bool withfallback=true); 73//US void addModule(const QString& module, bool withfallback=true);
74 74
75 75
76//US special method for microkde. We do not want to load everything dynamically. 76//US special method for microkde. We do not want to load everything dynamically.
77 void addModule(KCModule* module );//, const QString& modulename, const QString& iconname); 77 void addModule(KCModule* module );//, const QString& modulename, const QString& iconname);
78 QVBox* getNewVBoxPage(const QString & modulename) ; 78 Q3VBox* getNewVBoxPage(const QString & modulename) ;
79 79
80 80
81 bool showPage( int index ); 81 bool showPage( int index );
82 int activePageIndex() const; 82 int activePageIndex() const;
83 int pageIndex( QWidget *widget ) const; 83 int pageIndex( QWidget *widget ) const;
84 84
85protected slots: 85protected slots:
86 /** 86 /**
87 * This slot is called when the user presses the "Default" Button 87 * This slot is called when the user presses the "Default" Button
88 * You can reimplement it if needed. 88 * You can reimplement it if needed.
89 * 89 *
90 * @note Make sure you call the original implementation! 90 * @note Make sure you call the original implementation!
91 **/ 91 **/
92 virtual void slotDefault(); 92 virtual void slotDefault();
93 93
94 /** 94 /**
95 * This slot is called when the user presses the "Apply" Button 95 * This slot is called when the user presses the "Apply" Button
96 * You can reimplement it if needed 96 * You can reimplement it if needed
97 * 97 *
98 * @note Make sure you call the original implementation! 98 * @note Make sure you call the original implementation!
99 **/ 99 **/
100 virtual void slotApply(); 100 virtual void slotApply();
101 101
102 /** 102 /**
103 * This slot is called when the user presses the "OK" Button 103 * This slot is called when the user presses the "OK" Button
104 * You can reimplement it if needed 104 * You can reimplement it if needed
105 * 105 *
106 * @note Make sure you call the original implementation! 106 * @note Make sure you call the original implementation!
107 **/ 107 **/
108 virtual void slotOk(); 108 virtual void slotOk();
109 109
110 /** 110 /**
111 * This slot is called when the user presses the "Help" Button 111 * This slot is called when the user presses the "Help" Button
112 * You can reimplement it if needed 112 * You can reimplement it if needed
113 * 113 *
114 * @note Make sure you call the original implementation! 114 * @note Make sure you call the original implementation!
115 **/ 115 **/
116 virtual void slotHelp(); 116 virtual void slotHelp();
117 117
118 void accept(); 118 void accept();
119 119
120private slots: 120private slots:
121 121
122 void slotAboutToShow(QWidget *); 122 void slotAboutToShow(QWidget *);
123 123
124 void clientChanged(bool state); 124 void clientChanged(bool state);
125 125
126private: 126private:
127/*US 127/*US
128 struct LoadInfo { 128 struct LoadInfo {
129 LoadInfo(const QString &_path, bool _withfallback) 129 LoadInfo(const QString &_path, bool _withfallback)
130 : path(_path), withfallback(_withfallback) 130 : path(_path), withfallback(_withfallback)
131 { } 131 { }
132 QString path; 132 QString path;
133 bool withfallback; 133 bool withfallback;
134 }; 134 };
135*/ 135*/
136 QPtrList<KCModule> modules; 136 Q3PtrList<KCModule> modules;
137/* 137/*
138 QPtrDict<LoadInfo> moduleDict; 138 QPtrDict<LoadInfo> moduleDict;
139 QString _docPath; 139 QString _docPath;
140*/ 140*/
141 QString _baseGroup; 141 QString _baseGroup;
142 142
143//US 143//US
144 KJanusWidget* mMainWidget; 144 KJanusWidget* mMainWidget;
145 145
146 // For future use 146 // For future use
147 class KCMultiDialogPrivate; 147 class KCMultiDialogPrivate;
148 KCMultiDialogPrivate *d; 148 KCMultiDialogPrivate *d;
149}; 149};
150 150
151#endif //KCMULTIDIALOG_H 151#endif //KCMULTIDIALOG_H
diff --git a/microkde/microkde.pro b/microkde/microkde.pro
index 7120bdd..4ff06a3 100644
--- a/microkde/microkde.pro
+++ b/microkde/microkde.pro
@@ -1,180 +1,182 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2 CONFIG += qt warn_on 2 CONFIG += qt warn_on
3include( ../variables.pri ) 3include( ../variables.pri )
4#INCLUDEPATH += $(QTDIR)/include . 4#INCLUDEPATH += $(QTDIR)/include .
5#DEPENDPATH += $(QTDIR)/include 5#DEPENDPATH += $(QTDIR)/include
6INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio 6INCLUDEPATH += . ../ ../kabc ./kdecore ./kdeui ./kio/kfile ./kio/kio
7#LIBS += -lqtcompat 7#LIBS += -lqtcompat
8 8
9 TARGET = microkde 9 TARGET = xmicrokde
10DESTDIR= ../bin 10DESTDIR= ../bin
11DEFINES += DESKTOP_VERSION KDE_QT_ONLY 11DEFINES += DESKTOP_VERSION KDE_QT_ONLY
12unix : { 12unix : {
13staticlib: { 13staticlib: {
14INCLUDEPATH += ../kabc/plugins 14INCLUDEPATH += ../kabc/plugins
15DEFINES += STATIC_RESOURCES 15DEFINES += STATIC_RESOURCES
16} 16}
17 17
18 18
19OBJECTS_DIR = obj/unix 19OBJECTS_DIR = obj/unix
20MOC_DIR = moc/unix 20MOC_DIR = moc/unix
21} 21}
22win32: { 22win32: {
23DEFINES += _WIN32_ 23DEFINES += _WIN32_
24OBJECTS_DIR = obj/win 24OBJECTS_DIR = obj/win
25MOC_DIR = moc/win 25MOC_DIR = moc/win
26} 26}
27 27
28 28
29 29
30HEADERS = \ 30HEADERS = \
31qlayoutengine_p.h \ 31qlayoutengine_p.h \
32KDGanttMinimizeSplitter.h \ 32KDGanttMinimizeSplitter.h \
33 kapplication.h \ 33 kapplication.h \
34 kaudioplayer.h \ 34 kaudioplayer.h \
35 kcalendarsystem.h \ 35 kcalendarsystem.h \
36 kcalendarsystemgregorian.h \ 36 kcalendarsystemgregorian.h \
37 kcolorbutton.h \ 37 kcolorbutton.h \
38 kcombobox.h \ 38 kcombobox.h \
39 kconfig.h \ 39 kconfig.h \
40 kdatetbl.h \ 40 kdatetbl.h \
41 kdebug.h \ 41 kdebug.h \
42 kdialog.h \ 42 kdialog.h \
43 kdialogbase.h \ 43 kdialogbase.h \
44 keditlistbox.h \ 44 keditlistbox.h \
45 kemailsettings.h \ 45 kemailsettings.h \
46 kfiledialog.h \ 46 kfiledialog.h \
47 kfontdialog.h \ 47 kfontdialog.h \
48 kglobal.h \ 48 kglobal.h \
49 kglobalsettings.h \ 49 kglobalsettings.h \
50 kiconloader.h \ 50 kiconloader.h \
51 klineedit.h \ 51 klineedit.h \
52 klineeditdlg.h \ 52 klineeditdlg.h \
53 kmessagebox.h \ 53 kmessagebox.h \
54 knotifyclient.h \ 54 knotifyclient.h \
55 kprinter.h \ 55 kprinter.h \
56 kprocess.h \ 56 kprocess.h \
57 krestrictedline.h \ 57 krestrictedline.h \
58 krun.h \ 58 krun.h \
59 ksimpleconfig.h \ 59 ksimpleconfig.h \
60 kstaticdeleter.h \ 60 kstaticdeleter.h \
61 ksystemtray.h \ 61 ksystemtray.h \
62 ktempfile.h \ 62 ktempfile.h \
63 ktextedit.h \ 63 ktextedit.h \
64 kunload.h \ 64 kunload.h \
65 kurl.h \ 65 kurl.h \
66 kdeui/kguiitem.h \ 66 kdeui/kguiitem.h \
67 kdeui/kcmodule.h \ 67 kdeui/kcmodule.h \
68 kdeui/kbuttonbox.h \ 68 kdeui/kbuttonbox.h \
69 kdeui/klistbox.h \ 69 kdeui/klistbox.h \
70 kdeui/klistview.h \ 70 kdeui/klistview.h \
71 kdeui/kjanuswidget.h \ 71 kdeui/kjanuswidget.h \
72 kdeui/kseparator.h \ 72 kdeui/kseparator.h \
73 kdeui/knuminput.h \ 73 kdeui/knuminput.h \
74 kdeui/knumvalidator.h \ 74 kdeui/knumvalidator.h \
75 kdeui/ksqueezedtextlabel.h \ 75 kdeui/ksqueezedtextlabel.h \
76 kio/job.h \ 76 kio/job.h \
77 kio/kio/kdirwatch.h \ 77 kio/kio/kdirwatch.h \
78 kio/kio/kdirwatch_p.h \ 78 kio/kio/kdirwatch_p.h \
79 kio/kfile/kurlrequester.h \ 79 kio/kfile/kurlrequester.h \
80 kresources/resource.h \ 80 kresources/resource.h \
81 kresources/factory.h \ 81 kresources/factory.h \
82 kresources/managerimpl.h \ 82 kresources/managerimpl.h \
83 kresources/manager.h \ 83 kresources/manager.h \
84 kresources/selectdialog.h \ 84 kresources/selectdialog.h \
85 kresources/configpage.h \ 85 kresources/configpage.h \
86 kresources/configwidget.h \ 86 kresources/configwidget.h \
87 kresources/configdialog.h \ 87 kresources/configdialog.h \
88 kresources/kcmkresources.h \ 88 kresources/kcmkresources.h \
89 kdecore/kmdcodec.h \ 89 kdecore/kmdcodec.h \
90 kdecore/kconfigbase.h \ 90 kdecore/kconfigbase.h \
91 kdecore/klocale.h \ 91 kdecore/klocale.h \
92 kdecore/kcatalogue.h \ 92 kdecore/kcatalogue.h \
93 kdecore/ksharedptr.h \ 93 kdecore/ksharedptr.h \
94 kdecore/kshell.h \ 94 kdecore/kshell.h \
95 kdecore/kstandarddirs.h \ 95 kdecore/kstandarddirs.h \
96 kdecore/kstringhandler.h \ 96 kdecore/kstringhandler.h \
97 kdecore/kshortcut.h \ 97 kdecore/kshortcut.h \
98 kutils/kcmultidialog.h \ 98 kutils/kcmultidialog.h \
99 kdeui/kxmlguiclient.h \ 99 kdeui/kxmlguiclient.h \
100 kdeui/kstdaction.h \ 100 kdeui/kstdaction.h \
101 kdeui/kmainwindow.h \ 101 kdeui/kmainwindow.h \
102 kdeui/ktoolbar.h \ 102 kdeui/ktoolbar.h \
103 kdeui/ktoolbarbutton.h \ 103 kdeui/ktoolbarbutton.h \
104 kdeui/ktoolbarhandler.h \ 104 kdeui/ktoolbarhandler.h \
105 kdeui/kaction.h \ 105 kdeui/kaction.h \
106 kdeui/kpopupmenu.h \ 106 kdeui/kpopupmenu.h \
107 kdeui/kactionclasses.h \ 107 kdeui/kactionclasses.h \
108 kdeui/kactioncollection.h \ 108 kdeui/kactioncollection.h \
109 kdecore/kprefs.h \ 109 kdecore/kprefs.h \
110 kdecore/klibloader.h \ 110 kdecore/klibloader.h \
111 kidmanager.h 111 kidmanager.h
112 112
113 113
114# kdecore/klibloader.h \ 114# kdecore/klibloader.h \
115 115
116 116
117SOURCES = \ 117SOURCES = \
118KDGanttMinimizeSplitter.cpp \ 118KDGanttMinimizeSplitter.cpp \
119 kapplication.cpp \ 119 kapplication.cpp \
120 kcalendarsystem.cpp \ 120 kcalendarsystem.cpp \
121 kcalendarsystemgregorian.cpp \ 121 kcalendarsystemgregorian.cpp \
122 kcolorbutton.cpp \ 122 kcolorbutton.cpp \
123 kconfig.cpp \ 123 kconfig.cpp \
124 kdatetbl.cpp \ 124 kdatetbl.cpp \
125 kdialog.cpp \ 125 kdialog.cpp \
126 kdialogbase.cpp \ 126 kdialogbase.cpp \
127 keditlistbox.cpp \ 127 keditlistbox.cpp \
128 kemailsettings.cpp \ 128 kemailsettings.cpp \
129 kfontdialog.cpp \ 129 kfontdialog.cpp \
130 kfiledialog.cpp \ 130 kfiledialog.cpp \
131 kglobal.cpp \ 131 kglobal.cpp \
132 kglobalsettings.cpp \ 132 kglobalsettings.cpp \
133 kiconloader.cpp \ 133 kiconloader.cpp \
134 kmessagebox.cpp \ 134 kmessagebox.cpp \
135 ktextedit.cpp \ 135 ktextedit.cpp \
136 kprocess.cpp \ 136 kprocess.cpp \
137 krun.cpp \ 137 krun.cpp \
138 ksystemtray.cpp \ 138 ksystemtray.cpp \
139 ktempfile.cpp \ 139 ktempfile.cpp \
140 kurl.cpp \ 140 kurl.cpp \
141 kdecore/kcatalogue.cpp \ 141 kdecore/kcatalogue.cpp \
142 kdecore/klocale.cpp \ 142 kdecore/klocale.cpp \
143 kdecore/kmdcodec.cpp \ 143 kdecore/kmdcodec.cpp \
144 kdecore/kshell.cpp \ 144 kdecore/kshell.cpp \
145 kdecore/kstandarddirs.cpp \ 145 kdecore/kstandarddirs.cpp \
146 kdecore/kstringhandler.cpp \ 146 kdecore/kstringhandler.cpp \
147 kdeui/kbuttonbox.cpp \ 147 kdeui/kbuttonbox.cpp \
148 kdeui/kcmodule.cpp \ 148 kdeui/kcmodule.cpp \
149 kdeui/kguiitem.cpp \ 149 kdeui/kguiitem.cpp \
150 kdeui/kjanuswidget.cpp \ 150 kdeui/kjanuswidget.cpp \
151 kdeui/klistbox.cpp \ 151 kdeui/klistbox.cpp \
152 kdeui/klistview.cpp \ 152 kdeui/klistview.cpp \
153 kdeui/knuminput.cpp \ 153 kdeui/knuminput.cpp \
154 kdeui/knumvalidator.cpp \ 154 kdeui/knumvalidator.cpp \
155 kdeui/kseparator.cpp \ 155 kdeui/kseparator.cpp \
156 kdeui/ksqueezedtextlabel.cpp \ 156 kdeui/ksqueezedtextlabel.cpp \
157 kio/kio/kdirwatch.cpp \ 157 kio/kio/kdirwatch.cpp \
158 kio/kfile/kurlrequester.cpp \ 158 kio/kfile/kurlrequester.cpp \
159 kresources/configpage.cpp \ 159 kresources/configpage.cpp \
160 kresources/configdialog.cpp \ 160 kresources/configdialog.cpp \
161 kresources/configwidget.cpp \ 161 kresources/configwidget.cpp \
162 kresources/factory.cpp \ 162 kresources/factory.cpp \
163 kresources/kcmkresources.cpp \ 163 kresources/kcmkresources.cpp \
164 kresources/managerimpl.cpp \ 164 kresources/managerimpl.cpp \
165 kresources/resource.cpp \ 165 kresources/resource.cpp \
166 kresources/selectdialog.cpp \ 166 kresources/selectdialog.cpp \
167 kutils/kcmultidialog.cpp \ 167 kutils/kcmultidialog.cpp \
168 kdeui/kaction.cpp \ 168 kdeui/kaction.cpp \
169 kdeui/kpopupmenu.cpp \ 169 kdeui/kpopupmenu.cpp \
170 kdeui/kactionclasses.cpp \ 170 kdeui/kactionclasses.cpp \
171 kdeui/kactioncollection.cpp \ 171 kdeui/kactioncollection.cpp \
172 kdeui/kmainwindow.cpp \ 172 kdeui/kmainwindow.cpp \
173 kdeui/ktoolbar.cpp \ 173 kdeui/ktoolbar.cpp \
174 kdeui/ktoolbarbutton.cpp \ 174 kdeui/ktoolbarbutton.cpp \
175 kdeui/ktoolbarhandler.cpp \ 175 kdeui/ktoolbarhandler.cpp \
176 kdeui/kstdaction.cpp \ 176 kdeui/kstdaction.cpp \
177 kdeui/kxmlguiclient.cpp \ 177 kdeui/kxmlguiclient.cpp \
178 kdecore/kprefs.cpp \ 178 kdecore/kprefs.cpp \
179 kdecore/klibloader.cpp \ 179 kdecore/klibloader.cpp \
180 kidmanager.cpp 180 kidmanager.cpp
181#The following line was inserted by qt3to4
182QT += xml qt3support
diff --git a/microkde/microkdeE.pro b/microkde/microkdeE.pro
index 8fe2bd5..514e7b3 100644
--- a/microkde/microkdeE.pro
+++ b/microkde/microkdeE.pro
@@ -1,174 +1,174 @@
1 TEMPLATE= lib 1 TEMPLATE= lib
2CONFIG += qt warn_on 2CONFIG += qt warn_on
3INCLUDEPATH += . .. $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/kabc kdecore kdeui kio/kfile kio/kio $(QPEDIR)/include 3INCLUDEPATH += . .. $(KDEPIMDIR)/qtcompat $(KDEPIMDIR)/kabc kdecore kdeui kio/kfile kio/kio $(QPEDIR)/include
4 4
5DEPENDPATH += $(QPEDIR)/include 5DEPENDPATH += $(QPEDIR)/include
6LIBS += -lmicroqtcompat -L$(QPEDIR)/lib 6LIBS += -lmicroqtcompat -L$(QPEDIR)/lib
7 7
8DEFINES += KDE_QT_ONLY 8DEFINES += KDE_QT_ONLY
9 9
10 TARGET = microkde 10 TARGET = xmicrokde
11OBJECTS_DIR = obj/$(PLATFORM) 11OBJECTS_DIR = obj/$(PLATFORM)
12MOC_DIR = moc/$(PLATFORM) 12MOC_DIR = moc/$(PLATFORM)
13DESTDIR=$(QPEDIR)/lib 13DESTDIR=$(QPEDIR)/lib
14 14
15 15
16INTERFACES = \ 16INTERFACES = \
17 17
18HEADERS = \ 18HEADERS = \
19qlayoutengine_p.h fncolordialog.h\ 19qlayoutengine_p.h fncolordialog.h\
20KDGanttMinimizeSplitter.h \ 20KDGanttMinimizeSplitter.h \
21 kapplication.h \ 21 kapplication.h \
22 kaudioplayer.h \ 22 kaudioplayer.h \
23 kcalendarsystem.h \ 23 kcalendarsystem.h \
24 kcalendarsystemgregorian.h \ 24 kcalendarsystemgregorian.h \
25 kcolorbutton.h \ 25 kcolorbutton.h \
26 kcolordialog.h \ 26 kcolordialog.h \
27 kcombobox.h \ 27 kcombobox.h \
28 kconfig.h \ 28 kconfig.h \
29 kdatetbl.h \ 29 kdatetbl.h \
30 kdebug.h \ 30 kdebug.h \
31 kdialog.h \ 31 kdialog.h \
32 kdialogbase.h \ 32 kdialogbase.h \
33 keditlistbox.h \ 33 keditlistbox.h \
34 kemailsettings.h \ 34 kemailsettings.h \
35 kfiledialog.h \ 35 kfiledialog.h \
36 kfontdialog.h \ 36 kfontdialog.h \
37 kglobal.h \ 37 kglobal.h \
38 kglobalsettings.h \ 38 kglobalsettings.h \
39 kiconloader.h \ 39 kiconloader.h \
40 klineedit.h \ 40 klineedit.h \
41 klineeditdlg.h \ 41 klineeditdlg.h \
42 kmessagebox.h \ 42 kmessagebox.h \
43 knotifyclient.h \ 43 knotifyclient.h \
44 kprinter.h \ 44 kprinter.h \
45 kprocess.h \ 45 kprocess.h \
46 krestrictedline.h \ 46 krestrictedline.h \
47 krun.h \ 47 krun.h \
48 ksimpleconfig.h \ 48 ksimpleconfig.h \
49 kstaticdeleter.h \ 49 kstaticdeleter.h \
50 ksystemtray.h \ 50 ksystemtray.h \
51 ktempfile.h \ 51 ktempfile.h \
52 ktextedit.h \ 52 ktextedit.h \
53 kunload.h \ 53 kunload.h \
54 kurl.h \ 54 kurl.h \
55 ofileselector_p.h \ 55 ofileselector_p.h \
56 ofontselector.h \ 56 ofontselector.h \
57 kdeui/kguiitem.h \ 57 kdeui/kguiitem.h \
58 kdeui/kaction.h \ 58 kdeui/kaction.h \
59 kdeui/kpopupmenu.h \ 59 kdeui/kpopupmenu.h \
60 kdeui/kactionclasses.h \ 60 kdeui/kactionclasses.h \
61 kdeui/kactioncollection.h \ 61 kdeui/kactioncollection.h \
62 kdeui/kcmodule.h \ 62 kdeui/kcmodule.h \
63 kdeui/kstdaction.h \ 63 kdeui/kstdaction.h \
64 kdeui/kbuttonbox.h \ 64 kdeui/kbuttonbox.h \
65 kdeui/klistbox.h \ 65 kdeui/klistbox.h \
66 kdeui/klistview.h \ 66 kdeui/klistview.h \
67 kdeui/kjanuswidget.h \ 67 kdeui/kjanuswidget.h \
68 kdeui/kseparator.h \ 68 kdeui/kseparator.h \
69 kdeui/kmainwindow.h \ 69 kdeui/kmainwindow.h \
70 kdeui/knuminput.h \ 70 kdeui/knuminput.h \
71 kdeui/knumvalidator.h \ 71 kdeui/knumvalidator.h \
72 kdeui/ksqueezedtextlabel.h \ 72 kdeui/ksqueezedtextlabel.h \
73 kdeui/ktoolbar.h \ 73 kdeui/ktoolbar.h \
74 kdeui/ktoolbarbutton.h \ 74 kdeui/ktoolbarbutton.h \
75 kdeui/ktoolbarhandler.h \ 75 kdeui/ktoolbarhandler.h \
76 kdeui/kxmlguiclient.h \ 76 kdeui/kxmlguiclient.h \
77 kio/job.h \ 77 kio/job.h \
78 kio/kio/kdirwatch.h \ 78 kio/kio/kdirwatch.h \
79 kio/kio/kdirwatch_p.h \ 79 kio/kio/kdirwatch_p.h \
80 kio/kfile/kurlrequester.h \ 80 kio/kfile/kurlrequester.h \
81 kresources/resource.h \ 81 kresources/resource.h \
82 kresources/factory.h \ 82 kresources/factory.h \
83 kresources/managerimpl.h \ 83 kresources/managerimpl.h \
84 kresources/manager.h \ 84 kresources/manager.h \
85 kresources/selectdialog.h \ 85 kresources/selectdialog.h \
86 kresources/configpage.h \ 86 kresources/configpage.h \
87 kresources/configwidget.h \ 87 kresources/configwidget.h \
88 kresources/configdialog.h \ 88 kresources/configdialog.h \
89 kresources/kcmkresources.h \ 89 kresources/kcmkresources.h \
90 kdecore/kmdcodec.h \ 90 kdecore/kmdcodec.h \
91 kdecore/kconfigbase.h \ 91 kdecore/kconfigbase.h \
92 kdecore/klocale.h \ 92 kdecore/klocale.h \
93 kdecore/klibloader.h \ 93 kdecore/klibloader.h \
94 kdecore/kcatalogue.h \ 94 kdecore/kcatalogue.h \
95 kdecore/kprefs.h \ 95 kdecore/kprefs.h \
96 kdecore/ksharedptr.h \ 96 kdecore/ksharedptr.h \
97 kdecore/kshell.h \ 97 kdecore/kshell.h \
98 kdecore/kstandarddirs.h \ 98 kdecore/kstandarddirs.h \
99 kdecore/kstringhandler.h \ 99 kdecore/kstringhandler.h \
100 kdecore/kshortcut.h \ 100 kdecore/kshortcut.h \
101 kutils/kcmultidialog.h \ 101 kutils/kcmultidialog.h \
102 kidmanager.h 102 kidmanager.h
103 103
104 104
105 105
106 106
107SOURCES = \ 107SOURCES = \
108KDGanttMinimizeSplitter.cpp fncolordialog.cpp \ 108KDGanttMinimizeSplitter.cpp fncolordialog.cpp \
109 kapplication.cpp \ 109 kapplication.cpp \
110 kcalendarsystem.cpp \ 110 kcalendarsystem.cpp \
111 kcalendarsystemgregorian.cpp \ 111 kcalendarsystemgregorian.cpp \
112 kcolorbutton.cpp \ 112 kcolorbutton.cpp \
113 kcolordialog.cpp \ 113 kcolordialog.cpp \
114 kconfig.cpp \ 114 kconfig.cpp \
115 kdatetbl.cpp \ 115 kdatetbl.cpp \
116 kdialog.cpp \ 116 kdialog.cpp \
117 kdialogbase.cpp \ 117 kdialogbase.cpp \
118 keditlistbox.cpp \ 118 keditlistbox.cpp \
119 kemailsettings.cpp \ 119 kemailsettings.cpp \
120 kfontdialog.cpp \ 120 kfontdialog.cpp \
121 kfiledialog.cpp \ 121 kfiledialog.cpp \
122 kglobal.cpp \ 122 kglobal.cpp \
123 kglobalsettings.cpp \ 123 kglobalsettings.cpp \
124 kiconloader.cpp \ 124 kiconloader.cpp \
125 kmessagebox.cpp \ 125 kmessagebox.cpp \
126 kprocess.cpp \ 126 kprocess.cpp \
127 krun.cpp \ 127 krun.cpp \
128 ksystemtray.cpp \ 128 ksystemtray.cpp \
129 ktempfile.cpp \ 129 ktempfile.cpp \
130 kurl.cpp \ 130 kurl.cpp \
131 ktextedit.cpp \ 131 ktextedit.cpp \
132 ofileselector_p.cpp \ 132 ofileselector_p.cpp \
133 ofontselector.cpp \ 133 ofontselector.cpp \
134 kdecore/kcatalogue.cpp \ 134 kdecore/kcatalogue.cpp \
135 kdecore/klibloader.cpp \ 135 kdecore/klibloader.cpp \
136 kdecore/klocale.cpp \ 136 kdecore/klocale.cpp \
137 kdecore/kmdcodec.cpp \ 137 kdecore/kmdcodec.cpp \
138 kdecore/kprefs.cpp \ 138 kdecore/kprefs.cpp \
139 kdecore/kshell.cpp \ 139 kdecore/kshell.cpp \
140 kdecore/kstandarddirs.cpp \ 140 kdecore/kstandarddirs.cpp \
141 kdecore/kstringhandler.cpp \ 141 kdecore/kstringhandler.cpp \
142 kdeui/kaction.cpp \ 142 kdeui/kaction.cpp \
143 kdeui/kpopupmenu.cpp \ 143 kdeui/kpopupmenu.cpp \
144 kdeui/kactionclasses.cpp \ 144 kdeui/kactionclasses.cpp \
145 kdeui/kactioncollection.cpp \ 145 kdeui/kactioncollection.cpp \
146 kdeui/kbuttonbox.cpp \ 146 kdeui/kbuttonbox.cpp \
147 kdeui/kcmodule.cpp \ 147 kdeui/kcmodule.cpp \
148 kdeui/kguiitem.cpp \ 148 kdeui/kguiitem.cpp \
149 kdeui/kjanuswidget.cpp \ 149 kdeui/kjanuswidget.cpp \
150 kdeui/klistbox.cpp \ 150 kdeui/klistbox.cpp \
151 kdeui/klistview.cpp \ 151 kdeui/klistview.cpp \
152 kdeui/kmainwindow.cpp \ 152 kdeui/kmainwindow.cpp \
153 kdeui/knuminput.cpp \ 153 kdeui/knuminput.cpp \
154 kdeui/knumvalidator.cpp \ 154 kdeui/knumvalidator.cpp \
155 kdeui/kseparator.cpp \ 155 kdeui/kseparator.cpp \
156 kdeui/kstdaction.cpp \ 156 kdeui/kstdaction.cpp \
157 kdeui/ksqueezedtextlabel.cpp \ 157 kdeui/ksqueezedtextlabel.cpp \
158 kdeui/ktoolbar.cpp \ 158 kdeui/ktoolbar.cpp \
159 kdeui/ktoolbarbutton.cpp \ 159 kdeui/ktoolbarbutton.cpp \
160 kdeui/ktoolbarhandler.cpp \ 160 kdeui/ktoolbarhandler.cpp \
161 kdeui/kxmlguiclient.cpp \ 161 kdeui/kxmlguiclient.cpp \
162 kio/kfile/kurlrequester.cpp \ 162 kio/kfile/kurlrequester.cpp \
163 kio/kio/kdirwatch.cpp \ 163 kio/kio/kdirwatch.cpp \
164 kresources/configpage.cpp \ 164 kresources/configpage.cpp \
165 kresources/configdialog.cpp \ 165 kresources/configdialog.cpp \
166 kresources/configwidget.cpp \ 166 kresources/configwidget.cpp \
167 kresources/factory.cpp \ 167 kresources/factory.cpp \
168 kresources/kcmkresources.cpp \ 168 kresources/kcmkresources.cpp \
169 kresources/managerimpl.cpp \ 169 kresources/managerimpl.cpp \
170 kresources/resource.cpp \ 170 kresources/resource.cpp \
171 kresources/selectdialog.cpp \ 171 kresources/selectdialog.cpp \
172 kutils/kcmultidialog.cpp \ 172 kutils/kcmultidialog.cpp \
173 kidmanager.cpp 173 kidmanager.cpp
174 174
diff --git a/microkde/ofileselector_p.cpp b/microkde/ofileselector_p.cpp
index f4f112e..0f95c84 100644
--- a/microkde/ofileselector_p.cpp
+++ b/microkde/ofileselector_p.cpp
@@ -1,652 +1,652 @@
1#include <qcombobox.h> 1#include <qcombobox.h>
2#include <qdir.h> 2#include <qdir.h>
3#include <qhbox.h> 3#include <qhbox.h>
4#include <qheader.h> 4#include <qheader.h>
5#include <qlabel.h> 5#include <qlabel.h>
6#include <qlayout.h> 6#include <qlayout.h>
7#include <qlineedit.h> 7#include <qlineedit.h>
8#include <qlistview.h> 8#include <qlistview.h>
9#include <qpopupmenu.h> 9#include <qpopupmenu.h>
10#include <qwidgetstack.h> 10#include <qwidgetstack.h>
11#include <qregexp.h> 11#include <qregexp.h>
12#include <qobjectlist.h> 12#include <qobjectlist.h>
13 13
14/* hacky but we need to get FileSelector::filter */ 14/* hacky but we need to get FileSelector::filter */
15#define private public 15#define private public
16#include <qpe/fileselector.h> 16#include <qpe/fileselector.h>
17#undef private 17#undef private
18 18
19#include <qpe/qpeapplication.h> 19#include <qpe/qpeapplication.h>
20#include <qpe/mimetype.h> 20#include <qpe/mimetype.h>
21#include <qpe/resource.h> 21#include <qpe/resource.h>
22#include <qpe/storage.h> 22#include <qpe/storage.h>
23#include <kglobal.h> 23#include <kglobal.h>
24#include <klocale.h> 24#include <klocale.h>
25 25
26#include "ofileselector_p.h" 26#include "ofileselector_p.h"
27//US#include "ofileselector.h" 27//US#include "ofileselector.h"
28 28
29#include "klocale.h" 29#include "klocale.h"
30 30
31OFileViewInterface::OFileViewInterface( OFileSelector* selector ) 31OFileViewInterface::OFileViewInterface( OFileSelector* selector )
32 : m_selector( selector ) { 32 : m_selector( selector ) {
33} 33}
34OFileViewInterface::~OFileViewInterface() { 34OFileViewInterface::~OFileViewInterface() {
35} 35}
36QString OFileViewInterface::name()const{ 36QString OFileViewInterface::name()const{
37 return m_name; 37 return m_name;
38} 38}
39void OFileViewInterface::setName( const QString& name ) { 39void OFileViewInterface::setName( const QString& name ) {
40 m_name = name; 40 m_name = name;
41} 41}
42OFileSelector* OFileViewInterface::selector()const { 42OFileSelector* OFileViewInterface::selector()const {
43 return m_selector; 43 return m_selector;
44} 44}
45 45
46DocLnk OFileViewInterface::selectedDocument()const { 46DocLnk OFileViewInterface::selectedDocument()const {
47 return DocLnk( selectedName() ); 47 return DocLnk( selectedName() );
48} 48}
49 49
50bool OFileViewInterface::showNew()const { 50bool OFileViewInterface::showNew()const {
51 return selector()->showNew(); 51 return selector()->showNew();
52} 52}
53bool OFileViewInterface::showClose()const { 53bool OFileViewInterface::showClose()const {
54 return selector()->showClose(); 54 return selector()->showClose();
55} 55}
56MimeTypes OFileViewInterface::mimeTypes()const { 56MimeTypes OFileViewInterface::mimeTypes()const {
57 return selector()->mimeTypes(); 57 return selector()->mimeTypes();
58} 58}
59QStringList OFileViewInterface::currentMimeType()const { 59QStringList OFileViewInterface::currentMimeType()const {
60 return selector()->currentMimeType(); 60 return selector()->currentMimeType();
61} 61}
62void OFileViewInterface::activate( const QString& ) { 62void OFileViewInterface::activate( const QString& ) {
63 // not implemented here 63 // not implemented here
64} 64}
65void OFileViewInterface::ok() { 65void OFileViewInterface::ok() {
66 emit selector()->ok(); 66 emit selector()->ok();
67} 67}
68void OFileViewInterface::cancel() { 68void OFileViewInterface::cancel() {
69 emit selector()->cancel(); 69 emit selector()->cancel();
70} 70}
71void OFileViewInterface::closeMe() { 71void OFileViewInterface::closeMe() {
72 emit selector()->closeMe(); 72 emit selector()->closeMe();
73} 73}
74void OFileViewInterface::fileSelected( const QString& str) { 74void OFileViewInterface::fileSelected( const QString& str) {
75 emit selector()->fileSelected( str); 75 emit selector()->fileSelected( str);
76} 76}
77void OFileViewInterface::fileSelected( const DocLnk& lnk) { 77void OFileViewInterface::fileSelected( const DocLnk& lnk) {
78 emit selector()->fileSelected( lnk ); 78 emit selector()->fileSelected( lnk );
79} 79}
80void OFileViewInterface::setCurrentFileName( const QString& str ) { 80void OFileViewInterface::setCurrentFileName( const QString& str ) {
81 selector()->m_lneEdit->setText( str ); 81 selector()->m_lneEdit->setText( str );
82} 82}
83QString OFileViewInterface::currentFileName()const{ 83QString OFileViewInterface::currentFileName()const{
84 return selector()->m_lneEdit->text(); 84 return selector()->m_lneEdit->text();
85} 85}
86QString OFileViewInterface::startDirectory()const{ 86QString OFileViewInterface::startDirectory()const{
87 return selector()->m_startDir; 87 return selector()->m_startDir;
88} 88}
89 89
90 90
91ODocumentFileView::ODocumentFileView( OFileSelector* selector ) 91ODocumentFileView::ODocumentFileView( OFileSelector* selector )
92 : OFileViewInterface( selector ) { 92 : OFileViewInterface( selector ) {
93 m_selector = 0; 93 m_selector = 0;
94 setName( i18n("Documents") ); 94 setName( i18n("Documents") );
95} 95}
96ODocumentFileView::~ODocumentFileView() { 96ODocumentFileView::~ODocumentFileView() {
97 97
98} 98}
99QString ODocumentFileView::selectedName()const { 99QString ODocumentFileView::selectedName()const {
100 if (!m_selector) 100 if (!m_selector)
101 return QString::null; 101 return QString::null;
102 102
103 return m_selector->selected()->file(); 103 return m_selector->selected()->file();
104} 104}
105QString ODocumentFileView::selectedPath()const { 105QString ODocumentFileView::selectedPath()const {
106 return QPEApplication::documentDir(); 106 return QPEApplication::documentDir();
107} 107}
108QString ODocumentFileView::directory()const { 108QString ODocumentFileView::directory()const {
109 return selectedPath(); 109 return selectedPath();
110} 110}
111void ODocumentFileView::reread() { 111void ODocumentFileView::reread() {
112 if (!m_selector) 112 if (!m_selector)
113 return; 113 return;
114 114
115 m_selector->setNewVisible( showNew() ); 115 m_selector->setNewVisible( showNew() );
116 m_selector->setCloseVisible( showClose() ); 116 m_selector->setCloseVisible( showClose() );
117 m_selector->filter = currentMimeType().join(";"); 117 m_selector->filter = currentMimeType().join(";");
118 m_selector->reread(); 118 m_selector->reread();
119} 119}
120int ODocumentFileView::fileCount()const { 120int ODocumentFileView::fileCount()const {
121 if (!m_selector) 121 if (!m_selector)
122 return -1; 122 return -1;
123 123
124 return m_selector->fileCount(); 124 return m_selector->fileCount();
125} 125}
126 126
127DocLnk ODocumentFileView::selectedDocument()const { 127DocLnk ODocumentFileView::selectedDocument()const {
128 if (!m_selector) 128 if (!m_selector)
129 return DocLnk(); 129 return DocLnk();
130 DocLnk lnk = *m_selector->selected(); 130 DocLnk lnk = *m_selector->selected();
131 return lnk; 131 return lnk;
132} 132}
133 133
134QWidget* ODocumentFileView::widget( QWidget* parent ) { 134QWidget* ODocumentFileView::widget( QWidget* parent ) {
135 if (!m_selector ) { 135 if (!m_selector ) {
136 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() ); 136 m_selector = new FileSelector(currentMimeType().join(";"), parent, "fileselector", showNew(), showClose() );
137 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ), 137 QObject::connect(m_selector, SIGNAL(fileSelected( const DocLnk& ) ),
138 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) ); 138 selector(), SLOT(slotDocLnkBridge(const DocLnk&) ) );
139 QObject::connect(m_selector, SIGNAL(closeMe() ), 139 QObject::connect(m_selector, SIGNAL(closeMe() ),
140 selector(), SIGNAL(closeMe() ) ); 140 selector(), SIGNAL(closeMe() ) );
141 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ), 141 QObject::connect(m_selector, SIGNAL(newSelected(const DocLnk& ) ),
142 selector(), SIGNAL(newSelected(const DocLnk& ) ) ); 142 selector(), SIGNAL(newSelected(const DocLnk& ) ) );
143 } 143 }
144 144
145 return m_selector; 145 return m_selector;
146} 146}
147 147
148/* 148/*
149 * This is the file system view used 149 * This is the file system view used
150 * we use a QListView + QListViewItems for it 150 * we use a QListView + QListViewItems for it
151 */ 151 */
152 152
153OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap, 153OFileSelectorItem::OFileSelectorItem( QListView* view, const QPixmap& pixmap,
154 const QString& path, const QString& date, 154 const QString& path, const QString& date,
155 const QString& size, const QString& dir, 155 const QString& size, const QString& dir,
156 bool isLocked, bool isDir ) 156 bool isLocked, bool isDir )
157 : QListViewItem( view ) 157 : QListViewItem( view )
158{ 158{
159 159
160 QString kind = "dir";; 160 QString kind = "dir";;
161 QString _path = path; 161 QString _path = path;
162 if ( !isDir ){ 162 if ( !isDir ){
163 int arrow = path.findRev( "." ,-1); 163 int arrow = path.findRev( "." ,-1);
164 if (arrow > 0 ) { 164 if (arrow > 0 ) {
165 kind = path.mid(arrow+1); 165 kind = path.mid(arrow+1);
166 } 166 }
167 } 167 }
168 setPixmap(0, pixmap ); 168 setPixmap(0, pixmap );
169 int arrow = path.find( "->" ); 169 int arrow = path.find( "->" );
170 if (arrow > 0 ) { 170 if (arrow > 0 ) {
171 _path = path.left(arrow); 171 _path = path.left(arrow);
172 } 172 }
173 setText(1, _path ); 173 setText(1, _path );
174 setText(2, size ); 174 setText(2, size );
175 setText(3, date ); 175 setText(3, date );
176 setText(4, kind ); 176 setText(4, kind );
177 m_isDir = isDir; 177 m_isDir = isDir;
178 m_dir = dir; 178 m_dir = dir;
179 m_locked = isLocked; 179 m_locked = isLocked;
180} 180}
181OFileSelectorItem::~OFileSelectorItem() { 181OFileSelectorItem::~OFileSelectorItem() {
182 182
183} 183}
184bool OFileSelectorItem::isLocked()const { 184bool OFileSelectorItem::isLocked()const {
185 return m_locked; 185 return m_locked;
186} 186}
187QString OFileSelectorItem::directory()const { 187QString OFileSelectorItem::directory()const {
188 return m_dir; 188 return m_dir;
189} 189}
190bool OFileSelectorItem::isDir()const { 190bool OFileSelectorItem::isDir()const {
191 return m_isDir; 191 return m_isDir;
192} 192}
193QString OFileSelectorItem::path()const { 193QString OFileSelectorItem::path()const {
194 return text( 1 ); 194 return text( 1 );
195} 195}
196QString OFileSelectorItem::key( int id, bool )const { 196QString OFileSelectorItem::key( int id, bool )const {
197 QString ke; 197 QString ke;
198 if( id == 0 || id == 1 ){ // name 198 if( id == 0 || id == 1 ){ // name
199 if( m_isDir ){ 199 if( m_isDir ){
200 ke.append("0" ); 200 ke.append("0" );
201 ke.append( text(1) ); 201 ke.append( text(1) );
202 }else{ 202 }else{
203 ke.append("1" ); 203 ke.append("1" );
204 ke.append( text(1) ); 204 ke.append( text(1) );
205 } 205 }
206 return ke; 206 return ke;
207 } else if ( id == 2 ) { 207 } else if ( id == 2 ) {
208 QString sort = "00000000"; 208 QString sort = "00000000";
209 sort = sort.left( 9-text( 2 ).length()) + text( 2 ); 209 sort = sort.left( 9-text( 2 ).length()) + text( 2 );
210 return sort; 210 return sort;
211 211
212 } else 212 } else
213 return text( id ); 213 return text( id );
214 214
215} 215}
216 216
217OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir, 217OFileViewFileListView::OFileViewFileListView( QWidget* parent, const QString& startDir,
218 OFileSelector* sel) 218 OFileSelector* sel)
219 : QWidget( parent ), m_sel( sel ) { 219 : QWidget( parent ), m_sel( sel ) {
220 m_all = false; 220 m_all = false;
221 QVBoxLayout* lay = new QVBoxLayout( this ); 221 QVBoxLayout* lay = new QVBoxLayout( this );
222 m_currentDir = startDir; 222 m_currentDir = startDir;
223 223
224 /* 224 /*
225 * now we add a special bar 225 * now we add a special bar
226 * One Button For Up 226 * One Button For Up
227 * Home 227 * Home
228 * Doc 228 * Doc
229 * And a dropdown menu with FileSystems 229 * And a dropdown menu with FileSystems
230 * FUTURE: one to change dir with lineedit 230 * FUTURE: one to change dir with lineedit
231 * Bookmarks 231 * Bookmarks
232 * Create Dir 232 * Create Dir
233 */ 233 */
234 QHBox* box = new QHBox(this ); 234 QHBox* box = new QHBox(this );
235 box->setBackgroundMode( PaletteButton ); 235 box->setBackgroundMode( PaletteButton );
236 box->setSpacing( 0 ); 236 box->setSpacing( 0 );
237 237
238 QToolButton *btn = new QToolButton( box ); 238 QToolButton *btn = new QToolButton( box );
239 btn->setIconSet( Resource::loadPixmap("up") ); 239 btn->setIconSet( Resource::loadPixmap("up") );
240 connect(btn, SIGNAL(clicked() ), 240 connect(btn, SIGNAL(clicked() ),
241 this, SLOT( cdUP() ) ); 241 this, SLOT( cdUP() ) );
242 242
243 btn = new QToolButton( box ); 243 btn = new QToolButton( box );
244 btn->setIconSet( Resource::loadPixmap("home") ); 244 btn->setIconSet( Resource::loadPixmap("home") );
245 connect(btn, SIGNAL(clicked() ), 245 connect(btn, SIGNAL(clicked() ),
246 this, SLOT( cdHome() ) ); 246 this, SLOT( cdHome() ) );
247 247
248 btn = new QToolButton( box ); 248 btn = new QToolButton( box );
249 btn->setIconSet( Resource::loadPixmap("DocsIcon") ); 249 btn->setIconSet( Resource::loadPixmap("DocsIcon") );
250 connect(btn, SIGNAL(clicked() ), 250 connect(btn, SIGNAL(clicked() ),
251 this, SLOT(cdDoc() ) ); 251 this, SLOT(cdDoc() ) );
252 252
253 m_btnNew = new QToolButton( box ); 253 m_btnNew = new QToolButton( box );
254 m_btnNew->setIconSet( Resource::loadPixmap("new") ); 254 m_btnNew->setIconSet( Resource::loadPixmap("new") );
255 connect(m_btnNew, SIGNAL(clicked() ), 255 connect(m_btnNew, SIGNAL(clicked() ),
256 this, SLOT(slotNew() ) ); 256 this, SLOT(slotNew() ) );
257 257
258 258
259 m_btnClose = new QToolButton( box ); 259 m_btnClose = new QToolButton( box );
260 m_btnClose->setIconSet( Resource::loadPixmap("close") ); 260 m_btnClose->setIconSet( Resource::loadPixmap("close") );
261 connect(m_btnClose, SIGNAL(clicked() ), 261 connect(m_btnClose, SIGNAL(clicked() ),
262 selector(), SIGNAL(closeMe() ) ); 262 selector(), SIGNAL(closeMe() ) );
263 263
264 btn = new QToolButton( box ); 264 btn = new QToolButton( box );
265 btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") ); 265 btn->setIconSet( Resource::loadPixmap("cardmon/pcmcia") );
266 266
267 /* let's fill device parts */ 267 /* let's fill device parts */
268 QPopupMenu* pop = new QPopupMenu(this); 268 Q3PopupMenu* pop = new Q3PopupMenu(this);
269 connect(pop, SIGNAL( activated(int) ), 269 connect(pop, SIGNAL( activated(int) ),
270 this, SLOT(slotFSActivated(int) ) ); 270 this, SLOT(slotFSActivated(int) ) );
271 271
272 StorageInfo storage; 272 StorageInfo storage;
273 const QList<FileSystem> &fs = storage.fileSystems(); 273 const QList<FileSystem> &fs = storage.fileSystems();
274 QListIterator<FileSystem> it(fs); 274 QListIterator<FileSystem> it(fs);
275 for ( ; it.current(); ++it ) { 275 for ( ; it.current(); ++it ) {
276 const QString disk = (*it)->name(); 276 const QString disk = (*it)->name();
277 const QString path = (*it)->path(); 277 const QString path = (*it)->path();
278 m_dev.insert( disk, path ); 278 m_dev.insert( disk, path );
279 pop->insertItem( disk ); 279 pop->insertItem( disk );
280 } 280 }
281 m_fsPop = pop; 281 m_fsPop = pop;
282 282
283 283
284 btn->setPopup( pop ); 284 btn->setPopup( pop );
285 btn->setPopupDelay ( 0 ); 285 btn->setPopupDelay ( 0 );
286 lay->addWidget( box ); 286 lay->addWidget( box );
287 287
288 m_view = new QListView( this ); 288 m_view = new QListView( this );
289 289
290 m_view->installEventFilter(this); 290 m_view->installEventFilter(this);
291 291
292 QPEApplication::setStylusOperation( m_view->viewport(), 292 QPEApplication::setStylusOperation( m_view->viewport(),
293 QPEApplication::RightOnHold); 293 QPEApplication::RightOnHold);
294 m_view->addColumn(" " ); 294 m_view->addColumn(" " );
295 m_view->addColumn(i18n("Name"), 150 ); 295 m_view->addColumn(i18n("Name"), 150 );
296 m_view->addColumn(i18n("Size"), -1 ); 296 m_view->addColumn(i18n("Size"), -1 );
297 m_view->addColumn(i18n("Date"), -1 ); 297 m_view->addColumn(i18n("Date"), -1 );
298 m_view->addColumn(i18n("Mime Type"), -1 ); 298 m_view->addColumn(i18n("Mime Type"), -1 );
299 299
300 300
301 m_view->setSorting( 1 ); 301 m_view->setSorting( 1 );
302 m_view->setAllColumnsShowFocus( TRUE ); 302 m_view->setAllColumnsShowFocus( TRUE );
303 303
304 lay->addWidget( m_view, 1000 ); 304 lay->addWidget( m_view, 1000 );
305 connectSlots(); 305 connectSlots();
306} 306}
307OFileViewFileListView::~OFileViewFileListView() { 307OFileViewFileListView::~OFileViewFileListView() {
308} 308}
309void OFileViewFileListView::slotNew() { 309void OFileViewFileListView::slotNew() {
310 DocLnk lnk; 310 DocLnk lnk;
311 emit selector()->newSelected( lnk ); 311 emit selector()->newSelected( lnk );
312} 312}
313OFileSelectorItem* OFileViewFileListView::currentItem()const{ 313OFileSelectorItem* OFileViewFileListView::currentItem()const{
314 QListViewItem* item = m_view->currentItem(); 314 QListViewItem* item = m_view->currentItem();
315 if (!item ) 315 if (!item )
316 return 0l; 316 return 0l;
317 317
318 return static_cast<OFileSelectorItem*>(item); 318 return static_cast<OFileSelectorItem*>(item);
319} 319}
320void OFileViewFileListView::reread( bool all ) { 320void OFileViewFileListView::reread( bool all ) {
321 m_view->clear(); 321 m_view->clear();
322 322
323 if (selector()->showClose() ) 323 if (selector()->showClose() )
324 m_btnClose->show(); 324 m_btnClose->show();
325 else 325 else
326 m_btnClose->hide(); 326 m_btnClose->hide();
327 327
328 if (selector()->showNew() ) 328 if (selector()->showNew() )
329 m_btnNew->show(); 329 m_btnNew->show();
330 else 330 else
331 m_btnNew->hide(); 331 m_btnNew->hide();
332 332
333 m_mimes = selector()->currentMimeType(); 333 m_mimes = selector()->currentMimeType();
334 m_all = all; 334 m_all = all;
335 335
336 QDir dir( m_currentDir ); 336 QDir dir( m_currentDir );
337 if (!dir.exists() ) 337 if (!dir.exists() )
338 return; 338 return;
339 topLevelWidget()->setCaption( dir.path() ); 339 topLevelWidget()->setCaption( dir.path() );
340 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed ); 340 dir.setSorting( QDir::Name | QDir::DirsFirst | QDir::Reversed );
341 int filter; 341 int filter;
342 if (m_all ) 342 if (m_all )
343 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All; 343 filter = QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All;
344 else 344 else
345 filter = QDir::Files | QDir::Dirs | QDir::All; 345 filter = QDir::Files | QDir::Dirs | QDir::All;
346 dir.setFilter( filter ); 346 dir.setFilter( filter );
347 347
348 // now go through all files 348 // now go through all files
349 const QFileInfoList *list = dir.entryInfoList(); 349 const QFileInfoList *list = dir.entryInfoList();
350 if (!list) { 350 if (!list) {
351 cdUP(); 351 cdUP();
352 return; 352 return;
353 } 353 }
354 QFileInfoListIterator it( *list ); 354 QFileInfoListIterator it( *list );
355 QFileInfo *fi; 355 QFileInfo *fi;
356 while( (fi=it.current() ) ){ 356 while( (fi=it.current() ) ){
357 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){ 357 if( fi->fileName() == QString::fromLatin1("..") || fi->fileName() == QString::fromLatin1(".") ){
358 ++it; 358 ++it;
359 continue; 359 continue;
360 } 360 }
361 361
362 /* 362 /*
363 * It is a symlink we try to resolve it now but don't let us attack by DOS 363 * It is a symlink we try to resolve it now but don't let us attack by DOS
364 * 364 *
365 */ 365 */
366 if( fi->isSymLink() ){ 366 if( fi->isSymLink() ){
367 //qDebug("SYMLINK "); 367 //qDebug("SYMLINK ");
368 QString file = fi->readLink(); 368 QString file = fi->readLink();
369 for( int i = 0; i<=5; i++) { // 5 tries to prevent dos 369 for( int i = 0; i<=5; i++) { // 5 tries to prevent dos
370 QFileInfo info( file ); 370 QFileInfo info( file );
371 //qDebug("FILE %s ", file.latin1()); 371 //qDebug("FILE %s ", file.latin1());
372 if( !info.exists() ){ 372 if( !info.exists() ){
373 addSymlink( fi, TRUE ); 373 addSymlink( fi, TRUE );
374 break; 374 break;
375 }else if( info.isDir() ){ 375 }else if( info.isDir() ){
376 addDir( fi, TRUE ); 376 addDir( fi, TRUE );
377 break; 377 break;
378 }else if( info.isFile() ){ 378 }else if( info.isFile() ){
379 addFile( fi, TRUE ); 379 addFile( fi, TRUE );
380 break; 380 break;
381 }else if( info.isSymLink() ){ 381 }else if( info.isSymLink() ){
382 file = info.readLink() ; 382 file = info.readLink() ;
383 break; 383 break;
384 }else if( i == 4){ // couldn't resolve symlink add it as symlink 384 }else if( i == 4){ // couldn't resolve symlink add it as symlink
385 addSymlink( fi ); 385 addSymlink( fi );
386 } 386 }
387 } // off for loop for symlink resolving 387 } // off for loop for symlink resolving
388 }else if( fi->isDir() ) 388 }else if( fi->isDir() )
389 addDir( fi ); 389 addDir( fi );
390 else if( fi->isFile() ) 390 else if( fi->isFile() )
391 addFile( fi ); 391 addFile( fi );
392 392
393 ++it; 393 ++it;
394 } // of while loop 394 } // of while loop
395 m_view->sort(); 395 m_view->sort();
396 396
397} 397}
398int OFileViewFileListView::fileCount()const{ 398int OFileViewFileListView::fileCount()const{
399 return m_view->childCount(); 399 return m_view->childCount();
400} 400}
401QString OFileViewFileListView::currentDir()const{ 401QString OFileViewFileListView::currentDir()const{
402 return m_currentDir; 402 return m_currentDir;
403} 403}
404OFileSelector* OFileViewFileListView::selector() { 404OFileSelector* OFileViewFileListView::selector() {
405 return m_sel; 405 return m_sel;
406} 406}
407 407
408bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) { 408bool OFileViewFileListView::eventFilter (QObject *o, QEvent *e) {
409#if 0 409#if 0
410 if ( e->type() == QEvent::KeyPress ) { 410 if ( e->type() == QEvent::KeyPress ) {
411 QKeyEvent *k = (QKeyEvent *)e; 411 QKeyEvent *k = (QKeyEvent *)e;
412 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) { 412 if ( (k->key()==Key_Enter) || (k->key()==Key_Return)) {
413 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0); 413 slotClicked( Qt::LeftButton,m_view->currentItem(),QPoint(0,0),0);
414 return true; 414 return true;
415 } 415 }
416 } 416 }
417#endif 417#endif
418 return false; 418 return false;
419} 419}
420 420
421 421
422void OFileViewFileListView::connectSlots() { 422void OFileViewFileListView::connectSlots() {
423 connect(m_view, SIGNAL(clicked(QListViewItem*) ), 423 connect(m_view, SIGNAL(clicked(QListViewItem*) ),
424 this, SLOT(slotCurrentChanged(QListViewItem*) ) ); 424 this, SLOT(slotCurrentChanged(QListViewItem*) ) );
425 connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ), 425 connect(m_view, SIGNAL(mouseButtonClicked(int, QListViewItem*, const QPoint&, int ) ),
426 this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) ); 426 this, SLOT(slotClicked(int, QListViewItem*, const QPoint&, int ) ) );
427 connect(m_view, SIGNAL(doubleClicked( QListViewItem* )), 427 connect(m_view, SIGNAL(doubleClicked( QListViewItem* )),
428 this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); 428 this, SLOT(slotDoubleClicked(QListViewItem* ) ) );
429 connect(m_view, SIGNAL(returnPressed( QListViewItem* )), 429 connect(m_view, SIGNAL(returnPressed( QListViewItem* )),
430 this, SLOT(slotDoubleClicked(QListViewItem* ) ) ); 430 this, SLOT(slotDoubleClicked(QListViewItem* ) ) );
431} 431}
432void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) { 432void OFileViewFileListView::slotCurrentChanged( QListViewItem* item) {
433 if (!item) 433 if (!item)
434 return; 434 return;
435#if 0 435#if 0
436 436
437 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 437 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
438 438
439 if (!sel->isDir() ) { 439 if (!sel->isDir() ) {
440 selector()->m_lneEdit->setText( sel->text(1) ); 440 selector()->m_lneEdit->setText( sel->text(1) );
441 // if in fileselector mode we will emit selected 441 // if in fileselector mode we will emit selected
442 if ( selector()->mode() == OFileSelector::FileSelector ) { 442 if ( selector()->mode() == OFileSelector::FileSelector ) {
443 qWarning("slot Current Changed"); 443 qWarning("slot Current Changed");
444 QStringList str = QStringList::split("->", sel->text(1) ); 444 QStringList str = QStringList::split("->", sel->text(1) );
445 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 445 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
446 emit selector()->fileSelected( path ); 446 emit selector()->fileSelected( path );
447 DocLnk lnk( path ); 447 DocLnk lnk( path );
448 emit selector()->fileSelected( lnk ); 448 emit selector()->fileSelected( lnk );
449 } 449 }
450 } 450 }
451#endif 451#endif
452} 452}
453void OFileViewFileListView::slotDoubleClicked(QListViewItem* item ) { 453void OFileViewFileListView::slotDoubleClicked(QListViewItem* item ) {
454 if (!item ) return; 454 if (!item ) return;
455 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 455 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
456 if (!sel->isLocked() ) { 456 if (!sel->isLocked() ) {
457 QStringList str = QStringList::split("->", sel->text(1) ); 457 QStringList str = QStringList::split("->", sel->text(1) );
458 if (sel->isDir() ) { 458 if (sel->isDir() ) {
459 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 459 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
460 emit selector()->dirSelected( m_currentDir ); 460 emit selector()->dirSelected( m_currentDir );
461 reread( m_all ); 461 reread( m_all );
462 }else { // file 462 }else { // file
463 //qWarning("slot Clicked"); 463 //qWarning("slot Clicked");
464 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 464 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
465 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 465 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
466 emit selector()->fileSelected( path ); 466 emit selector()->fileSelected( path );
467 DocLnk lnk( path ); 467 DocLnk lnk( path );
468 emit selector()->fileSelected( lnk ); 468 emit selector()->fileSelected( lnk );
469 emit selector()->ok(); 469 emit selector()->ok();
470 } 470 }
471 } // not locked 471 } // not locked
472} 472}
473void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) { 473void OFileViewFileListView::slotClicked(int button , QListViewItem* item, const QPoint&, int ) {
474 if (!item || ( button != Qt::LeftButton) ) 474 if (!item || ( button != Qt::LeftButton) )
475 return; 475 return;
476 476
477 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item); 477 OFileSelectorItem *sel = static_cast<OFileSelectorItem*>(item);
478 if (!sel->isLocked() ) { 478 if (!sel->isLocked() ) {
479 QStringList str = QStringList::split("->", sel->text(1) ); 479 QStringList str = QStringList::split("->", sel->text(1) );
480 if (sel->isDir() ) { 480 if (sel->isDir() ) {
481 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace(); 481 m_currentDir = sel->directory() + "/" + str[0].stripWhiteSpace();
482 emit selector()->dirSelected( m_currentDir ); 482 emit selector()->dirSelected( m_currentDir );
483 reread( m_all ); 483 reread( m_all );
484 }else { // file 484 }else { // file
485 //qWarning("slot Clicked"); 485 //qWarning("slot Clicked");
486 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() ); 486 selector()->m_lneEdit->setText( str[0].stripWhiteSpace() );
487 QString path = sel->directory() + "/" + str[0].stripWhiteSpace(); 487 QString path = sel->directory() + "/" + str[0].stripWhiteSpace();
488 emit selector()->fileSelected( path ); 488 emit selector()->fileSelected( path );
489 DocLnk lnk( path ); 489 DocLnk lnk( path );
490 emit selector()->fileSelected( lnk ); 490 emit selector()->fileSelected( lnk );
491 } 491 }
492 } // not locked 492 } // not locked
493} 493}
494void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) { 494void OFileViewFileListView::addFile( QFileInfo* info, bool symlink ) {
495 MimeType type( info->absFilePath() ); 495 MimeType type( info->absFilePath() );
496 if (!compliesMime( type.id() ) ) 496 if (!compliesMime( type.id() ) )
497 return; 497 return;
498 498
499 QPixmap pix = type.pixmap(); 499 QPixmap pix = type.pixmap();
500 QString dir, name; bool locked; 500 QString dir, name; bool locked;
501 if ( pix.isNull() ) { 501 if ( pix.isNull() ) {
502 QWMatrix matrix; 502 QWMatrix matrix;
503 QPixmap pixer(Resource::loadPixmap("UnknownDocument") ); 503 QPixmap pixer(Resource::loadPixmap("UnknownDocument") );
504 matrix.scale( .4, .4 ); 504 matrix.scale( .4, .4 );
505 pix = pixer.xForm( matrix ); 505 pix = pixer.xForm( matrix );
506 } 506 }
507 dir = info->dirPath( true ); 507 dir = info->dirPath( true );
508 locked = false; 508 locked = false;
509 if ( symlink ) 509 if ( symlink )
510 name = info->fileName() + " -> " + info->readLink(); 510 name = info->fileName() + " -> " + info->readLink();
511 else{ 511 else{
512 name = info->fileName(); 512 name = info->fileName();
513 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) || 513 if ( ( (selector()->mode() == OFileSelector::Open)&& !info->isReadable() ) ||
514 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) { 514 ( (selector()->mode() == OFileSelector::Save)&& !info->isWritable() ) ) {
515 locked = true; pix = Resource::loadPixmap("locked"); 515 locked = true; pix = Resource::loadPixmap("locked");
516 } 516 }
517 } 517 }
518 (void)new OFileSelectorItem( m_view, pix, name, 518 (void)new OFileSelectorItem( m_view, pix, name,
519 KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), 519 KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate),
520 QString::number( info->size() ), 520 QString::number( info->size() ),
521 dir, locked ); 521 dir, locked );
522} 522}
523void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) { 523void OFileViewFileListView::addDir( QFileInfo* info, bool symlink ) {
524 bool locked = false; QString name; QPixmap pix; 524 bool locked = false; QString name; QPixmap pix;
525 525
526 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) || 526 if ( ( ( selector()->mode() == OFileSelector::Open ) && !info->isReadable() ) ||
527 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) { 527 ( ( selector()->mode() == OFileSelector::Save ) && !info->isWritable() ) ) {
528 locked = true; 528 locked = true;
529 if ( symlink ) 529 if ( symlink )
530 pix = Resource::loadPixmap( "symlink" ); 530 pix = Resource::loadPixmap( "symlink" );
531 else 531 else
532 pix = Resource::loadPixmap( "lockedfolder" ); 532 pix = Resource::loadPixmap( "lockedfolder" );
533 }else 533 }else
534 pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder"); 534 pix = symlink ? Resource::loadPixmap( "symlink") : Resource::loadPixmap("folder");
535 535
536 name = symlink ? info->fileName() + " -> " + info->readLink() : 536 name = symlink ? info->fileName() + " -> " + info->readLink() :
537 info->fileName(); 537 info->fileName();
538 538
539 (void)new OFileSelectorItem( m_view, pix, name, 539 (void)new OFileSelectorItem( m_view, pix, name,
540 KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate), 540 KGlobal::locale()->formatDateTime(info->lastModified(),true, true, KLocale::ISODate),
541 QString::number( info->size() ), 541 QString::number( info->size() ),
542 info->dirPath( true ), locked, true ); 542 info->dirPath( true ), locked, true );
543 543
544 544
545} 545}
546void OFileViewFileListView::addSymlink( QFileInfo* , bool ) { 546void OFileViewFileListView::addSymlink( QFileInfo* , bool ) {
547 547
548} 548}
549void OFileViewFileListView::cdUP() { 549void OFileViewFileListView::cdUP() {
550 QDir dir( m_currentDir ); 550 QDir dir( m_currentDir );
551 dir.cdUp(); 551 dir.cdUp();
552 552
553 if (!dir.exists() ) 553 if (!dir.exists() )
554 m_currentDir = "/"; 554 m_currentDir = "/";
555 else 555 else
556 m_currentDir = dir.absPath(); 556 m_currentDir = dir.absPath();
557 557
558 emit selector()->dirSelected( m_currentDir ); 558 emit selector()->dirSelected( m_currentDir );
559 reread( m_all ); 559 reread( m_all );
560} 560}
561void OFileViewFileListView::cdHome() { 561void OFileViewFileListView::cdHome() {
562 m_currentDir = QDir::homeDirPath(); 562 m_currentDir = QDir::homeDirPath();
563 emit selector()->dirSelected( m_currentDir ); 563 emit selector()->dirSelected( m_currentDir );
564 reread( m_all ); 564 reread( m_all );
565} 565}
566void OFileViewFileListView::cdDoc() { 566void OFileViewFileListView::cdDoc() {
567 m_currentDir = QPEApplication::documentDir(); 567 m_currentDir = QPEApplication::documentDir();
568 emit selector()->dirSelected( m_currentDir ); 568 emit selector()->dirSelected( m_currentDir );
569 reread( m_all ); 569 reread( m_all );
570} 570}
571void OFileViewFileListView::changeDir( const QString& dir ) { 571void OFileViewFileListView::changeDir( const QString& dir ) {
572 m_currentDir = dir; 572 m_currentDir = dir;
573 emit selector()->dirSelected( m_currentDir ); 573 emit selector()->dirSelected( m_currentDir );
574 reread( m_all ); 574 reread( m_all );
575} 575}
576void OFileViewFileListView::slotFSActivated( int id ) { 576void OFileViewFileListView::slotFSActivated( int id ) {
577 changeDir ( m_dev[m_fsPop->text(id)] ); 577 changeDir ( m_dev[m_fsPop->text(id)] );
578} 578}
579 579
580/* check if the mimetype in mime 580/* check if the mimetype in mime
581 * complies with the one which is current 581 * complies with the one which is current
582 */ 582 */
583/* 583/*
584 * We've the mimetype of the file 584 * We've the mimetype of the file
585 * We need to get the stringlist of the current mimetype 585 * We need to get the stringlist of the current mimetype
586 * 586 *
587 * mime = image@slashjpeg 587 * mime = image@slashjpeg
588 * QStringList = 'image@slash*' 588 * QStringList = 'image@slash*'
589 * or QStringList = image/jpeg;image/png;application/x-ogg 589 * or QStringList = image/jpeg;image/png;application/x-ogg
590 * or QStringList = application/x-ogg;image@slash*; 590 * or QStringList = application/x-ogg;image@slash*;
591 * with all these mime filters it should get acceptes 591 * with all these mime filters it should get acceptes
592 * to do so we need to look if mime is contained inside 592 * to do so we need to look if mime is contained inside
593 * the stringlist 593 * the stringlist
594 * if it's contained return true 594 * if it's contained return true
595 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*' 595 * if not ( I'm no RegExp expert at all ) we'll look if a '@slash*'
596 * is contained in the mimefilter and then we will 596 * is contained in the mimefilter and then we will
597 * look if both are equal until the '/' 597 * look if both are equal until the '/'
598 */ 598 */
599bool OFileViewFileListView::compliesMime( const QString& str) { 599bool OFileViewFileListView::compliesMime( const QString& str) {
600 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() ) 600 if (str.isEmpty() || m_mimes.isEmpty() || str.stripWhiteSpace().isEmpty() )
601 return true; 601 return true;
602 602
603 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) { 603 for (QStringList::Iterator it = m_mimes.begin(); it != m_mimes.end(); ++it ) {
604 QRegExp reg( (*it) ); 604 QRegExp reg( (*it) );
605 reg.setWildcard( true ); 605 reg.setWildcard( true );
606 if ( str.find( reg ) != -1 ) 606 if ( str.find( reg ) != -1 )
607 return true; 607 return true;
608 608
609 } 609 }
610 return false; 610 return false;
611} 611}
612/* 612/*
613 * The listView giving access to the file system! 613 * The listView giving access to the file system!
614 */ 614 */
615class OFileViewFileSystem : public OFileViewInterface { 615class OFileViewFileSystem : public OFileViewInterface {
616public: 616public:
617 OFileViewFileSystem( OFileSelector* ); 617 OFileViewFileSystem( OFileSelector* );
618 ~OFileViewFileSystem(); 618 ~OFileViewFileSystem();
619 619
620 QString selectedName() const; 620 QString selectedName() const;
621 QString selectedPath() const; 621 QString selectedPath() const;
622 622
623 QString directory()const; 623 QString directory()const;
624 void reread(); 624 void reread();
625 int fileCount()const; 625 int fileCount()const;
626 626
627 QWidget* widget( QWidget* parent ); 627 QWidget* widget( QWidget* parent );
628 void activate( const QString& ); 628 void activate( const QString& );
629private: 629private:
630 OFileViewFileListView* m_view; 630 OFileViewFileListView* m_view;
631 bool m_all : 1; 631 bool m_all : 1;
632}; 632};
633OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel) 633OFileViewFileSystem::OFileViewFileSystem( OFileSelector* sel)
634 : OFileViewInterface( sel ) { 634 : OFileViewInterface( sel ) {
635 m_view = 0; 635 m_view = 0;
636 m_all = false; 636 m_all = false;
637} 637}
638OFileViewFileSystem::~OFileViewFileSystem() { 638OFileViewFileSystem::~OFileViewFileSystem() {
639} 639}
640QString OFileViewFileSystem::selectedName()const{ 640QString OFileViewFileSystem::selectedName()const{
641 if (!m_view ) 641 if (!m_view )
642 return QString::null; 642 return QString::null;
643 643
644 QString cFN=currentFileName(); 644 QString cFN=currentFileName();
645 if (cFN.startsWith("/")) return cFN; 645 if (cFN.startsWith("/")) return cFN;
646 return m_view->currentDir() + "/" + cFN; 646 return m_view->currentDir() + "/" + cFN;
647} 647}
648QString OFileViewFileSystem::selectedPath()const{ 648QString OFileViewFileSystem::selectedPath()const{
649 return QString::null; 649 return QString::null;
650} 650}
651QString OFileViewFileSystem::directory()const{ 651QString OFileViewFileSystem::directory()const{
652 if (!m_view) 652 if (!m_view)
diff --git a/microkde/ofileselector_p.h b/microkde/ofileselector_p.h
index 834fd70..a7d97fe 100644
--- a/microkde/ofileselector_p.h
+++ b/microkde/ofileselector_p.h
@@ -1,259 +1,259 @@
1#ifndef OPIE_OFILE_SELECTOR_PRIVATE_H 1#ifndef OPIE_OFILE_SELECTOR_PRIVATE_H
2#define OPIE_OFILE_SELECTOR_PRIVATE_H 2#define OPIE_OFILE_SELECTOR_PRIVATE_H
3 3
4//US 4//US
5#pragma message("microkde/ofileselector_p.h") 5#pragma message("microkde/ofileselector_p.h")
6 6
7#include <qmap.h> 7#include <qmap.h>
8#include <qstringlist.h> 8#include <qstringlist.h>
9#include <qwidget.h> 9#include <qwidget.h>
10#include <qlistview.h> 10#include <qlistview.h>
11 11
12#include <qpe/applnk.h> 12#include <qpe/applnk.h>
13#include <qpe/fileselector.h> 13#include <qpe/fileselector.h>
14 14
15 15
16/* 16/*
17 * How to avoid having really two different objects 17 * How to avoid having really two different objects
18 * for Extended and ExtendedAll 18 * for Extended and ExtendedAll
19 * The only difference is the Lister... 19 * The only difference is the Lister...
20 * a) static object? 20 * a) static object?
21 * b) leave some object inside the OFileSelector which can be used? 21 * b) leave some object inside the OFileSelector which can be used?
22 * c) when switching views tell which view we want o have.. internally we can switch then 22 * c) when switching views tell which view we want o have.. internally we can switch then
23 * 23 *
24 * I'll take c) -zecke 24 * I'll take c) -zecke
25 */ 25 */
26 26
27 27
28/* the View Interface */ 28/* the View Interface */
29class OFileSelector; 29class OFileSelector;
30typedef QMap<QString, QStringList> MimeTypes; 30typedef QMap<QString, QStringList> MimeTypes;
31class QFileInfo; 31class QFileInfo;
32class QToolButton; 32class QToolButton;
33class OFileViewInterface { 33class OFileViewInterface {
34public: 34public:
35 OFileViewInterface( OFileSelector* selector ); 35 OFileViewInterface( OFileSelector* selector );
36 virtual ~OFileViewInterface(); 36 virtual ~OFileViewInterface();
37 virtual QString selectedName()const = 0; 37 virtual QString selectedName()const = 0;
38 virtual QString selectedPath()const = 0; 38 virtual QString selectedPath()const = 0;
39 virtual QString directory()const = 0; 39 virtual QString directory()const = 0;
40 virtual void reread() = 0; 40 virtual void reread() = 0;
41 virtual int fileCount()const = 0; 41 virtual int fileCount()const = 0;
42 virtual DocLnk selectedDocument()const; 42 virtual DocLnk selectedDocument()const;
43 virtual QWidget* widget( QWidget* parent) = 0; 43 virtual QWidget* widget( QWidget* parent) = 0;
44 virtual void activate( const QString& ); 44 virtual void activate( const QString& );
45 QString name()const; 45 QString name()const;
46protected: 46protected:
47 OFileSelector* selector()const; 47 OFileSelector* selector()const;
48 void setName( const QString& ); 48 void setName( const QString& );
49 bool showNew()const; 49 bool showNew()const;
50 bool showClose()const; 50 bool showClose()const;
51 MimeTypes mimeTypes()const; 51 MimeTypes mimeTypes()const;
52 QStringList currentMimeType()const; 52 QStringList currentMimeType()const;
53 QString startDirectory()const; 53 QString startDirectory()const;
54protected: 54protected:
55 void ok(); 55 void ok();
56 void cancel(); 56 void cancel();
57 void closeMe(); 57 void closeMe();
58 void fileSelected( const QString& ); 58 void fileSelected( const QString& );
59 void fileSelected( const DocLnk& ); 59 void fileSelected( const DocLnk& );
60 void setCurrentFileName( const QString& ); 60 void setCurrentFileName( const QString& );
61 QString currentFileName()const; 61 QString currentFileName()const;
62 62
63private: 63private:
64 QString m_name; 64 QString m_name;
65 OFileSelector* m_selector; 65 OFileSelector* m_selector;
66}; 66};
67 67
68 68
69/* THE Document View hosting a FileSelector*/ 69/* THE Document View hosting a FileSelector*/
70class ODocumentFileView : public OFileViewInterface { 70class ODocumentFileView : public OFileViewInterface {
71public: 71public:
72 ODocumentFileView( OFileSelector* selector ); 72 ODocumentFileView( OFileSelector* selector );
73 ~ODocumentFileView(); 73 ~ODocumentFileView();
74 74
75 QString selectedName() const; 75 QString selectedName() const;
76 QString selectedPath() const; 76 QString selectedPath() const;
77 77
78 QString directory() const; 78 QString directory() const;
79 void reread(); 79 void reread();
80 int fileCount()const; 80 int fileCount()const;
81 DocLnk selectedDocument()const; 81 DocLnk selectedDocument()const;
82 82
83 QWidget* widget( QWidget* parent ); 83 QWidget* widget( QWidget* parent );
84 84
85private: 85private:
86 mutable FileSelector* m_selector; 86 mutable FileSelector* m_selector;
87 87
88}; 88};
89 89
90class OFileSelectorItem : public QListViewItem { 90class OFileSelectorItem : public QListViewItem {
91public: 91public:
92 OFileSelectorItem( QListView* view, const QPixmap& pixmap, 92 OFileSelectorItem( QListView* view, const QPixmap& pixmap,
93 const QString& path, const QString& date, 93 const QString& path, const QString& date,
94 const QString& size, const QString& mDir, 94 const QString& size, const QString& mDir,
95 bool isLocked = false, bool isDir = false ); 95 bool isLocked = false, bool isDir = false );
96 ~OFileSelectorItem(); 96 ~OFileSelectorItem();
97 bool isLocked()const; 97 bool isLocked()const;
98 bool isDir()const; 98 bool isDir()const;
99 QString directory()const; 99 QString directory()const;
100 QString path()const; 100 QString path()const;
101 QString key(int id, bool )const; 101 QString key(int id, bool )const;
102 102
103private: 103private:
104 bool m_locked : 1; 104 bool m_locked : 1;
105 bool m_isDir : 1; 105 bool m_isDir : 1;
106 QString m_dir; 106 QString m_dir;
107}; 107};
108 108
109class OFileViewFileListView : public QWidget { 109class OFileViewFileListView : public QWidget {
110 Q_OBJECT 110 Q_OBJECT
111public: 111public:
112 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector ); 112 OFileViewFileListView( QWidget* parent, const QString& dir, OFileSelector* selector );
113 ~OFileViewFileListView(); 113 ~OFileViewFileListView();
114 114
115 OFileSelectorItem* currentItem()const; 115 OFileSelectorItem* currentItem()const;
116 void reread( bool all = false ); 116 void reread( bool all = false );
117 int fileCount()const; 117 int fileCount()const;
118 QString currentDir()const; 118 QString currentDir()const;
119protected: 119protected:
120 bool eventFilter (QObject *o, QEvent *e); 120 bool eventFilter (QObject *o, QEvent *e);
121private slots: 121private slots:
122 void slotNew(); // will emit newSelected 122 void slotNew(); // will emit newSelected
123 void cdUP(); 123 void cdUP();
124 void cdHome(); 124 void cdHome();
125 void cdDoc(); 125 void cdDoc();
126 void changeDir( const QString& ); 126 void changeDir( const QString& );
127 void slotCurrentChanged( QListViewItem* ); 127 void slotCurrentChanged( QListViewItem* );
128 void slotClicked(int, QListViewItem*, const QPoint&, int ); 128 void slotClicked(int, QListViewItem*, const QPoint&, int );
129 void slotDoubleClicked(QListViewItem*); 129 void slotDoubleClicked(QListViewItem*);
130 void slotFSActivated(int); 130 void slotFSActivated(int);
131 131
132protected: 132protected:
133 133
134 OFileSelector* selector(); 134 OFileSelector* selector();
135 135
136private: 136private:
137 QMap<QString, QString> m_dev; 137 QMap<QString, QString> m_dev;
138 bool m_all : 1; 138 bool m_all : 1;
139 OFileSelector* m_sel; 139 OFileSelector* m_sel;
140 QPopupMenu* m_fsPop; 140 Q3PopupMenu* m_fsPop;
141 bool compliesMime( const QString& ); 141 bool compliesMime( const QString& );
142 QStringList m_mimes; // used in compy mime 142 QStringList m_mimes; // used in compy mime
143 QString m_currentDir; 143 QString m_currentDir;
144 QToolButton *m_btnNew, *m_btnClose; 144 QToolButton *m_btnNew, *m_btnClose;
145 void connectSlots(); 145 void connectSlots();
146 void addFile( QFileInfo* info, bool symlink = FALSE ); 146 void addFile( QFileInfo* info, bool symlink = FALSE );
147 void addDir ( QFileInfo* info, bool symlink = FALSE ); 147 void addDir ( QFileInfo* info, bool symlink = FALSE );
148 void addSymlink( QFileInfo* info, bool = FALSE ); 148 void addSymlink( QFileInfo* info, bool = FALSE );
149 149
150 150
151private: 151private:
152 QListView* m_view; 152 QListView* m_view;
153}; 153};
154 154
155typedef QMap<QString, QStringList> MimeTypes; 155typedef QMap<QString, QStringList> MimeTypes;
156 156
157class OFileViewInterface; 157class OFileViewInterface;
158class OFileViewFileListView; 158class OFileViewFileListView;
159class QLineEdit; 159class QLineEdit;
160class QComboBox; 160class QComboBox;
161class QWidgetStack; 161class QWidgetStack;
162class QHBox; 162class QHBox;
163class OFileSelector : public QWidget { 163class OFileSelector : public QWidget {
164 Q_OBJECT 164 Q_OBJECT
165 friend class OFileViewInterface; 165 friend class OFileViewInterface;
166 friend class OFileViewFileListView; 166 friend class OFileViewFileListView;
167public: 167public:
168 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 }; 168 enum Mode { Open=1, Save=2, FileSelector=4, OPEN=1, SAVE=2, FILESELECTOR=4 };
169// enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 }; 169// enum OldMode { OPEN=1, SAVE=2, FILESELECTOR = 4 };
170 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 }; 170 enum Selector { Normal = 0, Extended=1, ExtendedAll =2, Default=3, NORMAL=0,EXTENDED=1, EXTENDED_ALL =2, DEFAULT=3 };
171// enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2}; 171// enum OldSelector { NORMAL = 0, EXTENDED =1, EXTENDED_ALL = 2};
172 172
173 OFileSelector(QWidget* parent, int mode, int selector, 173 OFileSelector(QWidget* parent, int mode, int selector,
174 const QString& dirName, 174 const QString& dirName,
175 const QString& fileName, 175 const QString& fileName,
176 const MimeTypes& mimetypes = MimeTypes(), 176 const MimeTypes& mimetypes = MimeTypes(),
177 bool newVisible = FALSE, bool closeVisible = FALSE ); 177 bool newVisible = FALSE, bool closeVisible = FALSE );
178 178
179 OFileSelector(const QString& mimeFilter, QWidget* parent, 179 OFileSelector(const QString& mimeFilter, QWidget* parent,
180 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE ); 180 const char* name = 0, bool newVisible = TRUE, bool closeVisible = FALSE );
181 ~OFileSelector(); 181 ~OFileSelector();
182 182
183 const DocLnk* selected(); 183 const DocLnk* selected();
184 184
185 QString selectedName()const; 185 QString selectedName()const;
186 QString selectedPath()const; 186 QString selectedPath()const;
187 QString directory()const; 187 QString directory()const;
188 188
189 DocLnk selectedDocument()const; 189 DocLnk selectedDocument()const;
190 190
191 int fileCount()const; 191 int fileCount()const;
192 void reread(); 192 void reread();
193 193
194 int mode()const; 194 int mode()const;
195 int selector()const; 195 int selector()const;
196 196
197 197
198 void setNewVisible( bool b ); 198 void setNewVisible( bool b );
199 void setCloseVisible( bool b ); 199 void setCloseVisible( bool b );
200 void setNameVisible( bool b ); 200 void setNameVisible( bool b );
201 201
202signals: 202signals:
203 void dirSelected( const QString& ); 203 void dirSelected( const QString& );
204 void fileSelected( const DocLnk& ); 204 void fileSelected( const DocLnk& );
205 void fileSelected( const QString& ); 205 void fileSelected( const QString& );
206 void newSelected( const DocLnk& ); 206 void newSelected( const DocLnk& );
207 void closeMe(); 207 void closeMe();
208 void ok(); 208 void ok();
209 void cancel(); 209 void cancel();
210 210
211/* used by the ViewInterface */ 211/* used by the ViewInterface */
212private: 212private:
213 bool showNew()const; 213 bool showNew()const;
214 bool showClose()const; 214 bool showClose()const;
215 MimeTypes mimeTypes()const; 215 MimeTypes mimeTypes()const;
216 QStringList currentMimeType()const; 216 QStringList currentMimeType()const;
217 217
218private: 218private:
219 /* inits the Widgets */ 219 /* inits the Widgets */
220 void initUI(); 220 void initUI();
221 /* inits the MimeType ComboBox content + connects signals and slots */ 221 /* inits the MimeType ComboBox content + connects signals and slots */
222 void initMime(); 222 void initMime();
223 /* init the Views :) */ 223 /* init the Views :) */
224 void initViews(); 224 void initViews();
225 225
226private: 226private:
227 QLineEdit* m_lneEdit; // the LineEdit for the Name 227 QLineEdit* m_lneEdit; // the LineEdit for the Name
228 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType 228 QComboBox *m_cmbView, *m_cmbMime; // two ComboBoxes to select the View and MimeType
229 QWidgetStack* m_stack; // our widget stack which will contain the views 229 QWidgetStack* m_stack; // our widget stack which will contain the views
230 OFileViewInterface* currentView()const; // returns the currentView 230 OFileViewInterface* currentView()const; // returns the currentView
231 OFileViewInterface* m_current; // here is the view saved 231 OFileViewInterface* m_current; // here is the view saved
232 bool m_shNew : 1; // should we show New? 232 bool m_shNew : 1; // should we show New?
233 bool m_shClose : 1; // should we show Close? 233 bool m_shClose : 1; // should we show Close?
234 MimeTypes m_mimeType; // list of mimetypes 234 MimeTypes m_mimeType; // list of mimetypes
235 235
236 QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr 236 QMap<QString, OFileViewInterface*> m_views; // QString translated view name + ViewInterface Ptr
237 QHBox* m_nameBox; // the LineEdit + Label is hold here 237 QHBox* m_nameBox; // the LineEdit + Label is hold here
238 QHBox* m_cmbBox; // this holds the two combo boxes 238 QHBox* m_cmbBox; // this holds the two combo boxes
239 239
240 QString m_startDir; 240 QString m_startDir;
241 int m_mode; 241 int m_mode;
242 int m_selector; 242 int m_selector;
243 243
244 struct Data; // used for future versions 244 struct Data; // used for future versions
245 Data *d; 245 Data *d;
246 246
247private slots: 247private slots:
248 void slotMimeTypeChanged(); 248 void slotMimeTypeChanged();
249 249
250 /* will set the text of the lineedit and emit a fileChanged signal */ 250 /* will set the text of the lineedit and emit a fileChanged signal */
251 void slotDocLnkBridge( const DocLnk& ); 251 void slotDocLnkBridge( const DocLnk& );
252 void slotFileBridge( const QString& ); 252 void slotFileBridge( const QString& );
253 void slotViewChange( const QString& ); 253 void slotViewChange( const QString& );
254 254
255 bool eventFilter (QObject *o, QEvent *e); 255 bool eventFilter (QObject *o, QEvent *e);
256 256
257}; 257};
258 258
259#endif 259#endif
diff --git a/microkde/qlayoutengine_p.h b/microkde/qlayoutengine_p.h
index 2d6a556..e782703 100644
--- a/microkde/qlayoutengine_p.h
+++ b/microkde/qlayoutengine_p.h
@@ -1,111 +1,109 @@
1//Added by qt3to4:
2#include <Q3MemArray>
1// THIS IS A COPY OF THE FILE FOUND IN $QTDIR/src/kernel. Needed to modify qsplitter 3// THIS IS A COPY OF THE FILE FOUND IN $QTDIR/src/kernel. Needed to modify qsplitter
2 4
3/**************************************************************************** 5/****************************************************************************
4** $Id$ 6** $Id$
5** 7**
6** Internal header file. 8** Internal header file.
7** 9**
8** Created : 981027 10** Created : 981027
9** 11**
10** Copyright (C) 1998-99 by Trolltech AS. All rights reserved. 12** Copyright (C) 1998-99 by Trolltech AS. All rights reserved.
11** 13**
12** This file is part of the kernel module of the Qt GUI Toolkit. 14** This file is part of the kernel module of the Qt GUI Toolkit.
13** 15**
14** This file may be distributed under the terms of the Q Public License 16** This file may be distributed under the terms of the Q Public License
15** as defined by Trolltech AS of Norway and appearing in the file 17** as defined by Trolltech AS of Norway and appearing in the file
16** LICENSE.QPL included in the packaging of this file. 18** LICENSE.QPL included in the packaging of this file.
17** 19**
18** This file may be distributed and/or modified under the terms of the 20** This file may be distributed and/or modified under the terms of the
19** GNU General Public License version 2 as published by the Free Software 21** GNU General Public License version 2 as published by the Free Software
20** Foundation and appearing in the file LICENSE.GPL included in the 22** Foundation and appearing in the file LICENSE.GPL included in the
21** packaging of this file. 23** packaging of this file.
22** 24**
23** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 25** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
24** licenses may use this file in accordance with the Qt Commercial License 26** licenses may use this file in accordance with the Qt Commercial License
25** Agreement provided with the Software. 27** Agreement provided with the Software.
26** 28**
27** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 29** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 30** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29** 31**
30** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 32** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
31** information about Qt Commercial License Agreements. 33** information about Qt Commercial License Agreements.
32** See http://www.trolltech.com/qpl/ for QPL licensing information. 34** See http://www.trolltech.com/qpl/ for QPL licensing information.
33** See http://www.trolltech.com/gpl/ for GPL licensing information. 35** See http://www.trolltech.com/gpl/ for GPL licensing information.
34** 36**
35** Contact info@trolltech.com if any conditions of this licensing are 37** Contact info@trolltech.com if any conditions of this licensing are
36** not clear to you. 38** not clear to you.
37** 39**
38**********************************************************************/ 40**********************************************************************/
39 41
40#ifndef QLAYOUTENGINE_P_H 42#ifndef QLAYOUTENGINE_P_H
41#define QLAYOUTENGINE_P_H 43#define QLAYOUTENGINE_P_H
42 44
43 45
44// 46//
45// W A R N I N G 47// W A R N I N G
46// ------------- 48// -------------
47// 49//
48// This file is not part of the Qt API. It exists for the convenience 50// This file is not part of the Qt API. It exists for the convenience
49// of qlayout.cpp, qlayoutengine.cpp, qmainwindow.cpp and qsplitter.cpp. 51// of qlayout.cpp, qlayoutengine.cpp, qmainwindow.cpp and qsplitter.cpp.
50// This header file may change from version to version without notice, 52// This header file may change from version to version without notice,
51// or even be removed. 53// or even be removed.
52// 54//
53// We mean it. 55// We mean it.
54// 56//
55// 57//
56 58
57 59
58#ifndef QT_H
59#include "qabstractlayout.h"
60#endif // QT_H
61
62#ifndef QT_NO_LAYOUT 60#ifndef QT_NO_LAYOUT
63struct QLayoutStruct 61struct QLayoutStruct
64{ 62{
65 void initParameters() { minimumSize = sizeHint = 0; 63 void initParameters() { minimumSize = sizeHint = 0;
66 maximumSize = QWIDGETSIZE_MAX; expansive = FALSE; empty = TRUE; } 64 maximumSize = QWIDGETSIZE_MAX; expansive = FALSE; empty = TRUE; }
67 void init() { stretch = 0; initParameters(); } 65 void init() { stretch = 0; initParameters(); }
68 //permanent storage: 66 //permanent storage:
69 int stretch; 67 int stretch;
70 //parameters: 68 //parameters:
71 QCOORD sizeHint; 69 QCOORD sizeHint;
72 QCOORD maximumSize; 70 QCOORD maximumSize;
73 QCOORD minimumSize; 71 QCOORD minimumSize;
74 bool expansive; 72 bool expansive;
75 bool empty; 73 bool empty;
76 //temporary storage: 74 //temporary storage:
77 bool done; 75 bool done;
78 //result: 76 //result:
79 int pos; 77 int pos;
80 int size; 78 int size;
81}; 79};
82 80
83 81
84void qGeomCalc( QMemArray<QLayoutStruct> &chain, int start, int count, int pos, 82void qGeomCalc( Q3MemArray<QLayoutStruct> &chain, int start, int count, int pos,
85 int space, int spacer ); 83 int space, int spacer );
86 84
87 85
88 86
89/* 87/*
90 Modify total maximum (max) and total expansion (exp) 88 Modify total maximum (max) and total expansion (exp)
91 when adding boxmax/boxexp. 89 when adding boxmax/boxexp.
92 90
93 Expansive boxes win over non-expansive boxes. 91 Expansive boxes win over non-expansive boxes.
94*/ 92*/
95static inline void qMaxExpCalc( QCOORD & max, bool &exp, 93static inline void qMaxExpCalc( QCOORD & max, bool &exp,
96 QCOORD boxmax, bool boxexp ) 94 QCOORD boxmax, bool boxexp )
97{ 95{
98 if ( exp ) { 96 if ( exp ) {
99 if ( boxexp ) 97 if ( boxexp )
100 max = QMAX( max, boxmax ); 98 max = QMAX( max, boxmax );
101 } else { 99 } else {
102 if ( boxexp ) 100 if ( boxexp )
103 max = boxmax; 101 max = boxmax;
104 else 102 else
105 max = QMIN( max, boxmax ); 103 max = QMIN( max, boxmax );
106 } 104 }
107 exp = exp || boxexp; 105 exp = exp || boxexp;
108} 106}
109 107
110#endif //QT_NO_LAYOUT 108#endif //QT_NO_LAYOUT
111#endif 109#endif