Diffstat (limited to 'microkde/kdeui/kactionclasses.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/kactionclasses.cpp | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/microkde/kdeui/kactionclasses.cpp b/microkde/kdeui/kactionclasses.cpp index 82e6c8b..c611865 100644 --- a/microkde/kdeui/kactionclasses.cpp +++ b/microkde/kdeui/kactionclasses.cpp | |||
@@ -1,520 +1,521 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> | 2 | Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> |
3 | (C) 1999 Simon Hausmann <hausmann@kde.org> | 3 | (C) 1999 Simon Hausmann <hausmann@kde.org> |
4 | (C) 2000 Nicolas Hadacek <haadcek@kde.org> | 4 | (C) 2000 Nicolas Hadacek <haadcek@kde.org> |
5 | (C) 2000 Kurt Granroth <granroth@kde.org> | 5 | (C) 2000 Kurt Granroth <granroth@kde.org> |
6 | (C) 2000 Michael Koch <koch@kde.org> | 6 | (C) 2000 Michael Koch <koch@kde.org> |
7 | (C) 2001 Holger Freyther <freyther@kde.org> | 7 | (C) 2001 Holger Freyther <freyther@kde.org> |
8 | (C) 2002 Ellis Whitehead <ellis@kde.org> | 8 | (C) 2002 Ellis Whitehead <ellis@kde.org> |
9 | (C) 2002 Joseph Wenninger <jowenn@kde.org> | 9 | (C) 2002 Joseph Wenninger <jowenn@kde.org> |
10 | 10 | ||
11 | This library is free software; you can redistribute it and/or | 11 | This library is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU Library General Public | 12 | modify it under the terms of the GNU Library General Public |
13 | License version 2 as published by the Free Software Foundation. | 13 | License version 2 as published by the Free Software Foundation. |
14 | 14 | ||
15 | This library is distributed in the hope that it will be useful, | 15 | This library is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | Library General Public License for more details. | 18 | Library General Public License for more details. |
19 | 19 | ||
20 | You should have received a copy of the GNU Library General Public License | 20 | You should have received a copy of the GNU Library General Public License |
21 | along with this library; see the file COPYING.LIB. If not, write to | 21 | along with this library; see the file COPYING.LIB. If not, write to |
22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 | Boston, MA 02111-1307, USA. | 23 | Boston, MA 02111-1307, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "kactionclasses.h" | 26 | #include "kactionclasses.h" |
27 | 27 | ||
28 | #include <assert.h> | 28 | #include <assert.h> |
29 | 29 | ||
30 | #include <qfontdatabase.h> | 30 | #include <qfontdatabase.h> |
31 | #include <qobjectlist.h> | 31 | #include <qobject.h> |
32 | //US#include <qwhatsthis.h> | 32 | //US#include <qwhatsthis.h> |
33 | #include <qtimer.h> | 33 | #include <qtimer.h> |
34 | //Added by qt3to4: | ||
35 | #include <Q3ValueList> | ||
34 | 36 | ||
35 | //US#include <kaccel.h> | 37 | //US#include <kaccel.h> |
36 | //US#include <kapplication.h> | 38 | //US#include <kapplication.h> |
37 | #include <kconfig.h> | 39 | #include <kconfig.h> |
38 | #include <kdebug.h> | 40 | #include <kdebug.h> |
39 | //US#include <kfontcombo.h> | 41 | //US#include <kfontcombo.h> |
40 | //US#include <kmainwindow.h> | 42 | //US#include <kmainwindow.h> |
41 | //US#include <kmenubar.h> | 43 | //US#include <kmenubar.h> |
42 | //US#include <kpopupmenu.h> | 44 | //US#include <kpopupmenu.h> |
43 | #include <kcombobox.h> | 45 | #include <kcombobox.h> |
44 | #include <ktoolbar.h> | 46 | #include <ktoolbar.h> |
45 | #include <ktoolbarbutton.h> | 47 | #include <ktoolbarbutton.h> |
46 | #include <kurl.h> | 48 | #include <kurl.h> |
47 | 49 | ||
48 | //US added the following includefiles | 50 | //US added the following includefiles |
49 | #include <kconfigbase.h> | 51 | #include <kconfigbase.h> |
50 | #include <qwidget.h> | 52 | #include <qwidget.h> |
51 | #include <qpopupmenu.h> | 53 | #include <q3popupmenu.h> |
52 | #include <qmenubar.h> | 54 | #include <qmenubar.h> |
53 | #include <qmainwindow.h> | 55 | #include <q3mainwindow.h> |
54 | #include <qtoolbar.h> | 56 | #include <q3toolbar.h> |
55 | #include <qcombobox.h> | 57 | #include <qcombobox.h> |
56 | #include <qmainwindow.h> | 58 | #include <q3mainwindow.h> |
57 | 59 | #include <qcoreapplication.h> | |
58 | 60 | ||
59 | static QFontDatabase *fontDataBase = 0; | 61 | static QFontDatabase *fontDataBase = 0; |
60 | 62 | ||
61 | static void cleanupFontDatabase() | 63 | static void cleanupFontDatabase() |
62 | { | 64 | { |
63 | delete fontDataBase; | 65 | delete fontDataBase; |
64 | fontDataBase = 0; | 66 | fontDataBase = 0; |
65 | } | 67 | } |
66 | 68 | ||
67 | static void get_fonts( QStringList &lst ) | 69 | static void get_fonts( QStringList &lst ) |
68 | { | 70 | { |
69 | if ( !fontDataBase ) { | 71 | if ( !fontDataBase ) { |
70 | fontDataBase = new QFontDatabase(); | 72 | fontDataBase = new QFontDatabase(); |
71 | qAddPostRoutine( cleanupFontDatabase ); | 73 | qAddPostRoutine( cleanupFontDatabase ); |
72 | } | 74 | } |
73 | lst.clear(); | 75 | lst.clear(); |
74 | QStringList families = fontDataBase->families(); | 76 | QStringList families = fontDataBase->families(); |
75 | for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) | 77 | for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) |
76 | { | 78 | { |
77 | QString family = *it; | 79 | QString family = *it; |
78 | if ( family. contains('-') ) // remove foundry | 80 | if ( family. contains('-') ) // remove foundry |
79 | family = family.right( family.length() - family.find('-' ) - 1); | 81 | family = family.right( family.length() - family.find('-' ) - 1); |
80 | if ( !lst.contains( family ) ) | 82 | if ( !lst.contains( family ) ) |
81 | lst.append( family ); | 83 | lst.append( family ); |
82 | } | 84 | } |
83 | lst.sort(); | 85 | lst.sort(); |
84 | } | 86 | } |
85 | 87 | ||
86 | static QValueList<int> get_standard_font_sizes() | 88 | static Q3ValueList<int> get_standard_font_sizes() |
87 | { | 89 | { |
88 | if ( !fontDataBase ) { | 90 | if ( !fontDataBase ) { |
89 | fontDataBase = new QFontDatabase(); | 91 | fontDataBase = new QFontDatabase(); |
90 | qAddPostRoutine( cleanupFontDatabase ); | 92 | qAddPostRoutine( cleanupFontDatabase ); |
91 | } | 93 | } |
92 | return fontDataBase->standardSizes(); | 94 | return fontDataBase->standardSizes(); |
93 | } | 95 | } |
94 | 96 | ||
95 | class KToggleAction::KToggleActionPrivate | 97 | class KToggleAction::KToggleActionPrivate |
96 | { | 98 | { |
97 | public: | 99 | public: |
98 | KToggleActionPrivate() | 100 | KToggleActionPrivate() |
99 | { | 101 | { |
100 | m_checked = false; | 102 | m_checked = false; |
101 | } | 103 | } |
102 | 104 | ||
103 | bool m_checked; | 105 | bool m_checked; |
104 | QString m_exclusiveGroup; | 106 | QString m_exclusiveGroup; |
105 | }; | 107 | }; |
106 | 108 | ||
107 | KToggleAction::KToggleAction( const QString& text, const KShortcut& cut, | 109 | KToggleAction::KToggleAction( const QString& text, const KShortcut& cut, |
108 | QObject* parent, | 110 | QObject* parent, |
109 | const char* name ) | 111 | const char* name ) |
110 | : KAction( text, cut, parent, name ) | 112 | : KAction( text, cut, parent, name ) |
111 | { | 113 | { |
112 | d = new KToggleActionPrivate; | 114 | d = new KToggleActionPrivate; |
113 | } | 115 | } |
114 | 116 | ||
115 | KToggleAction::KToggleAction( const QString& text, const KShortcut& cut, | 117 | KToggleAction::KToggleAction( const QString& text, const KShortcut& cut, |
116 | const QObject* receiver, const char* slot, | 118 | const QObject* receiver, const char* slot, |
117 | QObject* parent, const char* name ) | 119 | QObject* parent, const char* name ) |
118 | : KAction( text, cut, receiver, slot, parent, name ) | 120 | : KAction( text, cut, receiver, slot, parent, name ) |
119 | { | 121 | { |
120 | d = new KToggleActionPrivate; | 122 | d = new KToggleActionPrivate; |
121 | } | 123 | } |
122 | 124 | ||
123 | KToggleAction::KToggleAction( const QString& text, const QIconSet& pix, | 125 | KToggleAction::KToggleAction( const QString& text, const QIcon& pix, |
124 | const KShortcut& cut, | 126 | const KShortcut& cut, |
125 | QObject* parent, const char* name ) | 127 | QObject* parent, const char* name ) |
126 | : KAction( text, pix, cut, parent, name ) | 128 | : KAction( text, pix, cut, parent, name ) |
127 | { | 129 | { |
128 | d = new KToggleActionPrivate; | 130 | d = new KToggleActionPrivate; |
129 | } | 131 | } |
130 | 132 | ||
131 | KToggleAction::KToggleAction( const QString& text, const QString& pix, | 133 | KToggleAction::KToggleAction( const QString& text, const QString& pix, |
132 | const KShortcut& cut, | 134 | const KShortcut& cut, |
133 | QObject* parent, const char* name ) | 135 | QObject* parent, const char* name ) |
134 | : KAction( text, pix, cut, parent, name ) | 136 | : KAction( text, pix, cut, parent, name ) |
135 | { | 137 | { |
136 | d = new KToggleActionPrivate; | 138 | d = new KToggleActionPrivate; |
137 | } | 139 | } |
138 | 140 | ||
139 | KToggleAction::KToggleAction( const QString& text, const QIconSet& pix, | 141 | KToggleAction::KToggleAction( const QString& text, const QIcon& pix, |
140 | const KShortcut& cut, | 142 | const KShortcut& cut, |
141 | const QObject* receiver, | 143 | const QObject* receiver, |
142 | const char* slot, QObject* parent, | 144 | const char* slot, QObject* parent, |
143 | const char* name ) | 145 | const char* name ) |
144 | : KAction( text, pix, cut, receiver, slot, parent, name ) | 146 | : KAction( text, pix, cut, receiver, slot, parent, name ) |
145 | { | 147 | { |
146 | d = new KToggleActionPrivate; | 148 | d = new KToggleActionPrivate; |
147 | } | 149 | } |
148 | 150 | ||
149 | KToggleAction::KToggleAction( const QString& text, const QString& pix, | 151 | KToggleAction::KToggleAction( const QString& text, const QString& pix, |
150 | const KShortcut& cut, | 152 | const KShortcut& cut, |
151 | const QObject* receiver, | 153 | const QObject* receiver, |
152 | const char* slot, QObject* parent, | 154 | const char* slot, QObject* parent, |
153 | const char* name ) | 155 | const char* name ) |
154 | : KAction( text, pix, cut, receiver, slot, parent, name ) | 156 | : KAction( text, pix, cut, receiver, slot, parent, name ) |
155 | { | 157 | { |
156 | d = new KToggleActionPrivate; | 158 | d = new KToggleActionPrivate; |
157 | } | 159 | } |
158 | 160 | ||
159 | KToggleAction::KToggleAction( QObject* parent, const char* name ) | 161 | KToggleAction::KToggleAction( QObject* parent, const char* name ) |
160 | : KAction( parent, name ) | 162 | : KAction( parent, name ) |
161 | { | 163 | { |
162 | d = new KToggleActionPrivate; | 164 | d = new KToggleActionPrivate; |
163 | } | 165 | } |
164 | 166 | ||
165 | KToggleAction::~KToggleAction() | 167 | KToggleAction::~KToggleAction() |
166 | { | 168 | { |
167 | delete d; | 169 | delete d; |
168 | } | 170 | } |
169 | 171 | ||
170 | int KToggleAction::plug( QWidget* widget, int index ) | 172 | int KToggleAction::plug( QWidget* widget, int index ) |
171 | { | 173 | { |
172 | if ( !widget->inherits("QPopupMenu") && !widget->inherits("KToolBar") ) | 174 | if ( !widget->inherits("Q3PopupMenu") && !widget->inherits("KToolBar") ) |
173 | { | 175 | { |
174 | kdWarning() << "Can not plug KToggleAction in " << widget->className() << endl; | 176 | kdWarning() << "Can not plug KToggleAction in " << widget->className() << endl; |
175 | return -1; | 177 | return -1; |
176 | } | 178 | } |
177 | 179 | ||
178 | /*US | 180 | /*US |
179 | if (kapp && !kapp->authorizeKAction(name())) | 181 | if (kapp && !kapp->authorizeKAction(name())) |
180 | return -1; | 182 | return -1; |
181 | */ | 183 | */ |
182 | 184 | ||
183 | int _index = KAction::plug( widget, index ); | 185 | int _index = KAction::plug( widget, index ); |
184 | if ( _index == -1 ) | 186 | if ( _index == -1 ) |
185 | return _index; | 187 | return _index; |
186 | 188 | ||
187 | if ( widget->inherits("QPopupMenu") ) | 189 | if ( widget->inherits("Q3PopupMenu") ) |
188 | { | 190 | { |
189 | int id = itemId( _index ); | 191 | int id = itemId( _index ); |
190 | 192 | ||
191 | static_cast<QPopupMenu*>(widget)->setItemChecked( id, d->m_checked ); | 193 | static_cast<Q3PopupMenu*>(widget)->setItemChecked( id, d->m_checked ); |
192 | } else if ( widget->inherits( "KToolBar" ) ) { | 194 | } else if ( widget->inherits( "KToolBar" ) ) { |
193 | 195 | ||
194 | KToolBar *bar = static_cast<KToolBar *>( widget ); | 196 | KToolBar *bar = static_cast<KToolBar *>( widget ); |
195 | 197 | ||
196 | bar->setToggle( itemId( _index ), true ); | 198 | bar->setToggle( itemId( _index ), true ); |
197 | bar->setButton( itemId( _index ), isChecked() ); | 199 | bar->setButton( itemId( _index ), isChecked() ); |
198 | } | 200 | } |
199 | 201 | ||
200 | return _index; | 202 | return _index; |
201 | } | 203 | } |
202 | 204 | ||
203 | void KToggleAction::setChecked( bool c ) | 205 | void KToggleAction::setChecked( bool c ) |
204 | { | 206 | { |
205 | if ( c == d->m_checked ) | 207 | if ( c == d->m_checked ) |
206 | return; | 208 | return; |
207 | //kdDebug(129) << "KToggleAction::setChecked(" << c << ") " << this << " " << name() << endl; | 209 | //kdDebug(129) << "KToggleAction::setChecked(" << c << ") " << this << " " << name() << endl; |
208 | 210 | ||
209 | d->m_checked = c; | 211 | d->m_checked = c; |
210 | 212 | ||
211 | int len = containerCount(); | 213 | int len = containerCount(); |
212 | 214 | ||
213 | for( int i = 0; i < len; ++i ) | 215 | for( int i = 0; i < len; ++i ) |
214 | updateChecked( i ); | 216 | updateChecked( i ); |
215 | 217 | ||
216 | if ( c && parent() && !exclusiveGroup().isEmpty() ) { | 218 | if ( c && parent() && !exclusiveGroup().isEmpty() ) { |
217 | const QObjectList *list = parent()->children(); | 219 | const QObjectList list = parent()->children(); |
218 | if ( list ) { | 220 | if ( !list.empty() ) { |
219 | QObjectListIt it( *list ); | 221 | for(QObjectList::const_iterator it=list.begin();it!=list.end();++it) { |
220 | for( ; it.current(); ++it ) { | 222 | if ( (*it)->inherits( "KToggleAction" ) && (*it) != this && |
221 | if ( it.current()->inherits( "KToggleAction" ) && it.current() != this && | 223 | static_cast<KToggleAction*>((*it))->exclusiveGroup() == exclusiveGroup() ) { |
222 | static_cast<KToggleAction*>(it.current())->exclusiveGroup() == exclusiveGroup() ) { | 224 | KToggleAction *a = static_cast<KToggleAction*>(*it); |
223 | KToggleAction *a = static_cast<KToggleAction*>(it.current()); | ||
224 | if( a->isChecked() ) { | 225 | if( a->isChecked() ) { |
225 | a->setChecked( false ); | 226 | a->setChecked( false ); |
226 | emit a->toggled( false ); | 227 | emit a->toggled( false ); |
227 | } | 228 | } |
228 | } | 229 | } |
229 | } | 230 | } |
230 | } | 231 | } |
231 | } | 232 | } |
232 | } | 233 | } |
233 | 234 | ||
234 | void KToggleAction::updateChecked( int id ) | 235 | void KToggleAction::updateChecked( int id ) |
235 | { | 236 | { |
236 | QWidget *w = container( id ); | 237 | QWidget *w = container( id ); |
237 | 238 | ||
238 | if ( w->inherits( "QPopupMenu" ) ) | 239 | if ( w->inherits( "Q3PopupMenu" ) ) |
239 | static_cast<QPopupMenu*>(w)->setItemChecked( itemId( id ), d->m_checked ); | 240 | static_cast<Q3PopupMenu*>(w)->setItemChecked( itemId( id ), d->m_checked ); |
240 | else if ( w->inherits( "QMenuBar" ) ) | 241 | else if ( w->inherits( "QMenuBar" ) ) |
241 | static_cast<QMenuBar*>(w)->setItemChecked( itemId( id ), d->m_checked ); | 242 | static_cast<QMenuBar*>(w)->setItemChecked( itemId( id ), d->m_checked ); |
242 | else if ( w->inherits( "KToolBar" ) ) | 243 | else if ( w->inherits( "KToolBar" ) ) |
243 | { | 244 | { |
244 | QWidget* r = static_cast<KToolBar*>( w )->getButton( itemId( id ) ); | 245 | QWidget* r = static_cast<KToolBar*>( w )->getButton( itemId( id ) ); |
245 | if ( r && r->inherits( "KToolBarButton" ) ) | 246 | if ( r && r->inherits( "KToolBarButton" ) ) |
246 | static_cast<KToolBar*>( w )->setButton( itemId( id ), d->m_checked ); | 247 | static_cast<KToolBar*>( w )->setButton( itemId( id ), d->m_checked ); |
247 | } | 248 | } |
248 | } | 249 | } |
249 | 250 | ||
250 | void KToggleAction::slotActivated() | 251 | void KToggleAction::slotActivated() |
251 | { | 252 | { |
252 | setChecked( !isChecked() ); | 253 | setChecked( !isChecked() ); |
253 | emit activated(); | 254 | emit activated(); |
254 | emit toggled( isChecked() ); | 255 | emit toggled( isChecked() ); |
255 | } | 256 | } |
256 | 257 | ||
257 | bool KToggleAction::isChecked() const | 258 | bool KToggleAction::isChecked() const |
258 | { | 259 | { |
259 | return d->m_checked; | 260 | return d->m_checked; |
260 | } | 261 | } |
261 | 262 | ||
262 | void KToggleAction::setExclusiveGroup( const QString& name ) | 263 | void KToggleAction::setExclusiveGroup( const QString& name ) |
263 | { | 264 | { |
264 | d->m_exclusiveGroup = name; | 265 | d->m_exclusiveGroup = name; |
265 | } | 266 | } |
266 | 267 | ||
267 | QString KToggleAction::exclusiveGroup() const | 268 | QString KToggleAction::exclusiveGroup() const |
268 | { | 269 | { |
269 | return d->m_exclusiveGroup; | 270 | return d->m_exclusiveGroup; |
270 | } | 271 | } |
271 | 272 | ||
272 | 273 | ||
273 | KRadioAction::KRadioAction( const QString& text, const KShortcut& cut, | 274 | KRadioAction::KRadioAction( const QString& text, const KShortcut& cut, |
274 | QObject* parent, const char* name ) | 275 | QObject* parent, const char* name ) |
275 | : KToggleAction( text, cut, parent, name ) | 276 | : KToggleAction( text, cut, parent, name ) |
276 | { | 277 | { |
277 | } | 278 | } |
278 | 279 | ||
279 | KRadioAction::KRadioAction( const QString& text, const KShortcut& cut, | 280 | KRadioAction::KRadioAction( const QString& text, const KShortcut& cut, |
280 | const QObject* receiver, const char* slot, | 281 | const QObject* receiver, const char* slot, |
281 | QObject* parent, const char* name ) | 282 | QObject* parent, const char* name ) |
282 | : KToggleAction( text, cut, receiver, slot, parent, name ) | 283 | : KToggleAction( text, cut, receiver, slot, parent, name ) |
283 | { | 284 | { |
284 | } | 285 | } |
285 | 286 | ||
286 | KRadioAction::KRadioAction( const QString& text, const QIconSet& pix, | 287 | KRadioAction::KRadioAction( const QString& text, const QIcon& pix, |
287 | const KShortcut& cut, | 288 | const KShortcut& cut, |
288 | QObject* parent, const char* name ) | 289 | QObject* parent, const char* name ) |
289 | : KToggleAction( text, pix, cut, parent, name ) | 290 | : KToggleAction( text, pix, cut, parent, name ) |
290 | { | 291 | { |
291 | } | 292 | } |
292 | 293 | ||
293 | KRadioAction::KRadioAction( const QString& text, const QString& pix, | 294 | KRadioAction::KRadioAction( const QString& text, const QString& pix, |
294 | const KShortcut& cut, | 295 | const KShortcut& cut, |
295 | QObject* parent, const char* name ) | 296 | QObject* parent, const char* name ) |
296 | : KToggleAction( text, pix, cut, parent, name ) | 297 | : KToggleAction( text, pix, cut, parent, name ) |
297 | { | 298 | { |
298 | } | 299 | } |
299 | 300 | ||
300 | KRadioAction::KRadioAction( const QString& text, const QIconSet& pix, | 301 | KRadioAction::KRadioAction( const QString& text, const QIcon& pix, |
301 | const KShortcut& cut, | 302 | const KShortcut& cut, |
302 | const QObject* receiver, const char* slot, | 303 | const QObject* receiver, const char* slot, |
303 | QObject* parent, const char* name ) | 304 | QObject* parent, const char* name ) |
304 | : KToggleAction( text, pix, cut, receiver, slot, parent, name ) | 305 | : KToggleAction( text, pix, cut, receiver, slot, parent, name ) |
305 | { | 306 | { |
306 | } | 307 | } |
307 | 308 | ||
308 | KRadioAction::KRadioAction( const QString& text, const QString& pix, | 309 | KRadioAction::KRadioAction( const QString& text, const QString& pix, |
309 | const KShortcut& cut, | 310 | const KShortcut& cut, |
310 | const QObject* receiver, const char* slot, | 311 | const QObject* receiver, const char* slot, |
311 | QObject* parent, const char* name ) | 312 | QObject* parent, const char* name ) |
312 | : KToggleAction( text, pix, cut, receiver, slot, parent, name ) | 313 | : KToggleAction( text, pix, cut, receiver, slot, parent, name ) |
313 | { | 314 | { |
314 | } | 315 | } |
315 | 316 | ||
316 | KRadioAction::KRadioAction( QObject* parent, const char* name ) | 317 | KRadioAction::KRadioAction( QObject* parent, const char* name ) |
317 | : KToggleAction( parent, name ) | 318 | : KToggleAction( parent, name ) |
318 | { | 319 | { |
319 | } | 320 | } |
320 | 321 | ||
321 | void KRadioAction::slotActivated() | 322 | void KRadioAction::slotActivated() |
322 | { | 323 | { |
323 | if ( isChecked() ) | 324 | if ( isChecked() ) |
324 | { | 325 | { |
325 | const QObject *senderObj = sender(); | 326 | const QObject *senderObj = sender(); |
326 | 327 | ||
327 | if ( !senderObj || !senderObj->inherits( "KToolBarButton" ) ) | 328 | if ( !senderObj || !senderObj->inherits( "KToolBarButton" ) ) |
328 | return; | 329 | return; |
329 | 330 | ||
330 | qDebug("KRadioAction::slotActivated has to be fixed"); | 331 | qDebug("KRadioAction::slotActivated has to be fixed"); |
331 | const_cast<KToolBarButton *>( static_cast<const KToolBarButton *>( senderObj ) )->on( true ); | 332 | const_cast<KToolBarButton *>( static_cast<const KToolBarButton *>( senderObj ) )->on( true ); |
332 | 333 | ||
333 | return; | 334 | return; |
334 | } | 335 | } |
335 | 336 | ||
336 | KToggleAction::slotActivated(); | 337 | KToggleAction::slotActivated(); |
337 | } | 338 | } |
338 | 339 | ||
339 | class KSelectAction::KSelectActionPrivate | 340 | class KSelectAction::KSelectActionPrivate |
340 | { | 341 | { |
341 | public: | 342 | public: |
342 | KSelectActionPrivate() | 343 | KSelectActionPrivate() |
343 | { | 344 | { |
344 | m_edit = false; | 345 | m_edit = false; |
345 | m_menuAccelsEnabled = true; | 346 | m_menuAccelsEnabled = true; |
346 | m_menu = 0; | 347 | m_menu = 0; |
347 | m_current = -1; | 348 | m_current = -1; |
348 | m_comboWidth = -1; | 349 | m_comboWidth = -1; |
349 | } | 350 | } |
350 | bool m_edit; | 351 | bool m_edit; |
351 | bool m_menuAccelsEnabled; | 352 | bool m_menuAccelsEnabled; |
352 | QPopupMenu *m_menu; | 353 | Q3PopupMenu *m_menu; |
353 | int m_current; | 354 | int m_current; |
354 | int m_comboWidth; | 355 | int m_comboWidth; |
355 | QStringList m_list; | 356 | QStringList m_list; |
356 | 357 | ||
357 | QString makeMenuText( const QString &_text ) | 358 | QString makeMenuText( const QString &_text ) |
358 | { | 359 | { |
359 | if ( m_menuAccelsEnabled ) | 360 | if ( m_menuAccelsEnabled ) |
360 | return _text; | 361 | return _text; |
361 | QString text = _text; | 362 | QString text = _text; |
362 | uint i = 0; | 363 | uint i = 0; |
363 | while ( i < text.length() ) { | 364 | while ( i < text.length() ) { |
364 | if ( text.at( i ) == '&' ) { | 365 | if ( text.at( i ) == '&' ) { |
365 | text.insert( i, '&' ); | 366 | text.insert( i, '&' ); |
366 | i += 2; | 367 | i += 2; |
367 | } | 368 | } |
368 | else | 369 | else |
369 | ++i; | 370 | ++i; |
370 | } | 371 | } |
371 | return text; | 372 | return text; |
372 | } | 373 | } |
373 | }; | 374 | }; |
374 | 375 | ||
375 | KSelectAction::KSelectAction( const QString& text, const KShortcut& cut, | 376 | KSelectAction::KSelectAction( const QString& text, const KShortcut& cut, |
376 | QObject* parent, const char* name ) | 377 | QObject* parent, const char* name ) |
377 | : KAction( text, cut, parent, name ) | 378 | : KAction( text, cut, parent, name ) |
378 | { | 379 | { |
379 | d = new KSelectActionPrivate; | 380 | d = new KSelectActionPrivate; |
380 | } | 381 | } |
381 | 382 | ||
382 | KSelectAction::KSelectAction( const QString& text, const KShortcut& cut, | 383 | KSelectAction::KSelectAction( const QString& text, const KShortcut& cut, |
383 | const QObject* receiver, const char* slot, | 384 | const QObject* receiver, const char* slot, |
384 | QObject* parent, const char* name ) | 385 | QObject* parent, const char* name ) |
385 | : KAction( text, cut, receiver, slot, parent, name ) | 386 | : KAction( text, cut, receiver, slot, parent, name ) |
386 | { | 387 | { |
387 | d = new KSelectActionPrivate; | 388 | d = new KSelectActionPrivate; |
388 | } | 389 | } |
389 | 390 | ||
390 | KSelectAction::KSelectAction( const QString& text, const QIconSet& pix, | 391 | KSelectAction::KSelectAction( const QString& text, const QIcon& pix, |
391 | const KShortcut& cut, | 392 | const KShortcut& cut, |
392 | QObject* parent, const char* name ) | 393 | QObject* parent, const char* name ) |
393 | : KAction( text, pix, cut, parent, name ) | 394 | : KAction( text, pix, cut, parent, name ) |
394 | { | 395 | { |
395 | d = new KSelectActionPrivate; | 396 | d = new KSelectActionPrivate; |
396 | } | 397 | } |
397 | 398 | ||
398 | KSelectAction::KSelectAction( const QString& text, const QString& pix, | 399 | KSelectAction::KSelectAction( const QString& text, const QString& pix, |
399 | const KShortcut& cut, | 400 | const KShortcut& cut, |
400 | QObject* parent, const char* name ) | 401 | QObject* parent, const char* name ) |
401 | : KAction( text, pix, cut, parent, name ) | 402 | : KAction( text, pix, cut, parent, name ) |
402 | { | 403 | { |
403 | d = new KSelectActionPrivate; | 404 | d = new KSelectActionPrivate; |
404 | } | 405 | } |
405 | 406 | ||
406 | KSelectAction::KSelectAction( const QString& text, const QIconSet& pix, | 407 | KSelectAction::KSelectAction( const QString& text, const QIcon& pix, |
407 | const KShortcut& cut, | 408 | const KShortcut& cut, |
408 | const QObject* receiver, | 409 | const QObject* receiver, |
409 | const char* slot, QObject* parent, | 410 | const char* slot, QObject* parent, |
410 | const char* name ) | 411 | const char* name ) |
411 | : KAction( text, pix, cut, receiver, slot, parent, name ) | 412 | : KAction( text, pix, cut, receiver, slot, parent, name ) |
412 | { | 413 | { |
413 | d = new KSelectActionPrivate; | 414 | d = new KSelectActionPrivate; |
414 | } | 415 | } |
415 | 416 | ||
416 | KSelectAction::KSelectAction( const QString& text, const QString& pix, | 417 | KSelectAction::KSelectAction( const QString& text, const QString& pix, |
417 | const KShortcut& cut, | 418 | const KShortcut& cut, |
418 | const QObject* receiver, | 419 | const QObject* receiver, |
419 | const char* slot, QObject* parent, | 420 | const char* slot, QObject* parent, |
420 | const char* name ) | 421 | const char* name ) |
421 | : KAction( text, pix, cut, receiver, slot, parent, name ) | 422 | : KAction( text, pix, cut, receiver, slot, parent, name ) |
422 | { | 423 | { |
423 | d = new KSelectActionPrivate; | 424 | d = new KSelectActionPrivate; |
424 | } | 425 | } |
425 | 426 | ||
426 | KSelectAction::KSelectAction( QObject* parent, const char* name ) | 427 | KSelectAction::KSelectAction( QObject* parent, const char* name ) |
427 | : KAction( parent, name ) | 428 | : KAction( parent, name ) |
428 | { | 429 | { |
429 | d = new KSelectActionPrivate; | 430 | d = new KSelectActionPrivate; |
430 | } | 431 | } |
431 | 432 | ||
432 | KSelectAction::~KSelectAction() | 433 | KSelectAction::~KSelectAction() |
433 | { | 434 | { |
434 | assert(d); | 435 | assert(d); |
435 | delete d->m_menu; | 436 | delete d->m_menu; |
436 | delete d; d = 0; | 437 | delete d; d = 0; |
437 | } | 438 | } |
438 | 439 | ||
439 | void KSelectAction::setCurrentItem( int id ) | 440 | void KSelectAction::setCurrentItem( int id ) |
440 | { | 441 | { |
441 | if ( id >= (int)d->m_list.count() ) { | 442 | if ( id >= (int)d->m_list.count() ) { |
442 | ASSERT(id < (int)d->m_list.count()); | 443 | Q_ASSERT(id < (int)d->m_list.count()); |
443 | return; | 444 | return; |
444 | } | 445 | } |
445 | 446 | ||
446 | if ( d->m_menu ) | 447 | if ( d->m_menu ) |
447 | { | 448 | { |
448 | if ( d->m_current >= 0 ) | 449 | if ( d->m_current >= 0 ) |
449 | d->m_menu->setItemChecked( d->m_current, false ); | 450 | d->m_menu->setItemChecked( d->m_current, false ); |
450 | if ( id >= 0 ) | 451 | if ( id >= 0 ) |
451 | { | 452 | { |
452 | //US qDebug("KSelectAction::setCurrentItem %i", id); | 453 | //US qDebug("KSelectAction::setCurrentItem %i", id); |
453 | d->m_menu->setItemChecked( id, true ); | 454 | d->m_menu->setItemChecked( id, true ); |
454 | } | 455 | } |
455 | } | 456 | } |
456 | 457 | ||
457 | d->m_current = id; | 458 | d->m_current = id; |
458 | 459 | ||
459 | int len = containerCount(); | 460 | int len = containerCount(); |
460 | 461 | ||
461 | for( int i = 0; i < len; ++i ) | 462 | for( int i = 0; i < len; ++i ) |
462 | updateCurrentItem( i ); | 463 | updateCurrentItem( i ); |
463 | 464 | ||
464 | // emit KAction::activated(); | 465 | // emit KAction::activated(); |
465 | // emit activated( currentItem() ); | 466 | // emit activated( currentItem() ); |
466 | // emit activated( currentText() ); | 467 | // emit activated( currentText() ); |
467 | } | 468 | } |
468 | 469 | ||
469 | void KSelectAction::setComboWidth( int width ) | 470 | void KSelectAction::setComboWidth( int width ) |
470 | { | 471 | { |
471 | if ( width < 0 ) | 472 | if ( width < 0 ) |
472 | return; | 473 | return; |
473 | 474 | ||
474 | d->m_comboWidth=width; | 475 | d->m_comboWidth=width; |
475 | 476 | ||
476 | int len = containerCount(); | 477 | int len = containerCount(); |
477 | 478 | ||
478 | for( int i = 0; i < len; ++i ) | 479 | for( int i = 0; i < len; ++i ) |
479 | updateComboWidth( i ); | 480 | updateComboWidth( i ); |
480 | 481 | ||
481 | } | 482 | } |
482 | QPopupMenu* KSelectAction::popupMenu() const | 483 | Q3PopupMenu* KSelectAction::popupMenu() const |
483 | { | 484 | { |
484 | kdDebug(129) << "KSelectAction::popupMenu()" << endl; // remove -- ellis | 485 | kdDebug(129) << "KSelectAction::popupMenu()" << endl; // remove -- ellis |
485 | if ( !d->m_menu ) | 486 | if ( !d->m_menu ) |
486 | { | 487 | { |
487 | //US d->m_menu = new KPopupMenu(0L, "KSelectAction::popupMenu()"); | 488 | //US d->m_menu = new KPopupMenu(0L, "KSelectAction::popupMenu()"); |
488 | d->m_menu = new QPopupMenu(0L, "QSelectAction::popupMenu()"); | 489 | d->m_menu = new Q3PopupMenu(0L, "QSelectAction::popupMenu()"); |
489 | setupMenu(); | 490 | setupMenu(); |
490 | if ( d->m_current >= 0 ) | 491 | if ( d->m_current >= 0 ) |
491 | d->m_menu->setItemChecked( d->m_current, true ); | 492 | d->m_menu->setItemChecked( d->m_current, true ); |
492 | } | 493 | } |
493 | 494 | ||
494 | return d->m_menu; | 495 | return d->m_menu; |
495 | } | 496 | } |
496 | 497 | ||
497 | void KSelectAction::setupMenu() const | 498 | void KSelectAction::setupMenu() const |
498 | { | 499 | { |
499 | if ( !d->m_menu ) | 500 | if ( !d->m_menu ) |
500 | return; | 501 | return; |
501 | d->m_menu->clear(); | 502 | d->m_menu->clear(); |
502 | 503 | ||
503 | QStringList::ConstIterator it = d->m_list.begin(); | 504 | QStringList::ConstIterator it = d->m_list.begin(); |
504 | for( uint id = 0; it != d->m_list.end(); ++it, ++id ) { | 505 | for( uint id = 0; it != d->m_list.end(); ++it, ++id ) { |
505 | QString text = *it; | 506 | QString text = *it; |
506 | if ( !text.isEmpty() ) | 507 | if ( !text.isEmpty() ) |
507 | d->m_menu->insertItem( d->makeMenuText( text ), this, SLOT( slotActivated( int ) ), 0, id ); | 508 | d->m_menu->insertItem( d->makeMenuText( text ), this, SLOT( slotActivated( int ) ), 0, id ); |
508 | else | 509 | else |
509 | d->m_menu->insertSeparator(); | 510 | d->m_menu->insertSeparator(); |
510 | } | 511 | } |
511 | } | 512 | } |
512 | 513 | ||
513 | void KSelectAction::changeItem( int index, const QString& text ) | 514 | void KSelectAction::changeItem( int index, const QString& text ) |
514 | { | 515 | { |
515 | if ( index < 0 || index >= (int)d->m_list.count() ) | 516 | if ( index < 0 || index >= (int)d->m_list.count() ) |
516 | { | 517 | { |
517 | kdWarning() << "KSelectAction::changeItem Index out of scope" << endl; | 518 | kdWarning() << "KSelectAction::changeItem Index out of scope" << endl; |
518 | return; | 519 | return; |
519 | } | 520 | } |
520 | 521 | ||
@@ -614,104 +615,104 @@ void KSelectAction::updateComboWidth( int id ) | |||
614 | } | 615 | } |
615 | 616 | ||
616 | void KSelectAction::updateItems( int id ) | 617 | void KSelectAction::updateItems( int id ) |
617 | { | 618 | { |
618 | kdDebug(129) << "KAction::updateItems( " << id << ", lst )" << endl; // remove -- ellis | 619 | kdDebug(129) << "KAction::updateItems( " << id << ", lst )" << endl; // remove -- ellis |
619 | 620 | ||
620 | QWidget* w = container( id ); | 621 | QWidget* w = container( id ); |
621 | if ( w->inherits( "KToolBar" ) ) { | 622 | if ( w->inherits( "KToolBar" ) ) { |
622 | 623 | ||
623 | QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) ); | 624 | QWidget* r = static_cast<KToolBar*>( w )->getWidget( itemId( id ) ); |
624 | if ( r->inherits( "QComboBox" ) ) { | 625 | if ( r->inherits( "QComboBox" ) ) { |
625 | QComboBox *cb = static_cast<QComboBox*>( r ); | 626 | QComboBox *cb = static_cast<QComboBox*>( r ); |
626 | cb->clear(); | 627 | cb->clear(); |
627 | QStringList lst = comboItems(); | 628 | QStringList lst = comboItems(); |
628 | QStringList::ConstIterator it = lst.begin(); | 629 | QStringList::ConstIterator it = lst.begin(); |
629 | for( ; it != lst.end(); ++it ) | 630 | for( ; it != lst.end(); ++it ) |
630 | cb->insertItem( *it ); | 631 | cb->insertItem( *it ); |
631 | // Ok, this currently doesn't work due to a bug in QComboBox | 632 | // Ok, this currently doesn't work due to a bug in QComboBox |
632 | // (the sizehint is cached for ever and never recalculated) | 633 | // (the sizehint is cached for ever and never recalculated) |
633 | // Bug reported (against Qt 2.3.1). | 634 | // Bug reported (against Qt 2.3.1). |
634 | cb->setMinimumWidth( cb->sizeHint().width() ); | 635 | cb->setMinimumWidth( cb->sizeHint().width() ); |
635 | } | 636 | } |
636 | } | 637 | } |
637 | 638 | ||
638 | } | 639 | } |
639 | 640 | ||
640 | int KSelectAction::plug( QWidget *widget, int index ) | 641 | int KSelectAction::plug( QWidget *widget, int index ) |
641 | { | 642 | { |
642 | //US if (kapp && !kapp->authorizeKAction(name())) | 643 | //US if (kapp && !kapp->authorizeKAction(name())) |
643 | //US return -1; | 644 | //US return -1; |
644 | 645 | ||
645 | kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis | 646 | kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis |
646 | if ( widget->inherits("QPopupMenu") ) | 647 | if ( widget->inherits("Q3PopupMenu") ) |
647 | { | 648 | { |
648 | // Create the PopupMenu and store it in m_menu | 649 | // Create the PopupMenu and store it in m_menu |
649 | (void)popupMenu(); | 650 | (void)popupMenu(); |
650 | 651 | ||
651 | QPopupMenu* menu = static_cast<QPopupMenu*>( widget ); | 652 | Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( widget ); |
652 | int id; | 653 | int id; |
653 | 654 | ||
654 | if ( hasIconSet() ) | 655 | if ( hasIconSet() ) |
655 | id = menu->insertItem( iconSet(), text(), d->m_menu, -1, index ); | 656 | id = menu->insertItem( iconSet(), text(), d->m_menu, -1, index ); |
656 | else | 657 | else |
657 | id = menu->insertItem( text(), d->m_menu, -1, index ); | 658 | id = menu->insertItem( text(), d->m_menu, -1, index ); |
658 | 659 | ||
659 | if ( !isEnabled() ) | 660 | if ( !isEnabled() ) |
660 | menu->setItemEnabled( id, false ); | 661 | menu->setItemEnabled( id, false ); |
661 | 662 | ||
662 | QString wth = whatsThis(); | 663 | QString wth = whatsThis(); |
663 | if ( !wth.isEmpty() ) | 664 | if ( !wth.isEmpty() ) |
664 | menu->setWhatsThis( id, wth ); | 665 | menu->setWhatsThis( id, wth ); |
665 | 666 | ||
666 | addContainer( menu, id ); | 667 | addContainer( menu, id ); |
667 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 668 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
668 | 669 | ||
669 | return containerCount() - 1; | 670 | return containerCount() - 1; |
670 | } | 671 | } |
671 | else if ( widget->inherits("KToolBar") ) | 672 | else if ( widget->inherits("KToolBar") ) |
672 | { | 673 | { |
673 | 674 | ||
674 | KToolBar* bar = static_cast<KToolBar*>( widget ); | 675 | KToolBar* bar = static_cast<KToolBar*>( widget ); |
675 | int id_ = KAction::getToolButtonID(); | 676 | int id_ = KAction::getToolButtonID(); |
676 | bar->insertCombo( comboItems(), id_, isEditable(), | 677 | bar->insertCombo( comboItems(), id_, isEditable(), |
677 | SIGNAL( activated( const QString & ) ), this, | 678 | SIGNAL( activated( const QString & ) ), this, |
678 | SLOT( slotActivated( const QString & ) ), isEnabled(), | 679 | SLOT( slotActivated( const QString & ) ), isEnabled(), |
679 | toolTip(), -1, index ); | 680 | toolTip(), -1, index ); |
680 | 681 | ||
681 | KComboBox *cb = bar->getCombo( id_ ); | 682 | KComboBox *cb = bar->getCombo( id_ ); |
682 | if ( cb ) | 683 | if ( cb ) |
683 | { | 684 | { |
684 | cb->setMaximumHeight( 34 ); | 685 | cb->setMaximumHeight( 34 ); |
685 | if (!isEditable()) cb->setFocusPolicy(QWidget::NoFocus); | 686 | if (!isEditable()) cb->setFocusPolicy(Qt::NoFocus); |
686 | cb->setMinimumWidth( cb->sizeHint().width() ); | 687 | cb->setMinimumWidth( cb->sizeHint().width() ); |
687 | if ( d->m_comboWidth > 0 ) | 688 | if ( d->m_comboWidth > 0 ) |
688 | { | 689 | { |
689 | cb->setMinimumWidth( d->m_comboWidth ); | 690 | cb->setMinimumWidth( d->m_comboWidth ); |
690 | cb->setMaximumWidth( d->m_comboWidth ); | 691 | cb->setMaximumWidth( d->m_comboWidth ); |
691 | } | 692 | } |
692 | cb->setInsertionPolicy( QComboBox::NoInsertion ); | 693 | cb->setInsertionPolicy( QComboBox::NoInsertion ); |
693 | //US QWhatsThis::add( cb, whatsThis() ); | 694 | //US QWhatsThis::add( cb, whatsThis() ); |
694 | } | 695 | } |
695 | 696 | ||
696 | addContainer( bar, id_ ); | 697 | addContainer( bar, id_ ); |
697 | 698 | ||
698 | connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 699 | connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
699 | 700 | ||
700 | updateCurrentItem( containerCount() - 1 ); | 701 | updateCurrentItem( containerCount() - 1 ); |
701 | 702 | ||
702 | return containerCount() - 1; | 703 | return containerCount() - 1; |
703 | 704 | ||
704 | } | 705 | } |
705 | kdWarning() << "Can not plug KAction in " << widget->className() << endl; | 706 | kdWarning() << "Can not plug KAction in " << widget->className() << endl; |
706 | return -1; | 707 | return -1; |
707 | } | 708 | } |
708 | 709 | ||
709 | QStringList KSelectAction::comboItems() const | 710 | QStringList KSelectAction::comboItems() const |
710 | { | 711 | { |
711 | //qDebug("KSelectAction::comboItems has to be fixed"); | 712 | //qDebug("KSelectAction::comboItems has to be fixed"); |
712 | if( d->m_menuAccelsEnabled ) | 713 | if( d->m_menuAccelsEnabled ) |
713 | { | 714 | { |
714 | QStringList lst; | 715 | QStringList lst; |
715 | QStringList::ConstIterator it = d->m_list.begin(); | 716 | QStringList::ConstIterator it = d->m_list.begin(); |
716 | for( ; it != d->m_list.end(); ++it ) | 717 | for( ; it != d->m_list.end(); ++it ) |
717 | { | 718 | { |
@@ -823,81 +824,81 @@ void KSelectAction::setMenuAccelsEnabled( bool b ) | |||
823 | bool KSelectAction::menuAccelsEnabled() const | 824 | bool KSelectAction::menuAccelsEnabled() const |
824 | { | 825 | { |
825 | return d->m_menuAccelsEnabled; | 826 | return d->m_menuAccelsEnabled; |
826 | } | 827 | } |
827 | 828 | ||
828 | class KListAction::KListActionPrivate | 829 | class KListAction::KListActionPrivate |
829 | { | 830 | { |
830 | public: | 831 | public: |
831 | KListActionPrivate() | 832 | KListActionPrivate() |
832 | { | 833 | { |
833 | m_current = 0; | 834 | m_current = 0; |
834 | } | 835 | } |
835 | int m_current; | 836 | int m_current; |
836 | }; | 837 | }; |
837 | 838 | ||
838 | KListAction::KListAction( const QString& text, const KShortcut& cut, | 839 | KListAction::KListAction( const QString& text, const KShortcut& cut, |
839 | QObject* parent, const char* name ) | 840 | QObject* parent, const char* name ) |
840 | : KSelectAction( text, cut, parent, name ) | 841 | : KSelectAction( text, cut, parent, name ) |
841 | { | 842 | { |
842 | d = new KListActionPrivate; | 843 | d = new KListActionPrivate; |
843 | } | 844 | } |
844 | 845 | ||
845 | KListAction::KListAction( const QString& text, const KShortcut& cut, | 846 | KListAction::KListAction( const QString& text, const KShortcut& cut, |
846 | const QObject* receiver, const char* slot, | 847 | const QObject* receiver, const char* slot, |
847 | QObject* parent, const char* name ) | 848 | QObject* parent, const char* name ) |
848 | : KSelectAction( text, cut, parent, name ) | 849 | : KSelectAction( text, cut, parent, name ) |
849 | { | 850 | { |
850 | d = new KListActionPrivate; | 851 | d = new KListActionPrivate; |
851 | if ( receiver ) | 852 | if ( receiver ) |
852 | connect( this, SIGNAL( activated( int ) ), receiver, slot ); | 853 | connect( this, SIGNAL( activated( int ) ), receiver, slot ); |
853 | } | 854 | } |
854 | 855 | ||
855 | KListAction::KListAction( const QString& text, const QIconSet& pix, | 856 | KListAction::KListAction( const QString& text, const QIcon& pix, |
856 | const KShortcut& cut, | 857 | const KShortcut& cut, |
857 | QObject* parent, const char* name ) | 858 | QObject* parent, const char* name ) |
858 | : KSelectAction( text, pix, cut, parent, name ) | 859 | : KSelectAction( text, pix, cut, parent, name ) |
859 | { | 860 | { |
860 | d = new KListActionPrivate; | 861 | d = new KListActionPrivate; |
861 | } | 862 | } |
862 | 863 | ||
863 | KListAction::KListAction( const QString& text, const QString& pix, | 864 | KListAction::KListAction( const QString& text, const QString& pix, |
864 | const KShortcut& cut, | 865 | const KShortcut& cut, |
865 | QObject* parent, const char* name ) | 866 | QObject* parent, const char* name ) |
866 | : KSelectAction( text, pix, cut, parent, name ) | 867 | : KSelectAction( text, pix, cut, parent, name ) |
867 | { | 868 | { |
868 | d = new KListActionPrivate; | 869 | d = new KListActionPrivate; |
869 | } | 870 | } |
870 | 871 | ||
871 | KListAction::KListAction( const QString& text, const QIconSet& pix, | 872 | KListAction::KListAction( const QString& text, const QIcon& pix, |
872 | const KShortcut& cut, const QObject* receiver, | 873 | const KShortcut& cut, const QObject* receiver, |
873 | const char* slot, QObject* parent, | 874 | const char* slot, QObject* parent, |
874 | const char* name ) | 875 | const char* name ) |
875 | : KSelectAction( text, pix, cut, parent, name ) | 876 | : KSelectAction( text, pix, cut, parent, name ) |
876 | { | 877 | { |
877 | d = new KListActionPrivate; | 878 | d = new KListActionPrivate; |
878 | if ( receiver ) | 879 | if ( receiver ) |
879 | connect( this, SIGNAL( activated( int ) ), receiver, slot ); | 880 | connect( this, SIGNAL( activated( int ) ), receiver, slot ); |
880 | } | 881 | } |
881 | 882 | ||
882 | KListAction::KListAction( const QString& text, const QString& pix, | 883 | KListAction::KListAction( const QString& text, const QString& pix, |
883 | const KShortcut& cut, const QObject* receiver, | 884 | const KShortcut& cut, const QObject* receiver, |
884 | const char* slot, QObject* parent, | 885 | const char* slot, QObject* parent, |
885 | const char* name ) | 886 | const char* name ) |
886 | : KSelectAction( text, pix, cut, parent, name ) | 887 | : KSelectAction( text, pix, cut, parent, name ) |
887 | { | 888 | { |
888 | d = new KListActionPrivate; | 889 | d = new KListActionPrivate; |
889 | if ( receiver ) | 890 | if ( receiver ) |
890 | connect( this, SIGNAL( activated( int ) ), receiver, slot ); | 891 | connect( this, SIGNAL( activated( int ) ), receiver, slot ); |
891 | } | 892 | } |
892 | 893 | ||
893 | KListAction::KListAction( QObject* parent, const char* name ) | 894 | KListAction::KListAction( QObject* parent, const char* name ) |
894 | : KSelectAction( parent, name ) | 895 | : KSelectAction( parent, name ) |
895 | { | 896 | { |
896 | d = new KListActionPrivate; | 897 | d = new KListActionPrivate; |
897 | } | 898 | } |
898 | 899 | ||
899 | KListAction::~KListAction() | 900 | KListAction::~KListAction() |
900 | { | 901 | { |
901 | delete d; d = 0; | 902 | delete d; d = 0; |
902 | } | 903 | } |
903 | 904 | ||
@@ -936,91 +937,91 @@ public: | |||
936 | 937 | ||
937 | KRecentFilesAction::KRecentFilesAction( const QString& text, | 938 | KRecentFilesAction::KRecentFilesAction( const QString& text, |
938 | const KShortcut& cut, | 939 | const KShortcut& cut, |
939 | QObject* parent, const char* name, | 940 | QObject* parent, const char* name, |
940 | uint maxItems ) | 941 | uint maxItems ) |
941 | : KListAction( text, cut, parent, name) | 942 | : KListAction( text, cut, parent, name) |
942 | { | 943 | { |
943 | d = new KRecentFilesActionPrivate; | 944 | d = new KRecentFilesActionPrivate; |
944 | d->m_maxItems = maxItems; | 945 | d->m_maxItems = maxItems; |
945 | 946 | ||
946 | init(); | 947 | init(); |
947 | } | 948 | } |
948 | 949 | ||
949 | KRecentFilesAction::KRecentFilesAction( const QString& text, | 950 | KRecentFilesAction::KRecentFilesAction( const QString& text, |
950 | const KShortcut& cut, | 951 | const KShortcut& cut, |
951 | const QObject* receiver, | 952 | const QObject* receiver, |
952 | const char* slot, | 953 | const char* slot, |
953 | QObject* parent, const char* name, | 954 | QObject* parent, const char* name, |
954 | uint maxItems ) | 955 | uint maxItems ) |
955 | : KListAction( text, cut, parent, name) | 956 | : KListAction( text, cut, parent, name) |
956 | { | 957 | { |
957 | d = new KRecentFilesActionPrivate; | 958 | d = new KRecentFilesActionPrivate; |
958 | d->m_maxItems = maxItems; | 959 | d->m_maxItems = maxItems; |
959 | 960 | ||
960 | init(); | 961 | init(); |
961 | 962 | ||
962 | if ( receiver ) | 963 | if ( receiver ) |
963 | connect( this, SIGNAL(urlSelected(const KURL&)), | 964 | connect( this, SIGNAL(urlSelected(const KURL&)), |
964 | receiver, slot ); | 965 | receiver, slot ); |
965 | } | 966 | } |
966 | 967 | ||
967 | KRecentFilesAction::KRecentFilesAction( const QString& text, | 968 | KRecentFilesAction::KRecentFilesAction( const QString& text, |
968 | const QIconSet& pix, | 969 | const QIcon& pix, |
969 | const KShortcut& cut, | 970 | const KShortcut& cut, |
970 | QObject* parent, const char* name, | 971 | QObject* parent, const char* name, |
971 | uint maxItems ) | 972 | uint maxItems ) |
972 | : KListAction( text, pix, cut, parent, name) | 973 | : KListAction( text, pix, cut, parent, name) |
973 | { | 974 | { |
974 | d = new KRecentFilesActionPrivate; | 975 | d = new KRecentFilesActionPrivate; |
975 | d->m_maxItems = maxItems; | 976 | d->m_maxItems = maxItems; |
976 | 977 | ||
977 | init(); | 978 | init(); |
978 | } | 979 | } |
979 | 980 | ||
980 | KRecentFilesAction::KRecentFilesAction( const QString& text, | 981 | KRecentFilesAction::KRecentFilesAction( const QString& text, |
981 | const QString& pix, | 982 | const QString& pix, |
982 | const KShortcut& cut, | 983 | const KShortcut& cut, |
983 | QObject* parent, const char* name, | 984 | QObject* parent, const char* name, |
984 | uint maxItems ) | 985 | uint maxItems ) |
985 | : KListAction( text, pix, cut, parent, name) | 986 | : KListAction( text, pix, cut, parent, name) |
986 | { | 987 | { |
987 | d = new KRecentFilesActionPrivate; | 988 | d = new KRecentFilesActionPrivate; |
988 | d->m_maxItems = maxItems; | 989 | d->m_maxItems = maxItems; |
989 | 990 | ||
990 | init(); | 991 | init(); |
991 | } | 992 | } |
992 | 993 | ||
993 | KRecentFilesAction::KRecentFilesAction( const QString& text, | 994 | KRecentFilesAction::KRecentFilesAction( const QString& text, |
994 | const QIconSet& pix, | 995 | const QIcon& pix, |
995 | const KShortcut& cut, | 996 | const KShortcut& cut, |
996 | const QObject* receiver, | 997 | const QObject* receiver, |
997 | const char* slot, | 998 | const char* slot, |
998 | QObject* parent, const char* name, | 999 | QObject* parent, const char* name, |
999 | uint maxItems ) | 1000 | uint maxItems ) |
1000 | : KListAction( text, pix, cut, parent, name) | 1001 | : KListAction( text, pix, cut, parent, name) |
1001 | { | 1002 | { |
1002 | d = new KRecentFilesActionPrivate; | 1003 | d = new KRecentFilesActionPrivate; |
1003 | d->m_maxItems = maxItems; | 1004 | d->m_maxItems = maxItems; |
1004 | 1005 | ||
1005 | init(); | 1006 | init(); |
1006 | 1007 | ||
1007 | if ( receiver ) | 1008 | if ( receiver ) |
1008 | connect( this, SIGNAL(urlSelected(const KURL&)), | 1009 | connect( this, SIGNAL(urlSelected(const KURL&)), |
1009 | receiver, slot ); | 1010 | receiver, slot ); |
1010 | } | 1011 | } |
1011 | 1012 | ||
1012 | KRecentFilesAction::KRecentFilesAction( const QString& text, | 1013 | KRecentFilesAction::KRecentFilesAction( const QString& text, |
1013 | const QString& pix, | 1014 | const QString& pix, |
1014 | const KShortcut& cut, | 1015 | const KShortcut& cut, |
1015 | const QObject* receiver, | 1016 | const QObject* receiver, |
1016 | const char* slot, | 1017 | const char* slot, |
1017 | QObject* parent, const char* name, | 1018 | QObject* parent, const char* name, |
1018 | uint maxItems ) | 1019 | uint maxItems ) |
1019 | : KListAction( text, pix, cut, parent, name) | 1020 | : KListAction( text, pix, cut, parent, name) |
1020 | { | 1021 | { |
1021 | d = new KRecentFilesActionPrivate; | 1022 | d = new KRecentFilesActionPrivate; |
1022 | d->m_maxItems = maxItems; | 1023 | d->m_maxItems = maxItems; |
1023 | 1024 | ||
1024 | init(); | 1025 | init(); |
1025 | 1026 | ||
1026 | if ( receiver ) | 1027 | if ( receiver ) |
@@ -1172,87 +1173,87 @@ void KRecentFilesAction::itemSelected( const QString& text ) | |||
1172 | 1173 | ||
1173 | class KFontAction::KFontActionPrivate | 1174 | class KFontAction::KFontActionPrivate |
1174 | { | 1175 | { |
1175 | public: | 1176 | public: |
1176 | KFontActionPrivate() | 1177 | KFontActionPrivate() |
1177 | { | 1178 | { |
1178 | } | 1179 | } |
1179 | QStringList m_fonts; | 1180 | QStringList m_fonts; |
1180 | }; | 1181 | }; |
1181 | 1182 | ||
1182 | KFontAction::KFontAction( const QString& text, | 1183 | KFontAction::KFontAction( const QString& text, |
1183 | const KShortcut& cut, QObject* parent, | 1184 | const KShortcut& cut, QObject* parent, |
1184 | const char* name ) | 1185 | const char* name ) |
1185 | : KSelectAction( text, cut, parent, name ) | 1186 | : KSelectAction( text, cut, parent, name ) |
1186 | { | 1187 | { |
1187 | d = new KFontActionPrivate; | 1188 | d = new KFontActionPrivate; |
1188 | get_fonts( d->m_fonts ); | 1189 | get_fonts( d->m_fonts ); |
1189 | KSelectAction::setItems( d->m_fonts ); | 1190 | KSelectAction::setItems( d->m_fonts ); |
1190 | setEditable( true ); | 1191 | setEditable( true ); |
1191 | } | 1192 | } |
1192 | 1193 | ||
1193 | KFontAction::KFontAction( const QString& text, const KShortcut& cut, | 1194 | KFontAction::KFontAction( const QString& text, const KShortcut& cut, |
1194 | const QObject* receiver, const char* slot, | 1195 | const QObject* receiver, const char* slot, |
1195 | QObject* parent, const char* name ) | 1196 | QObject* parent, const char* name ) |
1196 | : KSelectAction( text, cut, receiver, slot, parent, name ) | 1197 | : KSelectAction( text, cut, receiver, slot, parent, name ) |
1197 | { | 1198 | { |
1198 | d = new KFontActionPrivate; | 1199 | d = new KFontActionPrivate; |
1199 | get_fonts( d->m_fonts ); | 1200 | get_fonts( d->m_fonts ); |
1200 | KSelectAction::setItems( d->m_fonts ); | 1201 | KSelectAction::setItems( d->m_fonts ); |
1201 | setEditable( true ); | 1202 | setEditable( true ); |
1202 | } | 1203 | } |
1203 | 1204 | ||
1204 | KFontAction::KFontAction( const QString& text, const QIconSet& pix, | 1205 | KFontAction::KFontAction( const QString& text, const QIcon& pix, |
1205 | const KShortcut& cut, | 1206 | const KShortcut& cut, |
1206 | QObject* parent, const char* name ) | 1207 | QObject* parent, const char* name ) |
1207 | : KSelectAction( text, pix, cut, parent, name ) | 1208 | : KSelectAction( text, pix, cut, parent, name ) |
1208 | { | 1209 | { |
1209 | d = new KFontActionPrivate; | 1210 | d = new KFontActionPrivate; |
1210 | get_fonts( d->m_fonts ); | 1211 | get_fonts( d->m_fonts ); |
1211 | KSelectAction::setItems( d->m_fonts ); | 1212 | KSelectAction::setItems( d->m_fonts ); |
1212 | setEditable( true ); | 1213 | setEditable( true ); |
1213 | } | 1214 | } |
1214 | 1215 | ||
1215 | KFontAction::KFontAction( const QString& text, const QString& pix, | 1216 | KFontAction::KFontAction( const QString& text, const QString& pix, |
1216 | const KShortcut& cut, | 1217 | const KShortcut& cut, |
1217 | QObject* parent, const char* name ) | 1218 | QObject* parent, const char* name ) |
1218 | : KSelectAction( text, pix, cut, parent, name ) | 1219 | : KSelectAction( text, pix, cut, parent, name ) |
1219 | { | 1220 | { |
1220 | d = new KFontActionPrivate; | 1221 | d = new KFontActionPrivate; |
1221 | get_fonts( d->m_fonts ); | 1222 | get_fonts( d->m_fonts ); |
1222 | KSelectAction::setItems( d->m_fonts ); | 1223 | KSelectAction::setItems( d->m_fonts ); |
1223 | setEditable( true ); | 1224 | setEditable( true ); |
1224 | } | 1225 | } |
1225 | 1226 | ||
1226 | KFontAction::KFontAction( const QString& text, const QIconSet& pix, | 1227 | KFontAction::KFontAction( const QString& text, const QIcon& pix, |
1227 | const KShortcut& cut, | 1228 | const KShortcut& cut, |
1228 | const QObject* receiver, const char* slot, | 1229 | const QObject* receiver, const char* slot, |
1229 | QObject* parent, const char* name ) | 1230 | QObject* parent, const char* name ) |
1230 | : KSelectAction( text, pix, cut, receiver, slot, parent, name ) | 1231 | : KSelectAction( text, pix, cut, receiver, slot, parent, name ) |
1231 | { | 1232 | { |
1232 | d = new KFontActionPrivate; | 1233 | d = new KFontActionPrivate; |
1233 | get_fonts( d->m_fonts ); | 1234 | get_fonts( d->m_fonts ); |
1234 | KSelectAction::setItems( d->m_fonts ); | 1235 | KSelectAction::setItems( d->m_fonts ); |
1235 | setEditable( true ); | 1236 | setEditable( true ); |
1236 | } | 1237 | } |
1237 | 1238 | ||
1238 | KFontAction::KFontAction( const QString& text, const QString& pix, | 1239 | KFontAction::KFontAction( const QString& text, const QString& pix, |
1239 | const KShortcut& cut, | 1240 | const KShortcut& cut, |
1240 | const QObject* receiver, const char* slot, | 1241 | const QObject* receiver, const char* slot, |
1241 | QObject* parent, const char* name ) | 1242 | QObject* parent, const char* name ) |
1242 | : KSelectAction( text, pix, cut, receiver, slot, parent, name ) | 1243 | : KSelectAction( text, pix, cut, receiver, slot, parent, name ) |
1243 | { | 1244 | { |
1244 | d = new KFontActionPrivate; | 1245 | d = new KFontActionPrivate; |
1245 | get_fonts( d->m_fonts ); | 1246 | get_fonts( d->m_fonts ); |
1246 | KSelectAction::setItems( d->m_fonts ); | 1247 | KSelectAction::setItems( d->m_fonts ); |
1247 | setEditable( true ); | 1248 | setEditable( true ); |
1248 | } | 1249 | } |
1249 | 1250 | ||
1250 | 1251 | ||
1251 | KFontAction::KFontAction( QObject* parent, const char* name ) | 1252 | KFontAction::KFontAction( QObject* parent, const char* name ) |
1252 | : KSelectAction( parent, name ) | 1253 | : KSelectAction( parent, name ) |
1253 | { | 1254 | { |
1254 | d = new KFontActionPrivate; | 1255 | d = new KFontActionPrivate; |
1255 | get_fonts( d->m_fonts ); | 1256 | get_fonts( d->m_fonts ); |
1256 | KSelectAction::setItems( d->m_fonts ); | 1257 | KSelectAction::setItems( d->m_fonts ); |
1257 | setEditable( true ); | 1258 | setEditable( true ); |
1258 | } | 1259 | } |
@@ -1332,298 +1333,298 @@ int KFontAction::plug( QWidget *w, int index ) | |||
1332 | return containerCount() - 1; | 1333 | return containerCount() - 1; |
1333 | } | 1334 | } |
1334 | else return KSelectAction::plug( w, index ); | 1335 | else return KSelectAction::plug( w, index ); |
1335 | */ | 1336 | */ |
1336 | return 3; | 1337 | return 3; |
1337 | } | 1338 | } |
1338 | 1339 | ||
1339 | class KFontSizeAction::KFontSizeActionPrivate | 1340 | class KFontSizeAction::KFontSizeActionPrivate |
1340 | { | 1341 | { |
1341 | public: | 1342 | public: |
1342 | KFontSizeActionPrivate() | 1343 | KFontSizeActionPrivate() |
1343 | { | 1344 | { |
1344 | } | 1345 | } |
1345 | }; | 1346 | }; |
1346 | 1347 | ||
1347 | KFontSizeAction::KFontSizeAction( const QString& text, | 1348 | KFontSizeAction::KFontSizeAction( const QString& text, |
1348 | const KShortcut& cut, | 1349 | const KShortcut& cut, |
1349 | QObject* parent, const char* name ) | 1350 | QObject* parent, const char* name ) |
1350 | : KSelectAction( text, cut, parent, name ) | 1351 | : KSelectAction( text, cut, parent, name ) |
1351 | { | 1352 | { |
1352 | init(); | 1353 | init(); |
1353 | } | 1354 | } |
1354 | 1355 | ||
1355 | KFontSizeAction::KFontSizeAction( const QString& text, | 1356 | KFontSizeAction::KFontSizeAction( const QString& text, |
1356 | const KShortcut& cut, | 1357 | const KShortcut& cut, |
1357 | const QObject* receiver, const char* slot, | 1358 | const QObject* receiver, const char* slot, |
1358 | QObject* parent, const char* name ) | 1359 | QObject* parent, const char* name ) |
1359 | : KSelectAction( text, cut, receiver, slot, parent, name ) | 1360 | : KSelectAction( text, cut, receiver, slot, parent, name ) |
1360 | { | 1361 | { |
1361 | init(); | 1362 | init(); |
1362 | } | 1363 | } |
1363 | 1364 | ||
1364 | KFontSizeAction::KFontSizeAction( const QString& text, const QIconSet& pix, | 1365 | KFontSizeAction::KFontSizeAction( const QString& text, const QIcon& pix, |
1365 | const KShortcut& cut, | 1366 | const KShortcut& cut, |
1366 | QObject* parent, const char* name ) | 1367 | QObject* parent, const char* name ) |
1367 | : KSelectAction( text, pix, cut, parent, name ) | 1368 | : KSelectAction( text, pix, cut, parent, name ) |
1368 | { | 1369 | { |
1369 | init(); | 1370 | init(); |
1370 | } | 1371 | } |
1371 | 1372 | ||
1372 | KFontSizeAction::KFontSizeAction( const QString& text, const QString& pix, | 1373 | KFontSizeAction::KFontSizeAction( const QString& text, const QString& pix, |
1373 | const KShortcut& cut, | 1374 | const KShortcut& cut, |
1374 | QObject* parent, const char* name ) | 1375 | QObject* parent, const char* name ) |
1375 | : KSelectAction( text, pix, cut, parent, name ) | 1376 | : KSelectAction( text, pix, cut, parent, name ) |
1376 | { | 1377 | { |
1377 | init(); | 1378 | init(); |
1378 | } | 1379 | } |
1379 | 1380 | ||
1380 | KFontSizeAction::KFontSizeAction( const QString& text, const QIconSet& pix, | 1381 | KFontSizeAction::KFontSizeAction( const QString& text, const QIcon& pix, |
1381 | const KShortcut& cut, | 1382 | const KShortcut& cut, |
1382 | const QObject* receiver, | 1383 | const QObject* receiver, |
1383 | const char* slot, QObject* parent, | 1384 | const char* slot, QObject* parent, |
1384 | const char* name ) | 1385 | const char* name ) |
1385 | : KSelectAction( text, pix, cut, receiver, slot, parent, name ) | 1386 | : KSelectAction( text, pix, cut, receiver, slot, parent, name ) |
1386 | { | 1387 | { |
1387 | init(); | 1388 | init(); |
1388 | } | 1389 | } |
1389 | 1390 | ||
1390 | KFontSizeAction::KFontSizeAction( const QString& text, const QString& pix, | 1391 | KFontSizeAction::KFontSizeAction( const QString& text, const QString& pix, |
1391 | const KShortcut& cut, | 1392 | const KShortcut& cut, |
1392 | const QObject* receiver, | 1393 | const QObject* receiver, |
1393 | const char* slot, QObject* parent, | 1394 | const char* slot, QObject* parent, |
1394 | const char* name ) | 1395 | const char* name ) |
1395 | : KSelectAction( text, pix, cut, receiver, slot, parent, name ) | 1396 | : KSelectAction( text, pix, cut, receiver, slot, parent, name ) |
1396 | { | 1397 | { |
1397 | init(); | 1398 | init(); |
1398 | } | 1399 | } |
1399 | 1400 | ||
1400 | KFontSizeAction::KFontSizeAction( QObject* parent, const char* name ) | 1401 | KFontSizeAction::KFontSizeAction( QObject* parent, const char* name ) |
1401 | : KSelectAction( parent, name ) | 1402 | : KSelectAction( parent, name ) |
1402 | { | 1403 | { |
1403 | init(); | 1404 | init(); |
1404 | } | 1405 | } |
1405 | 1406 | ||
1406 | KFontSizeAction::~KFontSizeAction() | 1407 | KFontSizeAction::~KFontSizeAction() |
1407 | { | 1408 | { |
1408 | delete d; | 1409 | delete d; |
1409 | d = 0; | 1410 | d = 0; |
1410 | } | 1411 | } |
1411 | 1412 | ||
1412 | void KFontSizeAction::init() | 1413 | void KFontSizeAction::init() |
1413 | { | 1414 | { |
1414 | d = new KFontSizeActionPrivate; | 1415 | d = new KFontSizeActionPrivate; |
1415 | 1416 | ||
1416 | setEditable( true ); | 1417 | setEditable( true ); |
1417 | QValueList<int> sizes = get_standard_font_sizes(); | 1418 | Q3ValueList<int> sizes = get_standard_font_sizes(); |
1418 | QStringList lst; | 1419 | QStringList lst; |
1419 | for ( QValueList<int>::Iterator it = sizes.begin(); it != sizes.end(); ++it ) | 1420 | for ( Q3ValueList<int>::Iterator it = sizes.begin(); it != sizes.end(); ++it ) |
1420 | lst.append( QString::number( *it ) ); | 1421 | lst.append( QString::number( *it ) ); |
1421 | 1422 | ||
1422 | setItems( lst ); | 1423 | setItems( lst ); |
1423 | } | 1424 | } |
1424 | 1425 | ||
1425 | void KFontSizeAction::setFontSize( int size ) | 1426 | void KFontSizeAction::setFontSize( int size ) |
1426 | { | 1427 | { |
1427 | if ( size == fontSize() ) { | 1428 | if ( size == fontSize() ) { |
1428 | setCurrentItem( items().findIndex( QString::number( size ) ) ); | 1429 | setCurrentItem( items().findIndex( QString::number( size ) ) ); |
1429 | return; | 1430 | return; |
1430 | } | 1431 | } |
1431 | 1432 | ||
1432 | if ( size < 1 ) { | 1433 | if ( size < 1 ) { |
1433 | kdWarning() << "KFontSizeAction: Size " << size << " is out of range" << endl; | 1434 | kdWarning() << "KFontSizeAction: Size " << size << " is out of range" << endl; |
1434 | return; | 1435 | return; |
1435 | } | 1436 | } |
1436 | 1437 | ||
1437 | int index = items().findIndex( QString::number( size ) ); | 1438 | int index = items().findIndex( QString::number( size ) ); |
1438 | if ( index == -1 ) { | 1439 | if ( index == -1 ) { |
1439 | // Insert at the correct position in the list (to keep sorting) | 1440 | // Insert at the correct position in the list (to keep sorting) |
1440 | QValueList<int> lst; | 1441 | Q3ValueList<int> lst; |
1441 | // Convert to list of ints | 1442 | // Convert to list of ints |
1442 | QStringList itemsList = items(); | 1443 | QStringList itemsList = items(); |
1443 | for (QStringList::Iterator it = itemsList.begin() ; it != itemsList.end() ; ++it) | 1444 | for (QStringList::Iterator it = itemsList.begin() ; it != itemsList.end() ; ++it) |
1444 | lst.append( (*it).toInt() ); | 1445 | lst.append( (*it).toInt() ); |
1445 | // New size | 1446 | // New size |
1446 | lst.append( size ); | 1447 | lst.append( size ); |
1447 | // Sort the list | 1448 | // Sort the list |
1448 | qDebug("KFontSizeAction::setFontSize heapsort not found."); | 1449 | qDebug("KFontSizeAction::setFontSize heapsort not found."); |
1449 | //US has to be fixed | 1450 | //US has to be fixed |
1450 | //US qHeapSort( lst ); | 1451 | //US qHeapSort( lst ); |
1451 | // Convert back to string list | 1452 | // Convert back to string list |
1452 | QStringList strLst; | 1453 | QStringList strLst; |
1453 | for (QValueList<int>::Iterator it = lst.begin() ; it != lst.end() ; ++it) | 1454 | for (Q3ValueList<int>::Iterator it = lst.begin() ; it != lst.end() ; ++it) |
1454 | strLst.append( QString::number(*it) ); | 1455 | strLst.append( QString::number(*it) ); |
1455 | KSelectAction::setItems( strLst ); | 1456 | KSelectAction::setItems( strLst ); |
1456 | // Find new current item | 1457 | // Find new current item |
1457 | index = lst.findIndex( size ); | 1458 | index = lst.findIndex( size ); |
1458 | setCurrentItem( index ); | 1459 | setCurrentItem( index ); |
1459 | } | 1460 | } |
1460 | else | 1461 | else |
1461 | setCurrentItem( index ); | 1462 | setCurrentItem( index ); |
1462 | 1463 | ||
1463 | 1464 | ||
1464 | //emit KAction::activated(); | 1465 | //emit KAction::activated(); |
1465 | //emit activated( index ); | 1466 | //emit activated( index ); |
1466 | //emit activated( QString::number( size ) ); | 1467 | //emit activated( QString::number( size ) ); |
1467 | //emit fontSizeChanged( size ); | 1468 | //emit fontSizeChanged( size ); |
1468 | } | 1469 | } |
1469 | 1470 | ||
1470 | int KFontSizeAction::fontSize() const | 1471 | int KFontSizeAction::fontSize() const |
1471 | { | 1472 | { |
1472 | return currentText().toInt(); | 1473 | return currentText().toInt(); |
1473 | } | 1474 | } |
1474 | 1475 | ||
1475 | void KFontSizeAction::slotActivated( int index ) | 1476 | void KFontSizeAction::slotActivated( int index ) |
1476 | { | 1477 | { |
1477 | KSelectAction::slotActivated( index ); | 1478 | KSelectAction::slotActivated( index ); |
1478 | 1479 | ||
1479 | emit fontSizeChanged( items()[ index ].toInt() ); | 1480 | emit fontSizeChanged( items()[ index ].toInt() ); |
1480 | } | 1481 | } |
1481 | 1482 | ||
1482 | void KFontSizeAction::slotActivated( const QString& size ) | 1483 | void KFontSizeAction::slotActivated( const QString& size ) |
1483 | { | 1484 | { |
1484 | setFontSize( size.toInt() ); // insert sorted first | 1485 | setFontSize( size.toInt() ); // insert sorted first |
1485 | KSelectAction::slotActivated( size ); | 1486 | KSelectAction::slotActivated( size ); |
1486 | emit fontSizeChanged( size.toInt() ); | 1487 | emit fontSizeChanged( size.toInt() ); |
1487 | } | 1488 | } |
1488 | 1489 | ||
1489 | class KActionMenu::KActionMenuPrivate | 1490 | class KActionMenu::KActionMenuPrivate |
1490 | { | 1491 | { |
1491 | public: | 1492 | public: |
1492 | KActionMenuPrivate() | 1493 | KActionMenuPrivate() |
1493 | { | 1494 | { |
1494 | //US m_popup = new KPopupMenu(0L,"KActionMenu::KActionMenuPrivate"); | 1495 | //US m_popup = new KPopupMenu(0L,"KActionMenu::KActionMenuPrivate"); |
1495 | m_popup = new QPopupMenu(0L,"KActionMenu::KActionMenuPrivate"); | 1496 | m_popup = new Q3PopupMenu(0L,"KActionMenu::KActionMenuPrivate"); |
1496 | m_delayed = true; | 1497 | m_delayed = true; |
1497 | m_stickyMenu = true; | 1498 | m_stickyMenu = true; |
1498 | } | 1499 | } |
1499 | ~KActionMenuPrivate() | 1500 | ~KActionMenuPrivate() |
1500 | { | 1501 | { |
1501 | delete m_popup; m_popup = 0; | 1502 | delete m_popup; m_popup = 0; |
1502 | } | 1503 | } |
1503 | 1504 | ||
1504 | //US KPopupMenu *m_popup; | 1505 | //US KPopupMenu *m_popup; |
1505 | QPopupMenu *m_popup; | 1506 | Q3PopupMenu *m_popup; |
1506 | bool m_delayed; | 1507 | bool m_delayed; |
1507 | bool m_stickyMenu; | 1508 | bool m_stickyMenu; |
1508 | }; | 1509 | }; |
1509 | 1510 | ||
1510 | KActionMenu::KActionMenu( QObject* parent, const char* name ) | 1511 | KActionMenu::KActionMenu( QObject* parent, const char* name ) |
1511 | : KAction( parent, name ) | 1512 | : KAction( parent, name ) |
1512 | { | 1513 | { |
1513 | d = new KActionMenuPrivate; | 1514 | d = new KActionMenuPrivate; |
1514 | setShortcutConfigurable( false ); | 1515 | setShortcutConfigurable( false ); |
1515 | } | 1516 | } |
1516 | 1517 | ||
1517 | KActionMenu::KActionMenu( const QString& text, QObject* parent, | 1518 | KActionMenu::KActionMenu( const QString& text, QObject* parent, |
1518 | const char* name ) | 1519 | const char* name ) |
1519 | : KAction( text, 0, parent, name ) | 1520 | : KAction( text, 0, parent, name ) |
1520 | { | 1521 | { |
1521 | d = new KActionMenuPrivate; | 1522 | d = new KActionMenuPrivate; |
1522 | setShortcutConfigurable( false ); | 1523 | setShortcutConfigurable( false ); |
1523 | } | 1524 | } |
1524 | 1525 | ||
1525 | KActionMenu::KActionMenu( const QString& text, const QIconSet& icon, | 1526 | KActionMenu::KActionMenu( const QString& text, const QIcon& icon, |
1526 | QObject* parent, const char* name ) | 1527 | QObject* parent, const char* name ) |
1527 | : KAction( text, icon, 0, parent, name ) | 1528 | : KAction( text, icon, 0, parent, name ) |
1528 | { | 1529 | { |
1529 | d = new KActionMenuPrivate; | 1530 | d = new KActionMenuPrivate; |
1530 | setShortcutConfigurable( false ); | 1531 | setShortcutConfigurable( false ); |
1531 | } | 1532 | } |
1532 | 1533 | ||
1533 | KActionMenu::KActionMenu( const QString& text, const QString& icon, | 1534 | KActionMenu::KActionMenu( const QString& text, const QString& icon, |
1534 | QObject* parent, const char* name ) | 1535 | QObject* parent, const char* name ) |
1535 | : KAction( text, icon, 0, parent, name ) | 1536 | : KAction( text, icon, 0, parent, name ) |
1536 | { | 1537 | { |
1537 | d = new KActionMenuPrivate; | 1538 | d = new KActionMenuPrivate; |
1538 | setShortcutConfigurable( false ); | 1539 | setShortcutConfigurable( false ); |
1539 | } | 1540 | } |
1540 | 1541 | ||
1541 | KActionMenu::~KActionMenu() | 1542 | KActionMenu::~KActionMenu() |
1542 | { | 1543 | { |
1543 | unplugAll(); | 1544 | unplugAll(); |
1544 | kdDebug(129) << "KActionMenu::~KActionMenu()" << endl; // ellis | 1545 | kdDebug(129) << "KActionMenu::~KActionMenu()" << endl; // ellis |
1545 | delete d; d = 0; | 1546 | delete d; d = 0; |
1546 | } | 1547 | } |
1547 | 1548 | ||
1548 | void KActionMenu::popup( const QPoint& global ) | 1549 | void KActionMenu::popup( const QPoint& global ) |
1549 | { | 1550 | { |
1550 | popupMenu()->popup( global ); | 1551 | popupMenu()->popup( global ); |
1551 | } | 1552 | } |
1552 | 1553 | ||
1553 | 1554 | ||
1554 | //US KPopupMenu* KActionMenu::popupMenu() const | 1555 | //US KPopupMenu* KActionMenu::popupMenu() const |
1555 | QPopupMenu* KActionMenu::popupMenu() const | 1556 | Q3PopupMenu* KActionMenu::popupMenu() const |
1556 | { | 1557 | { |
1557 | return d->m_popup; | 1558 | return d->m_popup; |
1558 | } | 1559 | } |
1559 | 1560 | ||
1560 | void KActionMenu::insert( KAction* cmd, int index ) | 1561 | void KActionMenu::insert( KAction* cmd, int index ) |
1561 | { | 1562 | { |
1562 | if ( cmd ) | 1563 | if ( cmd ) |
1563 | cmd->plug( d->m_popup, index ); | 1564 | cmd->plug( d->m_popup, index ); |
1564 | } | 1565 | } |
1565 | 1566 | ||
1566 | void KActionMenu::remove( KAction* cmd ) | 1567 | void KActionMenu::remove( KAction* cmd ) |
1567 | { | 1568 | { |
1568 | if ( cmd ) | 1569 | if ( cmd ) |
1569 | cmd->unplug( d->m_popup ); | 1570 | cmd->unplug( d->m_popup ); |
1570 | } | 1571 | } |
1571 | 1572 | ||
1572 | bool KActionMenu::delayed() const { | 1573 | bool KActionMenu::delayed() const { |
1573 | return d->m_delayed; | 1574 | return d->m_delayed; |
1574 | } | 1575 | } |
1575 | 1576 | ||
1576 | void KActionMenu::setDelayed(bool _delayed) { | 1577 | void KActionMenu::setDelayed(bool _delayed) { |
1577 | d->m_delayed = _delayed; | 1578 | d->m_delayed = _delayed; |
1578 | } | 1579 | } |
1579 | 1580 | ||
1580 | bool KActionMenu::stickyMenu() const { | 1581 | bool KActionMenu::stickyMenu() const { |
1581 | return d->m_stickyMenu; | 1582 | return d->m_stickyMenu; |
1582 | } | 1583 | } |
1583 | 1584 | ||
1584 | void KActionMenu::setStickyMenu(bool sticky) { | 1585 | void KActionMenu::setStickyMenu(bool sticky) { |
1585 | d->m_stickyMenu = sticky; | 1586 | d->m_stickyMenu = sticky; |
1586 | } | 1587 | } |
1587 | 1588 | ||
1588 | int KActionMenu::plug( QWidget* widget, int index ) | 1589 | int KActionMenu::plug( QWidget* widget, int index ) |
1589 | { | 1590 | { |
1590 | /*US | 1591 | /*US |
1591 | if (kapp && !kapp->authorizeKAction(name())) | 1592 | if (kapp && !kapp->authorizeKAction(name())) |
1592 | return -1; | 1593 | return -1; |
1593 | */ | 1594 | */ |
1594 | kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis | 1595 | kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis |
1595 | if ( widget->inherits("QPopupMenu") ) | 1596 | if ( widget->inherits("Q3PopupMenu") ) |
1596 | { | 1597 | { |
1597 | QPopupMenu* menu = static_cast<QPopupMenu*>( widget ); | 1598 | Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( widget ); |
1598 | int id; | 1599 | int id; |
1599 | if ( hasIconSet() ) | 1600 | if ( hasIconSet() ) |
1600 | id = menu->insertItem( iconSet(), text(), d->m_popup, -1, index ); | 1601 | id = menu->insertItem( iconSet(), text(), d->m_popup, -1, index ); |
1601 | else | 1602 | else |
1602 | id = menu->insertItem( text(), d->m_popup, -1, index ); | 1603 | id = menu->insertItem( text(), d->m_popup, -1, index ); |
1603 | 1604 | ||
1604 | if ( !isEnabled() ) | 1605 | if ( !isEnabled() ) |
1605 | menu->setItemEnabled( id, false ); | 1606 | menu->setItemEnabled( id, false ); |
1606 | 1607 | ||
1607 | addContainer( menu, id ); | 1608 | addContainer( menu, id ); |
1608 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 1609 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
1609 | 1610 | ||
1610 | if ( m_parentCollection ) | 1611 | if ( m_parentCollection ) |
1611 | m_parentCollection->connectHighlight( menu, this ); | 1612 | m_parentCollection->connectHighlight( menu, this ); |
1612 | 1613 | ||
1613 | return containerCount() - 1; | 1614 | return containerCount() - 1; |
1614 | } | 1615 | } |
1615 | else if ( widget->inherits( "KToolBar" ) ) | 1616 | else if ( widget->inherits( "KToolBar" ) ) |
1616 | { | 1617 | { |
1617 | KToolBar *bar = static_cast<KToolBar *>( widget ); | 1618 | KToolBar *bar = static_cast<KToolBar *>( widget ); |
1618 | 1619 | ||
1619 | int id_ = KAction::getToolButtonID(); | 1620 | int id_ = KAction::getToolButtonID(); |
1620 | 1621 | ||
1621 | if ( icon().isEmpty() && !iconSet().isNull() ) | 1622 | if ( icon().isEmpty() && !iconSet().isNull() ) |
1622 | bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, | 1623 | bar->insertButton( iconSet().pixmap(), id_, SIGNAL( clicked() ), this, |
1623 | SLOT( slotActivated() ), isEnabled(), plainText(), | 1624 | SLOT( slotActivated() ), isEnabled(), plainText(), |
1624 | index ); | 1625 | index ); |
1625 | else | 1626 | else |
1626 | { | 1627 | { |
1627 | /*US | 1628 | /*US |
1628 | KInstance *instance; | 1629 | KInstance *instance; |
1629 | 1630 | ||
@@ -1752,70 +1753,70 @@ int KToolBarPopupAction::plug( QWidget *widget, int index ) | |||
1752 | /*US | 1753 | /*US |
1753 | KInstance * instance; | 1754 | KInstance * instance; |
1754 | if ( m_parentCollection ) | 1755 | if ( m_parentCollection ) |
1755 | instance = m_parentCollection->instance(); | 1756 | instance = m_parentCollection->instance(); |
1756 | else | 1757 | else |
1757 | instance = KGlobal::instance(); | 1758 | instance = KGlobal::instance(); |
1758 | */ | 1759 | */ |
1759 | bar->insertButton( icon(), id_, SIGNAL( clicked() ), this, | 1760 | bar->insertButton( icon(), id_, SIGNAL( clicked() ), this, |
1760 | SLOT( slotActivated() ), isEnabled(), plainText(), | 1761 | SLOT( slotActivated() ), isEnabled(), plainText(), |
1761 | index/*US, instance*/ ); | 1762 | index/*US, instance*/ ); |
1762 | 1763 | ||
1763 | addContainer( bar, id_ ); | 1764 | addContainer( bar, id_ ); |
1764 | 1765 | ||
1765 | connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 1766 | connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
1766 | 1767 | ||
1767 | if (delayed()) { | 1768 | if (delayed()) { |
1768 | bar->setDelayedPopup( id_, popupMenu(), stickyMenu() ); | 1769 | bar->setDelayedPopup( id_, popupMenu(), stickyMenu() ); |
1769 | } else { | 1770 | } else { |
1770 | bar->getButton(id_)->setPopup(popupMenu(), stickyMenu()); | 1771 | bar->getButton(id_)->setPopup(popupMenu(), stickyMenu()); |
1771 | } | 1772 | } |
1772 | /*US | 1773 | /*US |
1773 | if ( !whatsThis().isEmpty() ) | 1774 | if ( !whatsThis().isEmpty() ) |
1774 | QWhatsThis::add( bar->getButton( id_ ), whatsThisWithIcon() ); | 1775 | QWhatsThis::add( bar->getButton( id_ ), whatsThisWithIcon() ); |
1775 | */ | 1776 | */ |
1776 | return containerCount() - 1; | 1777 | return containerCount() - 1; |
1777 | } | 1778 | } |
1778 | 1779 | ||
1779 | 1780 | ||
1780 | return KAction::plug( widget, index ); | 1781 | return KAction::plug( widget, index ); |
1781 | } | 1782 | } |
1782 | 1783 | ||
1783 | //US KPopupMenu *KToolBarPopupAction::popupMenu() const | 1784 | //US KPopupMenu *KToolBarPopupAction::popupMenu() const |
1784 | QPopupMenu *KToolBarPopupAction::popupMenu() const | 1785 | Q3PopupMenu *KToolBarPopupAction::popupMenu() const |
1785 | { | 1786 | { |
1786 | if ( !m_popup ) { | 1787 | if ( !m_popup ) { |
1787 | KToolBarPopupAction *that = const_cast<KToolBarPopupAction*>(this); | 1788 | KToolBarPopupAction *that = const_cast<KToolBarPopupAction*>(this); |
1788 | //US that->m_popup = new KPopupMenu; | 1789 | //US that->m_popup = new KPopupMenu; |
1789 | that->m_popup = new QPopupMenu; | 1790 | that->m_popup = new Q3PopupMenu; |
1790 | } | 1791 | } |
1791 | return m_popup; | 1792 | return m_popup; |
1792 | } | 1793 | } |
1793 | 1794 | ||
1794 | //////// | 1795 | //////// |
1795 | 1796 | ||
1796 | KToggleToolBarAction::KToggleToolBarAction( const char* toolBarName, | 1797 | KToggleToolBarAction::KToggleToolBarAction( const char* toolBarName, |
1797 | const QString& text, KActionCollection* parent, const char* name ) | 1798 | const QString& text, KActionCollection* parent, const char* name ) |
1798 | : KToggleAction( text, KShortcut(), parent, name ) | 1799 | : KToggleAction( text, KShortcut(), parent, name ) |
1799 | , m_toolBarName( toolBarName ) | 1800 | , m_toolBarName( toolBarName ) |
1800 | , m_toolBar( 0L ) | 1801 | , m_toolBar( 0L ) |
1801 | { | 1802 | { |
1802 | } | 1803 | } |
1803 | 1804 | ||
1804 | KToggleToolBarAction::KToggleToolBarAction( KToolBar *toolBar, const QString &text, | 1805 | KToggleToolBarAction::KToggleToolBarAction( KToolBar *toolBar, const QString &text, |
1805 | KActionCollection *parent, const char *name ) | 1806 | KActionCollection *parent, const char *name ) |
1806 | : KToggleAction( text, KShortcut(), parent, name ) | 1807 | : KToggleAction( text, KShortcut(), parent, name ) |
1807 | , m_toolBarName( 0 ) | 1808 | , m_toolBarName( 0 ) |
1808 | , m_toolBar( toolBar ) | 1809 | , m_toolBar( toolBar ) |
1809 | { | 1810 | { |
1810 | } | 1811 | } |
1811 | 1812 | ||
1812 | KToggleToolBarAction::~KToggleToolBarAction() | 1813 | KToggleToolBarAction::~KToggleToolBarAction() |
1813 | { | 1814 | { |
1814 | } | 1815 | } |
1815 | 1816 | ||
1816 | int KToggleToolBarAction::plug( QWidget* w, int index ) | 1817 | int KToggleToolBarAction::plug( QWidget* w, int index ) |
1817 | { | 1818 | { |
1818 | qDebug("KToggleToolBarAction::plug has to be fixed"); | 1819 | qDebug("KToggleToolBarAction::plug has to be fixed"); |
1819 | /*US | 1820 | /*US |
1820 | if (kapp && !kapp->authorizeKAction(name())) | 1821 | if (kapp && !kapp->authorizeKAction(name())) |
1821 | return -1; | 1822 | return -1; |
@@ -1924,88 +1925,88 @@ int KWidgetAction::plug( QWidget* w, int index ) | |||
1924 | 1925 | ||
1925 | m_widget->reparent( toolBar, QPoint() ); | 1926 | m_widget->reparent( toolBar, QPoint() ); |
1926 | toolBar->insertWidget( id, 0, m_widget, index ); | 1927 | toolBar->insertWidget( id, 0, m_widget, index ); |
1927 | toolBar->setItemAutoSized( id, m_autoSized ); | 1928 | toolBar->setItemAutoSized( id, m_autoSized ); |
1928 | 1929 | ||
1929 | //US QWhatsThis::add( m_widget, whatsThis() ); | 1930 | //US QWhatsThis::add( m_widget, whatsThis() ); |
1930 | addContainer( toolBar, id ); | 1931 | addContainer( toolBar, id ); |
1931 | 1932 | ||
1932 | connect( toolBar, SIGNAL( toolbarDestroyed() ), this, SLOT( slotToolbarDestroyed() ) ); | 1933 | connect( toolBar, SIGNAL( toolbarDestroyed() ), this, SLOT( slotToolbarDestroyed() ) ); |
1933 | connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 1934 | connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
1934 | 1935 | ||
1935 | return containerCount() - 1; | 1936 | return containerCount() - 1; |
1936 | } | 1937 | } |
1937 | 1938 | ||
1938 | void KWidgetAction::unplug( QWidget *w ) | 1939 | void KWidgetAction::unplug( QWidget *w ) |
1939 | { | 1940 | { |
1940 | if( !m_widget || !isPlugged() ) | 1941 | if( !m_widget || !isPlugged() ) |
1941 | return; | 1942 | return; |
1942 | 1943 | ||
1943 | KToolBar* toolBar = (KToolBar*)m_widget->parent(); | 1944 | KToolBar* toolBar = (KToolBar*)m_widget->parent(); |
1944 | if ( toolBar == w ) | 1945 | if ( toolBar == w ) |
1945 | { | 1946 | { |
1946 | disconnect( toolBar, SIGNAL( toolbarDestroyed() ), this, SLOT( slotToolbarDestroyed() ) ); | 1947 | disconnect( toolBar, SIGNAL( toolbarDestroyed() ), this, SLOT( slotToolbarDestroyed() ) ); |
1947 | m_widget->reparent( 0L, QPoint(), false ); // false = showit | 1948 | m_widget->reparent( 0L, QPoint(), false ); // false = showit |
1948 | } | 1949 | } |
1949 | KAction::unplug( w ); | 1950 | KAction::unplug( w ); |
1950 | } | 1951 | } |
1951 | 1952 | ||
1952 | void KWidgetAction::slotToolbarDestroyed() | 1953 | void KWidgetAction::slotToolbarDestroyed() |
1953 | { | 1954 | { |
1954 | //Q_ASSERT( m_widget ); // When exiting the app the widget could be destroyed before the toolbar. | 1955 | //Q_ASSERT( m_widget ); // When exiting the app the widget could be destroyed before the toolbar. |
1955 | 1956 | ||
1956 | ASSERT( isPlugged() ); | 1957 | Q_ASSERT( isPlugged() ); |
1957 | if( !m_widget || !isPlugged() ) | 1958 | if( !m_widget || !isPlugged() ) |
1958 | return; | 1959 | return; |
1959 | 1960 | ||
1960 | // Don't let a toolbar being destroyed, delete my widget. | 1961 | // Don't let a toolbar being destroyed, delete my widget. |
1961 | m_widget->reparent( 0L, QPoint(), false /*showIt*/ ); | 1962 | m_widget->reparent( 0L, QPoint(), false /*showIt*/ ); |
1962 | } | 1963 | } |
1963 | 1964 | ||
1964 | //////// | 1965 | //////// |
1965 | 1966 | ||
1966 | KActionSeparator::KActionSeparator( QObject *parent, const char *name ) | 1967 | KActionSeparator::KActionSeparator( QObject *parent, const char *name ) |
1967 | : KAction( parent, name ) | 1968 | : KAction( parent, name ) |
1968 | { | 1969 | { |
1969 | } | 1970 | } |
1970 | 1971 | ||
1971 | KActionSeparator::~KActionSeparator() | 1972 | KActionSeparator::~KActionSeparator() |
1972 | { | 1973 | { |
1973 | } | 1974 | } |
1974 | 1975 | ||
1975 | int KActionSeparator::plug( QWidget *widget, int index ) | 1976 | int KActionSeparator::plug( QWidget *widget, int index ) |
1976 | { | 1977 | { |
1977 | if ( widget->inherits("QPopupMenu") ) | 1978 | if ( widget->inherits("Q3PopupMenu") ) |
1978 | { | 1979 | { |
1979 | QPopupMenu* menu = static_cast<QPopupMenu*>( widget ); | 1980 | Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( widget ); |
1980 | 1981 | ||
1981 | int id = menu->insertSeparator( index ); | 1982 | int id = menu->insertSeparator( index ); |
1982 | 1983 | ||
1983 | addContainer( menu, id ); | 1984 | addContainer( menu, id ); |
1984 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 1985 | connect( menu, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
1985 | 1986 | ||
1986 | return containerCount() - 1; | 1987 | return containerCount() - 1; |
1987 | } | 1988 | } |
1988 | else if ( widget->inherits( "QMenuBar" ) ) | 1989 | else if ( widget->inherits( "QMenuBar" ) ) |
1989 | { | 1990 | { |
1990 | QMenuBar *menuBar = static_cast<QMenuBar *>( widget ); | 1991 | QMenuBar *menuBar = static_cast<QMenuBar *>( widget ); |
1991 | 1992 | ||
1992 | int id = menuBar->insertSeparator( index ); | 1993 | int id = menuBar->insertSeparator( index ); |
1993 | 1994 | ||
1994 | addContainer( menuBar, id ); | 1995 | addContainer( menuBar, id ); |
1995 | 1996 | ||
1996 | connect( menuBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 1997 | connect( menuBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
1997 | 1998 | ||
1998 | return containerCount() - 1; | 1999 | return containerCount() - 1; |
1999 | } | 2000 | } |
2000 | else if ( widget->inherits( "KToolBar" ) ) | 2001 | else if ( widget->inherits( "KToolBar" ) ) |
2001 | { | 2002 | { |
2002 | KToolBar *toolBar = static_cast<KToolBar *>( widget ); | 2003 | KToolBar *toolBar = static_cast<KToolBar *>( widget ); |
2003 | 2004 | ||
2004 | int id = toolBar->insertSeparator( index ); | 2005 | int id = toolBar->insertSeparator( index ); |
2005 | // toolBar->addSeparator(); | 2006 | // toolBar->addSeparator(); |
2006 | 2007 | ||
2007 | addContainer( toolBar, id ); | 2008 | addContainer( toolBar, id ); |
2008 | 2009 | ||
2009 | connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); | 2010 | connect( toolBar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) ); |
2010 | 2011 | ||
2011 | return containerCount() - 1; | 2012 | return containerCount() - 1; |