author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/kactioncollection.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
Diffstat (limited to 'microkde/kdeui/kactioncollection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | microkde/kdeui/kactioncollection.cpp | 50 |
1 files changed, 26 insertions, 24 deletions
diff --git a/microkde/kdeui/kactioncollection.cpp b/microkde/kdeui/kactioncollection.cpp index 69e5d02..4d66c7f 100644 --- a/microkde/kdeui/kactioncollection.cpp +++ b/microkde/kdeui/kactioncollection.cpp | |||
@@ -1,232 +1,234 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> | 2 | Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org> |
3 | (C) 1999 Simon Hausmann <hausmann@kde.org> | 3 | (C) 1999 Simon Hausmann <hausmann@kde.org> |
4 | (C) 2000 Nicolas Hadacek <haadcek@kde.org> | 4 | (C) 2000 Nicolas Hadacek <haadcek@kde.org> |
5 | (C) 2000 Kurt Granroth <granroth@kde.org> | 5 | (C) 2000 Kurt Granroth <granroth@kde.org> |
6 | (C) 2000 Michael Koch <koch@kde.org> | 6 | (C) 2000 Michael Koch <koch@kde.org> |
7 | (C) 2001 Holger Freyther <freyther@kde.org> | 7 | (C) 2001 Holger Freyther <freyther@kde.org> |
8 | (C) 2002 Ellis Whitehead <ellis@kde.org> | 8 | (C) 2002 Ellis Whitehead <ellis@kde.org> |
9 | (C) 2002 Joseph Wenninger <jowenn@kde.org> | 9 | (C) 2002 Joseph Wenninger <jowenn@kde.org> |
10 | 10 | ||
11 | This library is free software; you can redistribute it and/or | 11 | This library is free software; you can redistribute it and/or |
12 | modify it under the terms of the GNU Library General Public | 12 | modify it under the terms of the GNU Library General Public |
13 | License version 2 as published by the Free Software Foundation. | 13 | License version 2 as published by the Free Software Foundation. |
14 | 14 | ||
15 | This library is distributed in the hope that it will be useful, | 15 | This library is distributed in the hope that it will be useful, |
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
18 | Library General Public License for more details. | 18 | Library General Public License for more details. |
19 | 19 | ||
20 | You should have received a copy of the GNU Library General Public License | 20 | You should have received a copy of the GNU Library General Public License |
21 | along with this library; see the file COPYING.LIB. If not, write to | 21 | along with this library; see the file COPYING.LIB. If not, write to |
22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 | Boston, MA 02111-1307, USA. | 23 | Boston, MA 02111-1307, USA. |
24 | */ | 24 | */ |
25 | 25 | ||
26 | #include "kactioncollection.h" | 26 | #include "kactioncollection.h" |
27 | //US#include "kactionshortcutlist.h" | 27 | //US#include "kactionshortcutlist.h" |
28 | 28 | ||
29 | #include <qptrdict.h> | 29 | #include <q3ptrdict.h> |
30 | //Added by qt3to4: | ||
31 | #include <Q3ValueList> | ||
30 | //US#include <qvariant.h> | 32 | //US#include <qvariant.h> |
31 | 33 | ||
32 | //US#include <kaccel.h> | 34 | //US#include <kaccel.h> |
33 | //US#include <kaccelbase.h> | 35 | //US#include <kaccelbase.h> |
34 | //US#include <kapplication.h> | 36 | //US#include <kapplication.h> |
35 | #include <kdebug.h> | 37 | #include <kdebug.h> |
36 | //US#include <kxmlguifactory.h> | 38 | //US#include <kxmlguifactory.h> |
37 | 39 | ||
38 | //US I included the following files | 40 | //US I included the following files |
39 | #include <qasciidict.h> | 41 | #include <q3asciidict.h> |
40 | #include <qptrlist.h> | 42 | #include <q3ptrlist.h> |
41 | #include "kaction.h" | 43 | #include "kaction.h" |
42 | #include <kglobal.h> | 44 | #include <kglobal.h> |
43 | #include <qobject.h> | 45 | #include <qobject.h> |
44 | #include <qwidget.h> | 46 | #include <qwidget.h> |
45 | 47 | ||
46 | class KActionCollection::KActionCollectionPrivate | 48 | class KActionCollection::KActionCollectionPrivate |
47 | { | 49 | { |
48 | public: | 50 | public: |
49 | KActionCollectionPrivate() | 51 | KActionCollectionPrivate() |
50 | { | 52 | { |
51 | //US m_instance = 0; | 53 | //US m_instance = 0; |
52 | //m_bOneKAccelOnly = false; | 54 | //m_bOneKAccelOnly = false; |
53 | //m_iWidgetCurrent = 0; | 55 | //m_iWidgetCurrent = 0; |
54 | m_bAutoConnectShortcuts = true; | 56 | m_bAutoConnectShortcuts = true; |
55 | m_widget = 0; | 57 | m_widget = 0; |
56 | m_kaccel = m_builderKAccel = 0; | 58 | m_kaccel = m_builderKAccel = 0; |
57 | m_dctHighlightContainers.setAutoDelete( true ); | 59 | m_dctHighlightContainers.setAutoDelete( true ); |
58 | m_highlight = false; | 60 | m_highlight = false; |
59 | m_currentHighlightAction = 0; | 61 | m_currentHighlightAction = 0; |
60 | m_statusCleared = true; | 62 | m_statusCleared = true; |
61 | } | 63 | } |
62 | 64 | ||
63 | //US KInstance *m_instance; | 65 | //US KInstance *m_instance; |
64 | //US QString m_sXMLFile; | 66 | //US QString m_sXMLFile; |
65 | bool m_bAutoConnectShortcuts; | 67 | bool m_bAutoConnectShortcuts; |
66 | //bool m_bOneKAccelOnly; | 68 | //bool m_bOneKAccelOnly; |
67 | //int m_iWidgetCurrent; | 69 | //int m_iWidgetCurrent; |
68 | //QValueList<QWidget*> m_widgetList; | 70 | //QValueList<QWidget*> m_widgetList; |
69 | //QValueList<KAccel*> m_kaccelList; | 71 | //QValueList<KAccel*> m_kaccelList; |
70 | QValueList<KActionCollection*> m_docList; | 72 | Q3ValueList<KActionCollection*> m_docList; |
71 | QWidget *m_widget; | 73 | QWidget *m_widget; |
72 | KAccel *m_kaccel; | 74 | KAccel *m_kaccel; |
73 | KAccel *m_builderKAccel; | 75 | KAccel *m_builderKAccel; |
74 | 76 | ||
75 | QAsciiDict<KAction> m_actionDict; | 77 | Q3AsciiDict<KAction> m_actionDict; |
76 | QPtrDict< QPtrList<KAction> > m_dctHighlightContainers; | 78 | Q3PtrDict< Q3PtrList<KAction> > m_dctHighlightContainers; |
77 | bool m_highlight; | 79 | bool m_highlight; |
78 | KAction *m_currentHighlightAction; | 80 | KAction *m_currentHighlightAction; |
79 | bool m_statusCleared; | 81 | bool m_statusCleared; |
80 | }; | 82 | }; |
81 | 83 | ||
82 | KActionCollection::KActionCollection( QWidget *parent, const char *name /*US, | 84 | KActionCollection::KActionCollection( QWidget *parent, const char *name /*US, |
83 | KInstance *instance */) | 85 | KInstance *instance */) |
84 | : QObject( (QObject*)parent, name ) | 86 | : QObject( (QObject*)parent, name ) |
85 | { | 87 | { |
86 | kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis | 88 | kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis |
87 | d = new KActionCollectionPrivate; | 89 | d = new KActionCollectionPrivate; |
88 | if( parent ) | 90 | if( parent ) |
89 | setWidget( parent ); | 91 | setWidget( parent ); |
90 | //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); | 92 | //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); |
91 | //US setInstance( instance ); | 93 | //US setInstance( instance ); |
92 | } | 94 | } |
93 | 95 | ||
94 | 96 | ||
95 | KActionCollection::KActionCollection( QWidget *watch, QObject* parent, const char *name /*US, | 97 | KActionCollection::KActionCollection( QWidget *watch, QObject* parent, const char *name /*US, |
96 | KInstance *instance */) | 98 | KInstance *instance */) |
97 | : QObject( parent, name ) | 99 | : QObject( parent, name ) |
98 | { | 100 | { |
99 | kdDebug(129) << "KActionCollection::KActionCollection( " << watch << ", " << parent << ", " << name << " ): this = " << this << endl; //ellis | 101 | kdDebug(129) << "KActionCollection::KActionCollection( " << watch << ", " << parent << ", " << name << " ): this = " << this << endl; //ellis |
100 | d = new KActionCollectionPrivate; | 102 | d = new KActionCollectionPrivate; |
101 | if( watch ) | 103 | if( watch ) |
102 | setWidget( watch ); | 104 | setWidget( watch ); |
103 | //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); | 105 | //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); |
104 | //US setInstance( instance ); | 106 | //US setInstance( instance ); |
105 | } | 107 | } |
106 | 108 | ||
107 | // KDE 4: remove | 109 | // KDE 4: remove |
108 | KActionCollection::KActionCollection( QObject *parent, const char *name /*US, | 110 | KActionCollection::KActionCollection( QObject *parent, const char *name /*US, |
109 | KInstance *instance */) | 111 | KInstance *instance */) |
110 | : QObject( parent, name ) | 112 | : QObject( parent, name ) |
111 | { | 113 | { |
112 | kdWarning(129) << "KActionCollection::KActionCollection( QObject *parent, const char *name, KInstance *instance )" << endl; //ellis | 114 | kdWarning(129) << "KActionCollection::KActionCollection( QObject *parent, const char *name, KInstance *instance )" << endl; //ellis |
113 | //US kdBacktrace not available | 115 | //US kdBacktrace not available |
114 | //US kdDebug(129) << kdBacktrace() << endl; | 116 | //US kdDebug(129) << kdBacktrace() << endl; |
115 | d = new KActionCollectionPrivate; | 117 | d = new KActionCollectionPrivate; |
116 | //US QWidget* w = dynamic_cast<QWidget*>( parent ); | 118 | //US QWidget* w = dynamic_cast<QWidget*>( parent ); |
117 | QWidget* w = (QWidget*)( parent ); | 119 | QWidget* w = (QWidget*)( parent ); |
118 | if( w ) | 120 | if( w ) |
119 | setWidget( w ); | 121 | setWidget( w ); |
120 | //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); | 122 | //d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0); |
121 | //US setInstance( instance ); | 123 | //US setInstance( instance ); |
122 | } | 124 | } |
123 | 125 | ||
124 | KActionCollection::KActionCollection( const KActionCollection © ) | 126 | KActionCollection::KActionCollection( const KActionCollection © ) |
125 | : QObject() | 127 | : QObject() |
126 | { | 128 | { |
127 | kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl; | 129 | kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl; |
128 | d = new KActionCollectionPrivate; | 130 | d = new KActionCollectionPrivate; |
129 | *this = copy; | 131 | *this = copy; |
130 | } | 132 | } |
131 | // KDE 4: remove end | 133 | // KDE 4: remove end |
132 | 134 | ||
133 | KActionCollection::~KActionCollection() | 135 | KActionCollection::~KActionCollection() |
134 | { | 136 | { |
135 | kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl; | 137 | kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl; |
136 | for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { | 138 | for ( Q3AsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { |
137 | KAction* pAction = it.current(); | 139 | KAction* pAction = it.current(); |
138 | if ( pAction->m_parentCollection == this ) | 140 | if ( pAction->m_parentCollection == this ) |
139 | pAction->m_parentCollection = 0L; | 141 | pAction->m_parentCollection = 0L; |
140 | } | 142 | } |
141 | 143 | ||
142 | //US delete d->m_kaccel; | 144 | //US delete d->m_kaccel; |
143 | //US delete d->m_builderKAccel; | 145 | //US delete d->m_builderKAccel; |
144 | delete d; d = 0; | 146 | delete d; d = 0; |
145 | } | 147 | } |
146 | 148 | ||
147 | void KActionCollection::setWidget( QWidget* w ) | 149 | void KActionCollection::setWidget( QWidget* w ) |
148 | { | 150 | { |
149 | //if ( d->m_actionDict.count() > 0 ) { | 151 | //if ( d->m_actionDict.count() > 0 ) { |
150 | // kdError(129) << "KActionCollection::setWidget(): must be called before any actions are added to collection!" << endl; | 152 | // kdError(129) << "KActionCollection::setWidget(): must be called before any actions are added to collection!" << endl; |
151 | // kdDebug(129) << kdBacktrace() << endl; | 153 | // kdDebug(129) << kdBacktrace() << endl; |
152 | //} | 154 | //} |
153 | //else | 155 | //else |
154 | if ( !d->m_widget ) { | 156 | if ( !d->m_widget ) { |
155 | d->m_widget = w; | 157 | d->m_widget = w; |
156 | //qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde"); | 158 | //qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde"); |
157 | //US d->m_kaccel = new KAccel( w, this, "KActionCollection-KAccel" ); | 159 | //US d->m_kaccel = new KAccel( w, this, "KActionCollection-KAccel" ); |
158 | } | 160 | } |
159 | else if ( d->m_widget != w ) | 161 | else if ( d->m_widget != w ) |
160 | ; | 162 | ; |
161 | 163 | ||
162 | } | 164 | } |
163 | 165 | ||
164 | void KActionCollection::setAutoConnectShortcuts( bool b ) | 166 | void KActionCollection::setAutoConnectShortcuts( bool b ) |
165 | { | 167 | { |
166 | d->m_bAutoConnectShortcuts = b; | 168 | d->m_bAutoConnectShortcuts = b; |
167 | } | 169 | } |
168 | 170 | ||
169 | bool KActionCollection::isAutoConnectShortcuts() | 171 | bool KActionCollection::isAutoConnectShortcuts() |
170 | { | 172 | { |
171 | return d->m_bAutoConnectShortcuts; | 173 | return d->m_bAutoConnectShortcuts; |
172 | } | 174 | } |
173 | 175 | ||
174 | bool KActionCollection::addDocCollection( KActionCollection* pDoc ) | 176 | bool KActionCollection::addDocCollection( KActionCollection* pDoc ) |
175 | { | 177 | { |
176 | d->m_docList.append( pDoc ); | 178 | d->m_docList.append( pDoc ); |
177 | return true; | 179 | return true; |
178 | } | 180 | } |
179 | 181 | ||
180 | void KActionCollection::beginXMLPlug( QWidget *widget ) | 182 | void KActionCollection::beginXMLPlug( QWidget *widget ) |
181 | { | 183 | { |
182 | qDebug("KActionCollection::beginXMLPlug has to be fixed"); | 184 | qDebug("KActionCollection::beginXMLPlug has to be fixed"); |
183 | /*US | 185 | /*US |
184 | kdDebug(129) << "KActionCollection::beginXMLPlug( buildWidget = " << widget << " ): this = " << this << " d->m_builderKAccel = " << d->m_builderKAccel << endl; | 186 | kdDebug(129) << "KActionCollection::beginXMLPlug( buildWidget = " << widget << " ): this = " << this << " d->m_builderKAccel = " << d->m_builderKAccel << endl; |
185 | 187 | ||
186 | if( widget && !d->m_builderKAccel ) { | 188 | if( widget && !d->m_builderKAccel ) { |
187 | d->m_builderKAccel = new KAccel( widget, this, "KActionCollection-BuilderKAccel" ); | 189 | d->m_builderKAccel = new KAccel( widget, this, "KActionCollection-BuilderKAccel" ); |
188 | } | 190 | } |
189 | */ | 191 | */ |
190 | } | 192 | } |
191 | 193 | ||
192 | void KActionCollection::endXMLPlug() | 194 | void KActionCollection::endXMLPlug() |
193 | { | 195 | { |
194 | kdDebug(129) << "KActionCollection::endXMLPlug(): this = " << this << endl; | 196 | kdDebug(129) << "KActionCollection::endXMLPlug(): this = " << this << endl; |
195 | //s_kaccelXML = 0; | 197 | //s_kaccelXML = 0; |
196 | } | 198 | } |
197 | 199 | ||
198 | void KActionCollection::prepareXMLUnplug() | 200 | void KActionCollection::prepareXMLUnplug() |
199 | { | 201 | { |
200 | qDebug("KActionCollection::prepareXMLUnplug has to be fixed"); | 202 | qDebug("KActionCollection::prepareXMLUnplug has to be fixed"); |
201 | /*US | 203 | /*US |
202 | kdDebug(129) << "KActionCollection::prepareXMLUnplug(): this = " << this << endl; | 204 | kdDebug(129) << "KActionCollection::prepareXMLUnplug(): this = " << this << endl; |
203 | unplugShortcuts( d->m_kaccel ); | 205 | unplugShortcuts( d->m_kaccel ); |
204 | 206 | ||
205 | if( d->m_builderKAccel ) { | 207 | if( d->m_builderKAccel ) { |
206 | unplugShortcuts( d->m_builderKAccel ); | 208 | unplugShortcuts( d->m_builderKAccel ); |
207 | delete d->m_builderKAccel; | 209 | delete d->m_builderKAccel; |
208 | d->m_builderKAccel = 0; | 210 | d->m_builderKAccel = 0; |
209 | } | 211 | } |
210 | */ | 212 | */ |
211 | } | 213 | } |
212 | 214 | ||
213 | void KActionCollection::unplugShortcuts( KAccel* kaccel ) | 215 | void KActionCollection::unplugShortcuts( KAccel* kaccel ) |
214 | { | 216 | { |
215 | qDebug("KActionCollection::unplugShortcuts has to be fixed"); | 217 | qDebug("KActionCollection::unplugShortcuts has to be fixed"); |
216 | /*US | 218 | /*US |
217 | for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { | 219 | for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) { |
218 | KAction* pAction = it.current(); | 220 | KAction* pAction = it.current(); |
219 | pAction->removeKAccel( kaccel ); | 221 | pAction->removeKAccel( kaccel ); |
220 | } | 222 | } |
221 | 223 | ||
222 | for( uint i = 0; i < d->m_docList.count(); i++ ) | 224 | for( uint i = 0; i < d->m_docList.count(); i++ ) |
223 | d->m_docList[i]->unplugShortcuts( kaccel ); | 225 | d->m_docList[i]->unplugShortcuts( kaccel ); |
224 | */ | 226 | */ |
225 | 227 | ||
226 | } | 228 | } |
227 | 229 | ||
228 | /*void KActionCollection::addWidget( QWidget* w ) | 230 | /*void KActionCollection::addWidget( QWidget* w ) |
229 | { | 231 | { |
230 | if( !d->m_bOneKAccelOnly ) { | 232 | if( !d->m_bOneKAccelOnly ) { |
231 | kdDebug(129) << "KActionCollection::addWidget( " << w << " ): this = " << this << endl; | 233 | kdDebug(129) << "KActionCollection::addWidget( " << w << " ): this = " << this << endl; |
232 | for( uint i = 0; i < d->m_widgetList.count(); i++ ) { | 234 | for( uint i = 0; i < d->m_widgetList.count(); i++ ) { |
@@ -272,498 +274,498 @@ void KActionCollection::removeWidget( QWidget* w ) | |||
272 | } | 274 | } |
273 | 275 | ||
274 | bool KActionCollection::ownsKAccel() const | 276 | bool KActionCollection::ownsKAccel() const |
275 | { | 277 | { |
276 | return d->m_bOneKAccelOnly; | 278 | return d->m_bOneKAccelOnly; |
277 | } | 279 | } |
278 | 280 | ||
279 | uint KActionCollection::widgetCount() const | 281 | uint KActionCollection::widgetCount() const |
280 | { | 282 | { |
281 | return d->m_widgetList.count(); | 283 | return d->m_widgetList.count(); |
282 | } | 284 | } |
283 | 285 | ||
284 | const KAccel* KActionCollection::widgetKAccel( uint i ) const | 286 | const KAccel* KActionCollection::widgetKAccel( uint i ) const |
285 | { | 287 | { |
286 | return d->m_kaccelList[i]; | 288 | return d->m_kaccelList[i]; |
287 | }*/ | 289 | }*/ |
288 | 290 | ||
289 | //US we are using no accelerators so far. So just setup an empty implementation. | 291 | //US we are using no accelerators so far. So just setup an empty implementation. |
290 | KAccel* KActionCollection::kaccel() | 292 | KAccel* KActionCollection::kaccel() |
291 | { | 293 | { |
292 | //if( d->m_kaccelList.count() > 0 ) | 294 | //if( d->m_kaccelList.count() > 0 ) |
293 | // return d->m_kaccelList[d->m_iWidgetCurrent]; | 295 | // return d->m_kaccelList[d->m_iWidgetCurrent]; |
294 | //else | 296 | //else |
295 | // return 0; | 297 | // return 0; |
296 | //US return d->m_kaccel; | 298 | //US return d->m_kaccel; |
297 | return 0; | 299 | return 0; |
298 | } | 300 | } |
299 | 301 | ||
300 | //US we are using no accelerators so far. So just setup an empty implementation. | 302 | //US we are using no accelerators so far. So just setup an empty implementation. |
301 | const KAccel* KActionCollection::kaccel() const | 303 | const KAccel* KActionCollection::kaccel() const |
302 | { | 304 | { |
303 | //if( d->m_kaccelList.count() > 0 ) | 305 | //if( d->m_kaccelList.count() > 0 ) |
304 | // return d->m_kaccelList[d->m_iWidgetCurrent]; | 306 | // return d->m_kaccelList[d->m_iWidgetCurrent]; |
305 | //else | 307 | //else |
306 | // return 0; | 308 | // return 0; |
307 | //USreturn d->m_kaccel; | 309 | //USreturn d->m_kaccel; |
308 | return 0; | 310 | return 0; |
309 | } | 311 | } |
310 | 312 | ||
311 | /*void KActionCollection::findMainWindow( QWidget *w ) | 313 | /*void KActionCollection::findMainWindow( QWidget *w ) |
312 | { | 314 | { |
313 | // Note: topLevelWidget() stops too early, we can't use it. | 315 | // Note: topLevelWidget() stops too early, we can't use it. |
314 | QWidget * tl = w; | 316 | QWidget * tl = w; |
315 | while ( tl->parentWidget() ) // lookup parent and store | 317 | while ( tl->parentWidget() ) // lookup parent and store |
316 | tl = tl->parentWidget(); | 318 | tl = tl->parentWidget(); |
317 | 319 | ||
318 | KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow | 320 | KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow |
319 | if (mw) | 321 | if (mw) |
320 | d->m_mainwindow = mw; | 322 | d->m_mainwindow = mw; |
321 | else | 323 | else |
322 | kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; | 324 | kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl; |
323 | }*/ | 325 | }*/ |
324 | 326 | ||
325 | void KActionCollection::_insert( KAction* action ) | 327 | void KActionCollection::_insert( KAction* action ) |
326 | { | 328 | { |
327 | char unnamed_name[100]; | 329 | char unnamed_name[100]; |
328 | const char *name = action->name(); | 330 | const char *name = action->name(); |
329 | if( qstrcmp( name, "unnamed" ) == 0 ) | 331 | if( qstrcmp( name, "unnamed" ) == 0 ) |
330 | { | 332 | { |
331 | sprintf(unnamed_name, "unnamed-%p", (void *)action); | 333 | sprintf(unnamed_name, "unnamed-%p", (void *)action); |
332 | name = unnamed_name; | 334 | name = unnamed_name; |
333 | } | 335 | } |
334 | KAction *a = d->m_actionDict[ name ]; | 336 | KAction *a = d->m_actionDict[ name ]; |
335 | if ( a == action ) | 337 | if ( a == action ) |
336 | return; | 338 | return; |
337 | 339 | ||
338 | d->m_actionDict.insert( name, action ); | 340 | d->m_actionDict.insert( name, action ); |
339 | 341 | ||
340 | emit inserted( action ); | 342 | emit inserted( action ); |
341 | } | 343 | } |
342 | 344 | ||
343 | void KActionCollection::_remove( KAction* action ) | 345 | void KActionCollection::_remove( KAction* action ) |
344 | { | 346 | { |
345 | delete _take( action ); | 347 | delete _take( action ); |
346 | } | 348 | } |
347 | 349 | ||
348 | KAction* KActionCollection::_take( KAction* action ) | 350 | KAction* KActionCollection::_take( KAction* action ) |
349 | { | 351 | { |
350 | char unnamed_name[100]; | 352 | char unnamed_name[100]; |
351 | const char *name = action->name(); | 353 | const char *name = action->name(); |
352 | if( qstrcmp( name, "unnamed" ) == 0 ) | 354 | if( qstrcmp( name, "unnamed" ) == 0 ) |
353 | { | 355 | { |
354 | sprintf(unnamed_name, "unnamed-%p", (void *) action); | 356 | sprintf(unnamed_name, "unnamed-%p", (void *) action); |
355 | name = unnamed_name; | 357 | name = unnamed_name; |
356 | } | 358 | } |
357 | 359 | ||
358 | KAction *a = d->m_actionDict.take( name ); | 360 | KAction *a = d->m_actionDict.take( name ); |
359 | if ( !a || a != action ) | 361 | if ( !a || a != action ) |
360 | return 0; | 362 | return 0; |
361 | 363 | ||
362 | emit removed( action ); | 364 | emit removed( action ); |
363 | return a; | 365 | return a; |
364 | } | 366 | } |
365 | 367 | ||
366 | void KActionCollection::_clear() | 368 | void KActionCollection::_clear() |
367 | { | 369 | { |
368 | QAsciiDictIterator<KAction> it( d->m_actionDict ); | 370 | Q3AsciiDictIterator<KAction> it( d->m_actionDict ); |
369 | while ( it.current() ) | 371 | while ( it.current() ) |
370 | _remove( it.current() ); | 372 | _remove( it.current() ); |
371 | } | 373 | } |
372 | 374 | ||
373 | void KActionCollection::insert( KAction* action ) { _insert( action ); } | 375 | void KActionCollection::insert( KAction* action ) { _insert( action ); } |
374 | void KActionCollection::remove( KAction* action ) { _remove( action ); } | 376 | void KActionCollection::remove( KAction* action ) { _remove( action ); } |
375 | KAction* KActionCollection::take( KAction* action ) { return _take( action ); } | 377 | KAction* KActionCollection::take( KAction* action ) { return _take( action ); } |
376 | void KActionCollection::clear() { _clear(); } | 378 | void KActionCollection::clear() { _clear(); } |
377 | KAccel* KActionCollection::accel() { return kaccel(); } | 379 | KAccel* KActionCollection::accel() { return kaccel(); } |
378 | const KAccel* KActionCollection::accel() const { return kaccel(); } | 380 | const KAccel* KActionCollection::accel() const { return kaccel(); } |
379 | KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; } | 381 | KAccel* KActionCollection::builderKAccel() const { return d->m_builderKAccel; } |
380 | 382 | ||
381 | KAction* KActionCollection::action( const char* name, const char* classname ) const | 383 | KAction* KActionCollection::action( const char* name, const char* classname ) const |
382 | { | 384 | { |
383 | KAction* pAction = 0; | 385 | KAction* pAction = 0; |
384 | 386 | ||
385 | if ( !classname && name ) | 387 | if ( !classname && name ) |
386 | pAction = d->m_actionDict[ name ]; | 388 | pAction = d->m_actionDict[ name ]; |
387 | 389 | ||
388 | else { | 390 | else { |
389 | QAsciiDictIterator<KAction> it( d->m_actionDict ); | 391 | Q3AsciiDictIterator<KAction> it( d->m_actionDict ); |
390 | for( ; it.current(); ++it ) | 392 | for( ; it.current(); ++it ) |
391 | { | 393 | { |
392 | if ( ( !name || strcmp( it.current()->name(), name ) == 0 ) && | 394 | if ( ( !name || strcmp( it.current()->name(), name ) == 0 ) && |
393 | ( !classname || strcmp( it.current()->className(), classname ) == 0 ) ) { | 395 | ( !classname || strcmp( it.current()->className(), classname ) == 0 ) ) { |
394 | pAction = it.current(); | 396 | pAction = it.current(); |
395 | break; | 397 | break; |
396 | } | 398 | } |
397 | } | 399 | } |
398 | } | 400 | } |
399 | 401 | ||
400 | if( !pAction ) { | 402 | if( !pAction ) { |
401 | for( uint i = 0; i < d->m_docList.count() && !pAction; i++ ) | 403 | for( uint i = 0; i < d->m_docList.count() && !pAction; i++ ) |
402 | pAction = d->m_docList[i]->action( name, classname ); | 404 | pAction = d->m_docList[i]->action( name, classname ); |
403 | } | 405 | } |
404 | 406 | ||
405 | return pAction; | 407 | return pAction; |
406 | } | 408 | } |
407 | 409 | ||
408 | KAction* KActionCollection::action( int index ) const | 410 | KAction* KActionCollection::action( int index ) const |
409 | { | 411 | { |
410 | QAsciiDictIterator<KAction> it( d->m_actionDict ); | 412 | Q3AsciiDictIterator<KAction> it( d->m_actionDict ); |
411 | it += index; | 413 | it += index; |
412 | return it.current(); | 414 | return it.current(); |
413 | // return d->m_actions.at( index ); | 415 | // return d->m_actions.at( index ); |
414 | } | 416 | } |
415 | /*US | 417 | /*US |
416 | bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) | 418 | bool KActionCollection::readShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) |
417 | { | 419 | { |
418 | return KActionShortcutList(this).readSettings( sConfigGroup, pConfig ); | 420 | return KActionShortcutList(this).readSettings( sConfigGroup, pConfig ); |
419 | } | 421 | } |
420 | 422 | ||
421 | bool KActionCollection::writeShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) const | 423 | bool KActionCollection::writeShortcutSettings( const QString& sConfigGroup, KConfigBase* pConfig ) const |
422 | { | 424 | { |
423 | return KActionShortcutList((KActionCollection*)this).writeSettings( sConfigGroup, pConfig ); | 425 | return KActionShortcutList((KActionCollection*)this).writeSettings( sConfigGroup, pConfig ); |
424 | } | 426 | } |
425 | */ | 427 | */ |
426 | uint KActionCollection::count() const | 428 | uint KActionCollection::count() const |
427 | { | 429 | { |
428 | return d->m_actionDict.count(); | 430 | return d->m_actionDict.count(); |
429 | } | 431 | } |
430 | 432 | ||
431 | QStringList KActionCollection::groups() const | 433 | QStringList KActionCollection::groups() const |
432 | { | 434 | { |
433 | QStringList lst; | 435 | QStringList lst; |
434 | 436 | ||
435 | QAsciiDictIterator<KAction> it( d->m_actionDict ); | 437 | Q3AsciiDictIterator<KAction> it( d->m_actionDict ); |
436 | for( ; it.current(); ++it ) | 438 | for( ; it.current(); ++it ) |
437 | if ( !it.current()->group().isEmpty() && !lst.contains( it.current()->group() ) ) | 439 | if ( !it.current()->group().isEmpty() && !lst.contains( it.current()->group() ) ) |
438 | lst.append( it.current()->group() ); | 440 | lst.append( it.current()->group() ); |
439 | 441 | ||
440 | return lst; | 442 | return lst; |
441 | } | 443 | } |
442 | 444 | ||
443 | KActionPtrList KActionCollection::actions( const QString& group ) const | 445 | KActionPtrList KActionCollection::actions( const QString& group ) const |
444 | { | 446 | { |
445 | KActionPtrList lst; | 447 | KActionPtrList lst; |
446 | 448 | ||
447 | QAsciiDictIterator<KAction> it( d->m_actionDict ); | 449 | Q3AsciiDictIterator<KAction> it( d->m_actionDict ); |
448 | for( ; it.current(); ++it ) | 450 | for( ; it.current(); ++it ) |
449 | if ( it.current()->group() == group ) | 451 | if ( it.current()->group() == group ) |
450 | lst.append( it.current() ); | 452 | lst.append( it.current() ); |
451 | else if ( it.current()->group().isEmpty() && group.isEmpty() ) | 453 | else if ( it.current()->group().isEmpty() && group.isEmpty() ) |
452 | lst.append( it.current() ); | 454 | lst.append( it.current() ); |
453 | 455 | ||
454 | return lst; | 456 | return lst; |
455 | } | 457 | } |
456 | 458 | ||
457 | KActionPtrList KActionCollection::actions() const | 459 | KActionPtrList KActionCollection::actions() const |
458 | { | 460 | { |
459 | KActionPtrList lst; | 461 | KActionPtrList lst; |
460 | 462 | ||
461 | QAsciiDictIterator<KAction> it( d->m_actionDict ); | 463 | Q3AsciiDictIterator<KAction> it( d->m_actionDict ); |
462 | for( ; it.current(); ++it ) | 464 | for( ; it.current(); ++it ) |
463 | lst.append( it.current() ); | 465 | lst.append( it.current() ); |
464 | 466 | ||
465 | return lst; | 467 | return lst; |
466 | } | 468 | } |
467 | 469 | ||
468 | /*US we have no instance object. Use KGlobal instead | 470 | /*US we have no instance object. Use KGlobal instead |
469 | void KActionCollection::setInstance( KInstance *instance ) | 471 | void KActionCollection::setInstance( KInstance *instance ) |
470 | { | 472 | { |
471 | if ( instance ) | 473 | if ( instance ) |
472 | d->m_instance = instance; | 474 | d->m_instance = instance; |
473 | qDebug("KActionCollection::setInstance has to be fixed"); | 475 | qDebug("KActionCollection::setInstance has to be fixed"); |
474 | else | 476 | else |
475 | d->m_instance = KGlobal::instance(); | 477 | d->m_instance = KGlobal::instance(); |
476 | } | 478 | } |
477 | 479 | ||
478 | KInstance *KActionCollection::instance() const | 480 | KInstance *KActionCollection::instance() const |
479 | { | 481 | { |
480 | return d->m_instance; | 482 | return d->m_instance; |
481 | } | 483 | } |
482 | */ | 484 | */ |
483 | 485 | ||
484 | /*US we have no XML facility in microkde | 486 | /*US we have no XML facility in microkde |
485 | void KActionCollection::setXMLFile( const QString& sXMLFile ) | 487 | void KActionCollection::setXMLFile( const QString& sXMLFile ) |
486 | { | 488 | { |
487 | d->m_sXMLFile = sXMLFile; | 489 | d->m_sXMLFile = sXMLFile; |
488 | } | 490 | } |
489 | 491 | ||
490 | const QString& KActionCollection::xmlFile() const | 492 | const QString& KActionCollection::xmlFile() const |
491 | { | 493 | { |
492 | return d->m_sXMLFile; | 494 | return d->m_sXMLFile; |
493 | } | 495 | } |
494 | */ | 496 | */ |
495 | 497 | ||
496 | void KActionCollection::setHighlightingEnabled( bool enable ) | 498 | void KActionCollection::setHighlightingEnabled( bool enable ) |
497 | { | 499 | { |
498 | d->m_highlight = enable; | 500 | d->m_highlight = enable; |
499 | } | 501 | } |
500 | 502 | ||
501 | bool KActionCollection::highlightingEnabled() const | 503 | bool KActionCollection::highlightingEnabled() const |
502 | { | 504 | { |
503 | return d->m_highlight; | 505 | return d->m_highlight; |
504 | } | 506 | } |
505 | 507 | ||
506 | void KActionCollection::connectHighlight( QWidget *container, KAction *action ) | 508 | void KActionCollection::connectHighlight( QWidget *container, KAction *action ) |
507 | { | 509 | { |
508 | if ( !d->m_highlight ) | 510 | if ( !d->m_highlight ) |
509 | return; | 511 | return; |
510 | 512 | ||
511 | QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; | 513 | Q3PtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; |
512 | 514 | ||
513 | if ( !actionList ) | 515 | if ( !actionList ) |
514 | { | 516 | { |
515 | actionList = new QPtrList<KAction>; | 517 | actionList = new Q3PtrList<KAction>; |
516 | 518 | ||
517 | if ( container->inherits( "QPopupMenu" ) ) | 519 | if ( container->inherits( "Q3PopupMenu" ) ) |
518 | { | 520 | { |
519 | connect( container, SIGNAL( highlighted( int ) ), | 521 | connect( container, SIGNAL( highlighted( int ) ), |
520 | this, SLOT( slotMenuItemHighlighted( int ) ) ); | 522 | this, SLOT( slotMenuItemHighlighted( int ) ) ); |
521 | connect( container, SIGNAL( aboutToHide() ), | 523 | connect( container, SIGNAL( aboutToHide() ), |
522 | this, SLOT( slotMenuAboutToHide() ) ); | 524 | this, SLOT( slotMenuAboutToHide() ) ); |
523 | } | 525 | } |
524 | //US else if ( container->inherits( "KToolBar" ) ) | 526 | //US else if ( container->inherits( "KToolBar" ) ) |
525 | else if ( container->inherits( "QToolBar" ) ) | 527 | else if ( container->inherits( "Q3ToolBar" ) ) |
526 | { | 528 | { |
527 | connect( container, SIGNAL( highlighted( int, bool ) ), | 529 | connect( container, SIGNAL( highlighted( int, bool ) ), |
528 | this, SLOT( slotToolBarButtonHighlighted( int, bool ) ) ); | 530 | this, SLOT( slotToolBarButtonHighlighted( int, bool ) ) ); |
529 | } | 531 | } |
530 | 532 | ||
531 | connect( container, SIGNAL( destroyed() ), | 533 | connect( container, SIGNAL( destroyed() ), |
532 | this, SLOT( slotDestroyed() ) ); | 534 | this, SLOT( slotDestroyed() ) ); |
533 | 535 | ||
534 | d->m_dctHighlightContainers.insert( container, actionList ); | 536 | d->m_dctHighlightContainers.insert( container, actionList ); |
535 | } | 537 | } |
536 | 538 | ||
537 | actionList->append( action ); | 539 | actionList->append( action ); |
538 | } | 540 | } |
539 | 541 | ||
540 | void KActionCollection::disconnectHighlight( QWidget *container, KAction *action ) | 542 | void KActionCollection::disconnectHighlight( QWidget *container, KAction *action ) |
541 | { | 543 | { |
542 | if ( !d->m_highlight ) | 544 | if ( !d->m_highlight ) |
543 | return; | 545 | return; |
544 | 546 | ||
545 | QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; | 547 | Q3PtrList<KAction> *actionList = d->m_dctHighlightContainers[ container ]; |
546 | 548 | ||
547 | if ( !actionList ) | 549 | if ( !actionList ) |
548 | return; | 550 | return; |
549 | 551 | ||
550 | actionList->removeRef( action ); | 552 | actionList->removeRef( action ); |
551 | 553 | ||
552 | if ( actionList->count() == 0 ) | 554 | if ( actionList->count() == 0 ) |
553 | d->m_dctHighlightContainers.remove( container ); | 555 | d->m_dctHighlightContainers.remove( container ); |
554 | } | 556 | } |
555 | 557 | ||
556 | void KActionCollection::slotMenuItemHighlighted( int id ) | 558 | void KActionCollection::slotMenuItemHighlighted( int id ) |
557 | { | 559 | { |
558 | if ( !d->m_highlight ) | 560 | if ( !d->m_highlight ) |
559 | return; | 561 | return; |
560 | 562 | ||
561 | if ( d->m_currentHighlightAction ) | 563 | if ( d->m_currentHighlightAction ) |
562 | emit actionHighlighted( d->m_currentHighlightAction, false ); | 564 | emit actionHighlighted( d->m_currentHighlightAction, false ); |
563 | 565 | ||
564 | QWidget *container = static_cast<QWidget *>( const_cast<QObject *>( sender() ) ); | 566 | QWidget *container = static_cast<QWidget *>( const_cast<QObject *>( sender() ) ); |
565 | 567 | ||
566 | d->m_currentHighlightAction = findAction( container, id ); | 568 | d->m_currentHighlightAction = findAction( container, id ); |
567 | 569 | ||
568 | if ( !d->m_currentHighlightAction ) | 570 | if ( !d->m_currentHighlightAction ) |
569 | { | 571 | { |
570 | if ( !d->m_statusCleared ) | 572 | if ( !d->m_statusCleared ) |
571 | emit clearStatusText(); | 573 | emit clearStatusText(); |
572 | d->m_statusCleared = true; | 574 | d->m_statusCleared = true; |
573 | return; | 575 | return; |
574 | } | 576 | } |
575 | 577 | ||
576 | d->m_statusCleared = false; | 578 | d->m_statusCleared = false; |
577 | emit actionHighlighted( d->m_currentHighlightAction ); | 579 | emit actionHighlighted( d->m_currentHighlightAction ); |
578 | emit actionHighlighted( d->m_currentHighlightAction, true ); | 580 | emit actionHighlighted( d->m_currentHighlightAction, true ); |
579 | emit actionStatusText( d->m_currentHighlightAction->toolTip() ); | 581 | emit actionStatusText( d->m_currentHighlightAction->toolTip() ); |
580 | } | 582 | } |
581 | 583 | ||
582 | void KActionCollection::slotMenuAboutToHide() | 584 | void KActionCollection::slotMenuAboutToHide() |
583 | { | 585 | { |
584 | if ( d->m_currentHighlightAction ) | 586 | if ( d->m_currentHighlightAction ) |
585 | emit actionHighlighted( d->m_currentHighlightAction, false ); | 587 | emit actionHighlighted( d->m_currentHighlightAction, false ); |
586 | d->m_currentHighlightAction = 0; | 588 | d->m_currentHighlightAction = 0; |
587 | 589 | ||
588 | if ( !d->m_statusCleared ) | 590 | if ( !d->m_statusCleared ) |
589 | emit clearStatusText(); | 591 | emit clearStatusText(); |
590 | d->m_statusCleared = true; | 592 | d->m_statusCleared = true; |
591 | } | 593 | } |
592 | 594 | ||
593 | void KActionCollection::slotToolBarButtonHighlighted( int id, bool highlight ) | 595 | void KActionCollection::slotToolBarButtonHighlighted( int id, bool highlight ) |
594 | { | 596 | { |
595 | if ( !d->m_highlight ) | 597 | if ( !d->m_highlight ) |
596 | return; | 598 | return; |
597 | 599 | ||
598 | QWidget *container = static_cast<QWidget *>( const_cast<QObject *>( sender() ) ); | 600 | QWidget *container = static_cast<QWidget *>( const_cast<QObject *>( sender() ) ); |
599 | 601 | ||
600 | KAction *action = findAction( container, id ); | 602 | KAction *action = findAction( container, id ); |
601 | 603 | ||
602 | if ( !action ) | 604 | if ( !action ) |
603 | { | 605 | { |
604 | d->m_currentHighlightAction = 0; | 606 | d->m_currentHighlightAction = 0; |
605 | // use tooltip groups for toolbar status text stuff instead (Simon) | 607 | // use tooltip groups for toolbar status text stuff instead (Simon) |
606 | // emit clearStatusText(); | 608 | // emit clearStatusText(); |
607 | return; | 609 | return; |
608 | } | 610 | } |
609 | 611 | ||
610 | emit actionHighlighted( action, highlight ); | 612 | emit actionHighlighted( action, highlight ); |
611 | 613 | ||
612 | if ( highlight ) | 614 | if ( highlight ) |
613 | d->m_currentHighlightAction = action; | 615 | d->m_currentHighlightAction = action; |
614 | else | 616 | else |
615 | { | 617 | { |
616 | d->m_currentHighlightAction = 0; | 618 | d->m_currentHighlightAction = 0; |
617 | // emit clearStatusText(); | 619 | // emit clearStatusText(); |
618 | } | 620 | } |
619 | } | 621 | } |
620 | 622 | ||
621 | void KActionCollection::slotDestroyed() | 623 | void KActionCollection::slotDestroyed() |
622 | { | 624 | { |
623 | d->m_dctHighlightContainers.remove( reinterpret_cast<void *>( const_cast<QObject *>(sender()) ) ); | 625 | d->m_dctHighlightContainers.remove( reinterpret_cast<void *>( const_cast<QObject *>(sender()) ) ); |
624 | } | 626 | } |
625 | 627 | ||
626 | KAction *KActionCollection::findAction( QWidget *container, int id ) | 628 | KAction *KActionCollection::findAction( QWidget *container, int id ) |
627 | { | 629 | { |
628 | QPtrList<KAction> *actionList = d->m_dctHighlightContainers[ reinterpret_cast<void *>( container ) ]; | 630 | Q3PtrList<KAction> *actionList = d->m_dctHighlightContainers[ reinterpret_cast<void *>( container ) ]; |
629 | 631 | ||
630 | if ( !actionList ) | 632 | if ( !actionList ) |
631 | return 0; | 633 | return 0; |
632 | 634 | ||
633 | QPtrListIterator<KAction> it( *actionList ); | 635 | Q3PtrListIterator<KAction> it( *actionList ); |
634 | for (; it.current(); ++it ) | 636 | for (; it.current(); ++it ) |
635 | if ( it.current()->isPlugged( container, id ) ) | 637 | if ( it.current()->isPlugged( container, id ) ) |
636 | return it.current(); | 638 | return it.current(); |
637 | 639 | ||
638 | return 0; | 640 | return 0; |
639 | } | 641 | } |
640 | 642 | ||
641 | // KDE 4: remove | 643 | // KDE 4: remove |
642 | KActionCollection KActionCollection::operator+(const KActionCollection &c ) const | 644 | KActionCollection KActionCollection::operator+(const KActionCollection &c ) const |
643 | { | 645 | { |
644 | kdWarning(129) << "KActionCollection::operator+(): function is severely deprecated." << endl; | 646 | kdWarning(129) << "KActionCollection::operator+(): function is severely deprecated." << endl; |
645 | KActionCollection ret( *this ); | 647 | KActionCollection ret( *this ); |
646 | 648 | ||
647 | QValueList<KAction *> actions = c.actions(); | 649 | Q3ValueList<KAction *> actions = c.actions(); |
648 | QValueList<KAction *>::ConstIterator it = actions.begin(); | 650 | Q3ValueList<KAction *>::ConstIterator it = actions.begin(); |
649 | QValueList<KAction *>::ConstIterator end = actions.end(); | 651 | Q3ValueList<KAction *>::ConstIterator end = actions.end(); |
650 | for (; it != end; ++it ) | 652 | for (; it != end; ++it ) |
651 | ret.insert( *it ); | 653 | ret.insert( *it ); |
652 | 654 | ||
653 | return ret; | 655 | return ret; |
654 | } | 656 | } |
655 | 657 | ||
656 | KActionCollection &KActionCollection::operator=( const KActionCollection © ) | 658 | KActionCollection &KActionCollection::operator=( const KActionCollection © ) |
657 | { | 659 | { |
658 | kdWarning(129) << "KActionCollection::operator=(): function is severely deprecated." << endl; | 660 | kdWarning(129) << "KActionCollection::operator=(): function is severely deprecated." << endl; |
659 | //d->m_bOneKAccelOnly = copy.d->m_bOneKAccelOnly; | 661 | //d->m_bOneKAccelOnly = copy.d->m_bOneKAccelOnly; |
660 | //d->m_iWidgetCurrent = copy.d->m_iWidgetCurrent; | 662 | //d->m_iWidgetCurrent = copy.d->m_iWidgetCurrent; |
661 | //d->m_widgetList = copy.d->m_widgetList; | 663 | //d->m_widgetList = copy.d->m_widgetList; |
662 | //d->m_kaccelList = copy.d->m_kaccelList; | 664 | //d->m_kaccelList = copy.d->m_kaccelList; |
663 | d->m_widget = copy.d->m_widget; | 665 | d->m_widget = copy.d->m_widget; |
664 | d->m_kaccel = copy.d->m_kaccel; | 666 | d->m_kaccel = copy.d->m_kaccel; |
665 | d->m_actionDict = copy.d->m_actionDict; | 667 | d->m_actionDict = copy.d->m_actionDict; |
666 | //US setInstance( copy.instance() ); | 668 | //US setInstance( copy.instance() ); |
667 | return *this; | 669 | return *this; |
668 | } | 670 | } |
669 | 671 | ||
670 | KActionCollection &KActionCollection::operator+=( const KActionCollection &c ) | 672 | KActionCollection &KActionCollection::operator+=( const KActionCollection &c ) |
671 | { | 673 | { |
672 | kdWarning(129) << "KActionCollection::operator+=(): function is severely deprecated." << endl; | 674 | kdWarning(129) << "KActionCollection::operator+=(): function is severely deprecated." << endl; |
673 | QAsciiDictIterator<KAction> it(c.d->m_actionDict); | 675 | Q3AsciiDictIterator<KAction> it(c.d->m_actionDict); |
674 | for ( ; it.current(); ++it ) | 676 | for ( ; it.current(); ++it ) |
675 | insert( it.current() ); | 677 | insert( it.current() ); |
676 | 678 | ||
677 | return *this; | 679 | return *this; |
678 | } | 680 | } |
679 | // KDE 4: remove end | 681 | // KDE 4: remove end |
680 | 682 | ||
681 | //--------------------------------------------------------------------- | 683 | //--------------------------------------------------------------------- |
682 | // KActionShortcutList | 684 | // KActionShortcutList |
683 | //--------------------------------------------------------------------- | 685 | //--------------------------------------------------------------------- |
684 | /*US | 686 | /*US |
685 | KActionShortcutList::KActionShortcutList( KActionCollection* pColl ) | 687 | KActionShortcutList::KActionShortcutList( KActionCollection* pColl ) |
686 | : m_actions( *pColl ) | 688 | : m_actions( *pColl ) |
687 | { } | 689 | { } |
688 | KActionShortcutList::~KActionShortcutList() | 690 | KActionShortcutList::~KActionShortcutList() |
689 | { } | 691 | { } |
690 | uint KActionShortcutList::count() const | 692 | uint KActionShortcutList::count() const |
691 | { return m_actions.count(); } | 693 | { return m_actions.count(); } |
692 | QString KActionShortcutList::name( uint i ) const | 694 | QString KActionShortcutList::name( uint i ) const |
693 | { return m_actions.action(i)->name(); } | 695 | { return m_actions.action(i)->name(); } |
694 | QString KActionShortcutList::label( uint i ) const | 696 | QString KActionShortcutList::label( uint i ) const |
695 | { return m_actions.action(i)->text(); } | 697 | { return m_actions.action(i)->text(); } |
696 | QString KActionShortcutList::whatsThis( uint i ) const | 698 | QString KActionShortcutList::whatsThis( uint i ) const |
697 | { return m_actions.action(i)->whatsThis(); } | 699 | { return m_actions.action(i)->whatsThis(); } |
698 | const KShortcut& KActionShortcutList::shortcut( uint i ) const | 700 | const KShortcut& KActionShortcutList::shortcut( uint i ) const |
699 | { return m_actions.action(i)->shortcut(); } | 701 | { return m_actions.action(i)->shortcut(); } |
700 | const KShortcut& KActionShortcutList::shortcutDefault( uint i ) const | 702 | const KShortcut& KActionShortcutList::shortcutDefault( uint i ) const |
701 | { return m_actions.action(i)->shortcutDefault(); } | 703 | { return m_actions.action(i)->shortcutDefault(); } |
702 | bool KActionShortcutList::isConfigurable( uint i ) const | 704 | bool KActionShortcutList::isConfigurable( uint i ) const |
703 | { return m_actions.action(i)->isShortcutConfigurable(); } | 705 | { return m_actions.action(i)->isShortcutConfigurable(); } |
704 | bool KActionShortcutList::setShortcut( uint i, const KShortcut& cut ) | 706 | bool KActionShortcutList::setShortcut( uint i, const KShortcut& cut ) |
705 | { return m_actions.action(i)->setShortcut( cut ); } | 707 | { return m_actions.action(i)->setShortcut( cut ); } |
706 | const KInstance* KActionShortcutList::instance() const | 708 | const KInstance* KActionShortcutList::instance() const |
707 | { return m_actions.instance(); } | 709 | { return m_actions.instance(); } |
708 | QVariant KActionShortcutList::getOther( Other, uint ) const | 710 | QVariant KActionShortcutList::getOther( Other, uint ) const |
709 | { return QVariant(); } | 711 | { return QVariant(); } |
710 | bool KActionShortcutList::setOther( Other, uint, QVariant ) | 712 | bool KActionShortcutList::setOther( Other, uint, QVariant ) |
711 | { return false; } | 713 | { return false; } |
712 | 714 | ||
713 | bool KActionShortcutList::save() const | 715 | bool KActionShortcutList::save() const |
714 | { | 716 | { |
715 | kdDebug(129) << "KActionShortcutList::save(): xmlFile = " << m_actions.xmlFile() << endl; | 717 | kdDebug(129) << "KActionShortcutList::save(): xmlFile = " << m_actions.xmlFile() << endl; |
716 | 718 | ||
717 | if( m_actions.xmlFile().isEmpty() ) | 719 | if( m_actions.xmlFile().isEmpty() ) |
718 | return writeSettings(); | 720 | return writeSettings(); |
719 | 721 | ||
720 | QString tagActionProp = QString::fromLatin1("ActionProperties"); | 722 | QString tagActionProp = QString::fromLatin1("ActionProperties"); |
721 | QString tagAction = QString::fromLatin1("Action"); | 723 | QString tagAction = QString::fromLatin1("Action"); |
722 | QString attrName = QString::fromLatin1("name"); | 724 | QString attrName = QString::fromLatin1("name"); |
723 | QString attrShortcut = QString::fromLatin1("shortcut"); | 725 | QString attrShortcut = QString::fromLatin1("shortcut"); |
724 | QString attrAccel = QString::fromLatin1("accel"); // Depricated attribute | 726 | QString attrAccel = QString::fromLatin1("accel"); // Depricated attribute |
725 | 727 | ||
726 | // Read XML file | 728 | // Read XML file |
727 | QString sXml( KXMLGUIFactory::readConfigFile( m_actions.xmlFile(), false, instance() ) ); | 729 | QString sXml( KXMLGUIFactory::readConfigFile( m_actions.xmlFile(), false, instance() ) ); |
728 | QDomDocument doc; | 730 | QDomDocument doc; |
729 | doc.setContent( sXml ); | 731 | doc.setContent( sXml ); |
730 | 732 | ||
731 | // Process XML data | 733 | // Process XML data |
732 | 734 | ||
733 | // first, lets see if we have existing properties | 735 | // first, lets see if we have existing properties |
734 | QDomElement elem; | 736 | QDomElement elem; |
735 | QDomElement it = doc.documentElement(); | 737 | QDomElement it = doc.documentElement(); |
736 | // KXMLGUIFactory::removeDOMComments( it ); <-- What was this for? --ellis | 738 | // KXMLGUIFactory::removeDOMComments( it ); <-- What was this for? --ellis |
737 | it = it.firstChild().toElement(); | 739 | it = it.firstChild().toElement(); |
738 | for( ; !it.isNull(); it = it.nextSibling().toElement() ) { | 740 | for( ; !it.isNull(); it = it.nextSibling().toElement() ) { |
739 | if( it.tagName() == tagActionProp ) { | 741 | if( it.tagName() == tagActionProp ) { |
740 | elem = it; | 742 | elem = it; |
741 | break; | 743 | break; |
742 | } | 744 | } |
743 | } | 745 | } |
744 | 746 | ||
745 | // if there was none, create one | 747 | // if there was none, create one |
746 | if( elem.isNull() ) { | 748 | if( elem.isNull() ) { |
747 | elem = doc.createElement( tagActionProp ); | 749 | elem = doc.createElement( tagActionProp ); |
748 | doc.documentElement().appendChild( elem ); | 750 | doc.documentElement().appendChild( elem ); |
749 | } | 751 | } |
750 | 752 | ||
751 | // now, iterate through our actions | 753 | // now, iterate through our actions |
752 | uint nSize = count(); | 754 | uint nSize = count(); |
753 | for( uint i = 0; i < nSize; i++ ) { | 755 | for( uint i = 0; i < nSize; i++ ) { |
754 | const QString& sName = name(i); | 756 | const QString& sName = name(i); |
755 | 757 | ||
756 | bool bSameAsDefault = (shortcut(i) == shortcutDefault(i)); | 758 | bool bSameAsDefault = (shortcut(i) == shortcutDefault(i)); |
757 | //kdDebug(129) << "name = " << sName << " shortcut = " << shortcut(i).toStringInternal() << " def = " << shortcutDefault(i).toStringInternal() << endl; | 759 | //kdDebug(129) << "name = " << sName << " shortcut = " << shortcut(i).toStringInternal() << " def = " << shortcutDefault(i).toStringInternal() << endl; |
758 | 760 | ||
759 | // now see if this element already exists | 761 | // now see if this element already exists |
760 | QDomElement act_elem; | 762 | QDomElement act_elem; |
761 | for( it = elem.firstChild().toElement(); !it.isNull(); it = it.nextSibling().toElement() ) { | 763 | for( it = elem.firstChild().toElement(); !it.isNull(); it = it.nextSibling().toElement() ) { |
762 | if( it.attribute( attrName ) == sName ) { | 764 | if( it.attribute( attrName ) == sName ) { |
763 | act_elem = it; | 765 | act_elem = it; |
764 | break; | 766 | break; |
765 | } | 767 | } |
766 | } | 768 | } |
767 | 769 | ||
768 | // nope, create a new one | 770 | // nope, create a new one |
769 | if( act_elem.isNull() ) { | 771 | if( act_elem.isNull() ) { |