summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kactioncollection.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdeui/kactioncollection.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kactioncollection.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/microkde/kdeui/kactioncollection.cpp b/microkde/kdeui/kactioncollection.cpp
index b819e76..69e5d02 100644
--- a/microkde/kdeui/kactioncollection.cpp
+++ b/microkde/kdeui/kactioncollection.cpp
@@ -1,352 +1,353 @@
/* This file is part of the KDE libraries
Copyright (C) 1999 Reginald Stadlbauer <reggie@kde.org>
(C) 1999 Simon Hausmann <hausmann@kde.org>
(C) 2000 Nicolas Hadacek <haadcek@kde.org>
(C) 2000 Kurt Granroth <granroth@kde.org>
(C) 2000 Michael Koch <koch@kde.org>
(C) 2001 Holger Freyther <freyther@kde.org>
(C) 2002 Ellis Whitehead <ellis@kde.org>
(C) 2002 Joseph Wenninger <jowenn@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "kactioncollection.h"
//US#include "kactionshortcutlist.h"
#include <qptrdict.h>
//US#include <qvariant.h>
//US#include <kaccel.h>
//US#include <kaccelbase.h>
//US#include <kapplication.h>
#include <kdebug.h>
//US#include <kxmlguifactory.h>
//US I included the following files
#include <qasciidict.h>
#include <qptrlist.h>
#include "kaction.h"
#include <kglobal.h>
#include <qobject.h>
#include <qwidget.h>
class KActionCollection::KActionCollectionPrivate
{
public:
KActionCollectionPrivate()
{
//US m_instance = 0;
//m_bOneKAccelOnly = false;
//m_iWidgetCurrent = 0;
m_bAutoConnectShortcuts = true;
m_widget = 0;
m_kaccel = m_builderKAccel = 0;
m_dctHighlightContainers.setAutoDelete( true );
m_highlight = false;
m_currentHighlightAction = 0;
m_statusCleared = true;
}
//US KInstance *m_instance;
//US QString m_sXMLFile;
bool m_bAutoConnectShortcuts;
//bool m_bOneKAccelOnly;
//int m_iWidgetCurrent;
//QValueList<QWidget*> m_widgetList;
//QValueList<KAccel*> m_kaccelList;
QValueList<KActionCollection*> m_docList;
QWidget *m_widget;
KAccel *m_kaccel;
KAccel *m_builderKAccel;
QAsciiDict<KAction> m_actionDict;
QPtrDict< QPtrList<KAction> > m_dctHighlightContainers;
bool m_highlight;
KAction *m_currentHighlightAction;
bool m_statusCleared;
};
KActionCollection::KActionCollection( QWidget *parent, const char *name /*US,
KInstance *instance */)
: QObject( (QObject*)parent, name )
{
kdDebug(129) << "KActionCollection::KActionCollection( " << parent << ", " << name << " ): this = " << this << endl; // ellis
d = new KActionCollectionPrivate;
if( parent )
setWidget( parent );
//d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
//US setInstance( instance );
}
KActionCollection::KActionCollection( QWidget *watch, QObject* parent, const char *name /*US,
KInstance *instance */)
: QObject( parent, name )
{
kdDebug(129) << "KActionCollection::KActionCollection( " << watch << ", " << parent << ", " << name << " ): this = " << this << endl; //ellis
d = new KActionCollectionPrivate;
if( watch )
setWidget( watch );
//d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
//US setInstance( instance );
}
// KDE 4: remove
KActionCollection::KActionCollection( QObject *parent, const char *name /*US,
KInstance *instance */)
: QObject( parent, name )
{
kdWarning(129) << "KActionCollection::KActionCollection( QObject *parent, const char *name, KInstance *instance )" << endl; //ellis
//US kdBacktrace not available
//US kdDebug(129) << kdBacktrace() << endl;
d = new KActionCollectionPrivate;
//US QWidget* w = dynamic_cast<QWidget*>( parent );
QWidget* w = (QWidget*)( parent );
if( w )
setWidget( w );
//d->m_bOneKAccelOnly = (d->m_kaccelList.count() > 0);
//US setInstance( instance );
}
KActionCollection::KActionCollection( const KActionCollection &copy )
: QObject()
{
kdWarning(129) << "KActionCollection::KActionCollection( const KActionCollection & ): function is severely deprecated." << endl;
d = new KActionCollectionPrivate;
*this = copy;
}
// KDE 4: remove end
KActionCollection::~KActionCollection()
{
kdDebug(129) << "KActionCollection::~KActionCollection(): this = " << this << endl;
for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
KAction* pAction = it.current();
if ( pAction->m_parentCollection == this )
pAction->m_parentCollection = 0L;
}
//US delete d->m_kaccel;
//US delete d->m_builderKAccel;
delete d; d = 0;
}
void KActionCollection::setWidget( QWidget* w )
{
//if ( d->m_actionDict.count() > 0 ) {
// kdError(129) << "KActionCollection::setWidget(): must be called before any actions are added to collection!" << endl;
// kdDebug(129) << kdBacktrace() << endl;
//}
//else
if ( !d->m_widget ) {
d->m_widget = w;
- qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde");
+ //qDebug("KActionCollection::setWidget: warning: KAccel is never used in microkde");
//US d->m_kaccel = new KAccel( w, this, "KActionCollection-KAccel" );
}
else if ( d->m_widget != w )
- kdWarning(129) << "KActionCollection::setWidget(): tried to change widget from " << d->m_widget << " to " << w << endl;
+ ;
+
}
void KActionCollection::setAutoConnectShortcuts( bool b )
{
d->m_bAutoConnectShortcuts = b;
}
bool KActionCollection::isAutoConnectShortcuts()
{
return d->m_bAutoConnectShortcuts;
}
bool KActionCollection::addDocCollection( KActionCollection* pDoc )
{
d->m_docList.append( pDoc );
return true;
}
void KActionCollection::beginXMLPlug( QWidget *widget )
{
qDebug("KActionCollection::beginXMLPlug has to be fixed");
/*US
kdDebug(129) << "KActionCollection::beginXMLPlug( buildWidget = " << widget << " ): this = " << this << " d->m_builderKAccel = " << d->m_builderKAccel << endl;
if( widget && !d->m_builderKAccel ) {
d->m_builderKAccel = new KAccel( widget, this, "KActionCollection-BuilderKAccel" );
}
*/
}
void KActionCollection::endXMLPlug()
{
kdDebug(129) << "KActionCollection::endXMLPlug(): this = " << this << endl;
//s_kaccelXML = 0;
}
void KActionCollection::prepareXMLUnplug()
{
qDebug("KActionCollection::prepareXMLUnplug has to be fixed");
/*US
kdDebug(129) << "KActionCollection::prepareXMLUnplug(): this = " << this << endl;
unplugShortcuts( d->m_kaccel );
if( d->m_builderKAccel ) {
unplugShortcuts( d->m_builderKAccel );
delete d->m_builderKAccel;
d->m_builderKAccel = 0;
}
*/
}
void KActionCollection::unplugShortcuts( KAccel* kaccel )
{
qDebug("KActionCollection::unplugShortcuts has to be fixed");
/*US
for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
KAction* pAction = it.current();
pAction->removeKAccel( kaccel );
}
for( uint i = 0; i < d->m_docList.count(); i++ )
d->m_docList[i]->unplugShortcuts( kaccel );
*/
}
/*void KActionCollection::addWidget( QWidget* w )
{
if( !d->m_bOneKAccelOnly ) {
kdDebug(129) << "KActionCollection::addWidget( " << w << " ): this = " << this << endl;
for( uint i = 0; i < d->m_widgetList.count(); i++ ) {
if( d->m_widgetList[i] == w ) {
d->m_iWidgetCurrent = i;
return;
}
}
d->m_iWidgetCurrent = d->m_widgetList.count();
d->m_widgetList.append( w );
d->m_kaccelList.append( new KAccel( w, this, "KActionCollection-KAccel" ) );
}
}
void KActionCollection::removeWidget( QWidget* w )
{
if( !d->m_bOneKAccelOnly ) {
kdDebug(129) << "KActionCollection::removeWidget( " << w << " ): this = " << this << endl;
for( uint i = 0; i < d->m_widgetList.count(); i++ ) {
if( d->m_widgetList[i] == w ) {
// Remove KAccel object from children.
KAccel* pKAccel = d->m_kaccelList[i];
for ( QAsciiDictIterator<KAction> it( d->m_actionDict ); it.current(); ++it ) {
KAction* pAction = it.current();
if ( pAction->m_parentCollection == this ) {
pAction->removeKAccel( pKAccel );
}
}
delete pKAccel;
d->m_widgetList.remove( d->m_widgetList.at( i ) );
d->m_kaccelList.remove( d->m_kaccelList.at( i ) );
if( d->m_iWidgetCurrent == (int)i )
d->m_iWidgetCurrent = -1;
else if( d->m_iWidgetCurrent > (int)i )
d->m_iWidgetCurrent--;
return;
}
}
kdWarning(129) << "KActionCollection::removeWidget( " << w << " ): widget not in list." << endl;
}
}
bool KActionCollection::ownsKAccel() const
{
return d->m_bOneKAccelOnly;
}
uint KActionCollection::widgetCount() const
{
return d->m_widgetList.count();
}
const KAccel* KActionCollection::widgetKAccel( uint i ) const
{
return d->m_kaccelList[i];
}*/
//US we are using no accelerators so far. So just setup an empty implementation.
KAccel* KActionCollection::kaccel()
{
//if( d->m_kaccelList.count() > 0 )
// return d->m_kaccelList[d->m_iWidgetCurrent];
//else
// return 0;
//US return d->m_kaccel;
return 0;
}
//US we are using no accelerators so far. So just setup an empty implementation.
const KAccel* KActionCollection::kaccel() const
{
//if( d->m_kaccelList.count() > 0 )
// return d->m_kaccelList[d->m_iWidgetCurrent];
//else
// return 0;
//USreturn d->m_kaccel;
return 0;
}
/*void KActionCollection::findMainWindow( QWidget *w )
{
// Note: topLevelWidget() stops too early, we can't use it.
QWidget * tl = w;
while ( tl->parentWidget() ) // lookup parent and store
tl = tl->parentWidget();
KMainWindow * mw = dynamic_cast<KMainWindow *>(tl); // try to see if it's a kmainwindow
if (mw)
d->m_mainwindow = mw;
else
kdDebug(129) << "KAction::plugMainWindowAccel: Toplevel widget isn't a KMainWindow, can't plug accel. " << tl << endl;
}*/
void KActionCollection::_insert( KAction* action )
{
char unnamed_name[100];
const char *name = action->name();
if( qstrcmp( name, "unnamed" ) == 0 )
{
sprintf(unnamed_name, "unnamed-%p", (void *)action);
name = unnamed_name;
}
KAction *a = d->m_actionDict[ name ];
if ( a == action )
return;
d->m_actionDict.insert( name, action );
emit inserted( action );
}
void KActionCollection::_remove( KAction* action )
{
delete _take( action );
}
KAction* KActionCollection::_take( KAction* action )
{
char unnamed_name[100];
const char *name = action->name();
if( qstrcmp( name, "unnamed" ) == 0 )
{