diff options
Diffstat (limited to 'kivio/kiviopart/kiviosdk/kivio_py_stencil.cpp')
-rw-r--r-- | kivio/kiviopart/kiviosdk/kivio_py_stencil.cpp | 178 |
1 files changed, 89 insertions, 89 deletions
diff --git a/kivio/kiviopart/kiviosdk/kivio_py_stencil.cpp b/kivio/kiviopart/kiviosdk/kivio_py_stencil.cpp index 0b34f46d..46526892 100644 --- a/kivio/kiviopart/kiviosdk/kivio_py_stencil.cpp +++ b/kivio/kiviopart/kiviosdk/kivio_py_stencil.cpp @@ -24,9 +24,9 @@ KivioView *view; #include "kivio_page.h" -#include <qpainter.h> -#include <qbrush.h> -#include <qcolor.h> +#include <tqpainter.h> +#include <tqbrush.h> +#include <tqcolor.h> #include <kdebug.h> #include <math.h> #include <KoZoomHandler.h> @@ -40,7 +40,7 @@ extern "C" { KivioPyStencil::KivioPyStencil() : KivioStencil() { - m_pConnectorTargets = new QPtrList<KivioConnectorTarget>; + m_pConnectorTargets = new TQPtrList<KivioConnectorTarget>; m_pConnectorTargets->setAutoDelete(true); static bool first_time = true; @@ -63,7 +63,7 @@ KivioPyStencil::KivioPyStencil() vars = Py_BuildValue( "{s:d,s:d,s:d,s:d,s:d,s:d,s:{},s:[],s:[],s:{}}", - "x", m_x, "y", m_y, "w", m_w, "h", m_h, "x2", x2, "y2", y2 , "style","connectors","connector_targets","shapes"); + "x", m_x, "y", m_y, "w", m_w, "h", m_h, "x2", x2, "y2", y2 , "style","connectors","connector_targets","tqshapes"); resizeCode = ""; } @@ -74,7 +74,7 @@ KivioPyStencil::~KivioPyStencil() } -int KivioPyStencil::init( QString initCode ) +int KivioPyStencil::init( TQString initCode ) { runPython(kivio_module); if ( !runPython( initCode ) ) @@ -93,16 +93,16 @@ int KivioPyStencil::init( QString initCode ) } -bool KivioPyStencil::loadXML( const QDomElement &e ) +bool KivioPyStencil::loadXML( const TQDomElement &e ) { - QDomNode node; - QDomElement ele; + TQDomNode node; + TQDomElement ele; node = e.firstChild(); while( !node.isNull() ) { - QString nodeName = node.nodeName(); + TQString nodeName = node.nodeName(); ele = node.toElement(); @@ -110,7 +110,7 @@ bool KivioPyStencil::loadXML( const QDomElement &e ) { resizeCode = XmlReadString( ele, "resizeCode", "" ); - QString sVars = XmlReadString( ele, "vars", "" ); + TQString sVars = XmlReadString( ele, "vars", "" ); PyObject* mainmod = PyImport_AddModule("__main__"); PyObject* gdic = PyModule_GetDict(mainmod); @@ -150,11 +150,11 @@ bool KivioPyStencil::loadXML( const QDomElement &e ) /** * Help function for loading from an XML node. */ -void KivioPyStencil::loadConnectorTargetListXML( const QDomElement &e ) +void KivioPyStencil::loadConnectorTargetListXML( const TQDomElement &e ) { - QDomNode node; - QDomElement ele; - QString nodeName; + TQDomNode node; + TQDomElement ele; + TQString nodeName; KivioConnectorTarget *pTarget; pTarget = m_pConnectorTargets->first(); @@ -175,15 +175,15 @@ void KivioPyStencil::loadConnectorTargetListXML( const QDomElement &e ) } -QDomElement KivioPyStencil::saveXML( QDomDocument &doc ) +TQDomElement KivioPyStencil::saveXML( TQDomDocument &doc ) { - QDomElement e = doc.createElement("KivioPyStencil"); + TQDomElement e = doc.createElement("KivioPyStencil"); XmlWriteString( e, "id", m_pSpawner->info()->id() ); XmlWriteString( e, "setId", m_pSpawner->set()->id() ); - QDomElement dE = doc.createElement("PyData"); + TQDomElement dE = doc.createElement("PyData"); // The python variables PyObject* mainmod = PyImport_AddModule("__main__"); @@ -203,7 +203,7 @@ QDomElement KivioPyStencil::saveXML( QDomDocument &doc ) if ( !PyRun_String(dump_code, Py_file_input, gdic, ldic) ) PyErr_Print(); - QString sVars = PyString_AsString( PyDict_GetItemString( ldic, "res") ); + TQString sVars = PyString_AsString( PyDict_GetItemString( ldic, "res") ); XmlWriteString( dE, "vars", sVars ); XmlWriteString( dE, "resizeCode", resizeCode ); @@ -212,8 +212,8 @@ QDomElement KivioPyStencil::saveXML( QDomDocument &doc ) // Save the target list - QDomElement clE = doc.createElement("KivioConnectorTargetList"); - QDomElement targetE; + TQDomElement clE = doc.createElement("KivioConnectorTargetList"); + TQDomElement targetE; KivioConnectorTarget *pTarget = m_pConnectorTargets->first(); while( pTarget ) { @@ -247,7 +247,7 @@ void KivioPyStencil::updateGeometry() KivioConnectorTarget *pTarget, *pOriginal; - QPtrList<KivioConnectorTarget> *pOriginalTargets = ((KivioPyStencilSpawner*)m_pSpawner)->targets(); + TQPtrList<KivioConnectorTarget> *pOriginalTargets = ((KivioPyStencilSpawner*)m_pSpawner)->targets(); pTarget = m_pConnectorTargets->first(); pOriginal = pOriginalTargets->first(); @@ -406,45 +406,45 @@ void KivioPyStencil::paint( KivioIntraStencilData *d, bool outlined ) { KoZoomHandler* zoomHandler = d->zoomHandler; - PyObject *shapes = PyDict_Values( PyDict_GetItemString( vars, "shapes" ) ); + PyObject *tqshapes = PyDict_Values( PyDict_GetItemString( vars, "tqshapes" ) ); - if ( !shapes ) { + if ( !tqshapes ) { return; } - int size = PyList_Size( shapes ); + int size = PyList_Size( tqshapes ); for ( int i=0; i<size; i++ ) { - PyObject *shape = PyList_GetItem( shapes, i ); - if ( !PyDict_Check(shape) ) + PyObject *tqshape = PyList_GetItem( tqshapes, i ); + if ( !PyDict_Check(tqshape) ) continue; int fill = KivioFillStyle::kcsNone; - // if style dosn't defined for shape, applay default for stencil + // if style dosn't defined for tqshape, applay default for stencil setStyle( d, PyDict_GetItemString( vars, "style" ) , fill ); - setStyle( d, shape, fill ); + setStyle( d, tqshape, fill ); if ( isSelected() ) - setStyle( d, PyDict_GetItemString( shape, "selected" ) , fill ); + setStyle( d, PyDict_GetItemString( tqshape, "selected" ) , fill ); if ( outlined ) fill = KivioFillStyle::kcsNone; - QString stype = getStringFromDict( shape, "type" ); + TQString stype = getStringFromDict( tqshape, "type" ); stype = stype.lower(); - double x = zoomHandler->zoomItX(getDoubleFromDict(shape,"x")); - double y = zoomHandler->zoomItY(getDoubleFromDict(shape,"y")); - double w = zoomHandler->zoomItX(getDoubleFromDict(shape,"w")); - double h = zoomHandler->zoomItY(getDoubleFromDict(shape,"h")); - //double x2 = zoomHandler->zoomItX(getDoubleFromDict(shape,"x2")); - //double y2 = zoomHandler->zoomItY(getDoubleFromDict(shape,"y2")); + double x = zoomHandler->zoomItX(getDoubleFromDict(tqshape,"x")); + double y = zoomHandler->zoomItY(getDoubleFromDict(tqshape,"y")); + double w = zoomHandler->zoomItX(getDoubleFromDict(tqshape,"w")); + double h = zoomHandler->zoomItY(getDoubleFromDict(tqshape,"h")); + //double x2 = zoomHandler->zoomItX(getDoubleFromDict(tqshape,"x2")); + //double y2 = zoomHandler->zoomItY(getDoubleFromDict(tqshape,"y2")); // get points list - QPtrList<KivioPoint> points; + TQPtrList<KivioPoint> points; points.setAutoDelete(true); - PyObject *pyPoints = PyDict_GetItemString( shape, "points" ); + PyObject *pyPoints = PyDict_GetItemString( tqshape, "points" ); if ( pyPoints && PyList_Check(pyPoints) ) { int size = PyList_Size(pyPoints); for ( int i=0; i<size; i++ ) { @@ -466,26 +466,26 @@ void KivioPyStencil::paint( KivioIntraStencilData *d, bool outlined ) if ( stype == "textbox" ) { int tf = vTextAlign() | hTextAlign(); - QFont f = textFont(); + TQFont f = textFont(); f.setPointSizeFloat(f.pointSizeFloat() * (((float)zoomHandler->zoom()) / 100.0)); d->painter->setFont( f ); - QString text = getStringFromDict(shape,"text"); + TQString text = getStringFromDict(tqshape,"text"); if ( !text.isEmpty() ) { - d->painter->drawText( int( x ), int( y ), int( w ), int( h ), tf | Qt::WordBreak, text ); + d->painter->drawText( int( x ), int( y ), int( w ), int( h ), tf | TQt::WordBreak, text ); } } if ( stype == "arc" ) { - double a1 = getDoubleFromDict(shape,"a1"); - double a2 = getDoubleFromDict(shape,"a2"); + double a1 = getDoubleFromDict(tqshape,"a1"); + double a2 = getDoubleFromDict(tqshape,"a2"); d->painter->drawArc(x,y,w,h,a1,a2); } if ( stype == "roundrect" ) { - double rx = zoomHandler->zoomItX(getDoubleFromDict(shape,"rx")); - double ry = zoomHandler->zoomItY(getDoubleFromDict(shape,"ry")); + double rx = zoomHandler->zoomItX(getDoubleFromDict(tqshape,"rx")); + double ry = zoomHandler->zoomItY(getDoubleFromDict(tqshape,"ry")); if (fill) { d->painter->fillRoundRect( x, y, w, h, rx, ry ); @@ -526,7 +526,7 @@ void KivioPyStencil::paint( KivioIntraStencilData *d, bool outlined ) -int KivioPyStencil::runPython(QString code) +int KivioPyStencil::runPython(TQString code) { view = dynamic_cast<KivioView*>(KoDocument::documentList()->first()->views().getFirst()); @@ -572,13 +572,13 @@ double KivioPyStencil::getDoubleFromDict( PyObject *dict, const char *key ) return 0.0; } -QString KivioPyStencil::getStringFromDict( PyObject *dict, const char *key ) +TQString KivioPyStencil::getStringFromDict( PyObject *dict, const char *key ) { PyObject *val = PyDict_GetItemString(dict,const_cast<char*>(key)); if ( val && PyString_Check(val) ) - return QString( PyString_AsString(val) ); + return TQString( PyString_AsString(val) ); - return QString(""); + return TQString(""); } @@ -606,19 +606,19 @@ KivioCollisionType KivioPyStencil::checkForCollision( KoPoint *pPoint, double ) int KivioPyStencil::resizeHandlePositions() { // Calculate the resize handle positions - int mask = KIVIO_RESIZE_HANDLE_POSITION_ALL; + int tqmask = KIVIO_RESIZE_HANDLE_POSITION_ALL; if( m_pProtection->at( kpWidth ) ) { - mask &= ~(krhpNE | krhpNW | krhpSW | krhpSE | krhpE | krhpW); + tqmask &= ~(krhpNE | krhpNW | krhpSW | krhpSE | krhpE | krhpW); } if( m_pProtection->at( kpHeight) ) { - mask &= ~(krhpNE | krhpNW | krhpSW | krhpSE | krhpN | krhpS); + tqmask &= ~(krhpNE | krhpNW | krhpSW | krhpSE | krhpN | krhpS); } - return mask; + return tqmask; } @@ -627,7 +627,7 @@ int KivioPyStencil::resizeHandlePositions() */ void KivioPyStencil::paintConnectorTargets( KivioIntraStencilData *pData ) { - QPixmap targetPic; + TQPixmap targetPic; KivioPainter *painter; double x, y; @@ -756,7 +756,7 @@ void KivioPyStencil::setStyle( KivioIntraStencilData *d, PyObject *s, int &fillS PyObject *color = PyDict_GetItemString(s,"color"); if ( color ) { - QColor c = readColor(color); + TQColor c = readColor(color); if ( c.isValid() ) { p->setFGColor(c); @@ -766,7 +766,7 @@ void KivioPyStencil::setStyle( KivioIntraStencilData *d, PyObject *s, int &fillS color = PyDict_GetItemString(s,"bgcolor"); if ( color ) { - QColor c = readColor(color); + TQColor c = readColor(color); if ( c.isValid() ) { p->setBGColor(c); @@ -776,7 +776,7 @@ void KivioPyStencil::setStyle( KivioIntraStencilData *d, PyObject *s, int &fillS color = PyDict_GetItemString(s,"textcolor"); if ( color ) { - QColor c = readColor(color); + TQColor c = readColor(color); if ( c.isValid() ) { p->setTextColor(c); @@ -793,7 +793,7 @@ void KivioPyStencil::setStyle( KivioIntraStencilData *d, PyObject *s, int &fillS PyObject *o_fillStyle = PyDict_GetItemString(s,"fillstyle"); if ( o_fillStyle ) { - QString sfill = getStringFromDict(s,"fillstyle"); + TQString sfill = getStringFromDict(s,"fillstyle"); if ( sfill == "solid" ) { fillStyle = KivioFillStyle::kcsSolid; @@ -804,8 +804,8 @@ void KivioPyStencil::setStyle( KivioIntraStencilData *d, PyObject *s, int &fillS } } - QString sfont = getStringFromDict(s,"font"); - QFont f; + TQString sfont = getStringFromDict(s,"font"); + TQFont f; int fontSize = (int)getDoubleFromDict(s,"fontsize"); if(!fontSize) { @@ -824,13 +824,13 @@ void KivioPyStencil::setStyle( KivioIntraStencilData *d, PyObject *s, int &fillS p->setFont(f); } -QColor KivioPyStencil::readColor( PyObject *color ) +TQColor KivioPyStencil::readColor( PyObject *color ) { if ( !color ) - return QColor(); + return TQColor(); if ( PyString_Check(color) ) { - return QColor( PyString_AsString(color) ); + return TQColor( PyString_AsString(color) ); } if ( PyList_Check(color) ) { @@ -847,12 +847,12 @@ QColor KivioPyStencil::readColor( PyObject *color ) if ( PyNumber_Check(bo) ) b = PyInt_AsLong( PyNumber_Int(bo)); - return QColor(r,g,b); + return TQColor(r,g,b); } } - return QColor(); + return TQColor(); } @@ -862,46 +862,46 @@ void KivioPyStencil::PyDebug( PyObject * o ) } -QColor KivioPyStencil::fgColor() +TQColor KivioPyStencil::fgColor() { - QColor color = readColor( PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "color" ) ); + TQColor color = readColor( PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "color" ) ); if ( color.isValid() ) return color; else - return QColor(0,0,0); + return TQColor(0,0,0); } -void KivioPyStencil::setFGColor( QColor c ) +void KivioPyStencil::setFGColor( TQColor c ) { PyDict_SetItemString( PyDict_GetItemString(vars,"style") , "color" , Py_BuildValue("[i,i,i]", c.red(), c.green(), c.blue() ) ) ; } -QColor KivioPyStencil::bgColor() +TQColor KivioPyStencil::bgColor() { - QColor color = readColor( PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "bgcolor" ) ); + TQColor color = readColor( PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "bgcolor" ) ); if ( color.isValid() ) return color; else - return QColor(0,0,0); + return TQColor(0,0,0); } -void KivioPyStencil::setBGColor( QColor c ) +void KivioPyStencil::setBGColor( TQColor c ) { PyDict_SetItemString( PyDict_GetItemString(vars,"style") , "bgcolor" , Py_BuildValue("[i,i,i]", c.red(), c.green(), c.blue() ) ) ; } -QColor KivioPyStencil::textColor() +TQColor KivioPyStencil::textColor() { - QColor color = readColor( PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "textcolor" ) ); + TQColor color = readColor( PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "textcolor" ) ); if ( color.isValid() ) return color; else - return QColor(0,0,0); + return TQColor(0,0,0); } -void KivioPyStencil::setTextColor( QColor c ) +void KivioPyStencil::setTextColor( TQColor c ) { PyDict_SetItemString( PyDict_GetItemString(vars,"style") , "textcolor" , Py_BuildValue("[i,i,i]", c.red(), c.green(), c.blue() ) ) ; } @@ -922,27 +922,27 @@ void KivioPyStencil::setLineWidth( double w ) } -void KivioPyStencil::setText( const QString &s ) +void KivioPyStencil::setText( const TQString &s ) { - PyObject *to = PyDict_GetItemString( PyDict_GetItemString(vars,"shapes"), "text" ); + PyObject *to = PyDict_GetItemString( PyDict_GetItemString(vars,"tqshapes"), "text" ); if ( to ) PyDict_SetItemString(to, "text", Py_BuildValue("s", s.latin1() )); } -QString KivioPyStencil::text() +TQString KivioPyStencil::text() { - PyObject *to = PyDict_GetItemString( PyDict_GetItemString(vars,"shapes"), "text" ); + PyObject *to = PyDict_GetItemString( PyDict_GetItemString(vars,"tqshapes"), "text" ); if ( to ) { return getStringFromDict(to, "text"); } - return QString(""); + return TQString(""); } -void KivioPyStencil::setTextFont( const QFont &f ) +void KivioPyStencil::setTextFont( const TQFont &f ) { double fs = f.pointSizeFloat(); - QString family = f.family(); + TQString family = f.family(); int bold = f.bold(); int italic = f.italic(); @@ -955,7 +955,7 @@ void KivioPyStencil::setTextFont( const QFont &f ) PyDict_SetItemString( PyDict_GetItemString(vars,"style") , "underline" , Py_BuildValue("i",underline ) ) ; } -QFont KivioPyStencil::textFont() +TQFont KivioPyStencil::textFont() { PyObject *fn = PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "font" ); PyObject *fs = PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "fontsize" ); @@ -963,7 +963,7 @@ QFont KivioPyStencil::textFont() PyObject *it = PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "italic" ); PyObject *ul = PyDict_GetItemString( PyDict_GetItemString(vars,"style"), "underline" ); - QFont f; + TQFont f; if ( fs ) if ( PyNumber_Check(fs)) @@ -996,7 +996,7 @@ int KivioPyStencil::hTextAlign() if ( PyNumber_Check(hta) ) return ( PyInt_AsLong( PyNumber_Int(hta))); - return Qt::AlignHCenter; + return TQt::AlignHCenter; } int KivioPyStencil::vTextAlign() @@ -1007,7 +1007,7 @@ int KivioPyStencil::vTextAlign() if ( PyNumber_Check(vta) ) return ( PyInt_AsLong( PyNumber_Int(vta))); - return Qt::AlignVCenter; + return TQt::AlignVCenter; } void KivioPyStencil::setHTextAlign(int hta) |