summaryrefslogtreecommitdiffabout
path: root/microkde
authorzautrix <zautrix>2005-02-07 20:05:18 (UTC)
committer zautrix <zautrix>2005-02-07 20:05:18 (UTC)
commitda5e47069d88fa9aa656423ce4c60bf505728e1c (patch) (unidiff)
treefdbaf29835a028f1204a19fc10dea97d469c0b29 /microkde
parent456b0246521847635fe98471691ceecae211e0c3 (diff)
downloadkdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.zip
kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.gz
kdepimpi-da5e47069d88fa9aa656423ce4c60bf505728e1c.tar.bz2
fixes
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kapplication.cpp3
-rw-r--r--microkde/kdecore/klibloader.cpp14
-rw-r--r--microkde/kdeui/ktoolbar.cpp2
-rw-r--r--microkde/kdeui/ktoolbar.h2
4 files changed, 7 insertions, 14 deletions
diff --git a/microkde/kapplication.cpp b/microkde/kapplication.cpp
index 21aa0a4..f05b91b 100644
--- a/microkde/kapplication.cpp
+++ b/microkde/kapplication.cpp
@@ -1,110 +1,111 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <stdio.h> 2#include <stdio.h>
3 3
4#include "kapplication.h" 4#include "kapplication.h"
5#include "ktextedit.h" 5#include "ktextedit.h"
6#include <qapplication.h> 6#include <qapplication.h>
7#include <qstring.h> 7#include <qstring.h>
8#include <qfile.h> 8#include <qfile.h>
9#include <qtextstream.h> 9#include <qtextstream.h>
10#include <qdialog.h> 10#include <qdialog.h>
11#include <qlayout.h> 11#include <qlayout.h>
12#include <qtextbrowser.h> 12#include <qtextbrowser.h>
13 13
14int KApplication::random() 14int KApplication::random()
15{ 15{
16 return rand(); 16 return rand();
17} 17}
18 18
19//US 19//US
20QString KApplication::randomString(int length) 20QString KApplication::randomString(int length)
21{ 21{
22 if (length <=0 ) return QString::null; 22 if (length <=0 ) return QString::null;
23 23
24 QString str; 24 QString str;
25 while (length--) 25 while (length--)
26 { 26 {
27 int r=random() % 62; 27 int r=random() % 62;
28 r+=48; 28 r+=48;
29 if (r>57) r+=7; 29 if (r>57) r+=7;
30 if (r>90) r+=6; 30 if (r>90) r+=6;
31 str += char(r); 31 str += char(r);
32 // so what if I work backwards? 32 // so what if I work backwards?
33 } 33 }
34 return str; 34 return str;
35} 35}
36int KApplication::execDialog( QDialog* d ) 36int KApplication::execDialog( QDialog* d )
37{ 37{
38 if (QApplication::desktop()->width() <= 640 ) 38 if (QApplication::desktop()->width() <= 640 )
39 d->showMaximized(); 39 d->showMaximized();
40 else 40 else
41 ;//d->resize( 800, 600 ); 41 ;//d->resize( 800, 600 );
42 return d->exec(); 42 return d->exec();
43} 43}
44void KApplication::showLicence() 44void KApplication::showLicence()
45{ 45{
46 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" ); 46 KApplication::showFile( "KDE-Pim/Pi licence", "kdepim/licence.txt" );
47} 47}
48 48
49void KApplication::showFile(QString caption, QString fn) 49void KApplication::showFile(QString caption, QString fn)
50{ 50{
51 QString text; 51 QString text;
52 QString fileName; 52 QString fileName;
53#ifndef DESKTOP_VERSION 53#ifndef DESKTOP_VERSION
54 fileName = getenv("QPEDIR"); 54 fileName = getenv("QPEDIR");
55 fileName += "/pics/" + fn ; 55 fileName += "/pics/" + fn ;
56#else 56#else
57 fileName = qApp->applicationDirPath () + "/" + fn; 57 fileName = qApp->applicationDirPath () + "/" + fn;
58#endif 58#endif
59 QFile file( fileName ); 59 QFile file( fileName );
60 if (!file.open( IO_ReadOnly ) ) { 60 if (!file.open( IO_ReadOnly ) ) {
61 return ; 61 return ;
62 } 62 }
63 QTextStream ts( &file ); 63 QTextStream ts( &file );
64 text = ts.read(); 64 text = ts.read();
65 file.close(); 65 file.close();
66 KApplication::showText( caption, text ); 66 KApplication::showText( caption, text );
67 67
68} 68}
69 69
70bool KApplication::convert2latin1(QString fileName) 70bool KApplication::convert2latin1(QString fileName)
71{ 71{
72 QString text; 72 QString text;
73 QFile file( fileName ); 73 QFile file( fileName );
74 if (!file.open( IO_ReadOnly ) ) { 74 if (!file.open( IO_ReadOnly ) ) {
75 return false; 75 return false;
76 76
77 } 77 }
78 QTextStream ts( &file ); 78 QTextStream ts( &file );
79 ts.setEncoding( QTextStream::UnicodeUTF8 ); 79 ts.setEncoding( QTextStream::UnicodeUTF8 );
80 text = ts.read(); 80 text = ts.read();
81 file.close(); 81 file.close();
82 if (!file.open( IO_WriteOnly ) ) { 82 if (!file.open( IO_WriteOnly ) ) {
83 return false; 83 return false;
84 } 84 }
85 QTextStream tsIn( &file ); 85 QTextStream tsIn( &file );
86 tsIn.setEncoding( QTextStream::Latin1 ); 86 tsIn.setEncoding( QTextStream::Latin1 );
87 tsIn << text.latin1(); 87 tsIn << text.latin1();
88 file.close(); 88 file.close();
89 return true;
89 90
90 91
91} 92}
92void KApplication::showText(QString caption, QString text) 93void KApplication::showText(QString caption, QString text)
93{ 94{
94 QDialog dia( 0, "name", true ); ; 95 QDialog dia( 0, "name", true ); ;
95 dia.setCaption( caption ); 96 dia.setCaption( caption );
96 QVBoxLayout* lay = new QVBoxLayout( &dia ); 97 QVBoxLayout* lay = new QVBoxLayout( &dia );
97 lay->setSpacing( 3 ); 98 lay->setSpacing( 3 );
98 lay->setMargin( 3 ); 99 lay->setMargin( 3 );
99 KTextEdit tb ( &dia ); 100 KTextEdit tb ( &dia );
100 tb.setWordWrap( QMultiLineEdit::WidgetWidth ); 101 tb.setWordWrap( QMultiLineEdit::WidgetWidth );
101 lay->addWidget( &tb ); 102 lay->addWidget( &tb );
102 tb.setText( text ); 103 tb.setText( text );
103#ifdef DESKTOP_VERSION 104#ifdef DESKTOP_VERSION
104 dia.resize( 640, 480); 105 dia.resize( 640, 480);
105#else 106#else
106 dia.showMaximized(); 107 dia.showMaximized();
107#endif 108#endif
108 dia.exec(); 109 dia.exec();
109 110
110} 111}
diff --git a/microkde/kdecore/klibloader.cpp b/microkde/kdecore/klibloader.cpp
index 1394154..6d0475a 100644
--- a/microkde/kdecore/klibloader.cpp
+++ b/microkde/kdecore/klibloader.cpp
@@ -1,661 +1,653 @@
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 <qobjectdict.h>
24#include <qwidgetlist.h> 24#include <qwidgetlist.h>
25#include <qwidget.h> 25#include <qwidget.h>
26 26
27#include "kapplication.h" 27#include "kapplication.h"
28#include "klibloader.h" 28#include "klibloader.h"
29#include "kstandarddirs.h" 29#include "kstandarddirs.h"
30#include "kdebug.h" 30#include "kdebug.h"
31#include "klocale.h" 31#include "klocale.h"
32 32
33/*US 33/*US
34#ifndef NDEBUG 34#ifndef NDEBUG
35#include "ltdl.h" 35#include "ltdl.h"
36#endif 36#endif
37*/ 37*/
38 38
39//US do everything through qlibrary 39//US do everything through qlibrary
40#ifndef DESKTOP_VERSION 40#ifndef DESKTOP_VERSION
41#include <qpe/qpeapplication.h> 41#include <qpe/qpeapplication.h>
42#include <qtopia/qlibrary.h> 42#include <qtopia/qlibrary.h>
43#else 43#else
44#include <qlibrary.h> 44#include <qlibrary.h>
45#endif 45#endif
46 46
47 47
48template class QAsciiDict<KLibrary>; 48template class QAsciiDict<KLibrary>;
49 49
50#include <stdlib.h> //getenv 50#include <stdlib.h> //getenv
51 51
52/*US 52/*US
53#if HAVE_DLFCN_H 53#if HAVE_DLFCN_H
54# include <dlfcn.h> 54# include <dlfcn.h>
55#endif 55#endif
56 56
57#ifdef RTLD_GLOBAL 57#ifdef RTLD_GLOBAL
58# define LT_GLOBAL RTLD_GLOBAL 58# define LT_GLOBAL RTLD_GLOBAL
59#else 59#else
60# ifdef DL_GLOBAL 60# ifdef DL_GLOBAL
61# define LT_GLOBAL DL_GLOBAL 61# define LT_GLOBAL DL_GLOBAL
62# endif 62# endif
63#endif 63#endif
64#ifndef LT_GLOBAL 64#ifndef LT_GLOBAL
65# define LT_GLOBAL 0 65# define LT_GLOBAL 0
66#endif 66#endif
67*/ 67*/
68 68
69/*US 69/*US
70extern "C" { 70extern "C" {
71extern int lt_dlopen_flag; 71extern int lt_dlopen_flag;
72} 72}
73*/ 73*/
74 74
75KLibFactory::KLibFactory( QObject* parent, const char* name ) 75KLibFactory::KLibFactory( QObject* parent, const char* name )
76 : QObject( parent, name ) 76 : QObject( parent, name )
77{ 77{
78} 78}
79 79
80KLibFactory::~KLibFactory() 80KLibFactory::~KLibFactory()
81{ 81{
82// kdDebug(150) << "Deleting KLibFactory " << this << endl; 82// kdDebug(150) << "Deleting KLibFactory " << this << endl;
83} 83}
84 84
85QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args ) 85QObject* KLibFactory::create( QObject* parent, const char* name, const char* classname, const QStringList &args )
86{ 86{
87 QObject* obj = createObject( parent, name, classname, args ); 87 QObject* obj = createObject( parent, name, classname, args );
88 if ( obj ) 88 if ( obj )
89 emit objectCreated( obj ); 89 emit objectCreated( obj );
90 return obj; 90 return obj;
91} 91}
92 92
93 93
94QObject* KLibFactory::createObject( QObject*, const char*, const char*, const QStringList &) 94QObject* KLibFactory::createObject( QObject*, const char*, const char*, const QStringList &)
95{ 95{
96 return 0; 96 return 0;
97} 97}
98 98
99 99
100// ----------------------------------------------- 100// -----------------------------------------------
101 101
102//US KLibrary::KLibrary( const QString& libname, const QString& filename, void * handle ) 102//US KLibrary::KLibrary( const QString& libname, const QString& filename, void * handle )
103KLibrary::KLibrary( const QString& libname, const QString& filename, QLibrary* handle ) 103KLibrary::KLibrary( const QString& libname, const QString& filename, QLibrary* handle )
104{ 104{
105 /* Make sure, we have a KLibLoader */ 105 /* Make sure, we have a KLibLoader */
106 (void) KLibLoader::self(); 106 (void) KLibLoader::self();
107 m_libname = libname; 107 m_libname = libname;
108 m_filename = filename; 108 m_filename = filename;
109 m_handle = handle; 109 m_handle = handle;
110 m_factory = 0; 110 m_factory = 0;
111 m_timer = 0; 111 m_timer = 0;
112} 112}
113 113
114KLibrary::~KLibrary() 114KLibrary::~KLibrary()
115{ 115{
116// kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl; 116// kdDebug(150) << "Deleting KLibrary " << this << " " << m_libname << endl;
117 if ( m_timer && m_timer->isActive() ) 117 if ( m_timer && m_timer->isActive() )
118 m_timer->stop(); 118 m_timer->stop();
119 119
120 // If any object is remaining, delete 120 // If any object is remaining, delete
121 if ( m_objs.count() > 0 ) 121 if ( m_objs.count() > 0 )
122 { 122 {
123 QPtrListIterator<QObject> it( m_objs ); 123 QPtrListIterator<QObject> it( m_objs );
124 for ( ; it.current() ; ++it ) 124 for ( ; it.current() ; ++it )
125 { 125 {
126 kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl; 126 kdDebug(150) << "Factory still has object " << it.current() << " " << it.current()->name () << " Library = " << m_libname << endl;
127 disconnect( it.current(), SIGNAL( destroyed() ), 127 disconnect( it.current(), SIGNAL( destroyed() ),
128 this, SLOT( slotObjectDestroyed() ) ); 128 this, SLOT( slotObjectDestroyed() ) );
129 } 129 }
130 m_objs.setAutoDelete(true); 130 m_objs.setAutoDelete(true);
131 m_objs.clear(); 131 m_objs.clear();
132 } 132 }
133 133
134 if ( m_factory ) { 134 if ( m_factory ) {
135 //kdDebug(150) << " ... deleting the factory " << m_factory << endl; 135 //kdDebug(150) << " ... deleting the factory " << m_factory << endl;
136 delete m_factory; 136 delete m_factory;
137 } 137 }
138} 138}
139 139
140QString KLibrary::name() const 140QString KLibrary::name() const
141{ 141{
142 return m_libname; 142 return m_libname;
143} 143}
144 144
145QString KLibrary::fileName() const 145QString KLibrary::fileName() const
146{ 146{
147 return m_filename; 147 return m_filename;
148} 148}
149 149
150KLibFactory* KLibrary::factory() 150KLibFactory* KLibrary::factory()
151{ 151{
152 if ( m_factory ) 152 if ( m_factory )
153 return m_factory; 153 return m_factory;
154 154
155 QCString symname; 155 QCString symname;
156 symname.sprintf("init_%s", name().latin1() ); 156 symname.sprintf("init_%s", name().latin1() );
157 157
158 void* sym = symbol( symname ); 158 void* sym = symbol( symname );
159 if ( !sym ) 159 if ( !sym )
160 { 160 {
161 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data()); 161 qDebug("KLibrary: The library %s does not offer an %s function", name().latin1(), symname.data());
162#ifndef NDEBUG 162#ifndef NDEBUG
163//US qDebug("KLibrary: errorcode: %s", lt_dlerror()); 163//US qDebug("KLibrary: errorcode: %s", lt_dlerror());
164#endif 164#endif
165 kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl; 165 kdWarning(150) << "KLibrary: The library " << name().latin1() << " does not offer an init_" << name().latin1() << " function" << endl;
166 return 0; 166 return 0;
167 } 167 }
168 168
169 typedef KLibFactory* (*t_func)(); 169 typedef KLibFactory* (*t_func)();
170 t_func func = (t_func)sym; 170 t_func func = (t_func)sym;
171 m_factory = func(); 171 m_factory = func();
172 172
173 if( !m_factory ) 173 if( !m_factory )
174 { 174 {
175 kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl; 175 kdWarning(150) << "KLibrary: The library " << name() << " does not offer a KDE compatible factory" << endl;
176 return 0; 176 return 0;
177 } 177 }
178 178
179 connect( m_factory, SIGNAL( objectCreated( QObject * ) ), 179 connect( m_factory, SIGNAL( objectCreated( QObject * ) ),
180 this, SLOT( slotObjectCreated( QObject * ) ) ); 180 this, SLOT( slotObjectCreated( QObject * ) ) );
181 181
182 return m_factory; 182 return m_factory;
183} 183}
184 184
185void* KLibrary::symbol( const char* symname ) const 185void* KLibrary::symbol( const char* symname ) const
186{ 186{
187//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); 187//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname );
188 void* sym = m_handle->resolve( symname ); 188 void* sym = m_handle->resolve( symname );
189 if ( !sym ) 189 if ( !sym )
190 { 190 {
191//US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl; 191//US kdWarning(150) << "KLibrary: " << lt_dlerror() << endl;
192 return 0; 192 return 0;
193 } 193 }
194 194
195 return sym; 195 return sym;
196} 196}
197 197
198bool KLibrary::hasSymbol( const char* symname ) const 198bool KLibrary::hasSymbol( const char* symname ) const
199{ 199{
200//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname ); 200//US void* sym = lt_dlsym( (lt_dlhandle) m_handle, symname );
201 void* sym = m_handle->resolve( symname ); 201 void* sym = m_handle->resolve( symname );
202 return (sym != 0L ); 202 return (sym != 0L );
203} 203}
204 204
205void KLibrary::unload() const 205void KLibrary::unload() const
206{ 206{
207 if (KLibLoader::s_self) 207 if (KLibLoader::s_self)
208 KLibLoader::s_self->unloadLibrary(QFile::encodeName(name())); 208 KLibLoader::s_self->unloadLibrary(QFile::encodeName(name()));
209} 209}
210 210
211void KLibrary::slotObjectCreated( QObject *obj ) 211void KLibrary::slotObjectCreated( QObject *obj )
212{ 212{
213 if ( !obj ) 213 if ( !obj )
214 return; 214 return;
215 215
216 if ( m_timer && m_timer->isActive() ) 216 if ( m_timer && m_timer->isActive() )
217 m_timer->stop(); 217 m_timer->stop();
218 218
219 if ( m_objs.containsRef( obj ) ) 219 if ( m_objs.containsRef( obj ) )
220 return; // we know this object already 220 return; // we know this object already
221 221
222 connect( obj, SIGNAL( destroyed() ), 222 connect( obj, SIGNAL( destroyed() ),
223 this, SLOT( slotObjectDestroyed() ) ); 223 this, SLOT( slotObjectDestroyed() ) );
224 224
225 m_objs.append( obj ); 225 m_objs.append( obj );
226} 226}
227 227
228void KLibrary::slotObjectDestroyed() 228void KLibrary::slotObjectDestroyed()
229{ 229{
230 m_objs.removeRef( sender() ); 230 m_objs.removeRef( sender() );
231 231
232 if ( m_objs.count() == 0 ) 232 if ( m_objs.count() == 0 )
233 { 233 {
234// kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!" 234// kdDebug(150) << "KLibrary: shutdown timer for " << name() << " started!"
235// << endl; 235// << endl;
236 236
237 if ( !m_timer ) 237 if ( !m_timer )
238 { 238 {
239 m_timer = new QTimer( this, "klibrary_shutdown_timer" ); 239 m_timer = new QTimer( this, "klibrary_shutdown_timer" );
240 connect( m_timer, SIGNAL( timeout() ), 240 connect( m_timer, SIGNAL( timeout() ),
241 this, SLOT( slotTimeout() ) ); 241 this, SLOT( slotTimeout() ) );
242 } 242 }
243 243
244 // as long as it's not stable make the timeout short, for debugging 244 // as long as it's not stable make the timeout short, for debugging
245 // pleasure (matz) 245 // pleasure (matz)
246 //m_timer->start( 1000*60, true ); 246 //m_timer->start( 1000*60, true );
247 m_timer->start( 1000*10, true ); 247 m_timer->start( 1000*10, true );
248 } 248 }
249} 249}
250 250
251void KLibrary::slotTimeout() 251void KLibrary::slotTimeout()
252{ 252{
253 if ( m_objs.count() != 0 ) 253 if ( m_objs.count() != 0 )
254 return; 254 return;
255 255
256 /* Don't go through KLibLoader::unloadLibrary(), because that uses the 256 /* Don't go through KLibLoader::unloadLibrary(), because that uses the
257 ref counter, but this timeout means to unconditionally close this library 257 ref counter, but this timeout means to unconditionally close this library
258 The destroyed() signal will take care to remove us from all lists. 258 The destroyed() signal will take care to remove us from all lists.
259 */ 259 */
260 delete this; 260 delete this;
261} 261}
262 262
263// ------------------------------------------------- 263// -------------------------------------------------
264 264
265/* This helper class is needed, because KLibraries can go away without 265/* This helper class is needed, because KLibraries can go away without
266 being unloaded. So we need some info about KLibraries even after its 266 being unloaded. So we need some info about KLibraries even after its
267 death. */ 267 death. */
268class KLibWrapPrivate 268class KLibWrapPrivate
269{ 269{
270public: 270public:
271//US KLibWrapPrivate(KLibrary *l, lt_dlhandle h); 271//US KLibWrapPrivate(KLibrary *l, lt_dlhandle h);
272 KLibWrapPrivate(KLibrary *l, QLibrary* h); 272 KLibWrapPrivate(KLibrary *l, QLibrary* h);
273 273
274 KLibrary *lib; 274 KLibrary *lib;
275 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; 275 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode;
276 int ref_count; 276 int ref_count;
277//US lt_dlhandle handle; 277//US lt_dlhandle handle;
278 QLibrary *handle; 278 QLibrary *handle;
279 QString name; 279 QString name;
280 QString filename; 280 QString filename;
281}; 281};
282 282
283//US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h) 283//US KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, lt_dlhandle h)
284KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h) 284KLibWrapPrivate::KLibWrapPrivate(KLibrary *l, QLibrary* h)
285 : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName()) 285 : lib(l), ref_count(1), handle(h), name(l->name()), filename(l->fileName())
286{ 286{
287 unload_mode = UNKNOWN; 287 unload_mode = UNKNOWN;
288/*US 288/*US
289 if (lt_dlsym(handle, "__kde_do_not_unload") != 0) { 289 if (lt_dlsym(handle, "__kde_do_not_unload") != 0) {
290// kdDebug(150) << "Will not unload " << name << endl; 290// kdDebug(150) << "Will not unload " << name << endl;
291 unload_mode = DONT_UNLOAD; 291 unload_mode = DONT_UNLOAD;
292 } else if (lt_dlsym(handle, "__kde_do_unload") != 0) { 292 } else if (lt_dlsym(handle, "__kde_do_unload") != 0) {
293 unload_mode = UNLOAD; 293 unload_mode = UNLOAD;
294 } 294 }
295*/ 295*/
296//US use instead: 296//US use instead:
297 if (h->resolve("__kde_do_not_unload") != 0) { 297 if (h->resolve("__kde_do_not_unload") != 0) {
298// kdDebug(150) << "Will not unload " << name << endl; 298// kdDebug(150) << "Will not unload " << name << endl;
299 unload_mode = DONT_UNLOAD; 299 unload_mode = DONT_UNLOAD;
300 } else if (h->resolve("__kde_do_unload") != 0) { 300 } else if (h->resolve("__kde_do_unload") != 0) {
301 unload_mode = UNLOAD; 301 unload_mode = UNLOAD;
302 } 302 }
303} 303}
304 304
305class KLibLoaderPrivate 305class KLibLoaderPrivate
306{ 306{
307public: 307public:
308 QPtrList<KLibWrapPrivate> loaded_stack; 308 QPtrList<KLibWrapPrivate> loaded_stack;
309 QPtrList<KLibWrapPrivate> pending_close; 309 QPtrList<KLibWrapPrivate> pending_close;
310 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode; 310 enum {UNKNOWN, UNLOAD, DONT_UNLOAD} unload_mode;
311 311
312 QString errorMessage; 312 QString errorMessage;
313}; 313};
314 314
315KLibLoader* KLibLoader::s_self = 0; 315KLibLoader* KLibLoader::s_self = 0;
316 316
317KLibLoader* KLibLoader::self() 317KLibLoader* KLibLoader::self()
318{ 318{
319 if ( !s_self ) 319 if ( !s_self )
320 s_self = new KLibLoader; 320 s_self = new KLibLoader;
321 return s_self; 321 return s_self;
322} 322}
323 323
324void KLibLoader::cleanUp() 324void KLibLoader::cleanUp()
325{ 325{
326 if ( !s_self ) 326 if ( !s_self )
327 return; 327 return;
328 328
329 delete s_self; 329 delete s_self;
330 s_self = 0; 330 s_self = 0;
331} 331}
332 332
333KLibLoader::KLibLoader( QObject* parent, const char* name ) 333KLibLoader::KLibLoader( QObject* parent, const char* name )
334 : QObject( parent, name ) 334 : QObject( parent, name )
335{ 335{
336 s_self = this; 336 s_self = this;
337 d = new KLibLoaderPrivate; 337 d = new KLibLoaderPrivate;
338//US lt_dlinit(); 338//US lt_dlinit();
339 d->unload_mode = KLibLoaderPrivate::UNKNOWN; 339 d->unload_mode = KLibLoaderPrivate::UNKNOWN;
340 if (getenv("KDE_NOUNLOAD") != 0) 340 if (getenv("KDE_NOUNLOAD") != 0)
341 d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD; 341 d->unload_mode = KLibLoaderPrivate::DONT_UNLOAD;
342 else if (getenv("KDE_DOUNLOAD") != 0) 342 else if (getenv("KDE_DOUNLOAD") != 0)
343 d->unload_mode = KLibLoaderPrivate::UNLOAD; 343 d->unload_mode = KLibLoaderPrivate::UNLOAD;
344 d->loaded_stack.setAutoDelete( true ); 344 d->loaded_stack.setAutoDelete( true );
345} 345}
346 346
347KLibLoader::~KLibLoader() 347KLibLoader::~KLibLoader()
348{ 348{
349// kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl; 349// kdDebug(150) << "Deleting KLibLoader " << this << " " << name() << endl;
350 350
351 QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); 351 QAsciiDictIterator<KLibWrapPrivate> it( m_libs );
352 for (; it.current(); ++it ) 352 for (; it.current(); ++it )
353 { 353 {
354 kdDebug(150) << "The KLibLoader contains the library " << it.current()->name 354 kdDebug(150) << "The KLibLoader contains the library " << it.current()->name
355 << " (" << it.current()->lib << ")" << endl; 355 << " (" << it.current()->lib << ")" << endl;
356 d->pending_close.append(it.current()); 356 d->pending_close.append(it.current());
357 } 357 }
358 358
359 close_pending(0); 359 close_pending(0);
360 360
361 delete d; 361 delete d;
362} 362}
363 363
364//static 364//static
365QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ ) 365QString KLibLoader::findLibrary( const char * name/*US , const KInstance * instance*/ )
366{ 366{
367 QCString libname( name ); 367 QCString libname( name );
368 368
369 // only append ".la" if there is no extension 369 // only append ".la" if there is no extension
370 // this allows to load non-libtool libraries as well 370 // this allows to load non-libtool libraries as well
371 // (mhk, 20000228) 371 // (mhk, 20000228)
372 int pos = libname.findRev('/'); 372 int pos = libname.findRev('/');
373 if (pos < 0) 373 if (pos < 0)
374 pos = 0; 374 pos = 0;
375/*US 375/*US
376 if (libname.find('.', pos) < 0) { 376 if (libname.find('.', pos) < 0) {
377 libname += ".la"; 377 libname += ".la";
378 } 378 }
379*/ 379*/
380//US in the microedition we work only with shared libraries. 380//US in the microedition we work only with shared libraries.
381 381
382 if (libname.find('.', pos) < 0) { 382 if (libname.find('.', pos) < 0) {
383#ifdef _WIN32_ 383#ifdef _WIN32_
384 libname += ".dll"; 384 libname += ".dll";
385#else 385#else
386 libname += ".so"; 386 libname += ".so";
387#endif 387#endif
388 } 388 }
389 389
390 // only look up the file if it is not an absolute filename 390 // only look up the file if it is not an absolute filename
391 // (mhk, 20000228) 391 // (mhk, 20000228)
392 QString libfile; 392 QString libfile;
393 if (libname[0] == '/') 393 if (libname[0] == '/')
394 libfile = libname; 394 libfile = libname;
395 else 395 else
396 { 396 {
397//US at this point the libname must exist as real filesname. No expansions will be made later 397//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 398// 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? 399//US I add also the "lib" prefix. I do not how could this could have worked before without it?
400#ifndef _WIN32_ 400#ifndef _WIN32_
401 libname.insert(pos, "lib"); 401 libname.insert(pos, "lib");
402#endif 402#endif
403 403
404 404
405//US libfile = instance->dirs()->findResource( "module", libname ); 405//US libfile = instance->dirs()->findResource( "module", libname );
406 //qDebug("libname = %s ",libname.data() ); 406 //qDebug("libname = %s ",libname.data() );
407 libfile = KGlobal::dirs()->findResource( "module", libname ); 407 libfile = KGlobal::dirs()->findResource( "module", libname );
408 //qDebug("libfile = %s ",libfile.latin1() ); 408 //qDebug("libfile = %s ",libfile.latin1() );
409 409
410 if ( libfile.isEmpty() ) 410 if ( libfile.isEmpty() )
411 { 411 {
412//US libfile = instance->dirs()->findResource( "lib", libname ); 412//US libfile = instance->dirs()->findResource( "lib", libname );
413 libfile = KGlobal::dirs()->findResource( "lib", libname ); 413 libfile = KGlobal::dirs()->findResource( "lib", libname );
414 //qDebug("libfile2 = %s ",libfile.latin1() ); 414 //qDebug("libfile2 = %s ",libfile.latin1() );
415#ifndef NDEBUG 415#ifndef NDEBUG
416 if ( !libfile.isEmpty() && libname.left(3) == "lib" ) // don't warn for kdeinit modules 416 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; 417 kdDebug(150) << "library " << libname << " not found under 'module' but under 'lib'" << endl;
418#endif 418#endif
419 } 419 }
420 if ( libfile.isEmpty() ) 420 if ( libfile.isEmpty() )
421 { 421 {
422#ifndef NDEBUG 422#ifndef NDEBUG
423 kdDebug(150) << "library=" << libname << ": No file names " << libname.data() << " found in paths." << endl; 423 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); 424 self()->d->errorMessage = i18n("Library files for \"%1\" not found in paths").arg(libname);
425 425
426 qDebug("KLibLoader::library could not find library: %s", libname.data()); 426 qDebug("KLibLoader::library could not find library: %s", libname.data());
427#endif 427#endif
428 428
429 } 429 }
430 else 430 else
431 self()->d->errorMessage = QString::null; 431 self()->d->errorMessage = QString::null;
432 } 432 }
433 433
434 //qDebug("return libfile = %s ",libfile.latin1() ); 434 //qDebug("return libfile = %s ",libfile.latin1() );
435 return libfile; 435 return libfile;
436} 436}
437 437
438 438
439KLibrary* KLibLoader::globalLibrary( const char *name ) 439KLibrary* KLibLoader::globalLibrary( const char *name )
440{ 440{
441KLibrary *tmp; 441KLibrary *tmp;
442/*US 442/*US
443int olt_dlopen_flag = lt_dlopen_flag; 443int olt_dlopen_flag = lt_dlopen_flag;
444 444
445 lt_dlopen_flag |= LT_GLOBAL; 445 lt_dlopen_flag |= LT_GLOBAL;
446 kdDebug(150) << "Loading the next library global with flag " 446 kdDebug(150) << "Loading the next library global with flag "
447 << lt_dlopen_flag 447 << lt_dlopen_flag
448 << "." << endl; 448 << "." << endl;
449*/ 449*/
450 tmp = library(name); 450 tmp = library(name);
451/*US 451/*US
452 lt_dlopen_flag = olt_dlopen_flag; 452 lt_dlopen_flag = olt_dlopen_flag;
453*/ 453*/
454return tmp; 454return tmp;
455} 455}
456 456
457 457
458KLibrary* KLibLoader::library( const char *name ) 458KLibrary* KLibLoader::library( const char *name )
459{ 459{
460 if (!name) 460 if (!name)
461 return 0; 461 return 0;
462 462
463 KLibWrapPrivate* wrap = m_libs[name]; 463 KLibWrapPrivate* wrap = m_libs[name];
464 if (wrap) { 464 if (wrap) {
465 /* Nothing to do to load the library. */ 465 /* Nothing to do to load the library. */
466 wrap->ref_count++; 466 wrap->ref_count++;
467 return wrap->lib; 467 return wrap->lib;
468 } 468 }
469 469
470 /* Test if this library was loaded at some time, but got 470 /* Test if this library was loaded at some time, but got
471 unloaded meanwhile, whithout being dlclose()'ed. */ 471 unloaded meanwhile, whithout being dlclose()'ed. */
472 QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack); 472 QPtrListIterator<KLibWrapPrivate> it(d->loaded_stack);
473 for (; it.current(); ++it) { 473 for (; it.current(); ++it) {
474 if (it.current()->name == name) 474 if (it.current()->name == name)
475 wrap = it.current(); 475 wrap = it.current();
476 } 476 }
477 477
478 if (wrap) { 478 if (wrap) {
479 d->pending_close.removeRef(wrap); 479 d->pending_close.removeRef(wrap);
480 if (!wrap->lib) { 480 if (!wrap->lib) {
481 /* This lib only was in loaded_stack, but not in m_libs. */ 481 /* This lib only was in loaded_stack, but not in m_libs. */
482 wrap->lib = new KLibrary( name, wrap->filename, wrap->handle ); 482 wrap->lib = new KLibrary( name, wrap->filename, wrap->handle );
483 } 483 }
484 wrap->ref_count++; 484 wrap->ref_count++;
485 } else { 485 } else {
486 QString libfile = findLibrary( name ); 486 QString libfile = findLibrary( name );
487 if ( libfile.isEmpty() ) 487 if ( libfile.isEmpty() )
488 return 0; 488 return 0;
489#ifdef DESKTOP_VERSION 489#ifdef DESKTOP_VERSION
490 QLibrary *qlib = new QLibrary( libfile.latin1() ); 490 QLibrary *qlib = new QLibrary( libfile.latin1() );
491#else 491#else
492 QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately ); 492 QLibrary *qlib = new QLibrary( libfile.latin1(), QLibrary::Immediately );
493#endif 493#endif
494 494
495//US lt_dlhandle handle = lt_dlopen( libfile.latin1() ); 495//US lt_dlhandle handle = lt_dlopen( libfile.latin1() );
496//US if ( !handle ) 496//US if ( !handle )
497 if ( !qlib ) 497 if ( !qlib )
498 { 498 {
499//US const char* errmsg = lt_dlerror(); 499 qDebug( "KLibLoader::library could not load library: %s", libfile.latin1());
500 char* errmsg; 500 d->errorMessage = QString::null;
501 sprintf(errmsg, "KLibLoader::library could not load library: %s", libfile.latin1()); 501 return 0;
502 qDebug(errmsg);
503
504 if(errmsg)
505 d->errorMessage = QString::fromLatin1(errmsg);
506 else
507 d->errorMessage = QString::null;
508 kdWarning(150) << "library=" << name << ": file=" << libfile << ": " << d->errorMessage << endl;
509 return 0;
510 } 502 }
511 else 503 else
512 d->errorMessage = QString::null; 504 d->errorMessage = QString::null;
513 505
514 KLibrary *lib = new KLibrary( name, libfile, qlib ); 506 KLibrary *lib = new KLibrary( name, libfile, qlib );
515 wrap = new KLibWrapPrivate(lib, qlib); 507 wrap = new KLibWrapPrivate(lib, qlib);
516 d->loaded_stack.prepend(wrap); 508 d->loaded_stack.prepend(wrap);
517 } 509 }
518 m_libs.insert( name, wrap ); 510 m_libs.insert( name, wrap );
519 511
520 connect( wrap->lib, SIGNAL( destroyed() ), 512 connect( wrap->lib, SIGNAL( destroyed() ),
521 this, SLOT( slotLibraryDestroyed() ) ); 513 this, SLOT( slotLibraryDestroyed() ) );
522 514
523 return wrap->lib; 515 return wrap->lib;
524} 516}
525 517
526QString KLibLoader::lastErrorMessage() const 518QString KLibLoader::lastErrorMessage() const
527{ 519{
528 return d->errorMessage; 520 return d->errorMessage;
529} 521}
530 522
531void KLibLoader::unloadLibrary( const char *libname ) 523void KLibLoader::unloadLibrary( const char *libname )
532{ 524{
533 KLibWrapPrivate *wrap = m_libs[ libname ]; 525 KLibWrapPrivate *wrap = m_libs[ libname ];
534 if (!wrap) 526 if (!wrap)
535 return; 527 return;
536 if (--wrap->ref_count) 528 if (--wrap->ref_count)
537 return; 529 return;
538 530
539// kdDebug(150) << "closing library " << libname << endl; 531// kdDebug(150) << "closing library " << libname << endl;
540 532
541 m_libs.remove( libname ); 533 m_libs.remove( libname );
542 534
543 disconnect( wrap->lib, SIGNAL( destroyed() ), 535 disconnect( wrap->lib, SIGNAL( destroyed() ),
544 this, SLOT( slotLibraryDestroyed() ) ); 536 this, SLOT( slotLibraryDestroyed() ) );
545 close_pending( wrap ); 537 close_pending( wrap );
546} 538}
547 539
548KLibFactory* KLibLoader::factory( const char* name ) 540KLibFactory* KLibLoader::factory( const char* name )
549{ 541{
550 KLibrary* lib = library( name ); 542 KLibrary* lib = library( name );
551 if ( !lib ) 543 if ( !lib )
552 return 0; 544 return 0;
553 545
554 return lib->factory(); 546 return lib->factory();
555} 547}
556 548
557void KLibLoader::slotLibraryDestroyed() 549void KLibLoader::slotLibraryDestroyed()
558{ 550{
559 const KLibrary *lib = static_cast<const KLibrary *>( sender() ); 551 const KLibrary *lib = static_cast<const KLibrary *>( sender() );
560 552
561 QAsciiDictIterator<KLibWrapPrivate> it( m_libs ); 553 QAsciiDictIterator<KLibWrapPrivate> it( m_libs );
562 for (; it.current(); ++it ) 554 for (; it.current(); ++it )
563 if ( it.current()->lib == lib ) 555 if ( it.current()->lib == lib )
564 { 556 {
565 KLibWrapPrivate *wrap = it.current(); 557 KLibWrapPrivate *wrap = it.current();
566 wrap->lib = 0; /* the KLibrary object is already away */ 558 wrap->lib = 0; /* the KLibrary object is already away */
567 m_libs.remove( it.currentKey() ); 559 m_libs.remove( it.currentKey() );
568 close_pending( wrap ); 560 close_pending( wrap );
569 return; 561 return;
570 } 562 }
571} 563}
572 564
573void KLibLoader::close_pending(KLibWrapPrivate *wrap) 565void KLibLoader::close_pending(KLibWrapPrivate *wrap)
574{ 566{
575 if (wrap && !d->pending_close.containsRef( wrap )) 567 if (wrap && !d->pending_close.containsRef( wrap ))
576 d->pending_close.append( wrap ); 568 d->pending_close.append( wrap );
577 569
578 /* First delete all KLibrary objects in pending_close, but _don't_ unload 570 /* First delete all KLibrary objects in pending_close, but _don't_ unload
579 the DSO behind it. */ 571 the DSO behind it. */
580 QPtrListIterator<KLibWrapPrivate> it(d->pending_close); 572 QPtrListIterator<KLibWrapPrivate> it(d->pending_close);
581 for (; it.current(); ++it) { 573 for (; it.current(); ++it) {
582 wrap = it.current(); 574 wrap = it.current();
583 if (wrap->lib) { 575 if (wrap->lib) {
584 disconnect( wrap->lib, SIGNAL( destroyed() ), 576 disconnect( wrap->lib, SIGNAL( destroyed() ),
585 this, SLOT( slotLibraryDestroyed() ) ); 577 this, SLOT( slotLibraryDestroyed() ) );
586 delete wrap->lib; 578 delete wrap->lib;
587 wrap->lib = 0; 579 wrap->lib = 0;
588 } 580 }
589 } 581 }
590 582
591 if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return; 583 if (d->unload_mode == KLibLoaderPrivate::DONT_UNLOAD) return;
592 584
593 bool deleted_one = false; 585 bool deleted_one = false;
594 while ((wrap = d->loaded_stack.first())) { 586 while ((wrap = d->loaded_stack.first())) {
595 /* Let's first see, if we want to try to unload this lib. 587 /* Let's first see, if we want to try to unload this lib.
596 If the env. var KDE_DOUNLOAD is set, we try to unload every lib. 588 If the env. var KDE_DOUNLOAD is set, we try to unload every lib.
597 If not, we look at the lib itself, and unload it only, if it exports 589 If not, we look at the lib itself, and unload it only, if it exports
598 the symbol __kde_do_unload. */ 590 the symbol __kde_do_unload. */
599 if (d->unload_mode != KLibLoaderPrivate::UNLOAD 591 if (d->unload_mode != KLibLoaderPrivate::UNLOAD
600 && wrap->unload_mode != KLibWrapPrivate::UNLOAD) 592 && wrap->unload_mode != KLibWrapPrivate::UNLOAD)
601 break; 593 break;
602 594
603 /* Now ensure, that the libs are only unloaded in the reverse direction 595 /* Now ensure, that the libs are only unloaded in the reverse direction
604 they were loaded. */ 596 they were loaded. */
605 if (!d->pending_close.containsRef( wrap )) { 597 if (!d->pending_close.containsRef( wrap )) {
606 if (!deleted_one) 598 if (!deleted_one)
607 /* Only diagnose, if we really haven't deleted anything. */ 599 /* Only diagnose, if we really haven't deleted anything. */
608// kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl; 600// kdDebug(150) << "try to dlclose " << wrap->name << ": not yet" << endl;
609 break; 601 break;
610 } 602 }
611 603
612// kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl; 604// kdDebug(150) << "try to dlclose " << wrap->name << ": yes, done." << endl;
613 605
614#if 0 606#if 0
615#ifndef Q_WS_QWS 607#ifndef Q_WS_QWS
616 if ( !deleted_one ) { 608 if ( !deleted_one ) {
617 /* Only do the hack once in this loop. 609 /* Only do the hack once in this loop.
618 WABA: *HACK* 610 WABA: *HACK*
619 We need to make sure to clear the clipboard before unloading a DSO 611 We need to make sure to clear the clipboard before unloading a DSO
620 because the DSO could have defined an object derived from QMimeSource 612 because the DSO could have defined an object derived from QMimeSource
621 and placed that on the clipboard. */ 613 and placed that on the clipboard. */
622 /*kapp->clipboard()->clear();*/ 614 /*kapp->clipboard()->clear();*/
623 615
624 /* Well.. let's do something more subtle... convert the clipboard context 616 /* Well.. let's do something more subtle... convert the clipboard context
625 to text. That should be safe as it only uses objects defined by Qt. */ 617 to text. That should be safe as it only uses objects defined by Qt. */
626 618
627 QWidgetList *widgetlist = QApplication::topLevelWidgets(); 619 QWidgetList *widgetlist = QApplication::topLevelWidgets();
628 QWidget *co = widgetlist->first(); 620 QWidget *co = widgetlist->first();
629 while (co) { 621 while (co) {
630 if (qstrcmp(co->name(), "internal clipboard owner") == 0) { 622 if (qstrcmp(co->name(), "internal clipboard owner") == 0) {
631 if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId()) 623 if (XGetSelectionOwner(co->x11Display(), XA_PRIMARY) == co->winId())
632 kapp->clipboard()->setText(kapp->clipboard()->text()); 624 kapp->clipboard()->setText(kapp->clipboard()->text());
633 625
634 break; 626 break;
635 } 627 }
636 co = widgetlist->next(); 628 co = widgetlist->next();
637 } 629 }
638 delete widgetlist; 630 delete widgetlist;
639 } 631 }
640#else 632#else
641 // FIXME(E): Implement in Qt Embedded 633 // FIXME(E): Implement in Qt Embedded
642#endif 634#endif
643 635
644#endif // 0 636#endif // 0
645 deleted_one = true; 637 deleted_one = true;
646//US lt_dlclose(wrap->handle); 638//US lt_dlclose(wrap->handle);
647 wrap->handle->unload(); 639 wrap->handle->unload();
648 640
649 d->pending_close.removeRef(wrap); 641 d->pending_close.removeRef(wrap);
650 /* loaded_stack is AutoDelete, so wrap is freed */ 642 /* loaded_stack is AutoDelete, so wrap is freed */
651 d->loaded_stack.remove(); 643 d->loaded_stack.remove();
652 } 644 }
653} 645}
654 646
655void KLibLoader::virtual_hook( int, void* ) 647void KLibLoader::virtual_hook( int, void* )
656{ /*BASE::virtual_hook( id, data );*/ } 648{ /*BASE::virtual_hook( id, data );*/ }
657 649
658void KLibFactory::virtual_hook( int, void* ) 650void KLibFactory::virtual_hook( int, void* )
659{ /*BASE::virtual_hook( id, data );*/ } 651{ /*BASE::virtual_hook( id, data );*/ }
660 652
661//US #include "klibloader.moc" 653//US #include "klibloader.moc"
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp
index 1ad1728..09ad0c8 100644
--- a/microkde/kdeui/ktoolbar.cpp
+++ b/microkde/kdeui/ktoolbar.cpp
@@ -369,1025 +369,1025 @@ int KToolBar::insertLined (const QString& text, int id,
369 bool enabled , 369 bool enabled ,
370 const QString& toolTipText, 370 const QString& toolTipText,
371 int size, int index ) 371 int size, int index )
372{ 372{
373 KLineEdit *lined = new KLineEdit ( this, 0 ); 373 KLineEdit *lined = new KLineEdit ( this, 0 );
374 if ( !toolTipText.isEmpty() ) 374 if ( !toolTipText.isEmpty() )
375 QToolTip::add( lined, toolTipText ); 375 QToolTip::add( lined, toolTipText );
376 if ( size > 0 ) 376 if ( size > 0 )
377 lined->setMinimumWidth( size ); 377 lined->setMinimumWidth( size );
378 insertWidgetInternal( lined, index, id ); 378 insertWidgetInternal( lined, index, id );
379 connect( lined, signal, receiver, slot ); 379 connect( lined, signal, receiver, slot );
380 lined->setText(text); 380 lined->setText(text);
381 lined->setEnabled( enabled ); 381 lined->setEnabled( enabled );
382 return index; 382 return index;
383} 383}
384 384
385int KToolBar::insertCombo (const QStringList &list, int id, bool writable, 385int KToolBar::insertCombo (const QStringList &list, int id, bool writable,
386 const char *signal, const QObject *receiver, 386 const char *signal, const QObject *receiver,
387 const char *slot, bool enabled, 387 const char *slot, bool enabled,
388 const QString& tooltiptext, 388 const QString& tooltiptext,
389 int size, int index, 389 int size, int index,
390 QComboBox::Policy policy ) 390 QComboBox::Policy policy )
391{ 391{
392//US KComboBox *combo = new KComboBox ( writable, this ); 392//US KComboBox *combo = new KComboBox ( writable, this );
393 KComboBox *combo = new KComboBox ( this ); 393 KComboBox *combo = new KComboBox ( this );
394 combo->setEditable(writable); 394 combo->setEditable(writable);
395 395
396 insertWidgetInternal( combo, index, id ); 396 insertWidgetInternal( combo, index, id );
397 combo->insertStringList (list); 397 combo->insertStringList (list);
398 combo->setInsertionPolicy(policy); 398 combo->setInsertionPolicy(policy);
399 combo->setEnabled( enabled ); 399 combo->setEnabled( enabled );
400 if ( !tooltiptext.isEmpty() ) 400 if ( !tooltiptext.isEmpty() )
401 QToolTip::add( combo, tooltiptext ); 401 QToolTip::add( combo, tooltiptext );
402 if ( size > 0 ) 402 if ( size > 0 )
403 combo->setMinimumWidth( size ); 403 combo->setMinimumWidth( size );
404 if (!tooltiptext.isNull()) 404 if (!tooltiptext.isNull())
405 QToolTip::add( combo, tooltiptext ); 405 QToolTip::add( combo, tooltiptext );
406 406
407 if ( signal && receiver && slot ) 407 if ( signal && receiver && slot )
408 connect ( combo, signal, receiver, slot ); 408 connect ( combo, signal, receiver, slot );
409 return index; 409 return index;
410} 410}
411 411
412 412
413int KToolBar::insertCombo (const QString& text, int id, bool writable, 413int KToolBar::insertCombo (const QString& text, int id, bool writable,
414 const char *signal, QObject *receiver, 414 const char *signal, QObject *receiver,
415 const char *slot, bool enabled, 415 const char *slot, bool enabled,
416 const QString& tooltiptext, 416 const QString& tooltiptext,
417 int size, int index, 417 int size, int index,
418 QComboBox::Policy policy ) 418 QComboBox::Policy policy )
419{ 419{
420//US KComboBox *combo = new KComboBox ( writable, this ); 420//US KComboBox *combo = new KComboBox ( writable, this );
421 KComboBox *combo = new KComboBox ( this ); 421 KComboBox *combo = new KComboBox ( this );
422 combo->setEditable(writable); 422 combo->setEditable(writable);
423 423
424 insertWidgetInternal( combo, index, id ); 424 insertWidgetInternal( combo, index, id );
425 combo->insertItem (text); 425 combo->insertItem (text);
426 combo->setInsertionPolicy(policy); 426 combo->setInsertionPolicy(policy);
427 combo->setEnabled( enabled ); 427 combo->setEnabled( enabled );
428 if ( !tooltiptext.isEmpty() ) 428 if ( !tooltiptext.isEmpty() )
429 QToolTip::add( combo, tooltiptext ); 429 QToolTip::add( combo, tooltiptext );
430 if ( size > 0 ) 430 if ( size > 0 )
431 combo->setMinimumWidth( size ); 431 combo->setMinimumWidth( size );
432 if (!tooltiptext.isNull()) 432 if (!tooltiptext.isNull())
433 QToolTip::add( combo, tooltiptext ); 433 QToolTip::add( combo, tooltiptext );
434 connect (combo, signal, receiver, slot); 434 connect (combo, signal, receiver, slot);
435 return index; 435 return index;
436} 436}
437 437
438int KToolBar::insertSeparator(int index, int id) 438int KToolBar::insertSeparator(int index, int id)
439{ 439{
440 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" ); 440 QWidget *w = new KToolBarSeparator( orientation(), FALSE, this, "tool bar separator" );
441 insertWidgetInternal( w, index, id ); 441 insertWidgetInternal( w, index, id );
442 return index; 442 return index;
443} 443}
444 444
445int KToolBar::insertLineSeparator(int index, int id) 445int KToolBar::insertLineSeparator(int index, int id)
446{ 446{
447 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" ); 447 QWidget *w = new KToolBarSeparator( orientation(), TRUE, this, "tool bar separator" );
448 insertWidgetInternal( w, index, id ); 448 insertWidgetInternal( w, index, id );
449 return index; 449 return index;
450} 450}
451 451
452 452
453int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index) 453int KToolBar::insertWidget(int id, int /*width*/, QWidget *widget, int index)
454{ 454{
455 // removeWidgetInternal( widget ); // in case we already have it ? 455 // removeWidgetInternal( widget ); // in case we already have it ?
456 insertWidgetInternal( widget, index, id ); 456 insertWidgetInternal( widget, index, id );
457 return index; 457 return index;
458} 458}
459/*US 459/*US
460int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot, 460int KToolBar::insertAnimatedWidget(int id, QObject *receiver, const char *slot,
461 const QString& icons, int index ) 461 const QString& icons, int index )
462{ 462{
463 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this ); 463 KAnimWidget *anim = new KAnimWidget( icons, d->m_iconSize, this );
464 insertWidgetInternal( anim, index, id ); 464 insertWidgetInternal( anim, index, id );
465 465
466 if ( receiver ) 466 if ( receiver )
467 connect( anim, SIGNAL(clicked()), receiver, slot); 467 connect( anim, SIGNAL(clicked()), receiver, slot);
468 468
469 return index; 469 return index;
470} 470}
471 471
472KAnimWidget *KToolBar::animatedWidget( int id ) 472KAnimWidget *KToolBar::animatedWidget( int id )
473{ 473{
474 Id2WidgetMap::Iterator it = id2widget.find( id ); 474 Id2WidgetMap::Iterator it = id2widget.find( id );
475 if ( it == id2widget.end() ) 475 if ( it == id2widget.end() )
476 return 0; 476 return 0;
477 if ( (*it) && (*it)->inherits( "KAnimWidget" ) ) 477 if ( (*it) && (*it)->inherits( "KAnimWidget" ) )
478 return (KAnimWidget*)(*it); 478 return (KAnimWidget*)(*it);
479 QObjectList *l = queryList( "KAnimWidget" ); 479 QObjectList *l = queryList( "KAnimWidget" );
480 if ( !l || !l->first() ) { 480 if ( !l || !l->first() ) {
481 delete l; 481 delete l;
482 return 0; 482 return 0;
483 } 483 }
484 484
485 for ( QObject *o = l->first(); o; o = l->next() ) { 485 for ( QObject *o = l->first(); o; o = l->next() ) {
486 if ( o->inherits( "KAnimWidget" ) ) 486 if ( o->inherits( "KAnimWidget" ) )
487 { 487 {
488 delete l; 488 delete l;
489 return (KAnimWidget*)o; 489 return (KAnimWidget*)o;
490 } 490 }
491 } 491 }
492 492
493 delete l; 493 delete l;
494 return 0; 494 return 0;
495} 495}
496*/ 496*/
497 497
498void KToolBar::addConnection (int id, const char *signal, 498void KToolBar::addConnection (int id, const char *signal,
499 const QObject *receiver, const char *slot) 499 const QObject *receiver, const char *slot)
500{ 500{
501 Id2WidgetMap::Iterator it = id2widget.find( id ); 501 Id2WidgetMap::Iterator it = id2widget.find( id );
502 if ( it == id2widget.end() ) 502 if ( it == id2widget.end() )
503 return; 503 return;
504 if ( (*it) ) 504 if ( (*it) )
505 connect( (*it), signal, receiver, slot ); 505 connect( (*it), signal, receiver, slot );
506} 506}
507 507
508void KToolBar::setItemEnabled( int id, bool enabled ) 508void KToolBar::setItemEnabled( int id, bool enabled )
509{ 509{
510 Id2WidgetMap::Iterator it = id2widget.find( id ); 510 Id2WidgetMap::Iterator it = id2widget.find( id );
511 if ( it == id2widget.end() ) 511 if ( it == id2widget.end() )
512 return; 512 return;
513 if ( (*it) ) 513 if ( (*it) )
514 (*it)->setEnabled( enabled ); 514 (*it)->setEnabled( enabled );
515} 515}
516 516
517 517
518void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap ) 518void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap )
519{ 519{
520 Id2WidgetMap::Iterator it = id2widget.find( id ); 520 Id2WidgetMap::Iterator it = id2widget.find( id );
521 if ( it == id2widget.end() ) 521 if ( it == id2widget.end() )
522 return; 522 return;
523//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 523//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
524 KToolBarButton * button = (KToolBarButton *)( *it ); 524 KToolBarButton * button = (KToolBarButton *)( *it );
525 if ( button ) 525 if ( button )
526 button->setPixmap( _pixmap ); 526 button->setPixmap( _pixmap );
527} 527}
528 528
529 529
530void KToolBar::setButtonIcon( int id, const QString& _icon ) 530void KToolBar::setButtonIcon( int id, const QString& _icon )
531{ 531{
532 Id2WidgetMap::Iterator it = id2widget.find( id ); 532 Id2WidgetMap::Iterator it = id2widget.find( id );
533 if ( it == id2widget.end() ) 533 if ( it == id2widget.end() )
534 return; 534 return;
535//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 535//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
536 KToolBarButton * button = (KToolBarButton *)( *it ); 536 KToolBarButton * button = (KToolBarButton *)( *it );
537 if ( button ) 537 if ( button )
538 button->setIcon( _icon ); 538 button->setIcon( _icon );
539} 539}
540 540
541void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) 541void KToolBar::setButtonIconSet( int id, const QIconSet& iconset )
542{ 542{
543 Id2WidgetMap::Iterator it = id2widget.find( id ); 543 Id2WidgetMap::Iterator it = id2widget.find( id );
544 if ( it == id2widget.end() ) 544 if ( it == id2widget.end() )
545 return; 545 return;
546//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 546//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
547 KToolBarButton * button = (KToolBarButton *)( *it ); 547 KToolBarButton * button = (KToolBarButton *)( *it );
548 if ( button ) 548 if ( button )
549 button->setIconSet( iconset ); 549 button->setIconSet( iconset );
550} 550}
551 551
552 552
553void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) 553void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle )
554{ 554{
555 Id2WidgetMap::Iterator it = id2widget.find( id ); 555 Id2WidgetMap::Iterator it = id2widget.find( id );
556 if ( it == id2widget.end() ) 556 if ( it == id2widget.end() )
557 return; 557 return;
558//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 558//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
559 KToolBarButton * button = (KToolBarButton *)( *it ); 559 KToolBarButton * button = (KToolBarButton *)( *it );
560 if ( button ) 560 if ( button )
561 button->setDelayedPopup( _popup, toggle ); 561 button->setDelayedPopup( _popup, toggle );
562} 562}
563 563
564 564
565void KToolBar::setAutoRepeat (int id, bool flag) 565void KToolBar::setAutoRepeat (int id, bool flag)
566{ 566{
567 Id2WidgetMap::Iterator it = id2widget.find( id ); 567 Id2WidgetMap::Iterator it = id2widget.find( id );
568 if ( it == id2widget.end() ) 568 if ( it == id2widget.end() )
569 return; 569 return;
570//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 570//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
571 KToolBarButton * button = (KToolBarButton *)( *it ); 571 KToolBarButton * button = (KToolBarButton *)( *it );
572 if ( button ) 572 if ( button )
573 button->setAutoRepeat( flag ); 573 button->setAutoRepeat( flag );
574} 574}
575 575
576 576
577void KToolBar::setToggle (int id, bool flag ) 577void KToolBar::setToggle (int id, bool flag )
578{ 578{
579 Id2WidgetMap::Iterator it = id2widget.find( id ); 579 Id2WidgetMap::Iterator it = id2widget.find( id );
580 if ( it == id2widget.end() ) 580 if ( it == id2widget.end() )
581 return; 581 return;
582//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 582//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
583 KToolBarButton * button = (KToolBarButton *)( *it ); 583 KToolBarButton * button = (KToolBarButton *)( *it );
584 if ( button ) 584 if ( button )
585 button->setToggle( flag ); 585 button->setToggle( flag );
586} 586}
587 587
588 588
589void KToolBar::toggleButton (int id) 589void KToolBar::toggleButton (int id)
590{ 590{
591 Id2WidgetMap::Iterator it = id2widget.find( id ); 591 Id2WidgetMap::Iterator it = id2widget.find( id );
592 if ( it == id2widget.end() ) 592 if ( it == id2widget.end() )
593 return; 593 return;
594//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 594//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
595 KToolBarButton * button = (KToolBarButton *)( *it ); 595 KToolBarButton * button = (KToolBarButton *)( *it );
596 if ( button ) 596 if ( button )
597 button->toggle(); 597 button->toggle();
598} 598}
599 599
600 600
601void KToolBar::setButton (int id, bool flag) 601void KToolBar::setButton (int id, bool flag)
602{ 602{
603 Id2WidgetMap::Iterator it = id2widget.find( id ); 603 Id2WidgetMap::Iterator it = id2widget.find( id );
604 if ( it == id2widget.end() ) 604 if ( it == id2widget.end() )
605 return; 605 return;
606//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 606//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
607 KToolBarButton * button = (KToolBarButton *)( *it ); 607 KToolBarButton * button = (KToolBarButton *)( *it );
608 if ( button ) 608 if ( button )
609 button->on( flag ); 609 button->on( flag );
610} 610}
611 611
612 612
613bool KToolBar::isButtonOn (int id) const 613bool KToolBar::isButtonOn (int id) const
614{ 614{
615 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 615 Id2WidgetMap::ConstIterator it = id2widget.find( id );
616 if ( it == id2widget.end() ) 616 if ( it == id2widget.end() )
617 return false; 617 return false;
618//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 618//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
619 KToolBarButton * button = (KToolBarButton *)( *it ); 619 KToolBarButton * button = (KToolBarButton *)( *it );
620 return button ? button->isOn() : false; 620 return button ? button->isOn() : false;
621} 621}
622 622
623 623
624void KToolBar::setLinedText (int id, const QString& text) 624void KToolBar::setLinedText (int id, const QString& text)
625{ 625{
626 Id2WidgetMap::Iterator it = id2widget.find( id ); 626 Id2WidgetMap::Iterator it = id2widget.find( id );
627 if ( it == id2widget.end() ) 627 if ( it == id2widget.end() )
628 return; 628 return;
629//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 629//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
630 QLineEdit * lineEdit = (QLineEdit *)( *it ); 630 QLineEdit * lineEdit = (QLineEdit *)( *it );
631 if ( lineEdit ) 631 if ( lineEdit )
632 lineEdit->setText( text ); 632 lineEdit->setText( text );
633} 633}
634 634
635 635
636QString KToolBar::getLinedText (int id) const 636QString KToolBar::getLinedText (int id) const
637{ 637{
638 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 638 Id2WidgetMap::ConstIterator it = id2widget.find( id );
639 if ( it == id2widget.end() ) 639 if ( it == id2widget.end() )
640 return QString::null; 640 return QString::null;
641//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it ); 641//US QLineEdit * lineEdit = dynamic_cast<QLineEdit *>( *it );
642 QLineEdit * lineEdit = (QLineEdit *)( *it ); 642 QLineEdit * lineEdit = (QLineEdit *)( *it );
643 return lineEdit ? lineEdit->text() : QString::null; 643 return lineEdit ? lineEdit->text() : QString::null;
644} 644}
645 645
646 646
647void KToolBar::insertComboItem (int id, const QString& text, int index) 647void KToolBar::insertComboItem (int id, const QString& text, int index)
648{ 648{
649 Id2WidgetMap::Iterator it = id2widget.find( id ); 649 Id2WidgetMap::Iterator it = id2widget.find( id );
650 if ( it == id2widget.end() ) 650 if ( it == id2widget.end() )
651 return; 651 return;
652//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 652//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
653 QComboBox * comboBox = (QComboBox *)( *it ); 653 QComboBox * comboBox = (QComboBox *)( *it );
654 if (comboBox) 654 if (comboBox)
655 comboBox->insertItem( text, index ); 655 comboBox->insertItem( text, index );
656} 656}
657 657
658void KToolBar::insertComboList (int id, const QStringList &list, int index) 658void KToolBar::insertComboList (int id, const QStringList &list, int index)
659{ 659{
660 Id2WidgetMap::Iterator it = id2widget.find( id ); 660 Id2WidgetMap::Iterator it = id2widget.find( id );
661 if ( it == id2widget.end() ) 661 if ( it == id2widget.end() )
662 return; 662 return;
663//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 663//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
664 QComboBox * comboBox = (QComboBox *)( *it ); 664 QComboBox * comboBox = (QComboBox *)( *it );
665 if (comboBox) 665 if (comboBox)
666 comboBox->insertStringList( list, index ); 666 comboBox->insertStringList( list, index );
667} 667}
668 668
669 669
670void KToolBar::removeComboItem (int id, int index) 670void KToolBar::removeComboItem (int id, int index)
671{ 671{
672 Id2WidgetMap::Iterator it = id2widget.find( id ); 672 Id2WidgetMap::Iterator it = id2widget.find( id );
673 if ( it == id2widget.end() ) 673 if ( it == id2widget.end() )
674 return; 674 return;
675//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 675//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
676 QComboBox * comboBox = (QComboBox *)( *it ); 676 QComboBox * comboBox = (QComboBox *)( *it );
677 if (comboBox) 677 if (comboBox)
678 comboBox->removeItem( index ); 678 comboBox->removeItem( index );
679} 679}
680 680
681 681
682void KToolBar::setCurrentComboItem (int id, int index) 682void KToolBar::setCurrentComboItem (int id, int index)
683{ 683{
684 Id2WidgetMap::Iterator it = id2widget.find( id ); 684 Id2WidgetMap::Iterator it = id2widget.find( id );
685 if ( it == id2widget.end() ) 685 if ( it == id2widget.end() )
686 return; 686 return;
687//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 687//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
688 QComboBox * comboBox = (QComboBox *)( *it ); 688 QComboBox * comboBox = (QComboBox *)( *it );
689 if (comboBox) 689 if (comboBox)
690 comboBox->setCurrentItem( index ); 690 comboBox->setCurrentItem( index );
691} 691}
692 692
693 693
694void KToolBar::changeComboItem (int id, const QString& text, int index) 694void KToolBar::changeComboItem (int id, const QString& text, int index)
695{ 695{
696 Id2WidgetMap::Iterator it = id2widget.find( id ); 696 Id2WidgetMap::Iterator it = id2widget.find( id );
697 if ( it == id2widget.end() ) 697 if ( it == id2widget.end() )
698 return; 698 return;
699//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 699//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
700 QComboBox * comboBox = (QComboBox *)( *it ); 700 QComboBox * comboBox = (QComboBox *)( *it );
701 if (comboBox) 701 if (comboBox)
702 comboBox->changeItem( text, index ); 702 comboBox->changeItem( text, index );
703} 703}
704 704
705 705
706void KToolBar::clearCombo (int id) 706void KToolBar::clearCombo (int id)
707{ 707{
708 Id2WidgetMap::Iterator it = id2widget.find( id ); 708 Id2WidgetMap::Iterator it = id2widget.find( id );
709 if ( it == id2widget.end() ) 709 if ( it == id2widget.end() )
710 return; 710 return;
711//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 711//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
712 QComboBox * comboBox = (QComboBox *)( *it ); 712 QComboBox * comboBox = (QComboBox *)( *it );
713 if (comboBox) 713 if (comboBox)
714 comboBox->clear(); 714 comboBox->clear();
715} 715}
716 716
717 717
718QString KToolBar::getComboItem (int id, int index) const 718QString KToolBar::getComboItem (int id, int index) const
719{ 719{
720 Id2WidgetMap::ConstIterator it = id2widget.find( id ); 720 Id2WidgetMap::ConstIterator it = id2widget.find( id );
721 if ( it == id2widget.end() ) 721 if ( it == id2widget.end() )
722 return QString::null; 722 return QString::null;
723//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it ); 723//US QComboBox * comboBox = dynamic_cast<QComboBox *>( *it );
724 QComboBox * comboBox = (QComboBox *)( *it ); 724 QComboBox * comboBox = (QComboBox *)( *it );
725 return comboBox ? comboBox->text( index ) : QString::null; 725 return comboBox ? comboBox->text( index ) : QString::null;
726} 726}
727 727
728 728
729KComboBox * KToolBar::getCombo(int id) 729KComboBox * KToolBar::getCombo(int id)
730{ 730{
731 Id2WidgetMap::Iterator it = id2widget.find( id ); 731 Id2WidgetMap::Iterator it = id2widget.find( id );
732 if ( it == id2widget.end() ) 732 if ( it == id2widget.end() )
733 return 0; 733 return 0;
734//US return dynamic_cast<KComboBox *>( *it ); 734//US return dynamic_cast<KComboBox *>( *it );
735 return (KComboBox *)( *it ); 735 return (KComboBox *)( *it );
736} 736}
737 737
738 738
739KLineEdit * KToolBar::getLined (int id) 739KLineEdit * KToolBar::getLined (int id)
740{ 740{
741 Id2WidgetMap::Iterator it = id2widget.find( id ); 741 Id2WidgetMap::Iterator it = id2widget.find( id );
742 if ( it == id2widget.end() ) 742 if ( it == id2widget.end() )
743 return 0; 743 return 0;
744//US return dynamic_cast<KLineEdit *>( *it ); 744//US return dynamic_cast<KLineEdit *>( *it );
745 return (KLineEdit *)( *it ); 745 return (KLineEdit *)( *it );
746} 746}
747 747
748 748
749KToolBarButton * KToolBar::getButton (int id) 749KToolBarButton * KToolBar::getButton (int id)
750{ 750{
751 Id2WidgetMap::Iterator it = id2widget.find( id ); 751 Id2WidgetMap::Iterator it = id2widget.find( id );
752 if ( it == id2widget.end() ) 752 if ( it == id2widget.end() )
753 return 0; 753 return 0;
754//US return dynamic_cast<KToolBarButton *>( *it ); 754//US return dynamic_cast<KToolBarButton *>( *it );
755 return (KToolBarButton *)( *it ); 755 return (KToolBarButton *)( *it );
756} 756}
757 757
758 758
759void KToolBar::alignItemRight (int id, bool right ) 759void KToolBar::alignItemRight (int id, bool right )
760{ 760{
761 Id2WidgetMap::Iterator it = id2widget.find( id ); 761 Id2WidgetMap::Iterator it = id2widget.find( id );
762 if ( it == id2widget.end() ) 762 if ( it == id2widget.end() )
763 return; 763 return;
764 if ( rightAligned && !right && (*it) == rightAligned ) 764 if ( rightAligned && !right && (*it) == rightAligned )
765 rightAligned = 0; 765 rightAligned = 0;
766 if ( (*it) && right ) 766 if ( (*it) && right )
767 rightAligned = (*it); 767 rightAligned = (*it);
768} 768}
769 769
770 770
771QWidget *KToolBar::getWidget (int id) 771QWidget *KToolBar::getWidget (int id)
772{ 772{
773 Id2WidgetMap::Iterator it = id2widget.find( id ); 773 Id2WidgetMap::Iterator it = id2widget.find( id );
774 return ( it == id2widget.end() ) ? 0 : (*it); 774 return ( it == id2widget.end() ) ? 0 : (*it);
775} 775}
776 776
777 777
778void KToolBar::setItemAutoSized (int id, bool yes ) 778void KToolBar::setItemAutoSized (int id, bool yes )
779{ 779{
780 QWidget *w = getWidget(id); 780 QWidget *w = getWidget(id);
781 if ( w && yes ) 781 if ( w && yes )
782 setStretchableWidget( w ); 782 setStretchableWidget( w );
783} 783}
784 784
785 785
786void KToolBar::clear () 786void KToolBar::clear ()
787{ 787{
788 QToolBar::clear(); 788 QToolBar::clear();
789 widget2id.clear(); 789 widget2id.clear();
790 id2widget.clear(); 790 id2widget.clear();
791} 791}
792 792
793 793
794void KToolBar::removeItem(int id) 794void KToolBar::removeItem(int id)
795{ 795{
796 Id2WidgetMap::Iterator it = id2widget.find( id ); 796 Id2WidgetMap::Iterator it = id2widget.find( id );
797 if ( it == id2widget.end() ) 797 if ( it == id2widget.end() )
798 { 798 {
799 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 799 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
800 return; 800 return;
801 } 801 }
802 QWidget * w = (*it); 802 QWidget * w = (*it);
803 id2widget.remove( id ); 803 id2widget.remove( id );
804 widget2id.remove( w ); 804 widget2id.remove( w );
805 widgets.removeRef( w ); 805 widgets.removeRef( w );
806 delete w; 806 delete w;
807} 807}
808 808
809 809
810void KToolBar::removeItemDelayed(int id) 810void KToolBar::removeItemDelayed(int id)
811{ 811{
812 Id2WidgetMap::Iterator it = id2widget.find( id ); 812 Id2WidgetMap::Iterator it = id2widget.find( id );
813 if ( it == id2widget.end() ) 813 if ( it == id2widget.end() )
814 { 814 {
815 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl; 815 kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
816 return; 816 return;
817 } 817 }
818 QWidget * w = (*it); 818 QWidget * w = (*it);
819 id2widget.remove( id ); 819 id2widget.remove( id );
820 widget2id.remove( w ); 820 widget2id.remove( w );
821 widgets.removeRef( w ); 821 widgets.removeRef( w );
822 822
823 w->blockSignals(true); 823 w->blockSignals(true);
824 d->idleButtons.append(w); 824 d->idleButtons.append(w);
825 layoutTimer->start( 50, TRUE ); 825 layoutTimer->start( 50, TRUE );
826} 826}
827 827
828 828
829void KToolBar::hideItem (int id) 829void KToolBar::hideItem (int id)
830{ 830{
831 QWidget *w = getWidget(id); 831 QWidget *w = getWidget(id);
832 if ( w ) 832 if ( w )
833 w->hide(); 833 w->hide();
834} 834}
835 835
836 836
837void KToolBar::showItem (int id) 837void KToolBar::showItem (int id)
838{ 838{
839 QWidget *w = getWidget(id); 839 QWidget *w = getWidget(id);
840 if ( w ) 840 if ( w )
841 w->show(); 841 w->show();
842} 842}
843 843
844 844
845int KToolBar::itemIndex (int id) 845int KToolBar::itemIndex (int id)
846{ 846{
847 QWidget *w = getWidget(id); 847 QWidget *w = getWidget(id);
848 return w ? widgets.findRef(w) : -1; 848 return w ? widgets.findRef(w) : -1;
849} 849}
850 850
851 851
852void KToolBar::setFullSize(bool flag ) 852void KToolBar::setFullSize(bool flag )
853{ 853{
854 setHorizontalStretchable( flag ); 854 setHorizontalStretchable( flag );
855 setVerticalStretchable( flag ); 855 setVerticalStretchable( flag );
856} 856}
857 857
858 858
859bool KToolBar::fullSize() const 859bool KToolBar::fullSize() const
860{ 860{
861 return isHorizontalStretchable() || isVerticalStretchable(); 861 return isHorizontalStretchable() || isVerticalStretchable();
862} 862}
863 863
864 864
865void KToolBar::enableMoving(bool flag ) 865void KToolBar::enableMoving(bool flag )
866{ 866{
867//US setMovingEnabled(flag); 867//US setMovingEnabled(flag);
868 this->mainWindow()->setToolBarsMovable(flag); 868 this->mainWindow()->setToolBarsMovable(flag);
869} 869}
870 870
871 871
872void KToolBar::setBarPos (BarPosition bpos) 872void KToolBar::setBarPos (BarPosition bpos)
873{ 873{
874 if ( !mainWindow() ) 874 if ( !mainWindow() )
875 return; 875 return;
876//US mainWindow()->moveDockWindow( this, (Dock)bpos ); 876//US mainWindow()->moveDockWindow( this, (Dock)bpos );
877 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); 877 mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos );
878} 878}
879 879
880 880
881KToolBar::BarPosition KToolBar::barPos() 881KToolBar::BarPosition KToolBar::barPos() const
882{ 882{
883 if ( !(QMainWindow*)mainWindow() ) 883 if ( !(QMainWindow*)mainWindow() )
884 return KToolBar::Top; 884 return KToolBar::Top;
885//US Dock dock; 885//US Dock dock;
886 QMainWindow::ToolBarDock dock; 886 QMainWindow::ToolBarDock dock;
887 int dm1, dm2; 887 int dm1, dm2;
888 bool dm3; 888 bool dm3;
889 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); 889 ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 );
890//US if ( dock == DockUnmanaged ) { 890//US if ( dock == DockUnmanaged ) {
891 if ( dock == QMainWindow::Unmanaged ) { 891 if ( dock == QMainWindow::Unmanaged ) {
892 return (KToolBar::BarPosition)Top; 892 return (KToolBar::BarPosition)Top;
893 } 893 }
894 return (BarPosition)dock; 894 return (BarPosition)dock;
895} 895}
896 896
897 897
898bool KToolBar::enable(BarStatus stat) 898bool KToolBar::enable(BarStatus stat)
899{ 899{
900 bool mystat = isVisible(); 900 bool mystat = isVisible();
901 901
902 if ( (stat == Toggle && mystat) || stat == Hide ) 902 if ( (stat == Toggle && mystat) || stat == Hide )
903 hide(); 903 hide();
904 else 904 else
905 show(); 905 show();
906 906
907 return isVisible() == mystat; 907 return isVisible() == mystat;
908} 908}
909 909
910 910
911void KToolBar::setMaxHeight ( int h ) 911void KToolBar::setMaxHeight ( int h )
912{ 912{
913 setMaximumHeight( h ); 913 setMaximumHeight( h );
914} 914}
915 915
916int KToolBar::maxHeight() 916int KToolBar::maxHeight()
917{ 917{
918 return maximumHeight(); 918 return maximumHeight();
919} 919}
920 920
921 921
922void KToolBar::setMaxWidth (int dw) 922void KToolBar::setMaxWidth (int dw)
923{ 923{
924 setMaximumWidth( dw ); 924 setMaximumWidth( dw );
925} 925}
926 926
927 927
928int KToolBar::maxWidth() 928int KToolBar::maxWidth()
929{ 929{
930 return maximumWidth(); 930 return maximumWidth();
931} 931}
932 932
933 933
934void KToolBar::setTitle (const QString& _title) 934void KToolBar::setTitle (const QString& _title)
935{ 935{
936 setLabel( _title ); 936 setLabel( _title );
937} 937}
938 938
939 939
940void KToolBar::enableFloating (bool ) 940void KToolBar::enableFloating (bool )
941{ 941{
942} 942}
943 943
944 944
945void KToolBar::setIconText(IconText it) 945void KToolBar::setIconText(IconText it)
946{ 946{
947 setIconText( it, true ); 947 setIconText( it, true );
948} 948}
949 949
950 950
951void KToolBar::setIconText(IconText icontext, bool update) 951void KToolBar::setIconText(IconText icontext, bool update)
952{ 952{
953 bool doUpdate=false; 953 bool doUpdate=false;
954 954
955 if (icontext != d->m_iconText) { 955 if (icontext != d->m_iconText) {
956 d->m_iconText = icontext; 956 d->m_iconText = icontext;
957 doUpdate=true; 957 doUpdate=true;
958 } 958 }
959 959
960 if (update == false) 960 if (update == false)
961 return; 961 return;
962 962
963 if (doUpdate) 963 if (doUpdate)
964 emit modechange(); // tell buttons what happened 964 emit modechange(); // tell buttons what happened
965 965
966 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 966 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
967 if ( mainWindow() ) { 967 if ( mainWindow() ) {
968 QMainWindow *mw = mainWindow(); 968 QMainWindow *mw = mainWindow();
969 mw->setUpdatesEnabled( FALSE ); 969 mw->setUpdatesEnabled( FALSE );
970 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 970 mw->setToolBarsMovable( !mw->toolBarsMovable() );
971 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 971 mw->setToolBarsMovable( !mw->toolBarsMovable() );
972 mw->setUpdatesEnabled( TRUE ); 972 mw->setUpdatesEnabled( TRUE );
973 } 973 }
974} 974}
975 975
976 976
977KToolBar::IconText KToolBar::iconText() const 977KToolBar::IconText KToolBar::iconText() const
978{ 978{
979 return d->m_iconText; 979 return d->m_iconText;
980} 980}
981 981
982 982
983void KToolBar::setIconSize(int size) 983void KToolBar::setIconSize(int size)
984{ 984{
985 setIconSize( size, true ); 985 setIconSize( size, true );
986} 986}
987 987
988void KToolBar::setIconSize(int size, bool update) 988void KToolBar::setIconSize(int size, bool update)
989{ 989{
990 bool doUpdate=false; 990 bool doUpdate=false;
991 991
992 if ( size != d->m_iconSize ) { 992 if ( size != d->m_iconSize ) {
993 d->m_iconSize = size; 993 d->m_iconSize = size;
994 doUpdate=true; 994 doUpdate=true;
995 } 995 }
996 996
997 if (update == false) 997 if (update == false)
998 return; 998 return;
999 999
1000 if (doUpdate) 1000 if (doUpdate)
1001 emit modechange(); // tell buttons what happened 1001 emit modechange(); // tell buttons what happened
1002 1002
1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE ) 1003 // ugly hack to force a QMainWindow::triggerLayout( TRUE )
1004 if ( mainWindow() ) { 1004 if ( mainWindow() ) {
1005 QMainWindow *mw = mainWindow(); 1005 QMainWindow *mw = mainWindow();
1006 mw->setUpdatesEnabled( FALSE ); 1006 mw->setUpdatesEnabled( FALSE );
1007 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1007 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1008 mw->setToolBarsMovable( !mw->toolBarsMovable() ); 1008 mw->setToolBarsMovable( !mw->toolBarsMovable() );
1009 mw->setUpdatesEnabled( TRUE ); 1009 mw->setUpdatesEnabled( TRUE );
1010 } 1010 }
1011} 1011}
1012 1012
1013 1013
1014int KToolBar::iconSize() const 1014int KToolBar::iconSize() const
1015{ 1015{
1016/*US 1016/*US
1017 if ( !d->m_iconSize ) // default value? 1017 if ( !d->m_iconSize ) // default value?
1018 { 1018 {
1019 if (!::qstrcmp(QObject::name(), "mainToolBar")) 1019 if (!::qstrcmp(QObject::name(), "mainToolBar"))
1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar); 1020 return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar);
1021 else 1021 else
1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar); 1022 return KGlobal::iconLoader()->currentSize(KIcon::Toolbar);
1023 } 1023 }
1024 return d->m_iconSize; 1024 return d->m_iconSize;
1025*/ 1025*/
1026 int ret = 18; 1026 int ret = 18;
1027 if ( QApplication::desktop()->width() > 320 ) 1027 if ( QApplication::desktop()->width() > 320 )
1028 ret = 30; 1028 ret = 30;
1029 return ret; 1029 return ret;
1030} 1030}
1031 1031
1032 1032
1033void KToolBar::setEnableContextMenu(bool enable ) 1033void KToolBar::setEnableContextMenu(bool enable )
1034{ 1034{
1035 d->m_enableContext = enable; 1035 d->m_enableContext = enable;
1036} 1036}
1037 1037
1038 1038
1039bool KToolBar::contextMenuEnabled() const 1039bool KToolBar::contextMenuEnabled() const
1040{ 1040{
1041 return d->m_enableContext; 1041 return d->m_enableContext;
1042} 1042}
1043 1043
1044 1044
1045void KToolBar::setItemNoStyle(int id, bool no_style ) 1045void KToolBar::setItemNoStyle(int id, bool no_style )
1046{ 1046{
1047 Id2WidgetMap::Iterator it = id2widget.find( id ); 1047 Id2WidgetMap::Iterator it = id2widget.find( id );
1048 if ( it == id2widget.end() ) 1048 if ( it == id2widget.end() )
1049 return; 1049 return;
1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it ); 1050//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
1051 KToolBarButton * button = (KToolBarButton *)( *it ); 1051 KToolBarButton * button = (KToolBarButton *)( *it );
1052 if (button) 1052 if (button)
1053 button->setNoStyle( no_style ); 1053 button->setNoStyle( no_style );
1054} 1054}
1055 1055
1056 1056
1057void KToolBar::setFlat (bool flag) 1057void KToolBar::setFlat (bool flag)
1058{ 1058{
1059 if ( !mainWindow() ) 1059 if ( !mainWindow() )
1060 return; 1060 return;
1061 if ( flag ) 1061 if ( flag )
1062//US mainWindow()->moveDockWindow( this, DockMinimized ); 1062//US mainWindow()->moveDockWindow( this, DockMinimized );
1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized ); 1063 mainWindow()->moveToolBar( this, QMainWindow::Minimized );
1064 else 1064 else
1065//US mainWindow()->moveDockWindow( this, DockTop ); 1065//US mainWindow()->moveDockWindow( this, DockTop );
1066 mainWindow()->moveToolBar( this, QMainWindow::Top ); 1066 mainWindow()->moveToolBar( this, QMainWindow::Top );
1067 // And remember to save the new look later 1067 // And remember to save the new look later
1068/*US 1068/*US
1069 if ( mainWindow()->inherits( "KMainWindow" ) ) 1069 if ( mainWindow()->inherits( "KMainWindow" ) )
1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); 1070 static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
1071*/ 1071*/
1072} 1072}
1073 1073
1074 1074
1075int KToolBar::count() const 1075int KToolBar::count() const
1076{ 1076{
1077 return id2widget.count(); 1077 return id2widget.count();
1078} 1078}
1079 1079
1080 1080
1081void KToolBar::saveState() 1081void KToolBar::saveState()
1082{ 1082{
1083/*US 1083/*US
1084 // first, try to save to the xml file 1084 // first, try to save to the xml file
1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) { 1085 if ( d->m_xmlguiClient && !d->m_xmlguiClient->xmlFile().isEmpty() ) {
1086 // go down one level to get to the right tags 1086 // go down one level to get to the right tags
1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement(); 1087 QDomElement elem = d->m_xmlguiClient->domDocument().documentElement().toElement();
1088 elem = elem.firstChild().toElement(); 1088 elem = elem.firstChild().toElement();
1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name()); 1089 QString barname(!::qstrcmp(name(), "unnamed") ? "mainToolBar" : name());
1090 QDomElement current; 1090 QDomElement current;
1091 // now try to find our toolbar 1091 // now try to find our toolbar
1092 d->modified = false; 1092 d->modified = false;
1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1093 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1094 current = elem; 1094 current = elem;
1095 1095
1096 if ( current.tagName().lower() != "toolbar" ) 1096 if ( current.tagName().lower() != "toolbar" )
1097 continue; 1097 continue;
1098 1098
1099 QString curname(current.attribute( "name" )); 1099 QString curname(current.attribute( "name" ));
1100 1100
1101 if ( curname == barname ) { 1101 if ( curname == barname ) {
1102 saveState( current ); 1102 saveState( current );
1103 break; 1103 break;
1104 } 1104 }
1105 } 1105 }
1106 // if we didn't make changes, then just return 1106 // if we didn't make changes, then just return
1107 if ( !d->modified ) 1107 if ( !d->modified )
1108 return; 1108 return;
1109 1109
1110 // now we load in the (non-merged) local file 1110 // now we load in the (non-merged) local file
1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance())); 1111 QString local_xml(KXMLGUIFactory::readConfigFile(d->m_xmlguiClient->xmlFile(), true, d->m_xmlguiClient->instance()));
1112 QDomDocument local; 1112 QDomDocument local;
1113 local.setContent(local_xml); 1113 local.setContent(local_xml);
1114 1114
1115 // make sure we don't append if this toolbar already exists locally 1115 // make sure we don't append if this toolbar already exists locally
1116 bool just_append = true; 1116 bool just_append = true;
1117 elem = local.documentElement().toElement(); 1117 elem = local.documentElement().toElement();
1118 KXMLGUIFactory::removeDOMComments( elem ); 1118 KXMLGUIFactory::removeDOMComments( elem );
1119 elem = elem.firstChild().toElement(); 1119 elem = elem.firstChild().toElement();
1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) { 1120 for( ; !elem.isNull(); elem = elem.nextSibling().toElement() ) {
1121 if ( elem.tagName().lower() != "toolbar" ) 1121 if ( elem.tagName().lower() != "toolbar" )
1122 continue; 1122 continue;
1123 1123
1124 QString curname(elem.attribute( "name" )); 1124 QString curname(elem.attribute( "name" ));
1125 1125
1126 if ( curname == barname ) { 1126 if ( curname == barname ) {
1127 just_append = false; 1127 just_append = false;
1128 local.documentElement().replaceChild( current, elem ); 1128 local.documentElement().replaceChild( current, elem );
1129 break; 1129 break;
1130 } 1130 }
1131 } 1131 }
1132 1132
1133 if (just_append) 1133 if (just_append)
1134 local.documentElement().appendChild( current ); 1134 local.documentElement().appendChild( current );
1135 1135
1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() ); 1136 KXMLGUIFactory::saveConfigFile(local, d->m_xmlguiClient->localXMLFile(), d->m_xmlguiClient->instance() );
1137 1137
1138 return; 1138 return;
1139 } 1139 }
1140*/ 1140*/
1141 // if that didn't work, we save to the config file 1141 // if that didn't work, we save to the config file
1142 KConfig *config = KGlobal::config(); 1142 KConfig *config = KGlobal::config();
1143 saveSettings(config, QString::null); 1143 saveSettings(config, QString::null);
1144 config->sync(); 1144 config->sync();
1145} 1145}
1146 1146
1147QString KToolBar::settingsGroup() 1147QString KToolBar::settingsGroup()
1148{ 1148{
1149 QString configGroup; 1149 QString configGroup;
1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar")) 1150 if (!::qstrcmp(name(), "unnamed") || !::qstrcmp(name(), "mainToolBar"))
1151 configGroup = "Toolbar style"; 1151 configGroup = "Toolbar style";
1152 else 1152 else
1153 configGroup = QString(name()) + " Toolbar style"; 1153 configGroup = QString(name()) + " Toolbar style";
1154 if ( this->mainWindow() ) 1154 if ( this->mainWindow() )
1155 { 1155 {
1156 configGroup.prepend(" "); 1156 configGroup.prepend(" ");
1157 configGroup.prepend( this->mainWindow()->name() ); 1157 configGroup.prepend( this->mainWindow()->name() );
1158 } 1158 }
1159 return configGroup; 1159 return configGroup;
1160} 1160}
1161 1161
1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup) 1162void KToolBar::saveSettings(KConfig *config, const QString &_configGroup)
1163{ 1163{
1164 QString configGroup = _configGroup; 1164 QString configGroup = _configGroup;
1165 if (configGroup.isEmpty()) 1165 if (configGroup.isEmpty())
1166 configGroup = settingsGroup(); 1166 configGroup = settingsGroup();
1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl; 1167 //kdDebug(220) << "KToolBar::saveSettings group=" << _configGroup << " -> " << configGroup << endl;
1168 1168
1169 QString position, icontext; 1169 QString position, icontext;
1170 int index; 1170 int index;
1171 getAttributes( position, icontext, index ); 1171 getAttributes( position, icontext, index );
1172 1172
1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl; 1173 //kdDebug(220) << "KToolBar::saveSettings " << name() << " newLine=" << newLine << endl;
1174 1174
1175 KConfigGroupSaver saver(config, configGroup); 1175 KConfigGroupSaver saver(config, configGroup);
1176 1176
1177 if ( position != d->PositionDefault ) 1177 if ( position != d->PositionDefault )
1178 config->writeEntry("Position", position); 1178 config->writeEntry("Position", position);
1179 else 1179 else
1180 config->deleteEntry("Position"); 1180 config->deleteEntry("Position");
1181 1181
1182 if ( icontext != d->IconTextDefault ) 1182 if ( icontext != d->IconTextDefault )
1183 config->writeEntry("IconText", icontext); 1183 config->writeEntry("IconText", icontext);
1184 else 1184 else
1185 config->deleteEntry("IconText"); 1185 config->deleteEntry("IconText");
1186 1186
1187 if ( iconSize() != d->IconSizeDefault ) 1187 if ( iconSize() != d->IconSizeDefault )
1188 config->writeEntry("IconSize", iconSize()); 1188 config->writeEntry("IconSize", iconSize());
1189 else 1189 else
1190 config->deleteEntry("IconSize"); 1190 config->deleteEntry("IconSize");
1191 1191
1192 if ( isHidden() != d->HiddenDefault ) 1192 if ( isHidden() != d->HiddenDefault )
1193 config->writeEntry("Hidden", isHidden()); 1193 config->writeEntry("Hidden", isHidden());
1194 else 1194 else
1195 config->deleteEntry("Hidden"); 1195 config->deleteEntry("Hidden");
1196 1196
1197 if ( index != d->IndexDefault ) 1197 if ( index != d->IndexDefault )
1198 config->writeEntry( "Index", index ); 1198 config->writeEntry( "Index", index );
1199 else 1199 else
1200 config->deleteEntry("Index"); 1200 config->deleteEntry("Index");
1201//US the older version of KDE (used on the Zaurus) has no Offset property 1201//US the older version of KDE (used on the Zaurus) has no Offset property
1202/* if ( offset() != d->OffsetDefault ) 1202/* if ( offset() != d->OffsetDefault )
1203 config->writeEntry( "Offset", offset() ); 1203 config->writeEntry( "Offset", offset() );
1204 else 1204 else
1205*/ 1205*/
1206 config->deleteEntry("Offset"); 1206 config->deleteEntry("Offset");
1207 1207
1208//US the older version of KDE (used on the Zaurus) has no NewLine property 1208//US the older version of KDE (used on the Zaurus) has no NewLine property
1209/* 1209/*
1210 if ( newLine() != d->NewLineDefault ) 1210 if ( newLine() != d->NewLineDefault )
1211 config->writeEntry( "NewLine", newLine() ); 1211 config->writeEntry( "NewLine", newLine() );
1212 else 1212 else
1213*/ 1213*/
1214 config->deleteEntry("NewLine"); 1214 config->deleteEntry("NewLine");
1215} 1215}
1216 1216
1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client ) 1217void KToolBar::setXMLGUIClient( KXMLGUIClient *client )
1218{ 1218{
1219 d->m_xmlguiClient = client; 1219 d->m_xmlguiClient = client;
1220} 1220}
1221 1221
1222void KToolBar::setText( const QString & txt ) 1222void KToolBar::setText( const QString & txt )
1223{ 1223{
1224//US setLabel( txt + " ( " + kapp->caption() + " ) " ); 1224//US setLabel( txt + " ( " + kapp->caption() + " ) " );
1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " ); 1225 setLabel( txt + " ( " + KGlobal::getAppName() + " ) " );
1226} 1226}
1227 1227
1228 1228
1229QString KToolBar::text() const 1229QString KToolBar::text() const
1230{ 1230{
1231 return label(); 1231 return label();
1232} 1232}
1233 1233
1234 1234
1235void KToolBar::doConnections( KToolBarButton *button ) 1235void KToolBar::doConnections( KToolBarButton *button )
1236{ 1236{
1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) ); 1237 connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) ); 1238 connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) ); 1239 connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) ); 1240 connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) ); 1241 connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) ); 1242 connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
1243} 1243}
1244 1244
1245void KToolBar::mousePressEvent ( QMouseEvent *m ) 1245void KToolBar::mousePressEvent ( QMouseEvent *m )
1246{ 1246{
1247 if ( !mainWindow() ) 1247 if ( !mainWindow() )
1248 return; 1248 return;
1249 QMainWindow *mw = mainWindow(); 1249 QMainWindow *mw = mainWindow();
1250 if ( mw->toolBarsMovable() && d->m_enableContext ) { 1250 if ( mw->toolBarsMovable() && d->m_enableContext ) {
1251 if ( m->button() == RightButton ) { 1251 if ( m->button() == RightButton ) {
1252 int i = contextMenu()->exec( m->globalPos(), 0 ); 1252 int i = contextMenu()->exec( m->globalPos(), 0 );
1253 switch ( i ) { 1253 switch ( i ) {
1254 case -1: 1254 case -1:
1255 return; // popup cancelled 1255 return; // popup cancelled
1256 case CONTEXT_LEFT: 1256 case CONTEXT_LEFT:
1257//US mw->moveDockWindow( this, DockLeft ); 1257//US mw->moveDockWindow( this, DockLeft );
1258 mw->moveToolBar( this, QMainWindow::Left ); 1258 mw->moveToolBar( this, QMainWindow::Left );
1259 break; 1259 break;
1260 case CONTEXT_RIGHT: 1260 case CONTEXT_RIGHT:
1261//US mw->moveDockWindow( this, DockRight ); 1261//US mw->moveDockWindow( this, DockRight );
1262 mw->moveToolBar( this, QMainWindow::Right ); 1262 mw->moveToolBar( this, QMainWindow::Right );
1263 break; 1263 break;
1264 case CONTEXT_TOP: 1264 case CONTEXT_TOP:
1265//US mw->moveDockWindow( this, DockTop ); 1265//US mw->moveDockWindow( this, DockTop );
1266 mw->moveToolBar( this, QMainWindow::Top ); 1266 mw->moveToolBar( this, QMainWindow::Top );
1267 break; 1267 break;
1268 case CONTEXT_BOTTOM: 1268 case CONTEXT_BOTTOM:
1269//US mw->moveDockWindow( this, DockBottom ); 1269//US mw->moveDockWindow( this, DockBottom );
1270 mw->moveToolBar( this, QMainWindow::Bottom ); 1270 mw->moveToolBar( this, QMainWindow::Bottom );
1271 break; 1271 break;
1272 case CONTEXT_FLOAT: 1272 case CONTEXT_FLOAT:
1273 break; 1273 break;
1274 case CONTEXT_FLAT: 1274 case CONTEXT_FLAT:
1275//US mw->moveDockWindow( this, DockMinimized ); 1275//US mw->moveDockWindow( this, DockMinimized );
1276 mw->moveToolBar( this, QMainWindow::Minimized ); 1276 mw->moveToolBar( this, QMainWindow::Minimized );
1277 break; 1277 break;
1278 case CONTEXT_ICONS: 1278 case CONTEXT_ICONS:
1279 setIconText( IconOnly ); 1279 setIconText( IconOnly );
1280 break; 1280 break;
1281 case CONTEXT_TEXTRIGHT: 1281 case CONTEXT_TEXTRIGHT:
1282 setIconText( IconTextRight ); 1282 setIconText( IconTextRight );
1283 break; 1283 break;
1284 case CONTEXT_TEXT: 1284 case CONTEXT_TEXT:
1285 setIconText( TextOnly ); 1285 setIconText( TextOnly );
1286 break; 1286 break;
1287 case CONTEXT_TEXTUNDER: 1287 case CONTEXT_TEXTUNDER:
1288 setIconText( IconTextBottom ); 1288 setIconText( IconTextBottom );
1289 break; 1289 break;
1290 default: 1290 default:
1291 if ( i >= CONTEXT_ICONSIZES ) 1291 if ( i >= CONTEXT_ICONSIZES )
1292 setIconSize( i - CONTEXT_ICONSIZES ); 1292 setIconSize( i - CONTEXT_ICONSIZES );
1293 else 1293 else
1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty() 1294 return; // assume this was an action handled elsewhere, no need for setSettingsDirty()
1295 } 1295 }
1296/*US 1296/*US
1297 if ( mw->inherits("KMainWindow") ) 1297 if ( mw->inherits("KMainWindow") )
1298 static_cast<KMainWindow *>(mw)->setSettingsDirty(); 1298 static_cast<KMainWindow *>(mw)->setSettingsDirty();
1299*/ 1299*/
1300 } 1300 }
1301 } 1301 }
1302} 1302}
1303 1303
1304 1304
1305void KToolBar::rebuildLayout() 1305void KToolBar::rebuildLayout()
1306{ 1306{
1307 1307
1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next()) 1308 for(QWidget *w=d->idleButtons.first(); w; w=d->idleButtons.next())
1309 w->blockSignals(false); 1309 w->blockSignals(false);
1310 d->idleButtons.clear(); 1310 d->idleButtons.clear();
1311 1311
1312 layoutTimer->stop(); 1312 layoutTimer->stop();
1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted ); 1313 QApplication::sendPostedEvents( this, QEvent::ChildInserted );
1314 QBoxLayout *l = boxLayout(); 1314 QBoxLayout *l = boxLayout();
1315 l->setMargin( 1 ); 1315 l->setMargin( 1 );
1316 // clear the old layout 1316 // clear the old layout
1317 QLayoutIterator it = l->iterator(); 1317 QLayoutIterator it = l->iterator();
1318 1318
1319 while ( it.current() ) { 1319 while ( it.current() ) {
1320 it.deleteCurrent(); 1320 it.deleteCurrent();
1321 } 1321 }
1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) { 1322 for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
1323 if ( w == rightAligned ) { 1323 if ( w == rightAligned ) {
1324 continue; 1324 continue;
1325 } 1325 }
1326 if ( w->inherits( "KToolBarSeparator" ) && 1326 if ( w->inherits( "KToolBarSeparator" ) &&
1327 !( (KToolBarSeparator*)w )->showLine() ) { 1327 !( (KToolBarSeparator*)w )->showLine() ) {
1328 l->addSpacing( 6 ); 1328 l->addSpacing( 6 );
1329 w->hide(); 1329 w->hide();
1330 continue; 1330 continue;
1331 } 1331 }
1332 if ( w->inherits( "QPopupMenu" ) ) 1332 if ( w->inherits( "QPopupMenu" ) )
1333 continue; 1333 continue;
1334 l->addWidget( w ); 1334 l->addWidget( w );
1335 w->show(); 1335 w->show();
1336 } 1336 }
1337 if ( rightAligned ) { 1337 if ( rightAligned ) {
1338 l->addStretch(); 1338 l->addStretch();
1339 l->addWidget( rightAligned ); 1339 l->addWidget( rightAligned );
1340 rightAligned->show(); 1340 rightAligned->show();
1341 } 1341 }
1342 1342
1343 if ( fullSize() ) { 1343 if ( fullSize() ) {
1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword). 1344 // This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword).
1345 //if ( !stretchableWidget && widgets.last() && 1345 //if ( !stretchableWidget && widgets.last() &&
1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) ) 1346 // !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) )
1347 // setStretchableWidget( widgets.last() ); 1347 // setStretchableWidget( widgets.last() );
1348 if ( !rightAligned ) 1348 if ( !rightAligned )
1349 l->addStretch(); 1349 l->addStretch();
1350 if ( stretchableWidget ) 1350 if ( stretchableWidget )
1351 l->setStretchFactor( stretchableWidget, 10 ); 1351 l->setStretchFactor( stretchableWidget, 10 );
1352 } 1352 }
1353 l->invalidate(); 1353 l->invalidate();
1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) ); 1354 QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) );
1355 //#endif //DESKTOP_VERSION 1355 //#endif //DESKTOP_VERSION
1356} 1356}
1357 1357
1358void KToolBar::childEvent( QChildEvent *e ) 1358void KToolBar::childEvent( QChildEvent *e )
1359{ 1359{
1360 1360
1361 if ( e->child()->isWidgetType() ) { 1361 if ( e->child()->isWidgetType() ) {
1362 QWidget * w = (QWidget*)e->child(); 1362 QWidget * w = (QWidget*)e->child();
1363 if ( e->type() == QEvent::ChildInserted ) { 1363 if ( e->type() == QEvent::ChildInserted ) {
1364 if ( !e->child()->inherits( "QPopupMenu" ) && 1364 if ( !e->child()->inherits( "QPopupMenu" ) &&
1365 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { 1365 ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) {
1366 1366
1367 // prevent items that have been explicitly inserted by insert*() from 1367 // prevent items that have been explicitly inserted by insert*() from
1368 // being inserted again 1368 // being inserted again
1369 if ( !widget2id.contains( w ) ) 1369 if ( !widget2id.contains( w ) )
1370 { 1370 {
1371 int dummy = -1; 1371 int dummy = -1;
1372 insertWidgetInternal( w, dummy, -1 ); 1372 insertWidgetInternal( w, dummy, -1 );
1373 } 1373 }
1374 } 1374 }
1375 } else { 1375 } else {
1376 removeWidgetInternal( w ); 1376 removeWidgetInternal( w );
1377 } 1377 }
1378 if ( isVisibleTo( 0 ) ) 1378 if ( isVisibleTo( 0 ) )
1379 { 1379 {
1380 QBoxLayout *l = boxLayout(); 1380 QBoxLayout *l = boxLayout();
1381 // QLayout *l = layout(); 1381 // QLayout *l = layout();
1382 1382
1383 // clear the old layout so that we don't get unnecassery layout 1383 // clear the old layout so that we don't get unnecassery layout
1384 // changes till we have rebuild the thing 1384 // changes till we have rebuild the thing
1385 QLayoutIterator it = l->iterator(); 1385 QLayoutIterator it = l->iterator();
1386 while ( it.current() ) { 1386 while ( it.current() ) {
1387 it.deleteCurrent(); 1387 it.deleteCurrent();
1388 } 1388 }
1389 layoutTimer->start( 50, TRUE ); 1389 layoutTimer->start( 50, TRUE );
1390 } 1390 }
1391 } 1391 }
1392 QToolBar::childEvent( e ); 1392 QToolBar::childEvent( e );
1393} 1393}
diff --git a/microkde/kdeui/ktoolbar.h b/microkde/kdeui/ktoolbar.h
index 61b5ea3..49ff856 100644
--- a/microkde/kdeui/ktoolbar.h
+++ b/microkde/kdeui/ktoolbar.h
@@ -237,872 +237,872 @@ public:
237 * @param index The position of the button. (-1 = at end). 237 * @param index The position of the button. (-1 = at end).
238 * 238 *
239 * @return The item index. 239 * @return The item index.
240 */ 240 */
241 int insertButton(const QString& icon, int id, const char *signal, 241 int insertButton(const QString& icon, int id, const char *signal,
242 const QObject *receiver, const char *slot, 242 const QObject *receiver, const char *slot,
243 bool enabled = true, const QString& text = QString::null, 243 bool enabled = true, const QString& text = QString::null,
244 int index=-1/*US, KInstance *_instance = KGlobal::instance()*/ ); 244 int index=-1/*US, KInstance *_instance = KGlobal::instance()*/ );
245 245
246 /** 246 /**
247 * Inserts a button (a @ref KToolBarButton) with the specified 247 * Inserts a button (a @ref KToolBarButton) with the specified
248 * pixmap. This pixmap will be used as the "active" one and the 248 * pixmap. This pixmap will be used as the "active" one and the
249 * disabled and default ones will be autogenerated. 249 * disabled and default ones will be autogenerated.
250 * 250 *
251 * It is recommended that you use the insertButton function that 251 * It is recommended that you use the insertButton function that
252 * allows you to specify the icon name rather then the pixmap 252 * allows you to specify the icon name rather then the pixmap
253 * itself. Specifying the icon name is much more flexible. 253 * itself. Specifying the icon name is much more flexible.
254 * 254 *
255 * You should connect to one or more signals in KToolBar: 255 * You should connect to one or more signals in KToolBar:
256 * @ref clicked() , @ref pressed() , @ref released() , or 256 * @ref clicked() , @ref pressed() , @ref released() , or
257 * @ref highlighted() and if the button is a toggle button 257 * @ref highlighted() and if the button is a toggle button
258 * (@ref setToggle() ) @ref toggled() . Those signals have @p id 258 * (@ref setToggle() ) @ref toggled() . Those signals have @p id
259 * of a button that caused the signal. If you want to bind a popup 259 * of a button that caused the signal. If you want to bind a popup
260 * to button, see @ref setButton(). 260 * to button, see @ref setButton().
261 * 261 *
262 * @param pixmap The active pixmap 262 * @param pixmap The active pixmap
263 * @param id The id of this button 263 * @param id The id of this button
264 * @param enabled Enable or disable the button at startup 264 * @param enabled Enable or disable the button at startup
265 * @param text The tooltip or toolbar text (depending on state) 265 * @param text The tooltip or toolbar text (depending on state)
266 * @param index The position of the button. (-1 = at end). 266 * @param index The position of the button. (-1 = at end).
267 * 267 *
268 * @return The item index. 268 * @return The item index.
269 */ 269 */
270 int insertButton(const QPixmap& pixmap, int id, bool enabled = true, 270 int insertButton(const QPixmap& pixmap, int id, bool enabled = true,
271 const QString& text = QString::null, int index=-1 ); 271 const QString& text = QString::null, int index=-1 );
272 272
273 /** 273 /**
274 * This is the same as above, but with specified signals and 274 * This is the same as above, but with specified signals and
275 * slots to which this button will be connected. 275 * slots to which this button will be connected.
276 * 276 *
277 * You can add more signals with @ref addConnection(). 277 * You can add more signals with @ref addConnection().
278 * 278 *
279 * @param icon The name of the icon to use as the active pixmap 279 * @param icon The name of the icon to use as the active pixmap
280 * @param id The id of this button 280 * @param id The id of this button
281 * @param signal The signal to connect to 281 * @param signal The signal to connect to
282 * @param receiver The slot's parent 282 * @param receiver The slot's parent
283 * @param enabled Enable or disable the button at startup 283 * @param enabled Enable or disable the button at startup
284 * @param text The tooltip or toolbar text (depending on state) 284 * @param text The tooltip or toolbar text (depending on state)
285 * @param index The position of the button. (-1 = at end). 285 * @param index The position of the button. (-1 = at end).
286 * 286 *
287 * @return The item index. 287 * @return The item index.
288 */ 288 */
289 int insertButton(const QPixmap& pixmap, int id, const char *signal, 289 int insertButton(const QPixmap& pixmap, int id, const char *signal,
290 const QObject *receiver, const char *slot, 290 const QObject *receiver, const char *slot,
291 bool enabled = true, const QString& text = QString::null, 291 bool enabled = true, const QString& text = QString::null,
292 int index=-1 ); 292 int index=-1 );
293 293
294 /** 294 /**
295 * Inserts a button with popupmenu. 295 * Inserts a button with popupmenu.
296 * 296 *
297 * Button will have small 297 * Button will have small
298 * triangle. You have to connect to popup's signals. The 298 * triangle. You have to connect to popup's signals. The
299 * signals @ref KButton::pressed(), @ref KButton::released(), 299 * signals @ref KButton::pressed(), @ref KButton::released(),
300 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not 300 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not
301 * emmited by 301 * emmited by
302 * this button (see @ref setDelayedPopup() for that). 302 * this button (see @ref setDelayedPopup() for that).
303 * You can add custom popups which inherit @ref QPopupMenu to get popups 303 * You can add custom popups which inherit @ref QPopupMenu to get popups
304 * with tables, drawings etc. Just don't fiddle with events there. 304 * with tables, drawings etc. Just don't fiddle with events there.
305 */ 305 */
306 int insertButton(const QString& icon, int id, QPopupMenu *popup, 306 int insertButton(const QString& icon, int id, QPopupMenu *popup,
307 bool enabled, const QString&_text, int index=-1); 307 bool enabled, const QString&_text, int index=-1);
308 308
309 /** 309 /**
310 * Inserts a button with popupmenu. 310 * Inserts a button with popupmenu.
311 * 311 *
312 * Button will have small 312 * Button will have small
313 * triangle. You have to connect to popup's signals. The 313 * triangle. You have to connect to popup's signals. The
314 * signals @ref KButton::pressed(), @ref KButton::released(), 314 * signals @ref KButton::pressed(), @ref KButton::released(),
315 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not 315 * @ref KButton::clicked() or @ref KButton::doubleClicked() are @p not
316 * emmited by 316 * emmited by
317 * this button (see @ref setDelayedPopup() for that). 317 * this button (see @ref setDelayedPopup() for that).
318 * You can add custom popups which inherit @ref QPopupMenu to get popups 318 * You can add custom popups which inherit @ref QPopupMenu to get popups
319 * with tables, drawings etc. Just don't fiddle with events there. 319 * with tables, drawings etc. Just don't fiddle with events there.
320 */ 320 */
321 int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, 321 int insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup,
322 bool enabled, const QString&_text, int index=-1); 322 bool enabled, const QString&_text, int index=-1);
323 323
324 /** 324 /**
325 * Inserts a @ref KLineEdit. You have to specify signals and slots to 325 * Inserts a @ref KLineEdit. You have to specify signals and slots to
326 * which KLineEdit will be connected. KLineEdit has all slots QLineEdit 326 * which KLineEdit will be connected. KLineEdit has all slots QLineEdit
327 * has, plus signals @ref KLineEdit::completion and @ref KLineEdit::textRotation 327 * has, plus signals @ref KLineEdit::completion and @ref KLineEdit::textRotation
328 * KLineEdit can be set to autoresize itself to full free width 328 * KLineEdit can be set to autoresize itself to full free width
329 * in toolbar, that is to last right aligned item. For that, 329 * in toolbar, that is to last right aligned item. For that,
330 * toolbar must be set to full width (which it is by default). 330 * toolbar must be set to full width (which it is by default).
331 * @see setFullWidth() 331 * @see setFullWidth()
332 * @see setItemAutoSized() 332 * @see setItemAutoSized()
333 * @see KLineEdit 333 * @see KLineEdit
334 * @return Item index. 334 * @return Item index.
335 */ 335 */
336 int insertLined (const QString& text, int id, 336 int insertLined (const QString& text, int id,
337 const char *signal, 337 const char *signal,
338 const QObject *receiver, const char *slot, 338 const QObject *receiver, const char *slot,
339 bool enabled = true, 339 bool enabled = true,
340 const QString& toolTipText = QString::null, 340 const QString& toolTipText = QString::null,
341 int size = 70, int index =-1); 341 int size = 70, int index =-1);
342 342
343 /** 343 /**
344 * Inserts a @ref KComboBox with list. 344 * Inserts a @ref KComboBox with list.
345 * 345 *
346 * Can be writable, but cannot contain 346 * Can be writable, but cannot contain
347 * pixmaps. By default inserting policy is AtBottom, i.e. typed items 347 * 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 348 * 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 349 * argument is specified as -1, the width of the combobox is automatically
350 * computed. 350 * computed.
351 * 351 *
352 * @see setFullWidth() 352 * @see setFullWidth()
353 * @see setItemAutoSized() 353 * @see setItemAutoSized()
354 * @see KComboBox 354 * @see KComboBox
355 * @return Item index. 355 * @return Item index.
356 */ 356 */
357 int insertCombo (const QStringList &list, int id, bool writable, 357 int insertCombo (const QStringList &list, int id, bool writable,
358 const char *signal, const QObject *receiver, 358 const char *signal, const QObject *receiver,
359 const char *slot, bool enabled=true, 359 const char *slot, bool enabled=true,
360 const QString& tooltiptext=QString::null, 360 const QString& tooltiptext=QString::null,
361 int size=70, int index=-1, 361 int size=70, int index=-1,
362 QComboBox::Policy policy = QComboBox::AtBottom); 362 QComboBox::Policy policy = QComboBox::AtBottom);
363 363
364 /** 364 /**
365 * Insert a @ref KComboBox with text. 365 * Insert a @ref KComboBox with text.
366 * 366 *
367 * The rest is the same as above. 367 * The rest is the same as above.
368 * @see setItemAutoSized() 368 * @see setItemAutoSized()
369 * 369 *
370 * @see KComboBox 370 * @see KComboBox
371 * @return Item index. 371 * @return Item index.
372 */ 372 */
373 int insertCombo (const QString& text, int id, bool writable, 373 int insertCombo (const QString& text, int id, bool writable,
374 const char *signal, QObject *recevier, 374 const char *signal, QObject *recevier,
375 const char *slot, bool enabled=true, 375 const char *slot, bool enabled=true,
376 const QString& tooltiptext=QString::null, 376 const QString& tooltiptext=QString::null,
377 int size=70, int index=-1, 377 int size=70, int index=-1,
378 QComboBox::Policy policy = QComboBox::AtBottom); 378 QComboBox::Policy policy = QComboBox::AtBottom);
379 379
380 /** 380 /**
381 * Inserts a separator into the toolbar with the given id. 381 * Inserts a separator into the toolbar with the given id.
382 * Returns the separator's index 382 * Returns the separator's index
383 */ 383 */
384 int insertSeparator( int index = -1, int id = -1 ); 384 int insertSeparator( int index = -1, int id = -1 );
385 385
386 /** 386 /**
387 * Inserts a line separator into the toolbar with the given id. 387 * Inserts a line separator into the toolbar with the given id.
388 * Returns the separator's index 388 * Returns the separator's index
389 */ 389 */
390 int insertLineSeparator( int index = -1, int id = -1 ); 390 int insertLineSeparator( int index = -1, int id = -1 );
391 391
392 /** 392 /**
393 * Inserts a user-defined widget. The widget @p must have this 393 * Inserts a user-defined widget. The widget @p must have this
394 * toolbar as its parent. 394 * toolbar as its parent.
395 * 395 *
396 * Widget must have a QWidget for base class. Widget can be 396 * 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 397 * autosized to full width. If you forget about it, you can get a
398 * pointer to this widget with @ref getWidget(). 398 * pointer to this widget with @ref getWidget().
399 * @see setItemAutoSized() 399 * @see setItemAutoSized()
400 * @return Item index. 400 * @return Item index.
401 */ 401 */
402 int insertWidget(int id, int width, QWidget *_widget, int index=-1); 402 int insertWidget(int id, int width, QWidget *_widget, int index=-1);
403 403
404 /** 404 /**
405 * Inserts an animated widget. A @ref KAnimWidget will be created 405 * Inserts an animated widget. A @ref KAnimWidget will be created
406 * internally using the icon name you provide. 406 * internally using the icon name you provide.
407 * This will emit a signal (clicked()) whenever the 407 * This will emit a signal (clicked()) whenever the
408 * animation widget is clicked. 408 * animation widget is clicked.
409 * 409 *
410 * @see animatedWidget() 410 * @see animatedWidget()
411 * 411 *
412 * @param id The id for this toolbar item 412 * @param id The id for this toolbar item
413 * @param receiver The parent of your slot 413 * @param receiver The parent of your slot
414 * @param slot The slot to receive the clicked() signal 414 * @param slot The slot to receive the clicked() signal
415 * @param icons The name of the animation icon group to use 415 * @param icons The name of the animation icon group to use
416 * @param index The item index 416 * @param index The item index
417 * 417 *
418 * @return The item index 418 * @return The item index
419 */ 419 */
420/*US 420/*US
421 int insertAnimatedWidget(int id, QObject *receiver, const char *slot, 421 int insertAnimatedWidget(int id, QObject *receiver, const char *slot,
422 const QString& icons, int index = -1); 422 const QString& icons, int index = -1);
423*/ 423*/
424 /** 424 /**
425 * This will return a pointer to the given animated widget, if it 425 * This will return a pointer to the given animated widget, if it
426 * exists. 426 * exists.
427 * 427 *
428 * @see insertAnimatedWidget 428 * @see insertAnimatedWidget
429 * 429 *
430 * @param id The id for the widget you want to get a pointer to 430 * @param id The id for the widget you want to get a pointer to
431 * 431 *
432 * @return A pointer to the current animated widget or 0L 432 * @return A pointer to the current animated widget or 0L
433 */ 433 */
434//US KAnimWidget *animatedWidget( int id ); 434//US KAnimWidget *animatedWidget( int id );
435 435
436 /** 436 /**
437 * Adds connections to items. 437 * Adds connections to items.
438 * 438 *
439 * It is important that you 439 * It is important that you
440 * know the @p id of particular item. Nothing happens if you forget @p id. 440 * know the @p id of particular item. Nothing happens if you forget @p id.
441 */ 441 */
442 void addConnection (int id, const char *signal, 442 void addConnection (int id, const char *signal,
443 const QObject *receiver, const char *slot); 443 const QObject *receiver, const char *slot);
444 /** 444 /**
445 * Enables/disables item. 445 * Enables/disables item.
446 */ 446 */
447 void setItemEnabled( int id, bool enabled ); 447 void setItemEnabled( int id, bool enabled );
448 448
449 /** 449 /**
450 * Sets the icon for a button. 450 * Sets the icon for a button.
451 * 451 *
452 * Can be used while button is visible. 452 * Can be used while button is visible.
453 */ 453 */
454 void setButtonIcon( int id, const QString& _icon ); 454 void setButtonIcon( int id, const QString& _icon );
455 455
456 /** 456 /**
457 * Sets button pixmap. 457 * Sets button pixmap.
458 * 458 *
459 * Can be used while button is visible. 459 * Can be used while button is visible.
460 */ 460 */
461 void setButtonPixmap( int id, const QPixmap& _pixmap ); 461 void setButtonPixmap( int id, const QPixmap& _pixmap );
462 462
463 /** 463 /**
464 * Sets a button icon from a QIconSet. 464 * Sets a button icon from a QIconSet.
465 * 465 *
466 * Can be used while button is visible. 466 * Can be used while button is visible.
467 */ 467 */
468 void setButtonIconSet( int id, const QIconSet& iconset ); 468 void setButtonIconSet( int id, const QIconSet& iconset );
469 469
470 /** 470 /**
471 * Sets a delayed popup for a button. 471 * Sets a delayed popup for a button.
472 * 472 *
473 * Delayed popup is what you see in 473 * Delayed popup is what you see in
474 * Netscape Navigator's Previous and Next buttons: If you click them you 474 * Netscape Navigator's Previous and Next buttons: If you click them you
475 * go back 475 * go back
476 * or forth. If you press them long enough, you get a history-menu. 476 * or forth. If you press them long enough, you get a history-menu.
477 * This is exactly what we do here. 477 * This is exactly what we do here.
478 * 478 *
479 * You will insert normal a button with connection (or use signals from 479 * You will insert normal a button with connection (or use signals from
480 * toolbar): 480 * toolbar):
481 * <pre> 481 * <pre>
482 * bar->insertButton(icon, id, SIGNAL(clicked ()), this, 482 * bar->insertButton(icon, id, SIGNAL(clicked ()), this,
483 * SLOT (slotClick()), true, "click or wait for popup"); 483 * SLOT (slotClick()), true, "click or wait for popup");
484 * </pre> And then add a delayed popup: 484 * </pre> And then add a delayed popup:
485 * <pre> 485 * <pre>
486 * bar->setDelayedPopup (id, historyPopup); </pre> 486 * bar->setDelayedPopup (id, historyPopup); </pre>
487 * 487 *
488 * Don't add delayed popups to buttons which have normal popups. 488 * Don't add delayed popups to buttons which have normal popups.
489 * 489 *
490 * You may add popups which are derived from @ref QPopupMenu. You may 490 * 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 491 * add popups that are already in the menu bar or are submenus of
492 * other popups. 492 * other popups.
493 */ 493 */
494 void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false); 494 void setDelayedPopup (int id , QPopupMenu *_popup, bool toggle = false);
495 495
496 /** 496 /**
497 * Turns a button into an autorepeat button. 497 * Turns a button into an autorepeat button.
498 * 498 *
499 * Toggle buttons, buttons with menus, or 499 * Toggle buttons, buttons with menus, or
500 * buttons with delayed menus cannot be made into autorepeat buttons. 500 * buttons with delayed menus cannot be made into autorepeat buttons.
501 * Moreover, you can and will receive 501 * Moreover, you can and will receive
502 * only the signal clicked(), but not pressed() or released(). 502 * only the signal clicked(), but not pressed() or released().
503 * When the user presses this button, you will receive the signal clicked(), 503 * When the user presses this button, you will receive the signal clicked(),
504 * and if the button is still pressed after some time, 504 * and if the button is still pressed after some time,
505 * you will receive more clicked() signals separated by regular 505 * you will receive more clicked() signals separated by regular
506 * intervals. Since this uses @ref QButton::setAutoRepeat() , 506 * intervals. Since this uses @ref QButton::setAutoRepeat() ,
507 * I can't quantify 'some'. 507 * I can't quantify 'some'.
508 */ 508 */
509 void setAutoRepeat (int id, bool flag=true); 509 void setAutoRepeat (int id, bool flag=true);
510 510
511 511
512 /** 512 /**
513 * Turns button into a toggle button if @p flag is true. 513 * Turns button into a toggle button if @p flag is true.
514 */ 514 */
515 void setToggle (int id, bool flag = true); 515 void setToggle (int id, bool flag = true);
516 516
517 /** 517 /**
518 * Toggles a togglebutton. 518 * Toggles a togglebutton.
519 * 519 *
520 * If the button is a toggle button (see @ref setToggle()) 520 * If the button is a toggle button (see @ref setToggle())
521 * the button state will be toggled. This will also cause the toolbar to 521 * 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 522 * 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 523 * this signal, or use @ref addConnection() to connect directly to the
524 * button signal @ref KButton::toggled(). 524 * button signal @ref KButton::toggled().
525 */ 525 */
526 void toggleButton (int id); 526 void toggleButton (int id);
527 527
528 /** 528 /**
529 * Sets a toggle button state. 529 * Sets a toggle button state.
530 * 530 *
531 * If the button is a toggle button (see @ref setToggle()) 531 * If the button is a toggle button (see @ref setToggle())
532 * this will set its state flag. This will also emit the signal 532 * this will set its state flag. This will also emit the signal
533 * @ref KButton::toggled(). 533 * @ref KButton::toggled().
534 * 534 *
535 * @see setToggle() 535 * @see setToggle()
536 */ 536 */
537 void setButton (int id, bool flag); 537 void setButton (int id, bool flag);
538 538
539 /** 539 /**
540 * @return @p true if button is on, @p false if button is off or if the 540 * @return @p true if button is on, @p false if button is off or if the
541 * button is not a toggle button. 541 * button is not a toggle button.
542 * @see setToggle() 542 * @see setToggle()
543 */ 543 */
544 bool isButtonOn (int id) const; 544 bool isButtonOn (int id) const;
545 545
546 /** 546 /**
547 * Sets the text of a line editor. 547 * Sets the text of a line editor.
548 * 548 *
549 * Cursor is set at end of text. 549 * Cursor is set at end of text.
550 */ 550 */
551 void setLinedText (int id, const QString& text); 551 void setLinedText (int id, const QString& text);
552 552
553 /** 553 /**
554 * Returns a line editor text. 554 * Returns a line editor text.
555 */ 555 */
556 QString getLinedText (int id) const; 556 QString getLinedText (int id) const;
557 557
558 /** 558 /**
559 * Inserts @p text in combobox @p id at position @p index. 559 * Inserts @p text in combobox @p id at position @p index.
560 */ 560 */
561 void insertComboItem (int id, const QString& text, int index); 561 void insertComboItem (int id, const QString& text, int index);
562 562
563 /** 563 /**
564 * Inserts @p list in combobox @p id at position @p index. 564 * Inserts @p list in combobox @p id at position @p index.
565 */ 565 */
566 void insertComboList (int id, const QStringList &list, int index); 566 void insertComboList (int id, const QStringList &list, int index);
567 567
568 /** 568 /**
569 * Removes item @p index from combobox @p id. 569 * Removes item @p index from combobox @p id.
570 */ 570 */
571 void removeComboItem (int id, int index); 571 void removeComboItem (int id, int index);
572 572
573 /** 573 /**
574 * Sets item @p index to be current item in combobox @p id. 574 * Sets item @p index to be current item in combobox @p id.
575 */ 575 */
576 void setCurrentComboItem (int id, int index); 576 void setCurrentComboItem (int id, int index);
577 577
578 /** 578 /**
579 * Changes item @p index in combobox @p id to text. 579 * Changes item @p index in combobox @p id to text.
580 * 580 *
581 * @p index = -1 refers current item (one displayed in the button). 581 * @p index = -1 refers current item (one displayed in the button).
582 */ 582 */
583 void changeComboItem (int id, const QString& text, int index=-1); 583 void changeComboItem (int id, const QString& text, int index=-1);
584 584
585 /** 585 /**
586 * Clears the combobox @p id. 586 * Clears the combobox @p id.
587 * 587 *
588 * Does not delete it or hide it. 588 * Does not delete it or hide it.
589 */ 589 */
590 void clearCombo (int id); 590 void clearCombo (int id);
591 591
592 /** 592 /**
593 * Returns text of item @p index from combobox @p id. 593 * Returns text of item @p index from combobox @p id.
594 * 594 *
595 * @p index = -1 refers to current item. 595 * @p index = -1 refers to current item.
596 */ 596 */
597 597
598 QString getComboItem (int id, int index=-1) const; 598 QString getComboItem (int id, int index=-1) const;
599 599
600 /** 600 /**
601 * Returns a pointer to the combobox. 601 * Returns a pointer to the combobox.
602 * 602 *
603 * Example: 603 * Example:
604 * <pre> 604 * <pre>
605 * KComboBox *combo = toolbar->getCombo(combo_id); 605 * KComboBox *combo = toolbar->getCombo(combo_id);
606 * </pre> 606 * </pre>
607 * That way you can get access to other public methods 607 * That way you can get access to other public methods
608 * that @ref KComboBox provides. 608 * that @ref KComboBox provides.
609 */ 609 */
610 KComboBox * getCombo(int id); 610 KComboBox * getCombo(int id);
611 611
612 /** 612 /**
613 * Returns a pointer to KToolBarLined. 613 * Returns a pointer to KToolBarLined.
614 * 614 *
615 * Example: 615 * Example:
616 * <pre> 616 * <pre>
617 * KLineEdit * lined = toolbar->getKToolBarLined(lined_id); 617 * KLineEdit * lined = toolbar->getKToolBarLined(lined_id);
618 * </pre> 618 * </pre>
619 * That way you can get access to other public methods 619 * That way you can get access to other public methods
620 * that @ref KLineEdit provides. @ref KLineEdit is the same thing 620 * that @ref KLineEdit provides. @ref KLineEdit is the same thing
621 * as @ref QLineEdit plus completion signals. 621 * as @ref QLineEdit plus completion signals.
622 */ 622 */
623 KLineEdit * getLined (int id); 623 KLineEdit * getLined (int id);
624 624
625 /** 625 /**
626 * Returns a pointer to KToolBarButton. 626 * Returns a pointer to KToolBarButton.
627 * 627 *
628 * Example: 628 * Example:
629 * <pre> 629 * <pre>
630 * KToolBarButton * button = toolbar->getButton(button_id); 630 * KToolBarButton * button = toolbar->getButton(button_id);
631 * </pre> 631 * </pre>
632 * That way you can get access to other public methods 632 * That way you can get access to other public methods
633 * that @ref KToolBarButton provides. 633 * that @ref KToolBarButton provides.
634 * 634 *
635 * Using this method is not recommended. 635 * Using this method is not recommended.
636 */ 636 */
637 KToolBarButton * getButton (int id); 637 KToolBarButton * getButton (int id);
638 638
639 /** 639 /**
640 * Align item to the right. 640 * Align item to the right.
641 * 641 *
642 * This works only if toolbar is set to full width. 642 * This works only if toolbar is set to full width.
643 * @see setFullWidth() 643 * @see setFullWidth()
644 */ 644 */
645 void alignItemRight (int id, bool right = true); 645 void alignItemRight (int id, bool right = true);
646 646
647 /** 647 /**
648 * Returns a pointer to an inserted widget. 648 * Returns a pointer to an inserted widget.
649 * 649 *
650 * Wrong ids are not tested. 650 * Wrong ids are not tested.
651 * You can do with this whatever you want, 651 * You can do with this whatever you want,
652 * except change its height (hardcoded). If you change its width 652 * except change its height (hardcoded). If you change its width
653 * you will probably have to call QToolBar::updateRects(true) 653 * you will probably have to call QToolBar::updateRects(true)
654 * @see QWidget 654 * @see QWidget
655 * @see updateRects() 655 * @see updateRects()
656 * 656 *
657 * KDE4: make this const! 657 * KDE4: make this const!
658 */ 658 */
659 QWidget *getWidget (int id); 659 QWidget *getWidget (int id);
660 660
661 /** 661 /**
662 * Set item autosized. 662 * Set item autosized.
663 * 663 *
664 * This works only if the toolbar is set to full width. 664 * This works only if the toolbar is set to full width.
665 * Only @p one item can be autosized, and it has to be 665 * 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 666 * 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 667 * aligned. Items that can be right aligned are Lineds, Frames, Widgets and
668 * Combos. An autosized item will resize itself whenever the toolbar geometry 668 * 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 669 * changes to the last right-aligned item (or to end of toolbar if there
670 * are no right-aligned items.) 670 * are no right-aligned items.)
671 * @see setFullWidth() 671 * @see setFullWidth()
672 * @see alignItemRight() 672 * @see alignItemRight()
673 */ 673 */
674 void setItemAutoSized (int id, bool yes = true); 674 void setItemAutoSized (int id, bool yes = true);
675 675
676 /** 676 /**
677 * Remove all items. 677 * Remove all items.
678 * 678 *
679 * The toolbar is redrawn after it. 679 * The toolbar is redrawn after it.
680 */ 680 */
681 void clear (); 681 void clear ();
682 682
683 /** 683 /**
684 * Remove item @p id. 684 * Remove item @p id.
685 * 685 *
686 * Item is deleted. Toolbar is redrawn after it. 686 * Item is deleted. Toolbar is redrawn after it.
687 */ 687 */
688 void removeItem (int id); 688 void removeItem (int id);
689 689
690 /** 690 /**
691 * Remove item @p id. 691 * Remove item @p id.
692 * 692 *
693 * Item is deleted when toolbar is redrawn. 693 * Item is deleted when toolbar is redrawn.
694 */ 694 */
695 void removeItemDelayed (int id); 695 void removeItemDelayed (int id);
696 696
697 /** 697 /**
698 * Hide item. 698 * Hide item.
699 */ 699 */
700 void hideItem (int id); 700 void hideItem (int id);
701 701
702 /** 702 /**
703 * Show item. 703 * Show item.
704 */ 704 */
705 void showItem (int id); 705 void showItem (int id);
706 706
707 /** 707 /**
708 * Returns the index of the given item. 708 * Returns the index of the given item.
709 * 709 *
710 * KDE4: make this const! 710 * KDE4: make this const!
711 */ 711 */
712 int itemIndex (int id); 712 int itemIndex (int id);
713 713
714 /** 714 /**
715 * Set toolbar to full parent size (default). 715 * Set toolbar to full parent size (default).
716 * 716 *
717 * In full size mode the bar 717 * In full size mode the bar
718 * extends over the parent's full width or height. If the mode is disabled 718 * 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 719 * 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 720 * it does not exceed the parent box. You can force a certain width or
721 * height with @ref setMaxWidth() or @ref setMaxHeight(). 721 * height with @ref setMaxWidth() or @ref setMaxHeight().
722 * 722 *
723 * If you want to use right-aligned items or auto-sized items you must use 723 * If you want to use right-aligned items or auto-sized items you must use
724 * full size mode. 724 * full size mode.
725 */ 725 */
726 void setFullSize(bool flag = true); 726 void setFullSize(bool flag = true);
727 727
728 /** 728 /**
729 * @return @p true if the full-size mode is enabled. Otherwise 729 * @return @p true if the full-size mode is enabled. Otherwise
730 * it returns @false. 730 * it returns @false.
731 */ 731 */
732 bool fullSize() const; 732 bool fullSize() const;
733 733
734 /** 734 /**
735 * @deprecated use setMovingEnabled(bool) instead. 735 * @deprecated use setMovingEnabled(bool) instead.
736 * Enable or disable moving of toolbar. 736 * Enable or disable moving of toolbar.
737 */ 737 */
738 void enableMoving(bool flag = true); 738 void enableMoving(bool flag = true);
739 739
740 /** 740 /**
741 * Set position of toolbar. 741 * Set position of toolbar.
742 * @see BarPosition() 742 * @see BarPosition()
743 */ 743 */
744 void setBarPos (BarPosition bpos); 744 void setBarPos (BarPosition bpos);
745 745
746 /** 746 /**
747 * Returns position of toolbar. 747 * Returns position of toolbar.
748 */ 748 */
749 BarPosition barPos(); 749 BarPosition barPos() const;
750 750
751 /** 751 /**
752 * @deprecated 752 * @deprecated
753 * Show, hide, or toggle toolbar. 753 * Show, hide, or toggle toolbar.
754 * 754 *
755 * This method is provided for compatibility only, 755 * This method is provided for compatibility only,
756 * please use show() and/or hide() instead. 756 * please use show() and/or hide() instead.
757 * @see BarStatus 757 * @see BarStatus
758 */ 758 */
759 bool enable(BarStatus stat); 759 bool enable(BarStatus stat);
760 760
761 /** 761 /**
762 * @deprecated 762 * @deprecated
763 * Use setMaximumHeight() instead. 763 * Use setMaximumHeight() instead.
764 */ 764 */
765 void setMaxHeight (int h); // Set max height for vertical toolbars 765 void setMaxHeight (int h); // Set max height for vertical toolbars
766 766
767 /** 767 /**
768 * @deprecated 768 * @deprecated
769 * Use maximumHeight() instead. 769 * Use maximumHeight() instead.
770 * Returns the value that was set with @ref setMaxHeight(). 770 * Returns the value that was set with @ref setMaxHeight().
771 */ 771 */
772 int maxHeight(); 772 int maxHeight();
773 773
774 /** 774 /**
775 * @deprecated 775 * @deprecated
776 * Use setMaximumWidth() instead. 776 * Use setMaximumWidth() instead.
777 * Set maximal width of horizontal (top or bottom) toolbar. 777 * Set maximal width of horizontal (top or bottom) toolbar.
778 */ 778 */
779 void setMaxWidth (int dw); 779 void setMaxWidth (int dw);
780 780
781 /** 781 /**
782 * @deprecated 782 * @deprecated
783 * Use maximumWidth() instead. 783 * Use maximumWidth() instead.
784 * Returns the value that was set with @ref setMaxWidth(). 784 * Returns the value that was set with @ref setMaxWidth().
785 */ 785 */
786 int maxWidth(); 786 int maxWidth();
787 787
788 /** 788 /**
789 * Set title for toolbar when it floats. 789 * Set title for toolbar when it floats.
790 * 790 *
791 * Titles are however not (yet) 791 * Titles are however not (yet)
792 * visible. You can't change toolbar's title while it's floating. 792 * visible. You can't change toolbar's title while it's floating.
793 */ 793 */
794 void setTitle (const QString& _title); 794 void setTitle (const QString& _title);
795 795
796 /** 796 /**
797 * @deprecated 797 * @deprecated
798 * Use enableMoving() instead. 798 * Use enableMoving() instead.
799 */ 799 */
800 void enableFloating (bool arrrrrrgh); 800 void enableFloating (bool arrrrrrgh);
801 801
802 /** 802 /**
803 * Set the kind of painting for buttons. 803 * Set the kind of painting for buttons.
804 * 804 *
805 * Choose from: 805 * Choose from:
806 * @li IconOnly (only icons), 806 * @li IconOnly (only icons),
807 * @li IconTextRight (icon and text, text is left from icons), 807 * @li IconTextRight (icon and text, text is left from icons),
808 * @li TextOnly (only text), 808 * @li TextOnly (only text),
809 * @li IconTextBottom (icons and text, text is under icons). 809 * @li IconTextBottom (icons and text, text is under icons).
810 * @see IconText 810 * @see IconText
811 * 811 *
812 */ 812 */
813 void setIconText(IconText it); 813 void setIconText(IconText it);
814 // Note: don't merge with the next one, it breaks Qt properties 814 // Note: don't merge with the next one, it breaks Qt properties
815 815
816 /** 816 /**
817 * Similar to @ref setIconText(IconText it) but allows you to 817 * Similar to @ref setIconText(IconText it) but allows you to
818 * disable or enable updating. If @p update is false, then the 818 * disable or enable updating. If @p update is false, then the
819 * buttons will not be updated. This is useful only if you know 819 * buttons will not be updated. This is useful only if you know
820 * that you will be forcing an update later. 820 * that you will be forcing an update later.
821 */ 821 */
822 void setIconText(IconText it, bool update); 822 void setIconText(IconText it, bool update);
823 823
824 /** 824 /**
825 * @return The current text style for buttons. 825 * @return The current text style for buttons.
826 */ 826 */
827 IconText iconText() const; 827 IconText iconText() const;
828 828
829 /** 829 /**
830 * Set the icon size to load. Usually you should not call 830 * Set the icon size to load. Usually you should not call
831 * this, the icon size is taken care of by KIconLoader 831 * this, the icon size is taken care of by KIconLoader
832 * and globally configured. 832 * and globally configured.
833 * By default, the toolbar will load icons of size 32 for main 833 * By default, the toolbar will load icons of size 32 for main
834 * toolbars and 22 for other toolbars 834 * toolbars and 22 for other toolbars
835 * @see KIconLoader. 835 * @see KIconLoader.
836 * 836 *
837 * @param size The size to use 837 * @param size The size to use
838 */ 838 */
839 void setIconSize(int size); 839 void setIconSize(int size);
840 // Note: don't merge with the next one, it breaks Qt properties 840 // Note: don't merge with the next one, it breaks Qt properties
841 841
842 /** 842 /**
843 * Same as @ref setIconText(int size) but allows you 843 * Same as @ref setIconText(int size) but allows you
844 * to disable the toolbar update. 844 * to disable the toolbar update.
845 * 845 *
846 * @param size The size to use 846 * @param size The size to use
847 * @param update If true, then the toolbar will be updated after 847 * @param update If true, then the toolbar will be updated after
848 * this 848 * this
849 */ 849 */
850 void setIconSize(int size, bool update); 850 void setIconSize(int size, bool update);
851 851
852 /** 852 /**
853 * @return The current icon size for buttons. 853 * @return The current icon size for buttons.
854 */ 854 */
855 int iconSize() const; 855 int iconSize() const;
856 856
857 /** 857 /**
858 * This allows you to enable or disable the context menu. 858 * This allows you to enable or disable the context menu.
859 * 859 *
860 * @param enable If false, then the context menu will be disabled 860 * @param enable If false, then the context menu will be disabled
861 */ 861 */
862 void setEnableContextMenu(bool enable = true); 862 void setEnableContextMenu(bool enable = true);
863 863
864 /** 864 /**
865 * Returns whether or not the context menu is disabled 865 * Returns whether or not the context menu is disabled
866 * 866 *
867 * @return The context menu state 867 * @return The context menu state
868 */ 868 */
869 bool contextMenuEnabled() const; 869 bool contextMenuEnabled() const;
870 870
871 /** 871 /**
872 * This will inform a toolbar button to ignore certain style 872 * This will inform a toolbar button to ignore certain style
873 * changes. Specifically, it will ignore IconText (always IconOnly) 873 * changes. Specifically, it will ignore IconText (always IconOnly)
874 * and will not allow image effects to apply. 874 * and will not allow image effects to apply.
875 * 875 *
876 * @param id The button to exclude from styles 876 * @param id The button to exclude from styles
877 * @param no_style If true, then it is excluded (default: true). 877 * @param no_style If true, then it is excluded (default: true).
878 */ 878 */
879 void setItemNoStyle(int id, bool no_style = true); 879 void setItemNoStyle(int id, bool no_style = true);
880 880
881 void setFlat (bool flag); 881 void setFlat (bool flag);
882 882
883 /** 883 /**
884 * @return the number of items in the toolbar 884 * @return the number of items in the toolbar
885 */ 885 */
886 int count() const; 886 int count() const;
887 887
888 /** 888 /**
889 * Instruct the toolbar to save it's current state to either the app 889 * 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 890 * config file or to the XML-GUI resource file (whichever has
891 * precedence). 891 * precedence).
892 */ 892 */
893 void saveState(); 893 void saveState();
894 894
895 /** 895 /**
896 * Save the toolbar settings to group @p configGroup in @p config. 896 * Save the toolbar settings to group @p configGroup in @p config.
897 */ 897 */
898 void saveSettings(KConfig *config, const QString &configGroup); 898 void saveSettings(KConfig *config, const QString &configGroup);
899 899
900 /** 900 /**
901 * Read the toolbar settings from group @p configGroup in @p config 901 * Read the toolbar settings from group @p configGroup in @p config
902 * and apply them. 902 * and apply them.
903 */ 903 */
904 void applySettings(KConfig *config, const QString &configGroup); 904 void applySettings(KConfig *config, const QString &configGroup);
905 905
906 /** 906 /**
907 * Tell the toolbar what XML-GUI resource file it should use to save 907 * 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 908 * 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.. 909 * 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 910 * but if the app does, then it's saved the XML file. This function
911 * allows this to happen. 911 * allows this to happen.
912 * 912 *
913 * @param xmlfile The XML-GUI resource file to write to 913 * @param xmlfile The XML-GUI resource file to write to
914 * @param xml The DOM document for the XML-GUI building 914 * @param xml The DOM document for the XML-GUI building
915 */ 915 */
916 // void setXML(const QString& xmlfile, const QDomDocument& xml); 916 // void setXML(const QString& xmlfile, const QDomDocument& xml);
917 /* @internal */ 917 /* @internal */
918 void setXMLGUIClient( KXMLGUIClient *client ); 918 void setXMLGUIClient( KXMLGUIClient *client );
919 919
920 /** 920 /**
921 * Assign a (translated) text to this toolbar. This is used 921 * Assign a (translated) text to this toolbar. This is used
922 * for the tooltip on the handle, and when listing the toolbars. 922 * for the tooltip on the handle, and when listing the toolbars.
923 */ 923 */
924 void setText( const QString & txt ); 924 void setText( const QString & txt );
925 925
926 /** 926 /**
927 * @return the toolbar's text. 927 * @return the toolbar's text.
928 */ 928 */
929 QString text() const; 929 QString text() const;
930 930
931 void setStretchableWidget( QWidget *w ); 931 void setStretchableWidget( QWidget *w );
932 QSizePolicy sizePolicy() const; 932 QSizePolicy sizePolicy() const;
933 bool highlight() const; 933 bool highlight() const;
934 QSize sizeHint() const; 934 QSize sizeHint() const;
935 QSize minimumSizeHint() const; 935 QSize minimumSizeHint() const;
936 QSize minimumSize() const; 936 QSize minimumSize() const;
937 937
938 void hide(); 938 void hide();
939 void show(); 939 void show();
940 940
941 void updateRects( bool = FALSE ) {} 941 void updateRects( bool = FALSE ) {}
942 942
943//US void loadState( const QDomElement &e ); 943//US void loadState( const QDomElement &e );
944//US void saveState( QDomElement &e ); 944//US void saveState( QDomElement &e );
945 945
946 /** 946 /**
947 * @internal 947 * @internal
948 */ 948 */
949 void positionYourself( bool force = false); 949 void positionYourself( bool force = false);
950 950
951signals: 951signals:
952 /** 952 /**
953 * Emitted when button @p id is clicked. 953 * Emitted when button @p id is clicked.
954 */ 954 */
955 void clicked(int id); 955 void clicked(int id);
956 956
957 /** 957 /**
958 * Emitted when button @p id is double-clicked. 958 * Emitted when button @p id is double-clicked.
959 * 959 *
960 * Note: you will always 960 * Note: you will always
961 * recive two @ref clicked() , @ref pressed() and @ref released() signals. 961 * recive two @ref clicked() , @ref pressed() and @ref released() signals.
962 * There is no way to avoid it - at least no easy way. 962 * 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 963 * If you need to resolve this all you can do is set up timers
964 * which wait for @ref QApplication::doubleClickInterval() to expire. 964 * which wait for @ref QApplication::doubleClickInterval() to expire.
965 * If in that time you don't get this signal, you may belive that 965 * If in that time you don't get this signal, you may belive that
966 * button was only clicked and not double-clicked. 966 * button was only clicked and not double-clicked.
967 * And please note that butons with popup menus do not emit this signal, 967 * And please note that butons with popup menus do not emit this signal,
968 * but those with delayed popup do. 968 * but those with delayed popup do.
969 */ 969 */
970 void doubleClicked (int id); 970 void doubleClicked (int id);
971 971
972 /** 972 /**
973 * Emitted when button @p id is pressed. 973 * Emitted when button @p id is pressed.
974 */ 974 */
975 void pressed(int); 975 void pressed(int);
976 976
977 /** 977 /**
978 * Emits when button @p id is released. 978 * Emits when button @p id is released.
979 */ 979 */
980 void released(int); 980 void released(int);
981 981
982 /** 982 /**
983 * Emitted when a toggle button changes state. 983 * Emitted when a toggle button changes state.
984 * 984 *
985 * Emitted also if you change state 985 * Emitted also if you change state
986 * with @ref setButton() or @ref toggleButton() 986 * with @ref setButton() or @ref toggleButton()
987 * If you make a button normal again, with 987 * If you make a button normal again, with
988 * setToggle(false), this signal won't 988 * setToggle(false), this signal won't
989 * be emitted. 989 * be emitted.
990 */ 990 */
991 void toggled(int); 991 void toggled(int);
992 992
993 /** 993 /**
994 * This signal is emitted when item id gets highlighted/unhighlighted 994 * This signal is emitted when item id gets highlighted/unhighlighted
995 * (i.e when mouse enters/exits). 995 * (i.e when mouse enters/exits).
996 * 996 *
997 * Note that this signal is emitted from 997 * Note that this signal is emitted from
998 * all buttons (normal, disabled and toggle) even when there is no visible 998 * 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). 999 * 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 1000 * The parameter @p isHighlighted is @p true when mouse enters and @p false when
1001 * mouse exits. 1001 * mouse exits.
1002 */ 1002 */
1003 void highlighted(int id, bool isHighlighted); 1003 void highlighted(int id, bool isHighlighted);
1004 1004
1005 /** 1005 /**
1006 * This signal is emitted when item id gets highlighted/unhighlighted 1006 * This signal is emitted when item id gets highlighted/unhighlighted
1007 * (i.e when mouse enters/exits). 1007 * (i.e when mouse enters/exits).
1008 * 1008 *
1009 * Note that this signal is emitted from 1009 * Note that this signal is emitted from
1010 * all buttons (normal, disabled and toggle) even when there is no visible 1010 * 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). 1011 * change in buttons (i.e., buttons do not raise when mouse enters).
1012 */ 1012 */
1013 void highlighted(int id ); 1013 void highlighted(int id );
1014 1014
1015 /** 1015 /**
1016 * Emitted when toolbar changes position, or when 1016 * Emitted when toolbar changes position, or when
1017 * an item is removed from toolbar. 1017 * an item is removed from toolbar.
1018 * 1018 *
1019 * If you subclass @ref KMainWindow and reimplement 1019 * If you subclass @ref KMainWindow and reimplement
1020 * @ref KMainWindow::resizeEvent() be sure to connect to 1020 * @ref KMainWindow::resizeEvent() be sure to connect to
1021 * this signal. Note: You can connect this signal to a slot that 1021 * this signal. Note: You can connect this signal to a slot that
1022 * doesn't take parameter. 1022 * doesn't take parameter.
1023 */ 1023 */
1024 void moved( BarPosition ); 1024 void moved( BarPosition );
1025 1025
1026 /** 1026 /**
1027 * @internal 1027 * @internal
1028 * This signal is emitted when toolbar detects changing of 1028 * This signal is emitted when toolbar detects changing of
1029 * following parameters: 1029 * following parameters:
1030 * highlighting, button-size, button-mode. This signal is 1030 * highlighting, button-size, button-mode. This signal is
1031 * internal, aimed to buttons. 1031 * internal, aimed to buttons.
1032 */ 1032 */
1033 void modechange (); 1033 void modechange ();
1034 1034
1035 /** 1035 /**
1036 * This signal is emitted when the toolbar is getting deleted, 1036 * This signal is emitted when the toolbar is getting deleted,
1037 * and before ~KToolbar finishes (so it's still time to remove 1037 * and before ~KToolbar finishes (so it's still time to remove
1038 * widgets from the toolbar). 1038 * widgets from the toolbar).
1039 * Used by KWidgetAction. 1039 * Used by KWidgetAction.
1040 * @since 3.2 1040 * @since 3.2
1041 */ 1041 */
1042 void toolbarDestroyed(); 1042 void toolbarDestroyed();
1043 1043
1044public: 1044public:
1045 /** 1045 /**
1046 * @return global setting for "Highlight buttons under mouse" 1046 * @return global setting for "Highlight buttons under mouse"
1047 */ 1047 */
1048 void repaintMe(); 1048 void repaintMe();
1049 static bool highlightSetting(); 1049 static bool highlightSetting();
1050 1050
1051 /** 1051 /**
1052 * @return global setting for "Toolbars transparent when moving" 1052 * @return global setting for "Toolbars transparent when moving"
1053 */ 1053 */
1054 static bool transparentSetting(); 1054 static bool transparentSetting();
1055 1055
1056 /** 1056 /**
1057 * @return global setting for "Icon Text" 1057 * @return global setting for "Icon Text"
1058 */ 1058 */
1059 static IconText iconTextSetting(); 1059 static IconText iconTextSetting();
1060 1060
1061public slots: 1061public slots:
1062 virtual void setIconText( const QString &txt ) 1062 virtual void setIconText( const QString &txt )
1063 { QToolBar::setIconText( txt ); } 1063 { QToolBar::setIconText( txt ); }
1064 void slotRepaint(); 1064 void slotRepaint();
1065 1065
1066protected: 1066protected:
1067 void mousePressEvent( QMouseEvent * ); 1067 void mousePressEvent( QMouseEvent * );
1068 void childEvent( QChildEvent *e ); 1068 void childEvent( QChildEvent *e );
1069 void showEvent( QShowEvent *e ); 1069 void showEvent( QShowEvent *e );
1070 void resizeEvent( QResizeEvent *e ); 1070 void resizeEvent( QResizeEvent *e );
1071 bool event( QEvent *e ); 1071 bool event( QEvent *e );
1072 void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false); 1072 void applyAppearanceSettings(KConfig *config, const QString &_configGroup, bool forceGlobal = false);
1073 QString settingsGroup(); 1073 QString settingsGroup();
1074 1074
1075private slots: 1075private slots:
1076 void rebuildLayout(); 1076 void rebuildLayout();
1077 void slotReadConfig (); 1077 void slotReadConfig ();
1078 void slotAppearanceChanged(); 1078 void slotAppearanceChanged();
1079 void slotIconChanged(int); 1079 void slotIconChanged(int);
1080 void toolBarPosChanged( QToolBar *tb ); 1080 void toolBarPosChanged( QToolBar *tb );
1081 void slotContextAboutToShow(); 1081 void slotContextAboutToShow();
1082 void widgetDestroyed(); 1082 void widgetDestroyed();
1083 1083
1084private: 1084private:
1085 void init( bool readConfig = true, bool honorStyle = false ); 1085 void init( bool readConfig = true, bool honorStyle = false );
1086 void doConnections( KToolBarButton *button ); 1086 void doConnections( KToolBarButton *button );
1087 void insertWidgetInternal( QWidget *w, int &index, int id ); 1087 void insertWidgetInternal( QWidget *w, int &index, int id );
1088 void removeWidgetInternal( QWidget *w ); 1088 void removeWidgetInternal( QWidget *w );
1089 void getAttributes( QString &position, QString &icontext, int &index ); 1089 void getAttributes( QString &position, QString &icontext, int &index );
1090//US KPopupMenu *contextMenu(); 1090//US KPopupMenu *contextMenu();
1091 QPopupMenu *contextMenu(); 1091 QPopupMenu *contextMenu();
1092 1092
1093 QMap<QWidget*, int > widget2id; 1093 QMap<QWidget*, int > widget2id;
1094 typedef QMap<int, QWidget* > Id2WidgetMap; 1094 typedef QMap<int, QWidget* > Id2WidgetMap;
1095 Id2WidgetMap id2widget; 1095 Id2WidgetMap id2widget;
1096//US KPopupMenu *context; 1096//US KPopupMenu *context;
1097 QPopupMenu *context; 1097 QPopupMenu *context;
1098 QPtrList<QWidget> widgets; 1098 QPtrList<QWidget> widgets;
1099 QTimer *layoutTimer; 1099 QTimer *layoutTimer;
1100 QGuardedPtr<QWidget> stretchableWidget, rightAligned; 1100 QGuardedPtr<QWidget> stretchableWidget, rightAligned;
1101protected: 1101protected:
1102 virtual void virtual_hook( int id, void* data ); 1102 virtual void virtual_hook( int id, void* data );
1103private: 1103private:
1104 KToolBarPrivate *d; 1104 KToolBarPrivate *d;
1105 bool inshutdownprocess; 1105 bool inshutdownprocess;
1106}; 1106};
1107 1107
1108#endif 1108#endif