summaryrefslogtreecommitdiffstats
path: root/src/itemview.cpp
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-29 16:05:55 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-06-29 16:05:55 +0000
commit87a016680e3677da3993f333561e79eb0cead7d5 (patch)
treecbda2b4df8b8ee0d8d1617e6c75bec1e3ee0ccba /src/itemview.cpp
parent6ce3d1ad09c1096b5ed3db334e02859e45d5c32b (diff)
downloadktechlab-87a016680e3677da3993f333561e79eb0cead7d5.tar.gz
ktechlab-87a016680e3677da3993f333561e79eb0cead7d5.zip
TQt4 port ktechlab
This enables compilation under both Qt3 and Qt4 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/ktechlab@1238801 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/itemview.cpp')
-rw-r--r--src/itemview.cpp182
1 files changed, 91 insertions, 91 deletions
diff --git a/src/itemview.cpp b/src/itemview.cpp
index 452d33c..fd2d6af 100644
--- a/src/itemview.cpp
+++ b/src/itemview.cpp
@@ -26,9 +26,9 @@
#include <kurldrag.h>
#include <cmath>
-#include <qcursor.h>
-#include <qtimer.h>
-#include <qwmatrix.h>
+#include <tqcursor.h>
+#include <tqtimer.h>
+#include <tqwmatrix.h>
//BEGIN class ItemView
@@ -37,24 +37,24 @@ ItemView::ItemView( ItemDocument * itemDocument, ViewContainer *viewContainer, u
{
KActionCollection * ac = actionCollection();
- KStdAction::selectAll( itemDocument, SLOT(selectAll()), ac );
- KStdAction::zoomIn( this, SLOT(zoomIn()), ac );
- KStdAction::zoomOut( this, SLOT(zoomOut()), ac );
- KStdAction::actualSize( this, SLOT(actualSize()), ac )->setEnabled(false);
+ KStdAction::selectAll( itemDocument, TQT_SLOT(selectAll()), ac );
+ KStdAction::zoomIn( TQT_TQOBJECT(this), TQT_SLOT(zoomIn()), ac );
+ KStdAction::zoomOut( TQT_TQOBJECT(this), TQT_SLOT(zoomOut()), ac );
+ KStdAction::actualSize( TQT_TQOBJECT(this), TQT_SLOT(actualSize()), ac )->setEnabled(false);
KAccel *pAccel = new KAccel(this);
- pAccel->insert( "Cancel", i18n("Cancel"), i18n("Cancel the current operation"), Qt::Key_Escape, itemDocument, SLOT(cancelCurrentOperation()) );
+ pAccel->insert( "Cancel", i18n("Cancel"), i18n("Cancel the current operation"), TQt::Key_Escape, itemDocument, TQT_SLOT(cancelCurrentOperation()) );
pAccel->readSettings();
- new KAction( i18n("Delete"), "editdelete", Qt::Key_Delete, itemDocument, SLOT(deleteSelection()), ac, "edit_delete" );
- new KAction( i18n("Export as Image..."), 0, 0, itemDocument, SLOT(exportToImage()), ac, "file_export_image");
+ new KAction( i18n("Delete"), "editdelete", TQt::Key_Delete, itemDocument, TQT_SLOT(deleteSelection()), ac, "edit_delete" );
+ new KAction( i18n("Export as Image..."), 0, 0, itemDocument, TQT_SLOT(exportToImage()), ac, "file_export_image");
//BEGIN Item Alignment actions
- new KAction( i18n("Align Horizontally"), 0, 0, itemDocument, SLOT(alignHorizontally()), ac, "align_horizontally" );
- new KAction( i18n("Align Vertically"), 0, 0, itemDocument, SLOT(alignVertically()), ac, "align_vertically" );
- new KAction( i18n("Distribute Horizontally"), 0, 0, itemDocument, SLOT(distributeHorizontally()), ac, "distribute_horizontally" );
- new KAction( i18n("Distribute Vertically"), 0, 0, itemDocument, SLOT(distributeVertically()), ac, "distribute_vertically" );
+ new KAction( i18n("AlignQt::Horizontally"), 0, 0, itemDocument, TQT_SLOT(alignHorizontally()), ac, "align_horizontally" );
+ new KAction( i18n("AlignQt::Vertically"), 0, 0, itemDocument, TQT_SLOT(alignVertically()), ac, "align_vertically" );
+ new KAction( i18n("DistributeQt::Horizontally"), 0, 0, itemDocument, TQT_SLOT(distributeHorizontally()), ac, "distribute_horizontally" );
+ new KAction( i18n("DistributeQt::Vertically"), 0, 0, itemDocument, TQT_SLOT(distributeVertically()), ac, "distribute_vertically" );
//END Item Alignment actions
@@ -70,13 +70,13 @@ ItemView::ItemView( ItemDocument * itemDocument, ViewContainer *viewContainer, u
m->insertItem( KGlobal::iconLoader()->loadIcon( "tool_arrow", KIcon::Small ), i18n("Arrow"), DrawPart::da_arrow );
m->insertItem( KGlobal::iconLoader()->loadIcon( "tool_ellipse", KIcon::Small ), i18n("Ellipse"), DrawPart::da_ellipse );
m->insertItem( KGlobal::iconLoader()->loadIcon( "tool_rectangle", KIcon::Small ), i18n("Rectangle"), DrawPart::da_rectangle );
- connect( m, SIGNAL(activated(int)), itemDocument, SLOT(slotSetDrawAction(int)) );
+ connect( m, TQT_SIGNAL(activated(int)), itemDocument, TQT_SLOT(slotSetDrawAction(int)) );
//END Draw actions
//BEGIN Item Control actions
- new KAction( i18n("Raise Selection"), "1uparrow", Qt::Key_PageUp, itemDocument, SLOT(raiseZ()), ac, "edit_raise" );
- new KAction( i18n("Lower Selection"), "1downarrow", Qt::Key_PageDown, itemDocument, SLOT(lowerZ()), ac, "edit_lower" );
+ new KAction( i18n("Raise Selection"), "1uparrow", TQt::Key_PageUp, itemDocument, TQT_SLOT(raiseZ()), ac, "edit_raise" );
+ new KAction( i18n("Lower Selection"), "1downarrow", TQt::Key_PageDown, itemDocument, TQT_SLOT(lowerZ()), ac, "edit_lower" );
//END Item Control actions
@@ -85,9 +85,9 @@ ItemView::ItemView( ItemDocument * itemDocument, ViewContainer *viewContainer, u
setXMLFile( "ktechlabitemviewui.rc" );
- m_pUpdateStatusTmr = new QTimer(this);
- connect( m_pUpdateStatusTmr, SIGNAL(timeout()), this, SLOT(updateStatus()) );
- connect( this, SIGNAL(viewUnfocused()), this, SLOT(stopUpdatingStatus()) );
+ m_pUpdateStatusTmr = new TQTimer(this);
+ connect( m_pUpdateStatusTmr, TQT_SIGNAL(timeout()), this, TQT_SLOT(updatetqStatus()) );
+ connect( this, TQT_SIGNAL(viewUnfocused()), this, TQT_SLOT(stopUpdatingtqStatus()) );
p_itemDocument = itemDocument;
m_zoomLevel = 1.;
@@ -129,7 +129,7 @@ void ItemView::zoomIn()
m_zoomLevel = newZoom/100.;
- QWMatrix m( m_zoomLevel, 0.0, 0.0, m_zoomLevel, 1.0, 1.0 );
+ TQWMatrix m( m_zoomLevel, 0.0, 0.0, m_zoomLevel, 1.0, 1.0 );
m_CVBEditor->setWorldMatrix(m);
p_itemDocument->requestEvent( ItemDocument::ItemDocumentEvent::ResizeCanvasToItems );
@@ -153,7 +153,7 @@ void ItemView::zoomOut()
m_zoomLevel = newZoom/100.;
- QWMatrix m( m_zoomLevel, 0.0, 0.0, m_zoomLevel, 1.0, 1.0 );
+ TQWMatrix m( m_zoomLevel, 0.0, 0.0, m_zoomLevel, 1.0, 1.0 );
m_CVBEditor->setWorldMatrix(m);
p_itemDocument->requestEvent( ItemDocument::ItemDocumentEvent::ResizeCanvasToItems );
@@ -164,7 +164,7 @@ void ItemView::zoomOut()
void ItemView::actualSize()
{
m_zoomLevel = 1.0;
- QWMatrix m( m_zoomLevel, 0.0, 0.0, m_zoomLevel, 1.0, 1.0 );
+ TQWMatrix m( m_zoomLevel, 0.0, 0.0, m_zoomLevel, 1.0, 1.0 );
m_CVBEditor->setWorldMatrix(m);
p_itemDocument->requestEvent( ItemDocument::ItemDocumentEvent::ResizeCanvasToItems );
@@ -180,7 +180,7 @@ void ItemView::updateZoomActions()
}
-void ItemView::dropEvent( QDropEvent *event )
+void ItemView::dropEvent( TQDropEvent *event )
{
KURL::List urls;
if ( KURLDrag::decode( event, urls ) )
@@ -194,14 +194,14 @@ void ItemView::dropEvent( QDropEvent *event )
return;
}
- if ( !QString(event->format()).startsWith("ktechlab/") )
+ if ( !TQString(event->format()).startsWith("ktechlab/") )
return;
- QString text;
- QDataStream stream( event->encodedData(event->format()), IO_ReadOnly );
+ TQString text;
+ TQDataStream stream( event->tqencodedData(event->format()), IO_ReadOnly );
stream >> text;
- QPoint position = event->pos();
+ TQPoint position = event->pos();
position.setX( int((position.x() + m_CVBEditor->contentsX())/m_zoomLevel) );
position.setY( int((position.y() + m_CVBEditor->contentsY())/m_zoomLevel) );
@@ -212,9 +212,9 @@ void ItemView::dropEvent( QDropEvent *event )
}
-void ItemView::scrollToMouse( const QPoint &pos )
+void ItemView::scrollToMouse( const TQPoint &pos )
{
- QPoint position = pos * m_zoomLevel;
+ TQPoint position = pos * m_zoomLevel;
int left = m_CVBEditor->contentsX();
int top = m_CVBEditor->contentsY();
@@ -229,7 +229,7 @@ void ItemView::scrollToMouse( const QPoint &pos )
}
-void ItemView::contentsMousePressEvent( QMouseEvent *e )
+void ItemView::contentsMousePressEvent( TQMouseEvent *e )
{
if (!e)
return;
@@ -245,7 +245,7 @@ void ItemView::contentsMousePressEvent( QMouseEvent *e )
if ( !p_itemDocument )
return;
- p_itemDocument->canvas()->setMessage( QString::null );
+ p_itemDocument->canvas()->setMessage( TQString() );
p_itemDocument->m_cmManager->mousePressEvent( EventInfo( this, e ) );
if ( !wasFocused )
@@ -253,7 +253,7 @@ void ItemView::contentsMousePressEvent( QMouseEvent *e )
}
-void ItemView::contentsMouseDoubleClickEvent( QMouseEvent *e )
+void ItemView::contentsMouseDoubleClickEvent( TQMouseEvent *e )
{
if (!e)
return;
@@ -261,7 +261,7 @@ void ItemView::contentsMouseDoubleClickEvent( QMouseEvent *e )
e->accept();
//HACK: Pass this of as a single press event if widget underneath
- QCanvasItem * atTop = p_itemDocument->itemAtTop( e->pos()/zoomLevel() );
+ TQCanvasItem * atTop = p_itemDocument->itemAtTop( e->pos()/zoomLevel() );
if ( atTop && atTop->rtti() == ItemDocument::RTTI::Widget )
contentsMousePressEvent(e);
else
@@ -269,7 +269,7 @@ void ItemView::contentsMouseDoubleClickEvent( QMouseEvent *e )
}
-void ItemView::contentsMouseMoveEvent( QMouseEvent *e )
+void ItemView::contentsMouseMoveEvent( TQMouseEvent *e )
{
if ( !e || !p_itemDocument )
return;
@@ -278,11 +278,11 @@ void ItemView::contentsMouseMoveEvent( QMouseEvent *e )
p_itemDocument->m_cmManager->mouseMoveEvent( EventInfo( this, e ) );
if ( !m_pUpdateStatusTmr->isActive() )
- startUpdatingStatus();
+ startUpdatingtqStatus();
}
-void ItemView::contentsMouseReleaseEvent( QMouseEvent *e )
+void ItemView::contentsMouseReleaseEvent( TQMouseEvent *e )
{
if (!e)
return;
@@ -293,7 +293,7 @@ void ItemView::contentsMouseReleaseEvent( QMouseEvent *e )
}
-void ItemView::contentsWheelEvent( QWheelEvent *e )
+void ItemView::contentsWheelEvent( TQWheelEvent *e )
{
if (!e)
return;
@@ -304,9 +304,9 @@ void ItemView::contentsWheelEvent( QWheelEvent *e )
}
-void ItemView::dragEnterEvent( QDragEnterEvent *event )
+void ItemView::dragEnterEvent( TQDragEnterEvent *event )
{
- startUpdatingStatus();
+ startUpdatingtqStatus();
KURL::List urls;
if ( KURLDrag::decode( event, urls ) )
@@ -318,55 +318,55 @@ void ItemView::dragEnterEvent( QDragEnterEvent *event )
}
-void ItemView::enterEvent( QEvent * e )
+void ItemView::enterEvent( TQEvent * e )
{
Q_UNUSED(e);
- startUpdatingStatus();
+ startUpdatingtqStatus();
}
-void ItemView::leaveEvent( QEvent * e )
+void ItemView::leaveEvent( TQEvent * e )
{
Q_UNUSED(e);
- stopUpdatingStatus();
+ stopUpdatingtqStatus();
// Cleanup
- setCursor(Qt::ArrowCursor);
+ setCursor(TQt::ArrowCursor);
if (p_ktechlab)
- p_ktechlab->slotChangeStatusbar(QString::null);
+ p_ktechlab->slotChangeStatusbar(TQString());
if ( p_itemDocument )
- p_itemDocument->m_canvasTip->setVisible(false);
+ p_itemDocument->m_canvasTip->tqsetVisible(false);
}
void ItemView::slotUpdateConfiguration()
{
// m_CVBEditor->setEraseColor( KTLConfig::bgColor() );
- m_CVBEditor->setEraseColor( Qt::white );
+ m_CVBEditor->setEraseColor( TQt::white );
if ( m_pUpdateStatusTmr->isActive() )
- startUpdatingStatus();
+ startUpdatingtqStatus();
}
-void ItemView::startUpdatingStatus()
+void ItemView::startUpdatingtqStatus()
{
m_pUpdateStatusTmr->stop();
m_pUpdateStatusTmr->start( int(1000./KTLConfig::refreshRate()) );
}
-void ItemView::stopUpdatingStatus()
+void ItemView::stopUpdatingtqStatus()
{
m_pUpdateStatusTmr->stop();
}
-void ItemView::updateStatus()
+void ItemView::updatetqStatus()
{
- QPoint pos = (m_CVBEditor->mapFromGlobal( QCursor::pos() ) + QPoint( m_CVBEditor->contentsX(), m_CVBEditor->contentsY() )) / zoomLevel();
+ TQPoint pos = (m_CVBEditor->mapFromGlobal( TQCursor::pos() ) + TQPoint( m_CVBEditor->contentsX(), m_CVBEditor->contentsY() )) / zoomLevel();
ItemDocument * itemDocument = static_cast<ItemDocument*>(document());
if ( !itemDocument )
@@ -376,17 +376,17 @@ void ItemView::updateStatus()
CanvasTip * canvasTip = itemDocument->m_canvasTip;
bool displayTip = false;
- QCursor cursor = Qt::ArrowCursor;
- QString statusbar;
+ TQCursor cursor = TQt::ArrowCursor;
+ TQString statusbar;
if ( cmManager->cmState() & CMManager::cms_repeated_add )
{
- cursor = Qt::CrossCursor;
+ cursor = TQt::CrossCursor;
statusbar = i18n("Left click to add. Right click to resume normal editing");
}
else if ( cmManager->cmState() & CMManager::cms_draw )
{
- cursor = Qt::CrossCursor;
+ cursor = TQt::CrossCursor;
statusbar = i18n("Click and hold to start drawing.");
}
else if ( cmManager->currentManipulator())
@@ -394,34 +394,34 @@ void ItemView::updateStatus()
switch ( cmManager->currentManipulator()->type() )
{
case CanvasManipulator::RepeatedItemAdd:
- cursor = Qt::CrossCursor;
+ cursor = TQt::CrossCursor;
statusbar = i18n("Left click to add. Right click to resume normal editing");
break;
case CanvasManipulator::ManualConnector:
statusbar = i18n("Right click to cancel the connector");
// no break
case CanvasManipulator::AutoConnector:
- cursor = Qt::CrossCursor;
+ cursor = TQt::CrossCursor;
break;
case CanvasManipulator::ItemMove:
case CanvasManipulator::MechItemMove:
- cursor = Qt::SizeAllCursor;
+ cursor = TQt::SizeAllCursor;
break;
case CanvasManipulator::Draw:
- cursor = Qt::CrossCursor;
+ cursor = TQt::CrossCursor;
break;
default:
break;
}
}
- else if ( QCanvasItem *qcanvasItem = itemDocument->itemAtTop(pos) )
+ else if ( TQCanvasItem *qcanvasItem = itemDocument->itemAtTop(pos) )
{
switch( qcanvasItem->rtti() )
{
case ItemDocument::RTTI::Connector:
{
- cursor = Qt::CrossCursor;
+ cursor = TQt::CrossCursor;
if ( itemDocument->type() != Document::dt_circuit )
break;
@@ -431,7 +431,7 @@ void ItemView::updateStatus()
}
case ItemDocument::RTTI::Node:
{
- cursor = Qt::CrossCursor;
+ cursor = TQt::CrossCursor;
ECNode * ecnode = dynamic_cast<ECNode*>(qcanvasItem);
if ( !ecnode )
break;
@@ -456,7 +456,7 @@ void ItemView::updateStatus()
if (p_ktechlab)
p_ktechlab->slotChangeStatusbar(statusbar);
- canvasTip->setVisible(displayTip);
+ canvasTip->tqsetVisible(displayTip);
}
//END class ItemView
@@ -464,8 +464,8 @@ void ItemView::updateStatus()
//BEGIN class CVBEditor
-CVBEditor::CVBEditor( QCanvas *canvas, ItemView *itemView, const char *name )
- : QCanvasView( canvas, itemView, name, WNoAutoErase | WStaticContents )
+CVBEditor::CVBEditor( TQCanvas *canvas, ItemView *itemView, const char *name )
+ : TQCanvasView( canvas, itemView, name, WNoAutoErase | WStaticContents )
{
b_ignoreEvents = false;
b_passEventsToView = true;
@@ -474,86 +474,86 @@ CVBEditor::CVBEditor( QCanvas *canvas, ItemView *itemView, const char *name )
setAcceptDrops(true);
setFrameShape(NoFrame);
// setEraseColor( KTLConfig::bgColor() );
- setEraseColor( Qt::white );
- setPaletteBackgroundColor( Qt::white );
- viewport()->setEraseColor( Qt::white );
- viewport()->setPaletteBackgroundColor( Qt::white );
+ setEraseColor( TQt::white );
+ setPaletteBackgroundColor( TQt::white );
+ viewport()->setEraseColor( TQt::white );
+ viewport()->setPaletteBackgroundColor( TQt::white );
}
-void CVBEditor::contentsMousePressEvent( QMouseEvent* e )
+void CVBEditor::contentsMousePressEvent( TQMouseEvent* e )
{
if (b_passEventsToView)
p_itemView->contentsMousePressEvent(e);
else
- QCanvasView::contentsMousePressEvent(e);
+ TQCanvasView::contentsMousePressEvent(e);
}
-void CVBEditor::contentsMouseReleaseEvent( QMouseEvent* e )
+void CVBEditor::contentsMouseReleaseEvent( TQMouseEvent* e )
{
if (b_passEventsToView)
p_itemView->contentsMouseReleaseEvent(e);
else
- QCanvasView::contentsMouseReleaseEvent(e);
+ TQCanvasView::contentsMouseReleaseEvent(e);
}
-void CVBEditor::contentsMouseDoubleClickEvent( QMouseEvent* e )
+void CVBEditor::contentsMouseDoubleClickEvent( TQMouseEvent* e )
{
if (b_passEventsToView)
p_itemView->contentsMouseDoubleClickEvent(e);
else
- QCanvasView::contentsMouseDoubleClickEvent(e);
+ TQCanvasView::contentsMouseDoubleClickEvent(e);
}
-void CVBEditor::contentsMouseMoveEvent( QMouseEvent* e )
+void CVBEditor::contentsMouseMoveEvent( TQMouseEvent* e )
{
if (b_passEventsToView)
p_itemView->contentsMouseMoveEvent(e);
else
- QCanvasView::contentsMouseMoveEvent(e);
+ TQCanvasView::contentsMouseMoveEvent(e);
}
-void CVBEditor::dragEnterEvent( QDragEnterEvent* e )
+void CVBEditor::dragEnterEvent( TQDragEnterEvent* e )
{
if (b_passEventsToView)
p_itemView->dragEnterEvent(e);
else
- QCanvasView::dragEnterEvent(e);
+ TQCanvasView::dragEnterEvent(e);
}
-void CVBEditor::dropEvent( QDropEvent* e )
+void CVBEditor::dropEvent( TQDropEvent* e )
{
if (b_passEventsToView)
p_itemView->dropEvent(e);
else
- QCanvasView::dropEvent(e);
+ TQCanvasView::dropEvent(e);
}
-void CVBEditor::enterEvent( QEvent * e )
+void CVBEditor::enterEvent( TQEvent * e )
{
if (b_passEventsToView)
p_itemView->enterEvent(e);
else
- QCanvasView::enterEvent(e);
+ TQCanvasView::enterEvent(e);
}
-void CVBEditor::leaveEvent( QEvent* e )
+void CVBEditor::leaveEvent( TQEvent* e )
{
if (b_passEventsToView)
p_itemView->leaveEvent(e);
else
- QCanvasView::leaveEvent(e);
+ TQCanvasView::leaveEvent(e);
}
-void CVBEditor::contentsWheelEvent( QWheelEvent *e )
+void CVBEditor::contentsWheelEvent( TQWheelEvent *e )
{
if (b_ignoreEvents)
{
@@ -566,14 +566,14 @@ void CVBEditor::contentsWheelEvent( QWheelEvent *e )
else
{
b_ignoreEvents = true;
- QCanvasView::wheelEvent(e);
+ TQCanvasView::wheelEvent(e);
b_ignoreEvents = false;
}
}
-void CVBEditor::viewportResizeEvent( QResizeEvent * e )
+void CVBEditor::viewportResizeEvent( TQResizeEvent * e )
{
- QCanvasView::viewportResizeEvent(e);
+ TQCanvasView::viewportResizeEvent(e);
p_itemView->p_itemDocument->requestEvent( ItemDocument::ItemDocumentEvent::ResizeCanvasToItems );
}
//END class CVBEditor