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/ktoolbar.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.zip kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.gz kdepimpi-a08aff328d4393031d5ba7d622c2b05705a89d73.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | microkde/kdeui/ktoolbar.cpp | 185 |
1 files changed, 98 insertions, 87 deletions
diff --git a/microkde/kdeui/ktoolbar.cpp b/microkde/kdeui/ktoolbar.cpp index 027e5e9..02db316 100644 --- a/microkde/kdeui/ktoolbar.cpp +++ b/microkde/kdeui/ktoolbar.cpp @@ -25,9 +25,20 @@ #ifdef KDE_USE_FINAL #undef Always -#include <qdockwindow.h> +#include <q3dockwindow.h> #endif - +//Added by qt3to4: +#include <Q3ValueList> +#include <Q3PtrList> +#include <QPixmap> +#include <Q3Frame> +#include <QResizeEvent> +#include <QMouseEvent> +#include <QChildEvent> +#include <QEvent> +#include <QShowEvent> +#include <QDesktopWidget> +#include <QBoxLayout> #include "ktoolbar.h" @@ -40,7 +51,7 @@ #include <qdrawutil.h> #include <qstring.h> #include <qrect.h> -#include <qobjectlist.h> +#include <qobject.h> #include <qtimer.h> #include <qstyle.h> #include <qapplication.h> @@ -69,8 +80,8 @@ //US #include "kconfigbase.h" -#include <qpopupmenu.h> -#include <qmainwindow.h> +#include <q3popupmenu.h> +#include <q3mainwindow.h> enum { CONTEXT_TOP = 0, @@ -102,7 +113,7 @@ public: m_configurePlugged = false; //US oldPos = Qt::DockUnmanaged; - oldPos = QMainWindow::Unmanaged; + oldPos = Qt::Unmanaged; modified = m_isHorizontal = positioned = FALSE; @@ -129,24 +140,24 @@ public: QWidget *m_parent; - QMainWindow::ToolBarDock oldPos; + Qt::ToolBarDock oldPos; KXMLGUIClient *m_xmlguiClient; struct ToolBarInfo { //US ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} - ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( QMainWindow::Top ) {} + ToolBarInfo() : index( 0 ), offset( -1 ), newline( FALSE ), dock( Qt::DockTop ) {} //US ToolBarInfo( Qt::Dock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} - ToolBarInfo( QMainWindow::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} + ToolBarInfo( Qt::ToolBarDock d, int i, bool n, int o ) : index( i ), offset( o ), newline( n ), dock( d ) {} int index, offset; bool newline; //US Qt::Dock dock; - QMainWindow::ToolBarDock dock; + Qt::ToolBarDock dock; }; ToolBarInfo toolBarInfo; - QValueList<int> iconSizes; + Q3ValueList<int> iconSizes; QTimer repaintTimer; // Default Values. @@ -158,25 +169,25 @@ public: int OffsetDefault; QString PositionDefault; - QPtrList<QWidget> idleButtons; + Q3PtrList<QWidget> idleButtons; }; -KToolBarSeparator::KToolBarSeparator(Orientation o , bool l, QToolBar *parent, +KToolBarSeparator::KToolBarSeparator(Qt::Orientation o , bool l, Q3ToolBar *parent, const char* name ) - :QFrame( parent, name ), line( l ) + :Q3Frame( parent, name ), line( l ) { - connect( parent, SIGNAL(orientationChanged(Orientation)), - this, SLOT(setOrientation(Orientation)) ); + connect( parent, SIGNAL(orientationChanged(Qt::Orientation)), + this, SLOT(setOrientation(Qt::Orientation)) ); setOrientation( o ); setBackgroundMode( parent->backgroundMode() ); setBackgroundOrigin( ParentOrigin ); } -void KToolBarSeparator::setOrientation( Orientation o ) +void KToolBarSeparator::setOrientation( Qt::Orientation o ) { orient = o; if ( line ) { - if ( orientation() == Vertical ) + if ( orientation() == Qt::Vertical ) setFrameStyle( HLine + Sunken ); else setFrameStyle( VLine + Sunken ); @@ -192,7 +203,7 @@ void KToolBarSeparator::styleChange( QStyle& ) QSize KToolBarSeparator::sizeHint() const { - return orientation() == Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); + return orientation() == Qt::Vertical ? QSize( 0, 6 ) : QSize( 6, 0 ); } QSizePolicy KToolBarSeparator::sizePolicy() const @@ -202,12 +213,12 @@ QSizePolicy KToolBarSeparator::sizePolicy() const KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool readConfig ) #ifdef DESKTOP_VERSION - : QToolBar( QString::fromLatin1( name ), - parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, + : Q3ToolBar( QString::fromLatin1( name ), + parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0, parent, FALSE, name ? name : "mainToolBar") #else - : QPEToolBar( parent && parent->inherits( "QMainWindow" ) ? static_cast<QMainWindow*>(parent) : 0, + : QPEToolBar( parent && parent->inherits( "Q3MainWindow" ) ? static_cast<Q3MainWindow*>(parent) : 0, QString::fromLatin1( name )) @@ -216,9 +227,9 @@ KToolBar::KToolBar( QWidget *parent, const char *name, bool honorStyle, bool rea init( readConfig, honorStyle ); } -KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) +KToolBar::KToolBar( Q3MainWindow *parentWindow, Qt::ToolBarDock dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) #ifdef DESKTOP_VERSION - : QToolBar( QString::fromLatin1( name ), + : Q3ToolBar( QString::fromLatin1( name ), parentWindow, dock, newLine, name ? name : "mainToolBar") #else @@ -231,9 +242,9 @@ KToolBar::KToolBar( QMainWindow *parentWindow, QMainWindow::ToolBarDock dock, bo init( readConfig, honorStyle ); } -KToolBar::KToolBar( QMainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) +KToolBar::KToolBar( Q3MainWindow *parentWindow, QWidget *dock, bool newLine, const char *name, bool honorStyle, bool readConfig ) #ifdef DESKTOP_VERSION - : QToolBar( QString::fromLatin1( name ), + : Q3ToolBar( QString::fromLatin1( name ), parentWindow, dock, newLine, name ? name : "mainToolBar") #else @@ -280,8 +291,8 @@ void KToolBar::init( bool readConfig, bool honorStyle ) slotReadConfig(); if ( mainWindow() ) - connect( mainWindow(), SIGNAL( toolBarPositionChanged( QToolBar * ) ), - this, SLOT( toolBarPosChanged( QToolBar * ) ) ); + connect( mainWindow(), SIGNAL( toolBarPositionChanged( Q3ToolBar * ) ), + this, SLOT( toolBarPosChanged( Q3ToolBar * ) ) ); // Hack to make sure we recalculate our size when we dock. //US connect( this, SIGNAL(placeChanged(QDockWindow::Place)), SLOT(rebuildLayout()) ); @@ -341,7 +352,7 @@ int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal, } -int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, +int KToolBar::insertButton(const QString& icon, int id, Q3PopupMenu *popup, bool enabled, const QString &text, int index ) { KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text ); @@ -353,7 +364,7 @@ int KToolBar::insertButton(const QString& icon, int id, QPopupMenu *popup, } -int KToolBar::insertButton(const QPixmap& pixmap, int id, QPopupMenu *popup, +int KToolBar::insertButton(const QPixmap& pixmap, int id, Q3PopupMenu *popup, bool enabled, const QString &text, int index ) { KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text ); @@ -540,7 +551,7 @@ void KToolBar::setButtonIcon( int id, const QString& _icon ) button->setIcon( _icon ); } -void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) +void KToolBar::setButtonIconSet( int id, const QIcon& iconset ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) @@ -552,7 +563,7 @@ void KToolBar::setButtonIconSet( int id, const QIconSet& iconset ) } -void KToolBar::setDelayedPopup (int id , QPopupMenu *_popup, bool toggle ) +void KToolBar::setDelayedPopup (int id , Q3PopupMenu *_popup, bool toggle ) { Id2WidgetMap::Iterator it = id2widget.find( id ); if ( it == id2widget.end() ) @@ -787,7 +798,7 @@ void KToolBar::setItemAutoSized (int id, bool yes ) void KToolBar::clear () { - QToolBar::clear(); + Q3ToolBar::clear(); widget2id.clear(); id2widget.clear(); } @@ -876,21 +887,21 @@ void KToolBar::setBarPos (BarPosition bpos) if ( !mainWindow() ) return; //US mainWindow()->moveDockWindow( this, (Dock)bpos ); - mainWindow()->moveToolBar( this, (QMainWindow::ToolBarDock)bpos ); + mainWindow()->moveToolBar( this, (Qt::ToolBarDock)bpos ); } const KToolBar::BarPosition KToolBar::barPos() { - if ( !(QMainWindow*)mainWindow() ) + if ( !(Q3MainWindow*)mainWindow() ) return KToolBar::Top; //US Dock dock; - QMainWindow::ToolBarDock dock; + Qt::ToolBarDock dock; int dm1, dm2; bool dm3; - ((QMainWindow*)mainWindow())->getLocation( (QToolBar*)this, dock, dm1, dm3, dm2 ); + ((Q3MainWindow*)mainWindow())->getLocation( (Q3ToolBar*)this, dock, dm1, dm3, dm2 ); //US if ( dock == DockUnmanaged ) { - if ( dock == QMainWindow::Unmanaged ) { + if ( dock == Qt::Unmanaged ) { return (KToolBar::BarPosition)Top; } return (BarPosition)dock; @@ -967,7 +978,7 @@ void KToolBar::setIconText(IconText icontext, bool update) // ugly hack to force a QMainWindow::triggerLayout( TRUE ) if ( mainWindow() ) { - QMainWindow *mw = mainWindow(); + Q3MainWindow *mw = mainWindow(); mw->setUpdatesEnabled( FALSE ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); @@ -1004,7 +1015,7 @@ void KToolBar::setIconSize(int size, bool update) // ugly hack to force a QMainWindow::triggerLayout( TRUE ) if ( mainWindow() ) { - QMainWindow *mw = mainWindow(); + Q3MainWindow *mw = mainWindow(); mw->setUpdatesEnabled( FALSE ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); mw->setToolBarsMovable( !mw->toolBarsMovable() ); @@ -1062,10 +1073,10 @@ void KToolBar::setFlat (bool flag) return; if ( flag ) //US mainWindow()->moveDockWindow( this, DockMinimized ); - mainWindow()->moveToolBar( this, QMainWindow::Minimized ); + mainWindow()->moveToolBar( this, Qt::Minimized ); else //US mainWindow()->moveDockWindow( this, DockTop ); - mainWindow()->moveToolBar( this, QMainWindow::Top ); + mainWindow()->moveToolBar( this, Qt::Top ); // And remember to save the new look later /*US if ( mainWindow()->inherits( "KMainWindow" ) ) @@ -1249,34 +1260,34 @@ void KToolBar::mousePressEvent ( QMouseEvent *m ) { if ( !mainWindow() ) return; - QMainWindow *mw = mainWindow(); + Q3MainWindow *mw = mainWindow(); if ( mw->toolBarsMovable() && d->m_enableContext ) { - if ( m->button() == RightButton ) { + if ( m->button() == Qt::RightButton ) { int i = contextMenu()->exec( m->globalPos(), 0 ); switch ( i ) { case -1: return; // popup cancelled case CONTEXT_LEFT: //US mw->moveDockWindow( this, DockLeft ); - mw->moveToolBar( this, QMainWindow::Left ); + mw->moveToolBar( this, Qt::Left ); break; case CONTEXT_RIGHT: //US mw->moveDockWindow( this, DockRight ); - mw->moveToolBar( this, QMainWindow::Right ); + mw->moveToolBar( this, Qt::Right ); break; case CONTEXT_TOP: //US mw->moveDockWindow( this, DockTop ); - mw->moveToolBar( this, QMainWindow::Top ); + mw->moveToolBar( this, Qt::Top ); break; case CONTEXT_BOTTOM: //US mw->moveDockWindow( this, DockBottom ); - mw->moveToolBar( this, QMainWindow::Bottom ); + mw->moveToolBar( this, Qt::Bottom ); break; case CONTEXT_FLOAT: break; case CONTEXT_FLAT: //US mw->moveDockWindow( this, DockMinimized ); - mw->moveToolBar( this, QMainWindow::Minimized ); + mw->moveToolBar( this, Qt::Minimized ); break; case CONTEXT_ICONS: setIconText( IconOnly ); @@ -1332,7 +1343,7 @@ void KToolBar::rebuildLayout() w->hide(); continue; } - if ( w->inherits( "QPopupMenu" ) ) + if ( w->inherits( "Q3PopupMenu" ) ) continue; l->addWidget( w ); w->show(); @@ -1364,7 +1375,7 @@ void KToolBar::childEvent( QChildEvent *e ) if ( e->child()->isWidgetType() ) { QWidget * w = (QWidget*)e->child(); if ( e->type() == QEvent::ChildInserted ) { - if ( !e->child()->inherits( "QPopupMenu" ) && + if ( !e->child()->inherits( "Q3PopupMenu" ) && ::qstrcmp( "qt_dockwidget_internal", e->child()->name() ) != 0 ) { // prevent items that have been explicitly inserted by insert*() from @@ -1375,10 +1386,10 @@ void KToolBar::childEvent( QChildEvent *e ) insertWidgetInternal( w, dummy, -1 ); } } - } else { + } else if( e->type() == QEvent::ChildRemoved ) { removeWidgetInternal( w ); } - if ( isVisibleTo( 0 ) ) + /* TODO:hacker: if ( isVisibleTo( 0 ) ) { QBoxLayout *l = boxLayout(); // QLayout *l = layout(); @@ -1390,9 +1401,9 @@ void KToolBar::childEvent( QChildEvent *e ) it.deleteCurrent(); } layoutTimer->start( 50, TRUE ); - } + } */ } - QToolBar::childEvent( e ); + Q3ToolBar::childEvent( e ); } void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) @@ -1416,25 +1427,25 @@ void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id ) void KToolBar::repaintMe() { setUpdatesEnabled( true ); - QToolBar::repaint( true ); + Q3ToolBar::repaint( true ); qDebug(" KToolBar::repaintMe() "); } void KToolBar::showEvent( QShowEvent *e ) { rebuildLayout(); - QToolBar::showEvent( e ); + Q3ToolBar::showEvent( e ); } void KToolBar::setStretchableWidget( QWidget *w ) { - QToolBar::setStretchableWidget( w ); + Q3ToolBar::setStretchableWidget( w ); stretchableWidget = w; } QSizePolicy KToolBar::sizePolicy() const { - if ( orientation() == Horizontal ) + if ( orientation() == Qt::Horizontal ) return QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ); else return QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding ); @@ -1442,7 +1453,7 @@ QSizePolicy KToolBar::sizePolicy() const QSize KToolBar::sizeHint() const { - QSize sh = QToolBar::sizeHint(); + QSize sh = Q3ToolBar::sizeHint(); //qDebug("%x KToolBar::sizeHint() %d %d ",this, QToolBar::sizeHint().width(),QToolBar::sizeHint().height() ); if ( sh.height() <= 20 || sh.width() < 60 ) return QSize( sizeHintW, sizeHintH ); @@ -1508,7 +1519,7 @@ QSize KToolBar::sizeHint() const break; default: - minSize = QToolBar::sizeHint(); + minSize = Q3ToolBar::sizeHint(); break; } return minSize; @@ -1532,19 +1543,19 @@ bool KToolBar::highlight() const void KToolBar::hide() { - QToolBar::hide(); + Q3ToolBar::hide(); } void KToolBar::show() { - QToolBar::show(); + Q3ToolBar::show(); } void KToolBar::resizeEvent( QResizeEvent *e ) { bool b = isUpdatesEnabled(); setUpdatesEnabled( FALSE ); - QToolBar::resizeEvent( e ); + Q3ToolBar::resizeEvent( e ); if (b) d->repaintTimer.start( 100, true ); } @@ -1726,7 +1737,7 @@ void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGr doUpdate = true; } - QMainWindow *mw = mainWindow(); + Q3MainWindow *mw = mainWindow(); // ...and if we should highlight if ( highlight != d->m_highlight ) { @@ -1805,19 +1816,19 @@ void KToolBar::applySettings(KConfig *config, const QString &_configGroup) else if ( position == "Flat" ) pos = DockMinimized; */ - QMainWindow::ToolBarDock pos(QMainWindow::Top); + Qt::ToolBarDock pos(Qt::DockTop); if ( position == "Top" ) - pos = QMainWindow::Top; + pos = Qt::Top; else if ( position == "Bottom" ) - pos = QMainWindow::Bottom; + pos = Qt::Bottom; else if ( position == "Left" ) - pos = QMainWindow::Left; + pos = Qt::Left; else if ( position == "Right" ) - pos = QMainWindow::Right; + pos = Qt::Right; else if ( position == "Floating" ) - pos = QMainWindow::TornOff; + pos = Qt::TornOff; else if ( position == "Flat" ) - pos = QMainWindow::Minimized; + pos = Qt::Minimized; //kdDebug(220) << "KToolBar::applySettings hidden=" << hidden << endl; if (hidden) @@ -1827,7 +1838,7 @@ void KToolBar::applySettings(KConfig *config, const QString &_configGroup) if ( mainWindow() ) { - QMainWindow *mw = mainWindow(); + Q3MainWindow *mw = mainWindow(); //kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl; d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset ); @@ -1862,7 +1873,7 @@ bool KToolBar::event( QEvent *e ) return true; } - return QToolBar::event( e ); + return Q3ToolBar::event( e ); } void KToolBar::slotRepaint() @@ -1880,14 +1891,14 @@ void KToolBar::slotRepaint() repaint( TRUE ); } -void KToolBar::toolBarPosChanged( QToolBar *tb ) +void KToolBar::toolBarPosChanged( Q3ToolBar *tb ) { if ( tb != this ) return; //US if ( d->oldPos == DockMinimized ) - if ( d->oldPos == QMainWindow::Minimized ) + if ( d->oldPos == Qt::Minimized ) rebuildLayout(); - d->oldPos = (QMainWindow::ToolBarDock)barPos(); + d->oldPos = (Qt::ToolBarDock)barPos(); /*US if ( mainWindow() && mainWindow()->inherits( "KMainWindow" ) ) static_cast<KMainWindow *>(mainWindow())->setSettingsDirty(); @@ -2031,7 +2042,7 @@ void KToolBar::getAttributes( QString &position, QString &icontext, int &index ) } if ( mainWindow() ) { - QMainWindow::ToolBarDock dock; + Qt::ToolBarDock dock; bool newLine; int offset; mainWindow()->getLocation( this, dock, index, newLine, offset ); @@ -2100,7 +2111,7 @@ void KToolBar::positionYourself( bool force ) } //US KPopupMenu *KToolBar::contextMenu() -QPopupMenu *KToolBar::contextMenu() +Q3PopupMenu *KToolBar::contextMenu() { if ( context ) return context; @@ -2108,11 +2119,11 @@ QPopupMenu *KToolBar::contextMenu() // Construct our context popup menu. Name it qt_dockwidget_internal so it // won't be deleted by QToolBar::clear(). //US context = new KPopupMenu( this, "qt_dockwidget_internal" ); - context = new QPopupMenu( this, "qt_dockwidget_internal" ); + context = new Q3PopupMenu( this, "qt_dockwidget_internal" ); //US context->insertTitle(i18n("Toolbar Menu")); //US KPopupMenu *orient = new KPopupMenu( context, "orient" ); - QPopupMenu *orient = new QPopupMenu( context, "orient" ); + Q3PopupMenu *orient = new Q3PopupMenu( context, "orient" ); orient->insertItem( i18n("toolbar position string","Top"), CONTEXT_TOP ); orient->insertItem( i18n("toolbar position string","Left"), CONTEXT_LEFT ); orient->insertItem( i18n("toolbar position string","Right"), CONTEXT_RIGHT ); @@ -2122,17 +2133,17 @@ QPopupMenu *KToolBar::contextMenu() orient->insertItem( i18n("min toolbar", "Flat"), CONTEXT_FLAT ); //US KPopupMenu *mode = new KPopupMenu( context, "mode" ); - QPopupMenu *mode = new QPopupMenu( context, "mode" ); + Q3PopupMenu *mode = new Q3PopupMenu( context, "mode" ); mode->insertItem( i18n("Icons Only"), CONTEXT_ICONS ); mode->insertItem( i18n("Text Only"), CONTEXT_TEXT ); mode->insertItem( i18n("Text Alongside Icons"), CONTEXT_TEXTRIGHT ); mode->insertItem( i18n("Text Under Icons"), CONTEXT_TEXTUNDER ); //US KPopupMenu *size = new KPopupMenu( context, "size" ); - QPopupMenu *size = new QPopupMenu( context, "size" ); + Q3PopupMenu *size = new Q3PopupMenu( context, "size" ); size->insertItem( i18n("Default"), CONTEXT_ICONSIZES ); // Query the current theme for available sizes - QValueList<int> avSizes; + Q3ValueList<int> avSizes; /*US KIconTheme *theme = KGlobal::instance()->iconLoader()->theme(); if (!::qstrcmp(QObject::name(), "mainToolBar")) @@ -2145,7 +2156,7 @@ QPopupMenu *KToolBar::contextMenu() d->iconSizes = avSizes; - QValueList<int>::Iterator it; + Q3ValueList<int>::Iterator it; for (it=avSizes.begin(); it!=avSizes.end(); it++) { QString text; if ( *it < 19 ) @@ -2218,8 +2229,8 @@ void KToolBar::slotContextAboutToShow() break; } - QValueList<int>::ConstIterator iIt = d->iconSizes.begin(); - QValueList<int>::ConstIterator iEnd = d->iconSizes.end(); + Q3ValueList<int>::ConstIterator iIt = d->iconSizes.begin(); + Q3ValueList<int>::ConstIterator iEnd = d->iconSizes.end(); for (; iIt != iEnd; ++iIt ) context->setItemChecked( CONTEXT_ICONSIZES + *iIt, false ); |