summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/kaction.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdeui/kaction.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/kaction.cpp75
1 files changed, 39 insertions, 36 deletions
diff --git a/microkde/kdeui/kaction.cpp b/microkde/kdeui/kaction.cpp
index d38a6d5..c2df381 100644
--- a/microkde/kdeui/kaction.cpp
+++ b/microkde/kdeui/kaction.cpp
@@ -19,41 +19,44 @@
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 "kaction.h"
#include <assert.h>
#include <qtooltip.h>
+//Added by qt3to4:
+#include <Q3CString>
+#include <Q3ValueList>
//US#include <qwhatsthis.h>
//US#include <kaccel.h>
//US#include <kaccelbase.h>
#include <kapplication.h>
#include <kdebug.h>
#include <kguiitem.h>
//US#include <kmainwindow.h>
//US#include <kmenubar.h>
//US#include <kpopupmenu.h>
#include <ktoolbar.h>
#include <ktoolbarbutton.h>
//US added this includefiles
#include <qmenubar.h>
-#include <qtoolbar.h>
-#include <qpopupmenu.h>
-#include <qiconset.h>
+#include <q3toolbar.h>
+#include <q3popupmenu.h>
+#include <qicon.h>
/**
* How it works.
* KActionCollection is an organizing container for KActions.
* KActionCollection keeps track of the information necessary to handle
* configuration and shortcuts.
*
* Focus Widget pointer:
* This is the widget which is the focus for action shortcuts.
* It is set either by passing a QWidget* to the KActionCollection constructor
* or by calling setWidget() if the widget wasn't known when the object was
* initially constructed (as in KXMLGUIClient and KParts::PartBase)
@@ -78,68 +81,68 @@ int KAction::getToolButtonID()
//---------------------------------------------------------------------
class KAction::KActionPrivate : public KGuiItem
{
public:
KActionPrivate() : KGuiItem()
{
m_kaccel = 0;
m_configurable = true;
}
KAccel *m_kaccel;
- QValueList<KAccel*> m_kaccelList;
+ Q3ValueList<KAccel*> m_kaccelList;
QString m_groupText;
QString m_group;
KShortcut m_cut;
KShortcut m_cutDefault;
bool m_configurable;
struct Container
{
Container() { m_container = 0; m_representative = 0; m_id = 0; }
Container( const Container& s ) { m_container = s.m_container;
m_id = s.m_id; m_representative = s.m_representative; }
QWidget* m_container;
int m_id;
QWidget* m_representative;
};
- QValueList<Container> m_containers;
+ Q3ValueList<Container> m_containers;
};
//---------------------------------------------------------------------
// KAction
//---------------------------------------------------------------------
KAction::KAction( const QString& text, const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name )
: QObject( parent, name )
{
initPrivate( text, cut, receiver, slot );
}
KAction::KAction( const QString& text, const QString& sIconName, const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name )
: QObject( parent, name )
{
initPrivate( text, cut, receiver, slot );
d->setIconName( sIconName );
}
-KAction::KAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
+KAction::KAction( const QString& text, const QIcon& pix, const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name )
: QObject( parent, name )
{
initPrivate( text, cut, receiver, slot );
d->setIconSet( pix );
}
KAction::KAction( const KGuiItem& item, const KShortcut& cut,
const QObject* receiver, const char* slot,
KActionCollection* parent, const char* name )
: QObject( parent, name )
{
@@ -155,43 +158,43 @@ KAction::KAction( const QString& text, const KShortcut& cut,
QObject* parent, const char* name )
: QObject( parent, name )
{
initPrivate( text, cut, 0, 0 );
}
KAction::KAction( const QString& text, const KShortcut& cut,
const QObject* receiver,
const char* slot, QObject* parent, const char* name )
: QObject( parent, name )
{
initPrivate( text, cut, receiver, slot );
}
-KAction::KAction( const QString& text, const QIconSet& pix,
+KAction::KAction( const QString& text, const QIcon& pix,
const KShortcut& cut,
QObject* parent, const char* name )
: QObject( parent, name )
{
initPrivate( text, cut, 0, 0 );
setIconSet( pix );
}
KAction::KAction( const QString& text, const QString& pix,
const KShortcut& cut,
QObject* parent, const char* name )
: QObject( parent, name )
{
initPrivate( text, cut, 0, 0 );
d->setIconName( pix );
}
-KAction::KAction( const QString& text, const QIconSet& pix,
+KAction::KAction( const QString& text, const QIcon& pix,
const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent,
const char* name )
: QObject( parent, name )
{
initPrivate( text, cut, receiver, slot );
setIconSet( pix );
}
KAction::KAction( const QString& text, const QString& pix,
const KShortcut& cut,
const QObject* receiver, const char* slot, QObject* parent,
@@ -497,37 +500,37 @@ void KAction::removeKAccel( KAccel* kaccel )
// KDE 4: remove
void KAction::setAccel( int keyQt )
{
setShortcut( KShortcut(keyQt) );
}
// KDE 4: remove end
void KAction::updateShortcut( int i )
{
int id = itemId( i );
QWidget* w = container( i );
- if ( w->inherits( "QPopupMenu" ) ) {
- QPopupMenu* menu = static_cast<QPopupMenu*>(w);
+ if ( w->inherits( "Q3PopupMenu" ) ) {
+ Q3PopupMenu* menu = static_cast<Q3PopupMenu*>(w);
updateShortcut( menu, id );
}
else if ( w->inherits( "QMenuBar" ) )
//US static_cast<QMenuBar*>(w)->setAccel( d->m_cut.keyCodeQt(), id );
//US (QMenuBar*)(w)->setAccel( d->m_cut.keyCodeQt(), id );
; //qDebug("KAction::updateShortcut( int i ) ...1 has top be fixed");
}
-void KAction::updateShortcut( QPopupMenu* menu, int id )
+void KAction::updateShortcut( Q3PopupMenu* menu, int id )
{
/*US
//kdDebug(129) << "KAction::updateShortcut(): this = " << this << " d->m_kaccelList.count() = " << d->m_kaccelList.count() << endl;
// If the action has a KAccel object,
// show the string representation of its shortcut.
if ( d->m_kaccel || d->m_kaccelList.count() ) {
QString s = menu->text( id );
int i = s.find( '\t' );
if ( i >= 0 )
s.replace( i+1, s.length()-i, d->m_cut.seq(0).toString() );
else
s += "\t" + d->m_cut.seq(0).toString();
@@ -612,52 +615,52 @@ void KAction::setToolTip( const QString& tt )
int len = containerCount();
for( int i = 0; i < len; ++i )
updateToolTip( i );
}
void KAction::updateToolTip( int i )
{
//qDebug("KAction::updateToolTip ...1 has top be fixed");
QWidget *w = container( i );
if ( w->inherits( "KToolBar" ) )
QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() );
- else if ( w->inherits( "QToolBar" ) )
+ else if ( w->inherits( "Q3ToolBar" ) )
QToolTip::add( static_cast<KToolBar*>(w)->getWidget( itemId( i ) ), d->toolTip() );
}
QString KAction::toolTip() const
{
return d->toolTip();
}
int KAction::plug( QWidget *w, int index )
{
//kdDebug(129) << "KAction::plug( " << w << ", " << index << " )" << endl;
if (w == 0) {
kdWarning(129) << "KAction::plug called with 0 argument\n";
return -1;
}
// Check if action is permitted
//US if (kapp && !kapp->authorizeKAction(name()))
//US return -1;
plugShortcut();
- if ( w->inherits("QPopupMenu") )
+ if ( w->inherits("Q3PopupMenu") )
{
- QPopupMenu* menu = static_cast<QPopupMenu*>( w );
+ Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( w );
int id;
// Don't insert shortcut into menu if it's already in a KAccel object.
//qDebug("KAction::plug warning: real shortcuts not available yet. ");
//US int keyQt = (d->m_kaccelList.count() || d->m_kaccel) ? 0 : d->m_cut.keyCodeQt();
int keyQt = 0;
if ( d->hasIcon() )
{
/*US
KInstance *instance;
if ( m_parentCollection )
instance = m_parentCollection->instance();
@@ -712,25 +715,25 @@ int KAction::plug( QWidget *w, int index )
SLOT( slotActivated() ),
d->isEnabled(), d->plainText(), index );
}
else
{
QString icon = d->iconName();
if ( icon.isEmpty() )
icon = "unknown";
bar->insertButton( icon, id_, SIGNAL( clicked() ), this,
SLOT( slotActivated() ),
d->isEnabled(), d->plainText(), index/*US, instance*/ );
}
- bar->getButton( id_ )->setName( QCString("toolbutton_")+name() );
+ bar->getButton( id_ )->setName( Q3CString("toolbutton_")+name() );
//US if ( !d->whatsThis().isEmpty() )
//US QWhatsThis::add( bar->getButton(id_), whatsThisWithIcon() );
if ( !d->toolTip().isEmpty() )
QToolTip::add( bar->getButton(id_), d->toolTip() );
addContainer( bar, id_ );
connect( bar, SIGNAL( destroyed() ), this, SLOT( slotDestroyed() ) );
if ( m_parentCollection )
m_parentCollection->connectHighlight( bar, this );
@@ -740,27 +743,27 @@ int KAction::plug( QWidget *w, int index )
}
return -1;
}
void KAction::unplug( QWidget *w )
{
int i = findContainer( w );
if ( i == -1 )
return;
int id = itemId( i );
- if ( w->inherits( "QPopupMenu" ) )
+ if ( w->inherits( "Q3PopupMenu" ) )
{
- QPopupMenu *menu = static_cast<QPopupMenu *>( w );
+ Q3PopupMenu *menu = static_cast<Q3PopupMenu *>( w );
menu->removeItem( id );
}
else if ( w->inherits( "KToolBar" ) )
{
KToolBar *bar = static_cast<KToolBar *>( w );
bar->removeItemDelayed( id );
}
else if ( w->inherits( "QMenuBar" ) )
{
QMenuBar *bar = static_cast<QMenuBar *>( w );
bar->removeItem( id );
}
@@ -853,26 +856,26 @@ void KAction::setEnabled(bool enable)
int len = containerCount();
for( int i = 0; i < len; ++i )
updateEnabled( i );
emit enabled( d->isEnabled() );
}
void KAction::updateEnabled( int i )
{
QWidget *w = container( i );
- if ( w->inherits("QPopupMenu") )
- static_cast<QPopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
+ if ( w->inherits("Q3PopupMenu") )
+ static_cast<Q3PopupMenu*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
else if ( w->inherits("QMenuBar") )
static_cast<QMenuBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
else if ( w->inherits( "KToolBar" ) )
{
static_cast<KToolBar*>(w)->setItemEnabled( itemId( i ), d->isEnabled() );
}
}
void KAction::setShortcutConfigurable( bool b )
{
d->m_configurable = b;
}
@@ -897,28 +900,28 @@ void KAction::setText( const QString& text )
d->setText( text );
int len = containerCount();
for( int i = 0; i < len; ++i )
updateText( i );
}
void KAction::updateText( int i )
{
QWidget *w = container( i );
- if ( w->inherits( "QPopupMenu" ) ) {
+ if ( w->inherits( "Q3PopupMenu" ) ) {
int id = itemId( i );
- static_cast<QPopupMenu*>(w)->changeItem( id, d->text() );
- updateShortcut( static_cast<QPopupMenu*>(w), id );
+ static_cast<Q3PopupMenu*>(w)->changeItem( id, d->text() );
+ updateShortcut( static_cast<Q3PopupMenu*>(w), id );
}
else if ( w->inherits( "QMenuBar" ) )
static_cast<QMenuBar*>(w)->changeItem( itemId( i ), d->text() );
else if ( w->inherits( "KToolBar" ) )
{
//qDebug("KAction::updateText ...3 has top be fixed");
QWidget *button = static_cast<KToolBar *>(w)->getWidget( itemId( i ) );
if ( button->inherits( "KToolBarButton" ) )
static_cast<KToolBarButton *>(button)->setText( d->plainText() );
}
}
@@ -938,100 +941,100 @@ void KAction::setIcon( const QString &icon )
d->setIconName( icon );
// now handle any toolbars
int len = containerCount();
for ( int i = 0; i < len; ++i )
updateIcon( i );
}
void KAction::updateIcon( int id )
{
QWidget* w = container( id );
- if ( w->inherits( "QPopupMenu" ) ) {
+ if ( w->inherits( "Q3PopupMenu" ) ) {
int itemId_ = itemId( id );
- static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() );
- updateShortcut( static_cast<QPopupMenu*>(w), itemId_ );
+ static_cast<Q3PopupMenu*>(w)->changeItem( itemId_, d->iconSet( KIcon::Small ), d->text() );
+ updateShortcut( static_cast<Q3PopupMenu*>(w), itemId_ );
}
else if ( w->inherits( "QMenuBar" ) )
static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet( KIcon::Small ), d->text() );
else if ( w->inherits( "KToolBar" ) )
static_cast<KToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() );
- else if ( w->inherits( "QToolBar" ) )
+ else if ( w->inherits( "Q3ToolBar" ) )
{
qDebug("KAction::updateIcon has top be fixed");
//US static_cast<QToolBar *>(w)->setButtonIcon( itemId( id ), d->iconName() );
}
}
QString KAction::icon() const
{
return d->iconName( );
}
-void KAction::setIconSet( const QIconSet &iconset )
+void KAction::setIconSet( const QIcon &iconset )
{
d->setIconSet( iconset );
int len = containerCount();
for( int i = 0; i < len; ++i )
updateIconSet( i );
}
void KAction::updateIconSet( int id )
{
QWidget *w = container( id );
- if ( w->inherits( "QPopupMenu" ) )
+ if ( w->inherits( "Q3PopupMenu" ) )
{
int itemId_ = itemId( id );
- static_cast<QPopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() );
- updateShortcut( static_cast<QPopupMenu*>(w), itemId_ );
+ static_cast<Q3PopupMenu*>(w)->changeItem( itemId_, d->iconSet(), d->text() );
+ updateShortcut( static_cast<Q3PopupMenu*>(w), itemId_ );
}
else if ( w->inherits( "QMenuBar" ) )
static_cast<QMenuBar*>(w)->changeItem( itemId( id ), d->iconSet(), d->text() );
else if ( w->inherits( "KToolBar" ) )
{
if ( icon().isEmpty() && d->hasIconSet() ) // only if there is no named icon ( scales better )
static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet() );
else
static_cast<KToolBar *>(w)->setButtonIconSet( itemId( id ), d->iconSet( KIcon::Small ) );
}
}
-QIconSet KAction::iconSet( KIcon::Group group, int size ) const
+QIcon KAction::iconSet( KIcon::Group group, int size ) const
{
return d->iconSet( group, size );
}
bool KAction::hasIcon() const
{
return d->hasIcon();
}
void KAction::setWhatsThis( const QString& text )
{
d->setWhatsThis( text );
int len = containerCount();
for( int i = 0; i < len; ++i )
updateWhatsThis( i );
}
void KAction::updateWhatsThis( int i )
{
qDebug("KAction::updateWhatsThis ...1 has top be fixed");
- QPopupMenu* pm = popupMenu( i );
+ Q3PopupMenu* pm = popupMenu( i );
if ( pm )
{
pm->setWhatsThis( itemId( i ), d->whatsThis() );
return;
}
KToolBar *tb = toolBar( i );
if ( tb )
{
QWidget *w = tb->getButton( itemId( i ) );
//US QWhatsThis::remove( w );
//US QWhatsThis::add( w, d->whatsThis() );
@@ -1055,28 +1058,28 @@ QString KAction::whatsThisWithIcon() const
QWidget* KAction::container( int index ) const
{
assert( index < containerCount() );
return d->m_containers[ index ].m_container;
}
KToolBar* KAction::toolBar( int index ) const
{
//US return dynamic_cast<KToolBar *>( d->m_containers[ index ].m_container );
return (KToolBar *)( d->m_containers[ index ].m_container );
}
-QPopupMenu* KAction::popupMenu( int index ) const
+Q3PopupMenu* KAction::popupMenu( int index ) const
{
//US return dynamic_cast<QPopupMenu *>( d->m_containers[ index ].m_container );
- return (QPopupMenu *)( d->m_containers[ index ].m_container );
+ return (Q3PopupMenu *)( d->m_containers[ index ].m_container );
}
QWidget* KAction::representative( int index ) const
{
return d->m_containers[ index ].m_representative;
}
int KAction::itemId( int index ) const
{
return d->m_containers[ index ].m_id;
}
@@ -1146,40 +1149,40 @@ void KAction::slotDestroyed()
do
{
i = findContainer( static_cast<const QWidget*>( o ) );
if ( i != -1 )
removeContainer( i );
} while ( i != -1 );
}
int KAction::findContainer( const QWidget* widget ) const
{
int pos = 0;
- QValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin();
+ Q3ValueList<KActionPrivate::Container>::ConstIterator it = d->m_containers.begin();
while( it != d->m_containers.end() )
{
if ( (*it).m_representative == widget || (*it).m_container == widget )
return pos;
++it;
++pos;
}
return -1;
}
void KAction::removeContainer( int index )
{
int i = 0;
- QValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin();
+ Q3ValueList<KActionPrivate::Container>::Iterator it = d->m_containers.begin();
while( it != d->m_containers.end() )
{
if ( i == index )
{
d->m_containers.remove( it );
return;
}
++it;
++i;
}
}