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) (side-by-side diff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /microkde/kdeui/kactionclasses.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
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 @@ -27,11 +27,13 @@ #include <assert.h> #include <qfontdatabase.h> -#include <qobjectlist.h> +#include <qobject.h> //US#include <qwhatsthis.h> #include <qtimer.h> +//Added by qt3to4: +#include <Q3ValueList> //US#include <kaccel.h> //US#include <kapplication.h> #include <kconfig.h> @@ -47,15 +49,15 @@ //US added the following includefiles #include <kconfigbase.h> #include <qwidget.h> -#include <qpopupmenu.h> +#include <q3popupmenu.h> #include <qmenubar.h> -#include <qmainwindow.h> -#include <qtoolbar.h> +#include <q3mainwindow.h> +#include <q3toolbar.h> #include <qcombobox.h> -#include <qmainwindow.h> - +#include <q3mainwindow.h> +#include <qcoreapplication.h> static QFontDatabase *fontDataBase = 0; static void cleanupFontDatabase() @@ -82,9 +84,9 @@ static void get_fonts( QStringList &lst ) } lst.sort(); } -static QValueList<int> get_standard_font_sizes() +static Q3ValueList<int> get_standard_font_sizes() { if ( !fontDataBase ) { fontDataBase = new QFontDatabase(); qAddPostRoutine( cleanupFontDatabase ); @@ -119,9 +121,9 @@ KToggleAction::KToggleAction( const QString& text, const KShortcut& cut, { d = new KToggleActionPrivate; } -KToggleAction::KToggleAction( const QString& text, const QIconSet& pix, +KToggleAction::KToggleAction( const QString& text, const QIcon& pix, const KShortcut& cut, QObject* parent, const char* name ) : KAction( text, pix, cut, parent, name ) { @@ -135,9 +137,9 @@ KToggleAction::KToggleAction( const QString& text, const QString& pix, { d = new KToggleActionPrivate; } -KToggleAction::KToggleAction( const QString& text, const QIconSet& pix, +KToggleAction::KToggleAction( const QString& text, const QIcon& pix, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name ) @@ -168,9 +170,9 @@ KToggleAction::~KToggleAction() } int KToggleAction::plug( QWidget* widget, int index ) { - if ( !widget->inherits("QPopupMenu") && !widget->inherits("KToolBar") ) + if ( !widget->inherits("Q3PopupMenu") && !widget->inherits("KToolBar") ) { kdWarning() << "Can not plug KToggleAction in " << widget->className() << endl; return -1; } @@ -183,13 +185,13 @@ int KToggleAction::plug( QWidget* widget, int index ) int _index = KAction::plug( widget, index ); if ( _index == -1 ) return _index; - if ( widget->inherits("QPopupMenu") ) + if ( widget->inherits("Q3PopupMenu") ) { int id = itemId( _index ); - static_cast<QPopupMenu*>(widget)->setItemChecked( id, d->m_checked ); + static_cast<Q3PopupMenu*>(widget)->setItemChecked( id, d->m_checked ); } else if ( widget->inherits( "KToolBar" ) ) { KToolBar *bar = static_cast<KToolBar *>( widget ); @@ -213,15 +215,14 @@ void KToggleAction::setChecked( bool c ) for( int i = 0; i < len; ++i ) updateChecked( i ); if ( c && parent() && !exclusiveGroup().isEmpty() ) { - const QObjectList *list = parent()->children(); - if ( list ) { - QObjectListIt it( *list ); - for( ; it.current(); ++it ) { - if ( it.current()->inherits( "KToggleAction" ) && it.current() != this && - static_cast<KToggleAction*>(it.current())->exclusiveGroup() == exclusiveGroup() ) { - KToggleAction *a = static_cast<KToggleAction*>(it.current()); + const QObjectList list = parent()->children(); + if ( !list.empty() ) { + for(QObjectList::const_iterator it=list.begin();it!=list.end();++it) { + if ( (*it)->inherits( "KToggleAction" ) && (*it) != this && + static_cast<KToggleAction*>((*it))->exclusiveGroup() == exclusiveGroup() ) { + KToggleAction *a = static_cast<KToggleAction*>(*it); if( a->isChecked() ) { a->setChecked( false ); emit a->toggled( false ); } @@ -234,10 +235,10 @@ void KToggleAction::setChecked( bool c ) void KToggleAction::updateChecked( int id ) { QWidget *w = container( id ); - if ( w->inherits( "QPopupMenu" ) ) - static_cast<QPopupMenu*>(w)->setItemChecked( itemId( id ), d->m_checked ); + if ( w->inherits( "Q3PopupMenu" ) ) + static_cast<Q3PopupMenu*>(w)->setItemChecked( itemId( id ), d->m_checked ); else if ( w->inherits( "QMenuBar" ) ) static_cast<QMenuBar*>(w)->setItemChecked( itemId( id ), d->m_checked ); else if ( w->inherits( "KToolBar" ) ) { @@ -282,9 +283,9 @@ KRadioAction::KRadioAction( const QString& text, const KShortcut& cut, : KToggleAction( text, cut, receiver, slot, parent, name ) { } -KRadioAction::KRadioAction( const QString& text, const QIconSet& pix, +KRadioAction::KRadioAction( const QString& text, const QIcon& pix, const KShortcut& cut, QObject* parent, const char* name ) : KToggleAction( text, pix, cut, parent, name ) { @@ -296,9 +297,9 @@ KRadioAction::KRadioAction( const QString& text, const QString& pix, : KToggleAction( text, pix, cut, parent, name ) { } -KRadioAction::KRadioAction( const QString& text, const QIconSet& pix, +KRadioAction::KRadioAction( const QString& text, const QIcon& pix, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name ) : KToggleAction( text, pix, cut, receiver, slot, parent, name ) @@ -348,9 +349,9 @@ public: m_comboWidth = -1; } bool m_edit; bool m_menuAccelsEnabled; - QPopupMenu *m_menu; + Q3PopupMenu *m_menu; int m_current; int m_comboWidth; QStringList m_list; @@ -386,9 +387,9 @@ KSelectAction::KSelectAction( const QString& text, const KShortcut& cut, { d = new KSelectActionPrivate; } -KSelectAction::KSelectAction( const QString& text, const QIconSet& pix, +KSelectAction::KSelectAction( const QString& text, const QIcon& pix, const KShortcut& cut, QObject* parent, const char* name ) : KAction( text, pix, cut, parent, name ) { @@ -402,9 +403,9 @@ KSelectAction::KSelectAction( const QString& text, const QString& pix, { d = new KSelectActionPrivate; } -KSelectAction::KSelectAction( const QString& text, const QIconSet& pix, +KSelectAction::KSelectAction( const QString& text, const QIcon& pix, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name ) @@ -438,9 +439,9 @@ KSelectAction::~KSelectAction() void KSelectAction::setCurrentItem( int id ) { if ( id >= (int)d->m_list.count() ) { - ASSERT(id < (int)d->m_list.count()); + Q_ASSERT(id < (int)d->m_list.count()); return; } if ( d->m_menu ) @@ -478,15 +479,15 @@ void KSelectAction::setComboWidth( int width ) for( int i = 0; i < len; ++i ) updateComboWidth( i ); } -QPopupMenu* KSelectAction::popupMenu() const +Q3PopupMenu* KSelectAction::popupMenu() const { kdDebug(129) << "KSelectAction::popupMenu()" << endl; // remove -- ellis if ( !d->m_menu ) { //US d->m_menu = new KPopupMenu(0L, "KSelectAction::popupMenu()"); - d->m_menu = new QPopupMenu(0L, "QSelectAction::popupMenu()"); + d->m_menu = new Q3PopupMenu(0L, "QSelectAction::popupMenu()"); setupMenu(); if ( d->m_current >= 0 ) d->m_menu->setItemChecked( d->m_current, true ); } @@ -642,14 +643,14 @@ int KSelectAction::plug( QWidget *widget, int index ) //US if (kapp && !kapp->authorizeKAction(name())) //US return -1; kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis - if ( widget->inherits("QPopupMenu") ) + if ( widget->inherits("Q3PopupMenu") ) { // Create the PopupMenu and store it in m_menu (void)popupMenu(); - QPopupMenu* menu = static_cast<QPopupMenu*>( widget ); + Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( widget ); int id; if ( hasIconSet() ) id = menu->insertItem( iconSet(), text(), d->m_menu, -1, index ); @@ -681,9 +682,9 @@ int KSelectAction::plug( QWidget *widget, int index ) KComboBox *cb = bar->getCombo( id_ ); if ( cb ) { cb->setMaximumHeight( 34 ); - if (!isEditable()) cb->setFocusPolicy(QWidget::NoFocus); + if (!isEditable()) cb->setFocusPolicy(Qt::NoFocus); cb->setMinimumWidth( cb->sizeHint().width() ); if ( d->m_comboWidth > 0 ) { cb->setMinimumWidth( d->m_comboWidth ); @@ -851,9 +852,9 @@ KListAction::KListAction( const QString& text, const KShortcut& cut, if ( receiver ) connect( this, SIGNAL( activated( int ) ), receiver, slot ); } -KListAction::KListAction( const QString& text, const QIconSet& pix, +KListAction::KListAction( const QString& text, const QIcon& pix, const KShortcut& cut, QObject* parent, const char* name ) : KSelectAction( text, pix, cut, parent, name ) { @@ -867,9 +868,9 @@ KListAction::KListAction( const QString& text, const QString& pix, { d = new KListActionPrivate; } -KListAction::KListAction( const QString& text, const QIconSet& pix, +KListAction::KListAction( const QString& text, const QIcon& pix, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name ) : KSelectAction( text, pix, cut, parent, name ) @@ -964,9 +965,9 @@ KRecentFilesAction::KRecentFilesAction( const QString& text, receiver, slot ); } KRecentFilesAction::KRecentFilesAction( const QString& text, - const QIconSet& pix, + const QIcon& pix, const KShortcut& cut, QObject* parent, const char* name, uint maxItems ) : KListAction( text, pix, cut, parent, name) @@ -990,9 +991,9 @@ KRecentFilesAction::KRecentFilesAction( const QString& text, init(); } KRecentFilesAction::KRecentFilesAction( const QString& text, - const QIconSet& pix, + const QIcon& pix, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name, @@ -1200,9 +1201,9 @@ KFontAction::KFontAction( const QString& text, const KShortcut& cut, KSelectAction::setItems( d->m_fonts ); setEditable( true ); } -KFontAction::KFontAction( const QString& text, const QIconSet& pix, +KFontAction::KFontAction( const QString& text, const QIcon& pix, const KShortcut& cut, QObject* parent, const char* name ) : KSelectAction( text, pix, cut, parent, name ) { @@ -1222,9 +1223,9 @@ KFontAction::KFontAction( const QString& text, const QString& pix, KSelectAction::setItems( d->m_fonts ); setEditable( true ); } -KFontAction::KFontAction( const QString& text, const QIconSet& pix, +KFontAction::KFontAction( const QString& text, const QIcon& pix, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name ) : KSelectAction( text, pix, cut, receiver, slot, parent, name ) @@ -1360,9 +1361,9 @@ KFontSizeAction::KFontSizeAction( const QString& text, { init(); } -KFontSizeAction::KFontSizeAction( const QString& text, const QIconSet& pix, +KFontSizeAction::KFontSizeAction( const QString& text, const QIcon& pix, const KShortcut& cut, QObject* parent, const char* name ) : KSelectAction( text, pix, cut, parent, name ) { @@ -1376,9 +1377,9 @@ KFontSizeAction::KFontSizeAction( const QString& text, const QString& pix, { init(); } -KFontSizeAction::KFontSizeAction( const QString& text, const QIconSet& pix, +KFontSizeAction::KFontSizeAction( const QString& text, const QIcon& pix, const KShortcut& cut, const QObject* receiver, const char* slot, QObject* parent, const char* name ) @@ -1413,11 +1414,11 @@ void KFontSizeAction::init() { d = new KFontSizeActionPrivate; setEditable( true ); - QValueList<int> sizes = get_standard_font_sizes(); + Q3ValueList<int> sizes = get_standard_font_sizes(); QStringList lst; - for ( QValueList<int>::Iterator it = sizes.begin(); it != sizes.end(); ++it ) + for ( Q3ValueList<int>::Iterator it = sizes.begin(); it != sizes.end(); ++it ) lst.append( QString::number( *it ) ); setItems( lst ); } @@ -1436,9 +1437,9 @@ void KFontSizeAction::setFontSize( int size ) int index = items().findIndex( QString::number( size ) ); if ( index == -1 ) { // Insert at the correct position in the list (to keep sorting) - QValueList<int> lst; + Q3ValueList<int> lst; // Convert to list of ints QStringList itemsList = items(); for (QStringList::Iterator it = itemsList.begin() ; it != itemsList.end() ; ++it) lst.append( (*it).toInt() ); @@ -1449,9 +1450,9 @@ qDebug("KFontSizeAction::setFontSize heapsort not found."); //US has to be fixed //US qHeapSort( lst ); // Convert back to string list QStringList strLst; - for (QValueList<int>::Iterator it = lst.begin() ; it != lst.end() ; ++it) + for (Q3ValueList<int>::Iterator it = lst.begin() ; it != lst.end() ; ++it) strLst.append( QString::number(*it) ); KSelectAction::setItems( strLst ); // Find new current item index = lst.findIndex( size ); @@ -1491,9 +1492,9 @@ class KActionMenu::KActionMenuPrivate public: KActionMenuPrivate() { //US m_popup = new KPopupMenu(0L,"KActionMenu::KActionMenuPrivate"); - m_popup = new QPopupMenu(0L,"KActionMenu::KActionMenuPrivate"); + m_popup = new Q3PopupMenu(0L,"KActionMenu::KActionMenuPrivate"); m_delayed = true; m_stickyMenu = true; } ~KActionMenuPrivate() @@ -1501,9 +1502,9 @@ public: delete m_popup; m_popup = 0; } //US KPopupMenu *m_popup; - QPopupMenu *m_popup; + Q3PopupMenu *m_popup; bool m_delayed; bool m_stickyMenu; }; @@ -1521,9 +1522,9 @@ KActionMenu::KActionMenu( const QString& text, QObject* parent, d = new KActionMenuPrivate; setShortcutConfigurable( false ); } -KActionMenu::KActionMenu( const QString& text, const QIconSet& icon, +KActionMenu::KActionMenu( const QString& text, const QIcon& icon, QObject* parent, const char* name ) : KAction( text, icon, 0, parent, name ) { d = new KActionMenuPrivate; @@ -1551,9 +1552,9 @@ void KActionMenu::popup( const QPoint& global ) } //US KPopupMenu* KActionMenu::popupMenu() const -QPopupMenu* KActionMenu::popupMenu() const +Q3PopupMenu* KActionMenu::popupMenu() const { return d->m_popup; } @@ -1591,11 +1592,11 @@ int KActionMenu::plug( QWidget* widget, int index ) if (kapp && !kapp->authorizeKAction(name())) return -1; */ kdDebug(129) << "KAction::plug( " << widget << ", " << index << " )" << endl; // remove -- ellis - if ( widget->inherits("QPopupMenu") ) + if ( widget->inherits("Q3PopupMenu") ) { - QPopupMenu* menu = static_cast<QPopupMenu*>( widget ); + Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( widget ); int id; if ( hasIconSet() ) id = menu->insertItem( iconSet(), text(), d->m_popup, -1, index ); else @@ -1780,14 +1781,14 @@ int KToolBarPopupAction::plug( QWidget *widget, int index ) return KAction::plug( widget, index ); } //US KPopupMenu *KToolBarPopupAction::popupMenu() const -QPopupMenu *KToolBarPopupAction::popupMenu() const +Q3PopupMenu *KToolBarPopupAction::popupMenu() const { if ( !m_popup ) { KToolBarPopupAction *that = const_cast<KToolBarPopupAction*>(this); //US that->m_popup = new KPopupMenu; - that->m_popup = new QPopupMenu; + that->m_popup = new Q3PopupMenu; } return m_popup; } @@ -1952,9 +1953,9 @@ void KWidgetAction::unplug( QWidget *w ) void KWidgetAction::slotToolbarDestroyed() { //Q_ASSERT( m_widget ); // When exiting the app the widget could be destroyed before the toolbar. - ASSERT( isPlugged() ); + Q_ASSERT( isPlugged() ); if( !m_widget || !isPlugged() ) return; // Don't let a toolbar being destroyed, delete my widget. @@ -1973,11 +1974,11 @@ KActionSeparator::~KActionSeparator() } int KActionSeparator::plug( QWidget *widget, int index ) { - if ( widget->inherits("QPopupMenu") ) + if ( widget->inherits("Q3PopupMenu") ) { - QPopupMenu* menu = static_cast<QPopupMenu*>( widget ); + Q3PopupMenu* menu = static_cast<Q3PopupMenu*>( widget ); int id = menu->insertSeparator( index ); addContainer( menu, id ); |