diff options
Diffstat (limited to 'kdevdesigner/designer/menubareditor.cpp')
-rw-r--r-- | kdevdesigner/designer/menubareditor.cpp | 192 |
1 files changed, 96 insertions, 96 deletions
diff --git a/kdevdesigner/designer/menubareditor.cpp b/kdevdesigner/designer/menubareditor.cpp index 33cf923e..0c123886 100644 --- a/kdevdesigner/designer/menubareditor.cpp +++ b/kdevdesigner/designer/menubareditor.cpp @@ -24,14 +24,14 @@ ** **********************************************************************/ -#include <qaction.h> -#include <qapplication.h> -#include <qbitmap.h> -#include <qdragobject.h> -#include <qlineedit.h> -#include <qmainwindow.h> -#include <qpainter.h> -#include <qstyle.h> +#include <tqaction.h> +#include <tqapplication.h> +#include <tqbitmap.h> +#include <tqdragobject.h> +#include <tqlineedit.h> +#include <tqmainwindow.h> +#include <tqpainter.h> +#include <tqstyle.h> #include "command.h" #include "formwindow.h" #include "menubareditor.h" @@ -39,7 +39,7 @@ #include <klocale.h> -extern void find_accel( const QString &txt, QMap<QChar, QWidgetList > &accels, QWidget *w ); +extern void find_accel( const TQString &txt, TQMap<TQChar, TQWidgetList > &accels, TQWidget *w ); // Drag Object Declaration ------------------------------------------- @@ -47,35 +47,35 @@ class MenuBarEditorItemPtrDrag : public QStoredDrag { public: MenuBarEditorItemPtrDrag( MenuBarEditorItem * item, - QWidget * parent = 0, + TQWidget * parent = 0, const char * name = 0 ); ~MenuBarEditorItemPtrDrag() {}; - static bool canDecode( QDragMoveEvent * e ); - static bool decode( QDropEvent * e, MenuBarEditorItem ** i ); + static bool canDecode( TQDragMoveEvent * e ); + static bool decode( TQDropEvent * e, MenuBarEditorItem ** i ); }; // Drag Object Implementation --------------------------------------- MenuBarEditorItemPtrDrag::MenuBarEditorItemPtrDrag( MenuBarEditorItem * item, - QWidget * parent, + TQWidget * parent, const char * name ) - : QStoredDrag( "qt/menubareditoritemptr", parent, name ) + : TQStoredDrag( "qt/menubareditoritemptr", parent, name ) { - QByteArray data( sizeof( Q_LONG ) ); - QDataStream stream( data, IO_WriteOnly ); + TQByteArray data( sizeof( Q_LONG ) ); + TQDataStream stream( data, IO_WriteOnly ); stream << ( Q_LONG ) item; setEncodedData( data ); } -bool MenuBarEditorItemPtrDrag::canDecode( QDragMoveEvent * e ) +bool MenuBarEditorItemPtrDrag::canDecode( TQDragMoveEvent * e ) { return e->provides( "qt/menubareditoritemptr" ); } -bool MenuBarEditorItemPtrDrag::decode( QDropEvent * e, MenuBarEditorItem ** i ) +bool MenuBarEditorItemPtrDrag::decode( TQDropEvent * e, MenuBarEditorItem ** i ) { - QByteArray data = e->encodedData( "qt/menubareditoritemptr" ); - QDataStream stream( data, IO_ReadOnly ); + TQByteArray data = e->encodedData( "qt/menubareditoritemptr" ); + TQDataStream stream( data, IO_ReadOnly ); if ( !data.size() ) return FALSE; @@ -89,8 +89,8 @@ bool MenuBarEditorItemPtrDrag::decode( QDropEvent * e, MenuBarEditorItem ** i ) // MenuBarEditorItem --------------------------------------------------- -MenuBarEditorItem::MenuBarEditorItem( MenuBarEditor * bar, QObject * parent, const char * name ) - : QObject( parent, name ), +MenuBarEditorItem::MenuBarEditorItem( MenuBarEditor * bar, TQObject * parent, const char * name ) + : TQObject( parent, name ), menuBar( bar ), popupMenu( 0 ), visible( TRUE ), @@ -99,8 +99,8 @@ MenuBarEditorItem::MenuBarEditorItem( MenuBarEditor * bar, QObject * parent, con { } MenuBarEditorItem::MenuBarEditorItem( PopupMenuEditor * menu, MenuBarEditor * bar, - QObject * parent, const char * name ) - : QObject( parent, name ), + TQObject * parent, const char * name ) + : TQObject( parent, name ), menuBar( bar ), popupMenu( menu ), visible( TRUE ), @@ -110,9 +110,9 @@ MenuBarEditorItem::MenuBarEditorItem( PopupMenuEditor * menu, MenuBarEditor * ba text = menu->name(); } -MenuBarEditorItem::MenuBarEditorItem( QActionGroup * actionGroup, MenuBarEditor * bar, - QObject * parent, const char * name ) - : QObject( parent, name ), +MenuBarEditorItem::MenuBarEditorItem( TQActionGroup * actionGroup, MenuBarEditor * bar, + TQObject * parent, const char * name ) + : TQObject( parent, name ), menuBar( bar ), popupMenu( 0 ), visible( TRUE ), @@ -124,8 +124,8 @@ MenuBarEditorItem::MenuBarEditorItem( QActionGroup * actionGroup, MenuBarEditor popupMenu->insert( actionGroup ); } -MenuBarEditorItem::MenuBarEditorItem( MenuBarEditorItem * item, QObject * parent, const char * name ) - : QObject( parent, name ), +MenuBarEditorItem::MenuBarEditorItem( MenuBarEditorItem * item, TQObject * parent, const char * name ) + : TQObject( parent, name ), menuBar( item->menuBar ), popupMenu( 0 ), text( item->text ), @@ -141,8 +141,8 @@ MenuBarEditorItem::MenuBarEditorItem( MenuBarEditorItem * item, QObject * parent int MenuBarEditor::clipboardOperation = 0; MenuBarEditorItem * MenuBarEditor::clipboardItem = 0; -MenuBarEditor::MenuBarEditor( FormWindow * fw, QWidget * parent, const char * name ) - : QMenuBar( parent, name ), +MenuBarEditor::MenuBarEditor( FormWindow * fw, TQWidget * parent, const char * name ) + : TQMenuBar( parent, name ), formWnd( fw ), draggedItem( 0 ), currentIndex( 0 ), @@ -157,15 +157,15 @@ MenuBarEditor::MenuBarEditor( FormWindow * fw, QWidget * parent, const char * na addItem.setMenuText( i18n("new menu") ); addSeparator.setMenuText( i18n("new separator") ); - lineEdit = new QLineEdit( this, "menubar lineedit" ); + lineEdit = new TQLineEdit( this, "menubar lineedit" ); lineEdit->hide(); - lineEdit->setFrameStyle(QFrame::Plain | QFrame::NoFrame); + lineEdit->setFrameStyle(TQFrame::Plain | TQFrame::NoFrame); lineEdit->polish(); lineEdit->setBackgroundMode(PaletteButton); lineEdit->setBackgroundOrigin(ParentOrigin); lineEdit->installEventFilter( this ); - dropLine = new QWidget( this, "menubar dropline", Qt::WStyle_NoBorder | WStyle_StaysOnTop ); + dropLine = new TQWidget( this, "menubar dropline", Qt::WStyle_NoBorder | WStyle_StaysOnTop ); dropLine->setBackgroundColor( Qt::red ); dropLine->hide(); @@ -185,7 +185,7 @@ FormWindow * MenuBarEditor::formWindow() MenuBarEditorItem * MenuBarEditor::createItem( int index, bool addToCmdStack ) { MenuBarEditorItem * i = - new MenuBarEditorItem( new PopupMenuEditor( formWnd, ( QWidget * ) parent() ), this ); + new MenuBarEditorItem( new PopupMenuEditor( formWnd, ( TQWidget * ) parent() ), this ); if ( addToCmdStack ) { AddMenuCommand * cmd = new AddMenuCommand( i18n( "Add Menu" ), formWnd, this, i, index ); formWnd->commandHistory()->addCommand( cmd ); @@ -215,7 +215,7 @@ void MenuBarEditor::insertItem( MenuBarEditorItem * item, int index ) update(); } -void MenuBarEditor::insertItem( QString text, PopupMenuEditor * menu, int index ) +void MenuBarEditor::insertItem( TQString text, PopupMenuEditor * menu, int index ) { MenuBarEditorItem * item = new MenuBarEditorItem( menu, this ); if ( !text.isNull() ) @@ -223,7 +223,7 @@ void MenuBarEditor::insertItem( QString text, PopupMenuEditor * menu, int index insertItem( item, index ); } -void MenuBarEditor::insertItem( QString text, QActionGroup * group, int index ) +void MenuBarEditor::insertItem( TQString text, TQActionGroup * group, int index ) { MenuBarEditorItem * item = new MenuBarEditorItem( group, this ); if ( !text.isNull() ) @@ -289,14 +289,14 @@ int MenuBarEditor::findItem( PopupMenuEditor * menu ) return -1; } -int MenuBarEditor::findItem( QPoint & pos ) +int MenuBarEditor::findItem( TQPoint & pos ) { int x = borderSize(); int dx = 0; int y = 0; int w = width(); - QSize s; - QRect r; + TQSize s; + TQRect r; MenuBarEditorItem * i = itemList.first(); @@ -312,7 +312,7 @@ int MenuBarEditor::findItem( QPoint & pos ) x = borderSize(); } - r = QRect( x, y, s.width(), s.height() ); + r = TQRect( x, y, s.width(), s.height() ); if ( r.contains( pos ) ) return itemList.at(); @@ -332,7 +332,7 @@ int MenuBarEditor::findItem( QPoint & pos ) x = borderSize(); } - r = QRect( x, y, s.width(), s.height() ); + r = TQRect( x, y, s.width(), s.height() ); if ( r.contains( pos ) ) return itemList.count(); @@ -437,7 +437,7 @@ void MenuBarEditor::showLineEdit( int index ) // open edit field for item name lineEdit->setText( i->menuText() ); lineEdit->selectAll(); - QPoint pos = itemPos( index ); + TQPoint pos = itemPos( index ); lineEdit->move( pos.x() + borderSize(), pos.y() - ( borderSize() / 2 ) ); lineEdit->resize( itemSize( i ) ); lineEdit->show(); @@ -454,7 +454,7 @@ void MenuBarEditor::showItem( int index ) if ( i->isSeparator() || draggedItem ) return; PopupMenuEditor * m = i->menu(); - QPoint pos = itemPos( index ); + TQPoint pos = itemPos( index ); m->move( pos.x(), pos.y() + itemHeight - 1 ); m->raise(); m->show(); @@ -502,9 +502,9 @@ void MenuBarEditor::deleteItem( int index ) } } -QSize MenuBarEditor::sizeHint() const +TQSize MenuBarEditor::sizeHint() const { - return QSize( parentWidget()->width(), heightForWidth( parentWidget()->width() ) ); + return TQSize( parentWidget()->width(), heightForWidth( parentWidget()->width() ) ); } int MenuBarEditor::heightForWidth( int max_width ) const @@ -513,7 +513,7 @@ int MenuBarEditor::heightForWidth( int max_width ) const int x = borderSize(); int y = 0; - QPainter p( this ); + TQPainter p( this ); that->itemHeight = that->itemSize( &(that->addItem) ).height(); MenuBarEditorItem * i = that->itemList.first(); @@ -531,16 +531,16 @@ int MenuBarEditor::heightForWidth( int max_width ) const void MenuBarEditor::show() { - QWidget::show(); + TQWidget::show(); resizeInternals(); - QResizeEvent e( parentWidget()->size(), parentWidget()->size() ); - QApplication::sendEvent( parentWidget(), &e ); + TQResizeEvent e( parentWidget()->size(), parentWidget()->size() ); + TQApplication::sendEvent( parentWidget(), &e ); } -void MenuBarEditor::checkAccels( QMap<QChar, QWidgetList > &accels ) +void MenuBarEditor::checkAccels( TQMap<TQChar, TQWidgetList > &accels ) { - QString t; + TQString t; MenuBarEditorItem * i = itemList.first(); while ( i ) { t = i->menuText(); @@ -569,28 +569,28 @@ void MenuBarEditor::paste() // protected -bool MenuBarEditor::eventFilter( QObject * o, QEvent * e ) +bool MenuBarEditor::eventFilter( TQObject * o, TQEvent * e ) { - if ( o == lineEdit && e->type() == QEvent::FocusOut ) { + if ( o == lineEdit && e->type() == TQEvent::FocusOut ) { leaveEditMode(); lineEdit->hide(); update(); - } else if ( e->type() == QEvent::LayoutHint ) { + } else if ( e->type() == TQEvent::LayoutHint ) { resize( sizeHint() ); } - return QMenuBar::eventFilter( o, e ); + return TQMenuBar::eventFilter( o, e ); } -void MenuBarEditor::paintEvent( QPaintEvent * ) +void MenuBarEditor::paintEvent( TQPaintEvent * ) { - QPainter p( this ); - QRect r = rect(); - style().drawPrimitive( QStyle::PE_PanelMenuBar, &p, + TQPainter p( this ); + TQRect r = rect(); + style().drawPrimitive( TQStyle::PE_PanelMenuBar, &p, r, colorGroup() ); drawItems( p ); } -void MenuBarEditor::mousePressEvent( QMouseEvent * e ) +void MenuBarEditor::mousePressEvent( TQMouseEvent * e ) { mousePressPos = e->pos(); hideItem(); @@ -601,7 +601,7 @@ void MenuBarEditor::mousePressEvent( QMouseEvent * e ) e->accept(); } -void MenuBarEditor::mouseDoubleClickEvent( QMouseEvent * e ) +void MenuBarEditor::mouseDoubleClickEvent( TQMouseEvent * e ) { mousePressPos = e->pos(); currentIndex = findItem( mousePressPos ); @@ -614,7 +614,7 @@ void MenuBarEditor::mouseDoubleClickEvent( QMouseEvent * e ) } } -void MenuBarEditor::mouseMoveEvent( QMouseEvent * e ) +void MenuBarEditor::mouseMoveEvent( TQMouseEvent * e ) { if ( e->state() & Qt::LeftButton ) { if ( ( e->pos() - mousePressPos ).manhattanLength() > 3 ) { @@ -647,7 +647,7 @@ void MenuBarEditor::mouseMoveEvent( QMouseEvent * e ) // we will have two instances of the same pointer // in the list. itemList.find( draggedItem ); - QLNode * node = itemList.currentNode(); + TQLNode * node = itemList.currentNode(); dropConfirmed = FALSE; d->dragCopy(); // dragevents and stuff happens if ( draggedItem ) { // item was not dropped @@ -673,7 +673,7 @@ void MenuBarEditor::mouseMoveEvent( QMouseEvent * e ) } } -void MenuBarEditor::dragEnterEvent( QDragEnterEvent * e ) +void MenuBarEditor::dragEnterEvent( TQDragEnterEvent * e ) { if ( MenuBarEditorItemPtrDrag::canDecode( e ) ) { e->accept(); @@ -681,15 +681,15 @@ void MenuBarEditor::dragEnterEvent( QDragEnterEvent * e ) } } -void MenuBarEditor::dragLeaveEvent( QDragLeaveEvent * ) +void MenuBarEditor::dragLeaveEvent( TQDragLeaveEvent * ) { dropLine->hide(); } -void MenuBarEditor::dragMoveEvent( QDragMoveEvent * e ) +void MenuBarEditor::dragMoveEvent( TQDragMoveEvent * e ) { - QPoint pos = e->pos(); + TQPoint pos = e->pos(); dropLine->move( snapToItem( pos ) ); int idx = findItem( pos ); @@ -700,7 +700,7 @@ void MenuBarEditor::dragMoveEvent( QDragMoveEvent * e ) } } -void MenuBarEditor::dropEvent( QDropEvent * e ) +void MenuBarEditor::dropEvent( TQDropEvent * e ) { MenuBarEditorItem * i = 0; @@ -714,7 +714,7 @@ void MenuBarEditor::dropEvent( QDropEvent * e ) dropLine->hide(); } -void MenuBarEditor::keyPressEvent( QKeyEvent * e ) +void MenuBarEditor::keyPressEvent( TQKeyEvent * e ) { if ( lineEdit->isHidden() ) { // In navigation mode switch ( e->key() ) { @@ -789,7 +789,7 @@ void MenuBarEditor::keyPressEvent( QKeyEvent * e ) default: if ( e->ascii() >= 32 || e->ascii() == 0 ) { showLineEdit(); - QApplication::sendEvent( lineEdit, e ); + TQApplication::sendEvent( lineEdit, e ); e->accept(); } else { e->ignore(); @@ -815,9 +815,9 @@ void MenuBarEditor::keyPressEvent( QKeyEvent * e ) update(); } -void MenuBarEditor::focusOutEvent( QFocusEvent * e ) +void MenuBarEditor::focusOutEvent( TQFocusEvent * e ) { - QWidget * fw = qApp->focusWidget(); + TQWidget * fw = qApp->focusWidget(); if ( e->lostFocus() && !::qt_cast<PopupMenuEditor*>(fw) ) hideItem(); update(); @@ -829,9 +829,9 @@ void MenuBarEditor::resizeInternals() updateGeometry(); } -void MenuBarEditor::drawItems( QPainter & p ) +void MenuBarEditor::drawItems( TQPainter & p ) { - QPoint pos( borderSize(), 0 ); + TQPoint pos( borderSize(), 0 ); uint c = 0; p.setPen( colorGroup().buttonText() ); @@ -849,10 +849,10 @@ void MenuBarEditor::drawItems( QPainter & p ) drawItem( p, &addSeparator, c, pos ); } -void MenuBarEditor::drawItem( QPainter & p, +void MenuBarEditor::drawItem( TQPainter & p, MenuBarEditorItem * i, int idx, - QPoint & pos ) + TQPoint & pos ) { int w = itemSize( i ).width(); @@ -865,7 +865,7 @@ void MenuBarEditor::drawItem( QPainter & p, if ( i->isSeparator() ) { drawSeparator( p, pos ); } else { - int flags = QPainter::AlignLeft | QPainter::AlignVCenter | + int flags = TQPainter::AlignLeft | TQPainter::AlignVCenter | Qt::ShowPrefix | Qt::SingleLine; p.drawText( pos.x() + borderSize(), pos.y(), w - borderSize(), itemHeight, flags, i->menuText() ); @@ -877,7 +877,7 @@ void MenuBarEditor::drawItem( QPainter & p, pos.rx() += w; } -void MenuBarEditor::drawSeparator( QPainter & p, QPoint & pos ) +void MenuBarEditor::drawSeparator( TQPainter & p, TQPoint & pos ) { p.save(); p.setPen( darkBlue ); @@ -892,17 +892,17 @@ void MenuBarEditor::drawSeparator( QPainter & p, QPoint & pos ) p.fillRect( left, pos.y() + borderSize() * 2, separatorWidth - 1, itemHeight - borderSize() * 4, - QBrush( darkBlue, Qt::Dense5Pattern ) ); + TQBrush( darkBlue, Qt::Dense5Pattern ) ); p.restore(); } -QSize MenuBarEditor::itemSize( MenuBarEditorItem * i ) +TQSize MenuBarEditor::itemSize( MenuBarEditorItem * i ) { if ( i->isSeparator() ) - return QSize( separatorWidth, itemHeight ); - QRect r = fontMetrics().boundingRect( i->menuText().remove( "&") ); - return QSize( r.width() + borderSize() * 2, r.height() + borderSize() * 4 ); + return TQSize( separatorWidth, itemHeight ); + TQRect r = fontMetrics().boundingRect( i->menuText().remove( "&") ); + return TQSize( r.width() + borderSize() * 2, r.height() + borderSize() * 4 ); } void MenuBarEditor::addItemSizeToCoords( MenuBarEditorItem * i, int & x, int & y, int w ) @@ -915,7 +915,7 @@ void MenuBarEditor::addItemSizeToCoords( MenuBarEditorItem * i, int & x, int & y x += dx; } -QPoint MenuBarEditor::itemPos( int index ) +TQPoint MenuBarEditor::itemPos( int index ) { int x = borderSize(); int y = 0; @@ -933,7 +933,7 @@ QPoint MenuBarEditor::itemPos( int index ) x = borderSize(); } if ( c == index ) - return QPoint( x, y ); + return TQPoint( x, y ); x += dx; c++; } @@ -945,10 +945,10 @@ QPoint MenuBarEditor::itemPos( int index ) x = borderSize(); } - return QPoint( x, y ); + return TQPoint( x, y ); } -QPoint MenuBarEditor::snapToItem( const QPoint & pos ) +TQPoint MenuBarEditor::snapToItem( const TQPoint & pos ) { int x = borderSize(); int y = 0; @@ -966,17 +966,17 @@ QPoint MenuBarEditor::snapToItem( const QPoint & pos ) if ( pos.y() > y && pos.y() < y + itemHeight && pos.x() < x + dx / 2 ) { - return QPoint( x, y ); + return TQPoint( x, y ); } x += dx; } n = itemList.next(); } - return QPoint( x, y ); + return TQPoint( x, y ); } -void MenuBarEditor::dropInPlace( MenuBarEditorItem * i, const QPoint & pos ) +void MenuBarEditor::dropInPlace( MenuBarEditorItem * i, const TQPoint & pos ) { int x = borderSize(); int y = 0; @@ -1110,15 +1110,15 @@ void MenuBarEditor::leaveEditMode() showItem(); } -QPixmap MenuBarEditor::createTextPixmap( const QString &text ) +TQPixmap MenuBarEditor::createTextPixmap( const TQString &text ) { - QSize sz( fontMetrics().boundingRect( text ).size() ); - QPixmap pix( sz.width() + 20, sz.height() * 2 ); + TQSize sz( fontMetrics().boundingRect( text ).size() ); + TQPixmap pix( sz.width() + 20, sz.height() * 2 ); pix.fill( white ); - QPainter p( &pix, this ); + TQPainter p( &pix, this ); p.drawText( 2, 0, pix.width(), pix.height(), 0, text ); p.end(); - QBitmap bm( pix.size() ); + TQBitmap bm( pix.size() ); bm.fill( color0 ); p.begin( &bm ); p.setPen( color1 ); |