summaryrefslogtreecommitdiffabout
path: root/microkde/kdeui/ktoolbar.cpp
Side-by-side diff
Diffstat (limited to 'microkde/kdeui/ktoolbar.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kdeui/ktoolbar.cpp185
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
@@ -12,241 +12,252 @@
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.
*/
#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"
#include "kmainwindow.h"
#include <string.h>
#include <qpainter.h>
#include <qtooltip.h>
#include <qdrawutil.h>
#include <qstring.h>
#include <qrect.h>
-#include <qobjectlist.h>
+#include <qobject.h>
#include <qtimer.h>
#include <qstyle.h>
#include <qapplication.h>
//US #include <config.h>
#include "klineedit.h"
#include "kseparator.h"
#include <klocale.h>
#include <kapplication.h>
#include <kaction.h>
#include <kstdaction.h>
#include <kglobal.h>
#include <kconfig.h>
#include <kiconloader.h>
#include <kcombobox.h>
//US #include <kpopupmenu.h>
//US #include <kanimwidget.h>
//US #include <kipc.h>
//US #include <kwin.h>
#include <kdebug.h>
#include <qlayout.h>
#include "ktoolbarbutton.h"
//US
#include "kconfigbase.h"
-#include <qpopupmenu.h>
-#include <qmainwindow.h>
+#include <q3popupmenu.h>
+#include <q3mainwindow.h>
enum {
CONTEXT_TOP = 0,
CONTEXT_LEFT = 1,
CONTEXT_RIGHT = 2,
CONTEXT_BOTTOM = 3,
CONTEXT_FLOAT = 4,
CONTEXT_FLAT = 5,
CONTEXT_ICONS = 6,
CONTEXT_TEXT = 7,
CONTEXT_TEXTRIGHT = 8,
CONTEXT_TEXTUNDER = 9,
CONTEXT_ICONSIZES = 50 // starting point for the icon size list, put everything else before
};
class KToolBarPrivate
{
public:
KToolBarPrivate() {
m_iconSize = 0;
m_iconText = KToolBar::IconOnly;
m_highlight = true;
m_transparent = true;
m_honorStyle = false;
m_enableContext = true;
m_xmlguiClient = 0;
m_configurePlugged = false;
//US oldPos = Qt::DockUnmanaged;
- oldPos = QMainWindow::Unmanaged;
+ oldPos = Qt::Unmanaged;
modified = m_isHorizontal = positioned = FALSE;
HiddenDefault = false;
IconSizeDefault = 0;
IconTextDefault = "IconOnly";
IndexDefault = -1;
NewLineDefault = false;
OffsetDefault = -1;
PositionDefault = "Top";
idleButtons.setAutoDelete(true);
}
int m_iconSize;
KToolBar::IconText m_iconText;
bool m_highlight : 1;
bool m_transparent : 1;
bool m_honorStyle : 1;
bool m_isHorizontal : 1;
bool m_enableContext : 1;
bool m_configurePlugged : 1;
bool modified : 1;
bool positioned : 1;
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.
bool HiddenDefault;
int IconSizeDefault;
QString IconTextDefault;
int IndexDefault;
bool NewLineDefault;
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 );
} else {
setFrameStyle( NoFrame );
}
}
void KToolBarSeparator::styleChange( QStyle& )
{
setOrientation( orient );
}
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
{
return QSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
}
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 ))
#endif
{
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
: QPEToolBar( parentWindow,QString::fromLatin1( name ))
#endif
{
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
: QPEToolBar( parentWindow,QString::fromLatin1( name ))
#endif
{
init( readConfig, honorStyle );
}
KToolBar::~KToolBar()
{
inshutdownprocess = true;
emit toolbarDestroyed();
@@ -267,34 +278,34 @@ void KToolBar::init( bool readConfig, bool honorStyle )
this, SLOT( rebuildLayout() ) );
connect( &(d->repaintTimer), SIGNAL( timeout() ),
this, SLOT( slotRepaint() ) );
/*US
if ( kapp ) { // may be null when started inside designer
connect(kapp, SIGNAL(toolbarAppearanceChanged(int)), this, SLOT(slotAppearanceChanged()));
// request notification of changes in icon style
kapp->addKipcEventMask(KIPC::IconChanged);
connect(kapp, SIGNAL(iconChanged(int)), this, SLOT(slotIconChanged(int)));
}
*/
// finally, read in our configurable settings
if ( readConfig )
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()) );
}
int KToolBar::insertButton(const QString& icon, int id, bool enabled,
const QString& text, int index/*US, KInstance *_instance*/ )
{
KToolBarButton *button = new KToolBarButton( icon, id, this, 0, text/*US, _instance*/ );
insertWidgetInternal( button, index, id );
button->setEnabled( enabled );
doConnections( button );
return index;
}
@@ -328,45 +339,45 @@ int KToolBar::insertButton(const QPixmap& pixmap, int id, bool enabled,
#endif
int KToolBar::insertButton(const QPixmap& pixmap, int id, const char *signal,
const QObject *receiver, const char *slot,
bool enabled, const QString& text,
int index )
{
KToolBarButton *button = new KToolBarButton( pixmap, id, this, 0, text);
insertWidgetInternal( button, index, id );
button->setEnabled( enabled );
connect( button, signal, receiver, slot );
doConnections( button );
return index;
}
-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 );
insertWidgetInternal( button, index, id );
button->setEnabled( enabled );
button->setPopup( popup );
doConnections( button );
return index;
}
-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 );
insertWidgetInternal( button, index, id );
button->setEnabled( enabled );
button->setPopup( popup );
doConnections( button );
return index;
}
int KToolBar::insertLined (const QString& text, int id,
const char *signal,
const QObject *receiver, const char *slot,
bool enabled ,
const QString& toolTipText,
@@ -527,45 +538,45 @@ void KToolBar::setButtonPixmap( int id, const QPixmap& _pixmap )
if ( button )
button->setPixmap( _pixmap );
}
void KToolBar::setButtonIcon( int id, const QString& _icon )
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
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() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->setIconSet( 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() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if ( button )
button->setDelayedPopup( _popup, toggle );
}
void KToolBar::setAutoRepeat (int id, bool flag)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
@@ -774,33 +785,33 @@ QWidget *KToolBar::getWidget (int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
return ( it == id2widget.end() ) ? 0 : (*it);
}
void KToolBar::setItemAutoSized (int id, bool yes )
{
QWidget *w = getWidget(id);
if ( w && yes )
setStretchableWidget( w );
}
void KToolBar::clear ()
{
- QToolBar::clear();
+ Q3ToolBar::clear();
widget2id.clear();
id2widget.clear();
}
void KToolBar::removeItem(int id)
{
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
{
kdDebug(220) << "KToolBar::removeItem item " << id << " not found" << endl;
return;
}
QWidget * w = (*it);
id2widget.remove( id );
widget2id.remove( w );
@@ -863,47 +874,47 @@ bool KToolBar::fullSize() const
return isHorizontalStretchable() || isVerticalStretchable();
}
void KToolBar::enableMoving(bool flag )
{
//US setMovingEnabled(flag);
this->mainWindow()->setToolBarsMovable(flag);
}
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;
}
bool KToolBar::enable(BarStatus stat)
{
bool mystat = isVisible();
if ( (stat == Toggle && mystat) || stat == Hide )
hide();
else
show();
return isVisible() == mystat;
@@ -954,33 +965,33 @@ void KToolBar::setIconText(IconText icontext, bool update)
{
bool doUpdate=false;
if (icontext != d->m_iconText) {
d->m_iconText = icontext;
doUpdate=true;
}
if (update == false)
return;
if (doUpdate)
emit modechange(); // tell buttons what happened
// 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() );
mw->setUpdatesEnabled( TRUE );
}
}
KToolBar::IconText KToolBar::iconText() const
{
return d->m_iconText;
}
void KToolBar::setIconSize(int size)
{
@@ -991,33 +1002,33 @@ void KToolBar::setIconSize(int size, bool update)
{
bool doUpdate=false;
if ( size != d->m_iconSize ) {
d->m_iconSize = size;
doUpdate=true;
}
if (update == false)
return;
if (doUpdate)
emit modechange(); // tell buttons what happened
// 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() );
mw->setUpdatesEnabled( TRUE );
}
}
int KToolBar::iconSize() const
{
/*US
if ( !d->m_iconSize ) // default value?
{
if (!::qstrcmp(QObject::name(), "mainToolBar"))
return KGlobal::iconLoader()->currentSize(KIcon::MainToolbar);
else
@@ -1049,36 +1060,36 @@ void KToolBar::setItemNoStyle(int id, bool no_style )
Id2WidgetMap::Iterator it = id2widget.find( id );
if ( it == id2widget.end() )
return;
//US KToolBarButton * button = dynamic_cast<KToolBarButton *>( *it );
KToolBarButton * button = (KToolBarButton *)( *it );
if (button)
button->setNoStyle( no_style );
}
void KToolBar::setFlat (bool flag)
{
if ( !mainWindow() )
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" ) )
static_cast<KMainWindow *>(mainWindow())->setSettingsDirty();
*/
}
int KToolBar::count() const
{
return id2widget.count();
}
void KToolBar::saveState()
{
@@ -1236,60 +1247,60 @@ QString KToolBar::text() const
void KToolBar::doConnections( KToolBarButton *button )
{
connect(button, SIGNAL(clicked(int)), this, SIGNAL( clicked( int ) ) );
connect(button, SIGNAL(doubleClicked(int)), this, SIGNAL( doubleClicked( int ) ) );
connect(button, SIGNAL(released(int)), this, SIGNAL( released( int ) ) );
connect(button, SIGNAL(pressed(int)), this, SIGNAL( pressed( int ) ) );
connect(button, SIGNAL(toggled(int)), this, SIGNAL( toggled( int ) ) );
connect(button, SIGNAL(highlighted(int, bool)), this, SIGNAL( highlighted( int, bool ) ) );
}
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 );
break;
case CONTEXT_TEXTRIGHT:
setIconText( IconTextRight );
break;
case CONTEXT_TEXT:
setIconText( TextOnly );
break;
case CONTEXT_TEXTUNDER:
setIconText( IconTextBottom );
break;
default:
if ( i >= CONTEXT_ICONSIZES )
setIconSize( i - CONTEXT_ICONSIZES );
@@ -1319,143 +1330,143 @@ void KToolBar::rebuildLayout()
// clear the old layout
QLayoutIterator it = l->iterator();
while ( it.current() ) {
it.deleteCurrent();
}
for ( QWidget *w = widgets.first(); w; w = widgets.next() ) {
if ( w == rightAligned ) {
continue;
}
if ( w->inherits( "KToolBarSeparator" ) &&
!( (KToolBarSeparator*)w )->showLine() ) {
l->addSpacing( 6 );
w->hide();
continue;
}
- if ( w->inherits( "QPopupMenu" ) )
+ if ( w->inherits( "Q3PopupMenu" ) )
continue;
l->addWidget( w );
w->show();
}
if ( rightAligned ) {
l->addStretch();
l->addWidget( rightAligned );
rightAligned->show();
}
if ( fullSize() ) {
// This code sucks. It makes the last combo in a toolbar VERY big (e.g. zoom combo in kword).
//if ( !stretchableWidget && widgets.last() &&
// !widgets.last()->inherits( "QButton" ) && !widgets.last()->inherits( "KAnimWidget" ) )
// setStretchableWidget( widgets.last() );
if ( !rightAligned )
l->addStretch();
if ( stretchableWidget )
l->setStretchFactor( stretchableWidget, 10 );
}
l->invalidate();
QApplication::postEvent( this, new QEvent( QEvent::LayoutHint ) );
//#endif //DESKTOP_VERSION
}
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
// being inserted again
if ( !widget2id.contains( w ) )
{
int dummy = -1;
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();
// clear the old layout so that we don't get unnecassery layout
// changes till we have rebuild the thing
QLayoutIterator it = l->iterator();
while ( it.current() ) {
it.deleteCurrent();
}
layoutTimer->start( 50, TRUE );
- }
+ } */
}
- QToolBar::childEvent( e );
+ Q3ToolBar::childEvent( e );
}
void KToolBar::insertWidgetInternal( QWidget *w, int &index, int id )
{
// we can't have it in widgets, or something is really wrong
//widgets.removeRef( w );
connect( w, SIGNAL( destroyed() ),
this, SLOT( widgetDestroyed() ) );
if ( index == -1 || index > (int)widgets.count() ) {
widgets.append( w );
index = (int)widgets.count();
}
else
widgets.insert( index, w );
if ( id == -1 )
id = id2widget.count();
id2widget.insert( id, w );
widget2id.insert( w, 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 );
}
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 );
KToolBar* ttt = (KToolBar*) this;
ttt->sizeHintW = sh.width();
ttt->sizeHintH = sh.height();
return sh;
//return QToolBar::sizeHint();
#if 0
QWidget::polish();
static int iii = 0;
++iii;
qDebug("++++++++ KToolBar::sizeHint() %d ", iii );
int margin = static_cast<QWidget*>(ncThis)->layout()->margin();
switch( barPos() )
{
@@ -1495,69 +1506,69 @@ QSize KToolBar::sizeHint() const
else
{
QSize sh = w->sizeHint();
if (!sh.isValid())
sh = w->minimumSize();
minSize = minSize.expandedTo(QSize(sh.width(), 0));
minSize += QSize(0, sh.height()+1);
}
}
/*US
minSize += QSize(0, QApplication::style().pixelMetric( QStyle::PM_DockWindowHandleExtent ));
*/
minSize += QSize(margin*2, margin*2);
break;
default:
- minSize = QToolBar::sizeHint();
+ minSize = Q3ToolBar::sizeHint();
break;
}
return minSize;
#endif
}
QSize KToolBar::minimumSize() const
{
return minimumSizeHint();
}
QSize KToolBar::minimumSizeHint() const
{
return sizeHint();
}
bool KToolBar::highlight() const
{
return d->m_highlight;
}
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 );
}
void KToolBar::slotIconChanged(int group)
{
if ((group != KIcon::Toolbar) && (group != KIcon::MainToolbar))
return;
if ((group == KIcon::MainToolbar) != !::qstrcmp(name(), "mainToolBar"))
return;
emit modechange();
if (isVisible())
updateGeometry();
}
@@ -1713,33 +1724,33 @@ void KToolBar::applyAppearanceSettings(KConfig *config, const QString &_configGr
else
icon_text = IconOnly;
// check if the icon/text has changed
if (icon_text != d->m_iconText) {
//kdDebug(220) << "KToolBar::applyAppearanceSettings setIconText " << icon_text << endl;
setIconText(icon_text, false);
doUpdate = true;
}
// ...and check if the icon size has changed
if (iconsize != d->m_iconSize) {
setIconSize(iconsize, false);
doUpdate = true;
}
- QMainWindow *mw = mainWindow();
+ Q3MainWindow *mw = mainWindow();
// ...and if we should highlight
if ( highlight != d->m_highlight ) {
d->m_highlight = highlight;
doUpdate = true;
}
// ...and if we should move transparently
if ( mw && transparent != (!mw->opaqueMoving()) ) {
mw->setOpaqueMoving( !transparent );
}
if (doUpdate)
emit modechange(); // tell buttons what happened
if (isVisible ())
updateGeometry();
@@ -1792,55 +1803,55 @@ void KToolBar::applySettings(KConfig *config, const QString &_configGroup)
bool hidden = config->readBoolEntry("Hidden", d->HiddenDefault);
/*US Dock pos(DockTop);
if ( position == "Top" )
pos = DockTop;
else if ( position == "Bottom" )
pos = DockBottom;
else if ( position == "Left" )
pos = DockLeft;
else if ( position == "Right" )
pos = DockRight;
else if ( position == "Floating" )
pos = DockTornOff;
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)
hide();
else
show();
if ( mainWindow() )
{
- QMainWindow *mw = mainWindow();
+ Q3MainWindow *mw = mainWindow();
//kdDebug(220) << "KToolBar::applySettings updating ToolbarInfo" << endl;
d->toolBarInfo = KToolBarPrivate::ToolBarInfo( pos, index, newLine, offset );
// moveDockWindow calls QDockArea which does a reparent() on us with
// showIt = true, so we loose our visibility status
bool doHide = isHidden();
//US mw->moveDockWindow( this, pos, newLine, index, offset );
mw->moveToolBar( this, pos, newLine, index, offset );
//kdDebug(220) << "KToolBar::applySettings " << name() << " moveDockWindow with pos=" << pos << " newLine=" << newLine << " idx=" << index << " offs=" << offset << endl;
if ( doHide )
hide();
}
if (isVisible ())
@@ -1849,58 +1860,58 @@ void KToolBar::applySettings(KConfig *config, const QString &_configGroup)
}
bool KToolBar::event( QEvent *e )
{
if ( (e->type() == QEvent::LayoutHint) && isUpdatesEnabled() )
d->repaintTimer.start( 100, true );
if (e->type() == QEvent::ChildInserted )
{
// By pass QToolBar::event,
// it will show() the inserted child and we don't want to
// do that until we have rebuild the layout.
childEvent((QChildEvent *)e);
return true;
}
- return QToolBar::event( e );
+ return Q3ToolBar::event( e );
}
void KToolBar::slotRepaint()
{
setUpdatesEnabled( FALSE );
// Send a resizeEvent to update the "toolbar extension arrow"
// (The button you get when your toolbar-items don't fit in
// the available space)
QResizeEvent ev(size(), size());
resizeEvent(&ev);
//#ifdef DESKTOP_VERSION
QApplication::sendPostedEvents( this, QEvent::LayoutHint );
//#endif //DESKTOP_VERSION
setUpdatesEnabled( TRUE );
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();
*/
}
/*US
void KToolBar::loadState( const QDomElement &element )
{
//kdDebug(220) << "KToolBar::loadState " << this << endl;
if ( !mainWindow() )
return;
{
QCString text = element.namedItem( "text" ).toElement().text().utf8();
if ( text.isEmpty() )
@@ -2018,33 +2029,33 @@ void KToolBar::getAttributes( QString &position, QString &icontext, int &index )
case KToolBar::Left:
position = "Left";
break;
case KToolBar::Right:
position = "Right";
break;
case KToolBar::Floating:
position = "Floating";
break;
case KToolBar::Top:
default:
position = "Top";
break;
}
if ( mainWindow() ) {
- QMainWindow::ToolBarDock dock;
+ Qt::ToolBarDock dock;
bool newLine;
int offset;
mainWindow()->getLocation( this, dock, index, newLine, offset );
}
switch (d->m_iconText) {
case KToolBar::IconTextRight:
icontext = "IconTextRight";
break;
case KToolBar::IconTextBottom:
icontext = "IconTextBottom";
break;
case KToolBar::TextOnly:
icontext = "TextOnly";
break;
case KToolBar::IconOnly:
@@ -2087,78 +2098,78 @@ void KToolBar::positionYourself( bool force )
bool doHide = isHidden();
//kdDebug(220) << "positionYourself " << name() << " dock=" << d->toolBarInfo.dock << " newLine=" << d->toolBarInfo.newline << " offset=" << d->toolBarInfo.offset << endl;
/*US mainWindow()->moveDockWindow( this, d->toolBarInfo.dock,
d->toolBarInfo.newline,
d->toolBarInfo.index,
d->toolBarInfo.offset );
*/
mainWindow()->moveToolBar( this, d->toolBarInfo.dock, d->NewLineDefault, d->IndexDefault, d->OffsetDefault );
if ( doHide )
hide();
// This method can only have an effect once - unless force is set
d->positioned = TRUE;
}
//US KPopupMenu *KToolBar::contextMenu()
-QPopupMenu *KToolBar::contextMenu()
+Q3PopupMenu *KToolBar::contextMenu()
{
if ( context )
return context;
// 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 );
orient->insertItem( i18n("toolbar position string","Bottom"), CONTEXT_BOTTOM );
orient->insertSeparator(-1);
//orient->insertItem( i18n("toolbar position string","Floating"), CONTEXT_FLOAT );
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"))
avSizes = theme->querySizes( KIcon::MainToolbar);
else
avSizes = theme->querySizes( KIcon::Toolbar);
*/
avSizes << 16;
avSizes << 32;
d->iconSizes = avSizes;
- QValueList<int>::Iterator it;
+ Q3ValueList<int>::Iterator it;
for (it=avSizes.begin(); it!=avSizes.end(); it++) {
QString text;
if ( *it < 19 )
text = i18n("Small (%1x%2)").arg(*it).arg(*it);
else if (*it < 25)
text = i18n("Medium (%1x%2)").arg(*it).arg(*it);
else
text = i18n("Large (%1x%2)").arg(*it).arg(*it);
//we use the size as an id, with an offset
size->insertItem( text, CONTEXT_ICONSIZES + *it );
}
context->insertItem( i18n("Orientation"), orient );
orient->setItemChecked(CONTEXT_TOP, true);
context->insertItem( i18n("Text Position"), mode );
context->setItemChecked(CONTEXT_ICONS, true);
@@ -2205,34 +2216,34 @@ void KToolBar::slotContextAboutToShow()
{
case IconOnly:
default:
context->setItemChecked(CONTEXT_ICONS, true);
break;
case IconTextRight:
context->setItemChecked(CONTEXT_TEXTRIGHT, true);
break;
case TextOnly:
context->setItemChecked(CONTEXT_TEXT, true);
break;
case IconTextBottom:
context->setItemChecked(CONTEXT_TEXTUNDER, true);
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 );
context->setItemChecked( CONTEXT_ICONSIZES, false );
context->setItemChecked( CONTEXT_ICONSIZES + d->m_iconSize, true );
for ( int i = CONTEXT_TOP; i <= CONTEXT_FLAT; ++i )
context->setItemChecked( i, false );
switch ( barPos() )
{
case KToolBar::Flat:
context->setItemChecked( CONTEXT_FLAT, true );
break;
case KToolBar::Bottom: