# HG changeset patch # User insilmaril # Date 1165609136 0 # Node ID c2a05fa925a1c6ca6af79e8b00a005f58121b17e # Parent 5db8dfd30ea25ce1f119e2a4239c061425973b06 1.6.1 Port to QGraphics diff -r 5db8dfd30ea2 -r c2a05fa925a1 branchobj.cpp --- a/branchobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/branchobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -37,25 +37,25 @@ depth=-1; } -BranchObj::BranchObj (Q3Canvas* c):OrnamentedObj (c) +BranchObj::BranchObj (QGraphicsScene* s):OrnamentedObj (s) { -// cout << "Const BranchObj (c) called from MapCenterObj (c)\n"; +// cout << "Const BranchObj (s) called from MapCenterObj (s)\n"; parObj=NULL; - canvas=c; + scene=s; } -BranchObj::BranchObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c) +BranchObj::BranchObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s) { -// cout << "Const BranchObj (c,p)\n"; - canvas=c; +// cout << "Const BranchObj (s,p)\n"; + scene=s; setParObj (p); depth=p->getDepth()+1; if (depth==1) // Calc angle to mapCenter if I am a mainbranch // needed for reordering the mainbranches clockwise // around mapcenter - angle=getAngle (QPoint ((int)(x() - parObj->getChildPos().x() ), - (int)(y() - parObj->getChildPos().y() ) ) ); + angle=getAngle (QPointF (x() - parObj->getChildPos().x() , + (y() - parObj->getChildPos().y() ) ) ); init(); } @@ -93,7 +93,7 @@ absPos+=parObj->getChildPos(); } - lastSelectedBranch=-1; + lastSelectedBranch=0; setChildObj(this); @@ -171,7 +171,7 @@ return xlink.count(); } -void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPoint m, int off) +void BranchObj::setParObjTmp(LinkableMapObj* lmo, QPointF m, int off) { // Temporary link to lmo // m is position of mouse pointer @@ -202,17 +202,17 @@ if (depth==1) { // new parent is the mapcenter itself - QPoint p= normalise ( QPoint (m.x() - o->getChildPos().x(), + QPointF p= normalise ( QPointF (m.x() - o->getChildPos().x(), m.y() - o->getChildPos().y() )); if (p.x()<0) p.setX( p.x()-bbox.width() ); move2RelPos (p); } else { - int y; + qreal y; if (off==0) { // new parent is just a branch, link to it - QRect t=o->getBBoxSizeWithChilds(); + QRectF t=o->getBBoxSizeWithChilds(); if (o->getLastBranch()) y=t.y() + t.height() ; else @@ -547,7 +547,7 @@ positionBBox(); } -void BranchObj::move (QPoint p) +void BranchObj::move (QPointF p) { move (p.x(), p.y()); } @@ -560,7 +560,7 @@ positionBBox(); } -void BranchObj::moveBy (QPoint p) +void BranchObj::moveBy (QPointF p) { moveBy (p.x(), p.y()); } @@ -568,13 +568,13 @@ void BranchObj::positionBBox() { - QPoint ap=getAbsPos(); + QPointF ap=getAbsPos(); bbox.moveTopLeft (ap); positionContents(); setSelBox(); // set the frame - frame->setRect(QRect(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); + frame->setRect(QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() ) ); // Update links to other branches for (int i=0; igetSize(); - int heading_w=(int) heading_r.width() ; - int heading_h=(int) heading_r.height() ; - QSize sysflags_r=systemFlags->getSize(); - int sysflags_h=sysflags_r.height(); - int sysflags_w=sysflags_r.width(); - QSize stanflags_r=standardFlags->getSize(); - int stanflags_h=stanflags_r.height(); - int stanflags_w=stanflags_r.width(); - int w; - int h; + QSizeF heading_r=heading->getSize(); + qreal heading_w=(qreal) heading_r.width() ; + qreal heading_h=(qreal) heading_r.height() ; + QSizeF sysflags_r=systemFlags->getSize(); + qreal sysflags_h=sysflags_r.height(); + qreal sysflags_w=sysflags_r.width(); + QSizeF stanflags_r=standardFlags->getSize(); + qreal stanflags_h=stanflags_r.height(); + qreal stanflags_w=stanflags_r.width(); + qreal w; + qreal h; // set width to sum of all widths w=heading_w + sysflags_w + stanflags_w; @@ -602,13 +602,13 @@ h=max (h,heading_h); // Save the dimension of flags and heading - ornamentsBBox.setSize ( QSize(w,h)); + ornamentsBBox.setSize ( QSizeF(w,h)); // clickBox includes Flags and Heading clickBox.setSize (ornamentsBBox.size() ); // Floatimages - QPoint rp; + QPointF rp; topPad=botPad=leftPad=rightPad=0; if (includeImagesVer || includeImagesHor) @@ -652,7 +652,7 @@ h+=frame->getBorder(); // Finally set size - bbox.setSize (QSize (w,h)); + bbox.setSize (QSizeF (w,h)); } void BranchObj::setDockPos() @@ -660,16 +660,16 @@ // Sets childpos and parpos depending on orientation if (getOrientation()==OrientLeftOfCenter ) { - childPos=QPoint (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() ); - parPos=QPoint (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() ); + childPos=QPointF (ornamentsBBox.bottomLeft().x(), ornamentsBBox.bottomLeft().y() ); + parPos=QPointF (ornamentsBBox.bottomRight().x(),ornamentsBBox.bottomRight().y() ); } else { - childPos=QPoint (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() ); - parPos=QPoint (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() ); + childPos=QPointF (ornamentsBBox.bottomRight().x(), ornamentsBBox.bottomRight().y() ); + parPos=QPointF (ornamentsBBox.bottomLeft().x(),ornamentsBBox.bottomLeft().y() ); } } -LinkableMapObj* BranchObj::findMapObj(QPoint p, LinkableMapObj* excludeLMO) +LinkableMapObj* BranchObj::findMapObj(QPointF p, LinkableMapObj* excludeLMO) { // Search branches LinkableMapObj *lmo; @@ -735,7 +735,7 @@ return false; } -QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPoint& offset) +QString BranchObj::saveToDir (const QString &tmpdir,const QString &prefix, const QPointF& offset) { if (hidden) return ""; @@ -757,10 +757,10 @@ if (!((BranchObj*)(parObj))->isScrolled() ) { areaAttr= - attribut("x1",QString().setNum(absPos.x()-offset.x(),10)) + - attribut("y1",QString().setNum(absPos.y()-offset.y(),10)) + - attribut("x2",QString().setNum(absPos.x()+width()-offset.x(),10)) + - attribut("y2",QString().setNum(absPos.y()+height()-offset.y(),10)); + attribut("x1",QString().setNum(absPos.x()-offset.x())) + + attribut("y1",QString().setNum(absPos.y()-offset.y())) + + attribut("x2",QString().setNum(absPos.x()+width()-offset.x())) + + attribut("y2",QString().setNum(absPos.y()+height()-offset.y())); } else areaAttr=""; @@ -913,7 +913,7 @@ FloatImageObj* BranchObj::addFloatImage () { - FloatImageObj *newfi=new FloatImageObj (canvas,this); + FloatImageObj *newfi=new FloatImageObj (scene,this); floatimage.append (newfi); if (hasScrolledParent(this) ) newfi->setVisibility (false); @@ -929,7 +929,7 @@ FloatImageObj* BranchObj::addFloatImage (FloatImageObj *fio) { - FloatImageObj *newfi=new FloatImageObj (canvas,this); + FloatImageObj *newfi=new FloatImageObj (scene,this); floatimage.append (newfi); newfi->copy (fio); if (hasScrolledParent(this) ) @@ -1000,7 +1000,7 @@ BranchObj* BranchObj::addBranch() { - BranchObj* newbo=new BranchObj(canvas,this); + BranchObj* newbo=new BranchObj(scene,this); branch.append (newbo); newbo->setParObj(this); newbo->setDefAttr(NewBranch); @@ -1016,7 +1016,7 @@ BranchObj* BranchObj::addBranch(BranchObj* bo) { - BranchObj* newbo=new BranchObj(canvas,this); + BranchObj* newbo=new BranchObj(scene,this); branch.append (newbo); newbo->copy(bo); newbo->setParObj(this); @@ -1129,22 +1129,25 @@ BranchObj* BranchObj::getLastSelectedBranch () { - if (lastSelectedBranch>=0) - { - BranchObj* bo=branch.at(lastSelectedBranch); - if (bo) return bo; - } - return branch.first(); + if (lastSelectedBranch>=0 && branch.size()>0) + return branch.at(lastSelectedBranch); + return NULL; } BranchObj* BranchObj::getFirstBranch () { - return branch.first(); + if (branch.size()>0) + return branch.first(); + else + return NULL; } BranchObj* BranchObj::getLastBranch () { - return branch.last(); + if (branch.size()>0) + return branch.last(); + else + return NULL; } BranchObj* BranchObj::getBranchNum (int i) @@ -1238,9 +1241,9 @@ } } -void BranchObj::alignRelativeTo (QPoint ref) +void BranchObj::alignRelativeTo (QPointF ref) { - int th = bboxTotal.height(); + qreal th = bboxTotal.height(); // TODO testing /* cout << "BO::alignRelTo "<getChildPos().x() ), + angle=getAngle (QPointF ((int)(x() - parObj->getChildPos().x() ), (int)(y() - parObj->getChildPos().y() ) ) ); } } @@ -1296,7 +1299,7 @@ if (scrolled) return; // Set reference point for alignment of childs - QPoint ref2; + QPointF ref2; if (orientation==OrientLeftOfCenter) ref2.setX(bbox.topLeft().x() - linkwidth); else @@ -1336,11 +1339,11 @@ // changes its height, // all upper LMOs have to change, too. calcBBoxSizeWithChilds(); - updateLink(); // This update is needed if the canvas is resized + updateLink(); // This update is needed if the scene is resized // due to excessive moving of a FIO // FIXME really needed? reposition is also called from updateLink... - alignRelativeTo ( QPoint (absPos.x(), + alignRelativeTo ( QPointF (absPos.x(), absPos.y()-(bboxTotal.height()-bbox.height())/2) ); //FIXME branch.sort(); positionBBox(); // Reposition bbox and contents @@ -1348,7 +1351,7 @@ { // This is only important for moving branches: // For editing a branch it isn't called... - alignRelativeTo ( QPoint (absPos.x(), + alignRelativeTo ( QPointF (absPos.x(), absPos.y()-(bboxTotal.height()-bbox.height())/2) ); } } @@ -1361,9 +1364,9 @@ } -QRect BranchObj::getTotalBBox() +QRectF BranchObj::getTotalBBox() { - QRect r=bbox; + QRectF r=bbox; if (scrolled) return r; @@ -1378,7 +1381,7 @@ return r; } -QRect BranchObj::getBBoxSizeWithChilds() +QRectF BranchObj::getBBoxSizeWithChilds() { return bboxTotal; } @@ -1419,8 +1422,8 @@ return; } - QRect r(0,0,0,0); - QRect br; + QRectF r(0,0,0,0); + QRectF br; // Now calculate recursivly // sum of heights // maximum of widths diff -r 5db8dfd30ea2 -r c2a05fa925a1 branchobj.h --- a/branchobj.h Thu Nov 23 16:18:26 2006 +0000 +++ b/branchobj.h Fri Dec 08 20:18:56 2006 +0000 @@ -14,8 +14,8 @@ class BranchObj:public OrnamentedObj { public: BranchObj (); - BranchObj (Q3Canvas*); - BranchObj (Q3Canvas*, LinkableMapObj* parent); + BranchObj (QGraphicsScene*); + BranchObj (QGraphicsScene*, LinkableMapObj* parent); ~BranchObj (); bool operator< ( const BranchObj & ); bool operator== ( const BranchObj & ); @@ -28,7 +28,7 @@ virtual int countBranches(); virtual int countFloatImages(); virtual int countXLinks(); - virtual void setParObjTmp (LinkableMapObj*,QPoint,int);// Only for moving Obj around + virtual void setParObjTmp (LinkableMapObj*,QPointF,int);// Only for moving Obj around virtual void unsetParObjTmp(); // reuse original ParObj virtual void unScroll(); @@ -50,19 +50,19 @@ virtual void positionContents(); virtual void move (double x,double y); - virtual void move (QPoint); + virtual void move (QPointF); virtual void moveBy (double x,double y); - virtual void moveBy (QPoint); + virtual void moveBy (QPointF); virtual void positionBBox(); virtual void calcBBoxSize(); virtual void setDockPos(); - virtual LinkableMapObj* findMapObj(QPoint,LinkableMapObj*); // find MapObj + virtual LinkableMapObj* findMapObj(QPointF,LinkableMapObj*); // find MapObj virtual void setHeading (QString); virtual void setHideTmp (HideTmpMode); virtual bool hasHiddenExportParent (BranchObj*); - virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data recursivly to tempdir + virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data recursivly to tempdir virtual void addXLink (XLinkObj*); virtual void removeXLinkRef (XLinkObj*);// Remove ref in list virtual void deleteXLink (XLinkObj*); // remove references and delete XLinkObj @@ -105,12 +105,12 @@ virtual bool canMoveBranchDown(); virtual BranchObj* moveBranchDown(BranchObj*); virtual BranchObj* moveBranchTo (BranchObj*, int); - virtual void alignRelativeTo(const QPoint ); + virtual void alignRelativeTo(const QPointF ); virtual void reposition(); virtual void unsetAllRepositionRequests(); - virtual QRect getTotalBBox(); // return BBox including childs - virtual QRect getBBoxSizeWithChilds(); // return size of BBox including childs + virtual QRectF getTotalBBox(); // return BBox including childs + virtual QRectF getBBoxSizeWithChilds(); // return size of BBox including childs virtual void calcBBoxSizeWithChilds(); // calc size of BBox including childs recursivly virtual void select(); diff -r 5db8dfd30ea2 -r c2a05fa925a1 demos/todo.vym Binary file demos/todo.vym has changed diff -r 5db8dfd30ea2 -r c2a05fa925a1 exportxhtmldialog.cpp --- a/exportxhtmldialog.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/exportxhtmldialog.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -386,17 +386,16 @@ spath.replace ("%f",fpath); QStringList args=QStringList::split (' ',spath,false); - scriptProc->clearArguments(); - scriptProc->setArguments (args); - p.addOutput ("vym is executing: \n" + scriptProc->arguments().join(" ") ); - if (!scriptProc->start() ) + p.addOutput ("vym is executing: \n" + spath+" "+args.join(" ") ); + scriptProc->start (spath,args); + if (!scriptProc->waitForStarted() ) { QMessageBox::critical( 0, tr( "Critical Error" ), tr("Could not start %1").arg(spath) ); } else { scriptProc->waitFinished(); - if (!scriptProc->normalExit() ) + if (scriptProc->exitStatus()!=QProcess::NormalExit ) QMessageBox::critical( 0, tr( "Critical Error" ), tr("%1 didn't exit normally").arg(spath) + scriptProc->getErrout() ); diff -r 5db8dfd30ea2 -r c2a05fa925a1 file.cpp --- a/file.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/file.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -1,6 +1,4 @@ -#include -#include -//Added by qt3to4: +#include #include #include #include @@ -141,15 +139,15 @@ ErrorCode err=success; // zip the temporary directory + QStringList args; Process *zipProc=new Process (); - zipProc->clearArguments(); - zipProc->setWorkingDirectory (QDir(zipDir)); - zipProc->addArgument ("zip"); - zipProc->addArgument ("-r"); - zipProc->addArgument (zipName); - zipProc->addArgument ("."); + zipProc->setWorkingDirectory (zipDir.path()); + args <<"-r"; + args <start() ) + zipProc->start ("zip",args); + if (!zipProc->waitForStarted() ) { // zip could not be started QMessageBox::critical( 0, QObject::tr( "Critical Error" ), @@ -158,8 +156,8 @@ } else { // zip could be started - zipProc->waitFinished(); - if (!zipProc->normalExit() ) + zipProc->waitForFinished(); + if (zipProc->exitStatus()!=QProcess::NormalExit ) { QMessageBox::critical( 0, QObject::tr( "Critical Error" ), QObject::tr("zip didn't exit normally")+ @@ -167,10 +165,10 @@ err=aborted; } else { - if (zipProc->exitStatus()>0) + if (zipProc->exitCode()>0) { QMessageBox::critical( 0, QObject::tr( "Critical Error" ), - QString("zip exit code: %1").arg(zipProc->exitStatus() )+ + QString("zip exit code: %1").arg(zipProc->exitCode() )+ "\n" + zipProc->getErrout() ); err=aborted; } @@ -184,16 +182,16 @@ ErrorCode err=success; // Try to unzip file + QStringList args; Process *zipProc=new Process (); - zipProc->clearArguments(); - zipProc->setWorkingDirectory (zipDir); - zipProc->addArgument ("unzip"); - zipProc->addArgument ("-o"); // overwrite existing files! - zipProc->addArgument (zipName ); - zipProc->addArgument ("-d"); - zipProc->addArgument (zipDir.path()); + zipProc->setWorkingDirectory (zipDir.path()); + args << "-o"; // overwrite existing files! + args << zipName ; + args << "-d"; + args << zipDir.path(); - if (!zipProc->start() ) + zipProc->start ("unzip",args); + if (!zipProc->waitForStarted() ) { QMessageBox::critical( 0, QObject::tr( "Critical Error" ), QObject::tr("Couldn't start unzip to decompress data.")); @@ -201,8 +199,8 @@ } else { - zipProc->waitFinished(); - if (!zipProc->normalExit() ) + zipProc->waitForFinished(); + if (zipProc->exitStatus()!=QProcess::NormalExit ) { QMessageBox::critical( 0,QObject::tr( "Critical Error" ), QObject::tr("unzip didn't exit normally") + @@ -210,7 +208,7 @@ err=aborted; } else { - if (zipProc->exitStatus()>0) + if (zipProc->exitCode()>0) { if (zipProc->exitStatus()==9) // no zipped file, but maybe .xml or old version? Try again. @@ -218,7 +216,7 @@ else { QMessageBox::critical( 0, QObject::tr( "Critical Error" ), - QString("unzip exit code: %1").arg(zipProc->exitStatus() ) + + QString("unzip exit code: %1").arg(zipProc->exitCode() ) + zipProc->getErrout() ); err=aborted; } diff -r 5db8dfd30ea2 -r c2a05fa925a1 flagobj.cpp --- a/flagobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/flagobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -9,9 +9,9 @@ init (); } -FlagObj::FlagObj(Q3Canvas* c):MapObj(c) +FlagObj::FlagObj(QGraphicsScene* s):MapObj(s) { -// cout << "Const FlagObj canvas="<move (absPos.x(), absPos.y() ); + icon=new ImageObj (scene); + icon->setPos (absPos.x(), absPos.y() ); state=false; action=NULL; } @@ -53,7 +53,7 @@ void FlagObj::move(double x, double y) { MapObj::move(x,y); - icon->move(x,y); + icon->setPos(x,y); positionBBox(); } @@ -117,7 +117,7 @@ QPixmap FlagObj::getPixmap() { - return icon->getPixmap(); + return icon->pixmap(); } void FlagObj::setAction (QAction* a) @@ -150,6 +150,8 @@ if (visible) { icon->setVisibility (true); + //icon->setPos (100,100); + //icon->setPos (rand()%100,rand()%130); calcBBoxSize(); } } @@ -191,12 +193,12 @@ { if (visible && state) { - bbox.setSize ( QSize( + bbox.setSize ( QSizeF( icon->boundingRect().width(), icon->boundingRect().height() ) ); } else { - bbox.setSize (QSize(0,0)); + bbox.setSize (QSizeF(0,0)); } clickBox.setSize (bbox.size()); } diff -r 5db8dfd30ea2 -r c2a05fa925a1 flagobj.h --- a/flagobj.h Thu Nov 23 16:18:26 2006 +0000 +++ b/flagobj.h Fri Dec 08 20:18:56 2006 +0000 @@ -2,9 +2,7 @@ #define FLAGOBJ_H -#include -#include -//Added by qt3to4: +#include #include #include "mapobj.h" @@ -14,7 +12,7 @@ class FlagObj:public MapObj { public: FlagObj (); - FlagObj (Q3Canvas*); + FlagObj (QGraphicsScene*); FlagObj (FlagObj*); ~FlagObj (); virtual void init (); diff -r 5db8dfd30ea2 -r c2a05fa925a1 flagrowobj.cpp --- a/flagrowobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/flagrowobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -11,9 +11,9 @@ init (); } -FlagRowObj::FlagRowObj(Q3Canvas* c):MapObj(c) +FlagRowObj::FlagRowObj(QGraphicsScene* s):MapObj(s) { -// cout << "Const FlagRowObj\n"; +// cout << "Const FlagRowObj (s)\n"; init (); } @@ -53,11 +53,11 @@ void FlagRowObj::move(double x, double y) { MapObj::move(x,y); - int dx=0; + qreal dx=0; for (int i=0; imove(x+dx,y); - dx+=QSize(flag.at(i)->getSize() ).width(); + dx+=QSizeF(flag.at(i)->getSize() ).width(); } } @@ -75,9 +75,9 @@ FlagObj* FlagRowObj::addFlag (FlagObj *fo) { - FlagObj *newfo=new FlagObj (canvas); + FlagObj *newfo=new FlagObj (scene); + newfo->copy (fo); // create a deep copy of fo newfo->move (absPos.x() + bbox.width(), absPos.y() ); - newfo->copy (fo); // create a deep copy of fo flag.append(newfo); calcBBoxSize(); positionBBox(); @@ -92,8 +92,8 @@ void FlagRowObj::calcBBoxSize() { - QSize size(0,0); - QSize boxsize(0,0); + QSizeF size(0,0); + QSizeF boxsize(0,0); for (int i=0; igetSize(); @@ -107,7 +107,7 @@ clickBox.setSize (boxsize); } -QString FlagRowObj::getFlagName (const QPoint &p) +QString FlagRowObj::getFlagName (const QPointF &p) { if (!inBox (p)) return ""; for (int i=0; ideactivate(); + if (flag.at(i)->isActive()) flag.at(i)->deactivate(); } else qWarning ("FlagRowObj::deactivateAll mustn't be called for ordinary rows"); } @@ -222,7 +227,11 @@ { for (int i=0; igetGroup() && keepfo!=flag.at(i)) + { flag.remove(flag.at(i)); + //FIXME also delete flags + //and better only delete flags that are really set + } } } } diff -r 5db8dfd30ea2 -r c2a05fa925a1 flagrowobj.h --- a/flagrowobj.h Thu Nov 23 16:18:26 2006 +0000 +++ b/flagrowobj.h Fri Dec 08 20:18:56 2006 +0000 @@ -9,7 +9,7 @@ class FlagRowObj:public QObject,public MapObj { public: FlagRowObj (); - FlagRowObj (Q3Canvas*); + FlagRowObj (QGraphicsScene *); ~FlagRowObj (); virtual void init (); virtual void copy (FlagRowObj*); @@ -20,7 +20,7 @@ virtual FlagObj* addFlag (FlagObj *fo); // make deep copy of FlagObj virtual void positionBBox(); virtual void calcBBoxSize(); - virtual QString getFlagName (const QPoint &p); // Find flag by position + virtual QString getFlagName (const QPointF &p); // Find flag by position bool isActive(const QString&); void toggle (const QString&,bool); void activate(const QString&); diff -r 5db8dfd30ea2 -r c2a05fa925a1 floatimageobj.cpp --- a/floatimageobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/floatimageobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -1,8 +1,8 @@ +#include +#include + #include "floatimageobj.h" #include "branchobj.h" -//Added by qt3to4: -#include - ///////////////////////////////////////////////////////////////// // FloatImageObj @@ -19,15 +19,15 @@ depth=-1; } -FloatImageObj::FloatImageObj (Q3Canvas* c):FloatObj(c) +FloatImageObj::FloatImageObj (QGraphicsScene* s):FloatObj(s) { - // cout << "Const FloatImageObj (c) called from MapCenterObj (c)\n"; + // cout << "Const FloatImageObj (s) called from MapCenterObj (s)\n"; setParObj (this); init(); depth=-1; } -FloatImageObj::FloatImageObj (Q3Canvas* c, OrnamentedObj* p):FloatObj(c,p) +FloatImageObj::FloatImageObj (QGraphicsScene *s, OrnamentedObj* p):FloatObj(s,p) { // cout << "Const FloatImageObj (c,p)\n"; init(); @@ -41,13 +41,12 @@ void FloatImageObj::init () { - icon=new ImageObj (canvas); - icon->move (absPos.x(), absPos.y() ); + icon=new ImageObj (scene); + icon->setPos (absPos.x(), absPos.y() ); icon->setVisibility (true); - setZ (Z_FLOATIMG); - bbox.setSize (QSize(icon->size().width(), icon->size().height())); - clickBox.setSize (QSize(icon->size().width(), icon->size().height())); - filename=""; + setZValue (Z_FLOATIMG); + bbox.setSize (QSizeF(icon->boundingRect().width(), icon->boundingRect().height())); + clickBox.setSize (QSizeF(icon->boundingRect().width(), icon->boundingRect().height()));filename=""; originalFilename="no original name available"; filetype=""; saveInMap=true; @@ -68,35 +67,41 @@ positionBBox(); } -void FloatImageObj::setZ (const int &i) +void FloatImageObj::setZValue (const int &i) { - icon->setZ (i); + icon->setZValue (i); zPlane=i; } int FloatImageObj::z () { - return qRound (icon->z()); + return qRound (icon->zValue()); } void FloatImageObj::load (const QPixmap &pixmap) { - icon->load(pixmap); - bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8)); - clickBox.setSize (QSize(icon->size().width()+8, icon->size().height()+8)); - positionBBox(); - filetype="PNG"; - filename="No filename given"; + icon->load(pixmap); + bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8)); + clickBox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8)); + selbox->setRect(0,0,clickBox.width(),clickBox.height()); + positionBBox(); + filetype="PNG"; + filename="No filename given"; } bool FloatImageObj::load (const QString &fn) { - if( icon->load (fn)) + QImageReader reader (fn); + QImage img; + + if( reader.read (&img)) { - bbox.setSize (QSize(icon->size().width()+8, icon->size().height()+8)); + icon->setPixmap(QPixmap::fromImage(img)); + bbox.setSize (QSizeF(icon->boundingRect().width()+8, icon->boundingRect().height()+8)); + selbox->setRect(0,0,clickBox.width(),clickBox.height()); positionBBox(); filename=fn; -//FIXME QT3 was filetype=QPixmap::imageFormat (fn); + filetype=reader.format(); setOriginalFilename (fn); return true; } else @@ -135,18 +140,19 @@ void FloatImageObj::move (double x, double y) { FloatObj::move(x,y); - icon->move (x+4,y+4); + icon->setPos (x+4,y+4); positionBBox(); } -void FloatImageObj::move (QPoint p) +void FloatImageObj::move (QPointF p) { - move (p.x(), p.y()); + OrnamentedObj::move (p.x(),p.y()); } void FloatImageObj::positionBBox() { clickBox=bbox; + setSelBox(); } void FloatImageObj::calcBBoxSize() @@ -206,12 +212,12 @@ } -QRect FloatImageObj::getTotalBBox() +QRectF FloatImageObj::getTotalBBox() { return bbox; } -QRect FloatImageObj::getBBoxSizeWithChilds() +QRectF FloatImageObj::getBBoxSizeWithChilds() { //FIXME abstract in linkablemapobj.h, not calculated return bboxTotal; diff -r 5db8dfd30ea2 -r c2a05fa925a1 floatimageobj.h --- a/floatimageobj.h Thu Nov 23 16:18:26 2006 +0000 +++ b/floatimageobj.h Fri Dec 08 20:18:56 2006 +0000 @@ -9,12 +9,12 @@ class FloatImageObj:public FloatObj { public: FloatImageObj (); - FloatImageObj (Q3Canvas*); - FloatImageObj (Q3Canvas*, OrnamentedObj* parent); + FloatImageObj (QGraphicsScene*); + FloatImageObj (QGraphicsScene*, OrnamentedObj* parent); ~FloatImageObj (); virtual void init (); virtual void copy (FloatImageObj*); - virtual void setZ (const int&); + virtual void setZValue (const int&); virtual int z(); virtual void load (const QPixmap &); @@ -24,11 +24,11 @@ virtual QString getOriginalFilename(); virtual void setVisibility(bool); // set vis. for w virtual void move (double x,double y); - virtual void move (QPoint); + virtual void move (QPointF); virtual void positionBBox(); virtual void calcBBoxSize(); - virtual QRect getTotalBBox(); // return BBox including childs - virtual QRect getBBoxSizeWithChilds(); // return size of BBox including childs + virtual QRectF getTotalBBox(); // return BBox including childs + virtual QRectF getBBoxSizeWithChilds(); // return size of BBox including childs virtual void calcBBoxSizeWithChilds(); // calc size of BBox including childs recursivly virtual QString saveToDir(const QString &,const QString&); virtual void resetSaveCounter(); diff -r 5db8dfd30ea2 -r c2a05fa925a1 floatobj.cpp --- a/floatobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/floatobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -14,17 +14,17 @@ depth=-1; } -FloatObj::FloatObj (Q3Canvas* c):OrnamentedObj(c) +FloatObj::FloatObj (QGraphicsScene* s):OrnamentedObj(s) { -// cout << "Const FloatObj (c) called from MapCenterObj (c)\n"; +// cout << "Const FloatObj (s) called from MapCenterObj (s)\n"; setParObj (this); init(); depth=-1; } -FloatObj::FloatObj (Q3Canvas* c, LinkableMapObj* p):OrnamentedObj (c) +FloatObj::FloatObj (QGraphicsScene* s, LinkableMapObj* p):OrnamentedObj (s) { -// cout << "Const FloatObj (c,p)\n"; +// cout << "Const FloatObj (s,p)\n"; setParObj (p); depth=p->getDepth()+1; init(); @@ -50,12 +50,12 @@ setVisibility (other->visible); } -void FloatObj::setZ(const int &i) +void FloatObj::setZValue(const int &i) { zPlane=i; } -int FloatObj::z() +int FloatObj::zValue() { return zPlane; } @@ -73,12 +73,14 @@ void FloatObj::move (double x, double y) { MapObj::move(x,y); - selbox->move(x,y); + //selbox->setPos(x,y); + selbox->rect().moveTo (QPointF (x,y)); } -void FloatObj::move (QPoint p) +void FloatObj::move (QPointF p) { - move (p.x(), p.y()); + MapObj::move (p); + selbox->rect().moveTo (p); } void FloatObj::setDockPos() @@ -93,12 +95,12 @@ updateLink(); } -QRect FloatObj::getTotalBBox() +QRectF FloatObj::getTotalBBox() { return bbox; } -QRect FloatObj::getBBoxSizeWithChilds() +QRectF FloatObj::getBBoxSizeWithChilds() { return bboxTotal; } diff -r 5db8dfd30ea2 -r c2a05fa925a1 floatobj.h --- a/floatobj.h Thu Nov 23 16:18:26 2006 +0000 +++ b/floatobj.h Fri Dec 08 20:18:56 2006 +0000 @@ -7,24 +7,24 @@ class FloatObj:public OrnamentedObj { public: FloatObj (); - FloatObj (Q3Canvas*); - FloatObj (Q3Canvas*, LinkableMapObj* parent); + FloatObj (QGraphicsScene*); + FloatObj (QGraphicsScene*, LinkableMapObj* parent); ~FloatObj (); virtual void init (); virtual void copy (FloatObj*); virtual bool load (const QString&)=0; - virtual void setZ(const int&); // set zPlane - virtual int z(); + virtual void setZValue(const int&); // set zPlane + virtual int zValue(); virtual void setFloatExport (const bool &); virtual bool getFloatExport (); virtual void move (double,double); - virtual void move (QPoint); + virtual void move (QPointF); virtual void setDockPos(); virtual void reposition(); - virtual QRect getTotalBBox(); // return BBox including childs - virtual QRect getBBoxSizeWithChilds(); // return size of BBox including childs + virtual QRectF getTotalBBox(); // return BBox including childs + virtual QRectF getBBoxSizeWithChilds(); // return size of BBox including childs virtual void resetSaveCounter()=0; diff -r 5db8dfd30ea2 -r c2a05fa925a1 frameobj.cpp --- a/frameobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/frameobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -11,7 +11,7 @@ init (); } -FrameObj::FrameObj(Q3Canvas* c) :MapObj(c) +FrameObj::FrameObj(QGraphicsScene *s) :MapObj(s) { // cout << "Const FrameObj\n"; init (); @@ -49,7 +49,7 @@ case NoFrame: break; case Rectangle: - rectFrame->move (x,y); + rectFrame->setPos (x,y); break; } } @@ -67,7 +67,7 @@ { } -void FrameObj::setRect(const QRect &r) +void FrameObj::setRect(const QRectF &r) { bbox=r; switch (type) @@ -75,9 +75,7 @@ case NoFrame: break; case Rectangle: - rectFrame->setX (bbox.x() ); - rectFrame->setY (bbox.y() ); - rectFrame->setSize (bbox.width(),bbox.height() ); + rectFrame->setRect (QRectF(bbox.x(),bbox.y(),bbox.width(),bbox.height() )); break; } } @@ -117,10 +115,9 @@ break; case Rectangle: border=10; - rectFrame = new Q3CanvasRectangle (canvas); - rectFrame->setZ(Z_FRAME); - rectFrame->setBrush( QColor("white") ); - rectFrame->setPen( QPen(QColor("black") )); + rectFrame = scene->addRect(QRectF(0,0,0,0), QPen(QColor("black") ), QColor("white")); + rectFrame->setZValue(Z_FRAME); + break; } setVisibility (visible); diff -r 5db8dfd30ea2 -r c2a05fa925a1 frameobj.h --- a/frameobj.h Thu Nov 23 16:18:26 2006 +0000 +++ b/frameobj.h Fri Dec 08 20:18:56 2006 +0000 @@ -8,7 +8,7 @@ class FrameObj:public MapObj { public: FrameObj(); - FrameObj(Q3Canvas*); + FrameObj(QGraphicsScene*); ~FrameObj(); void init(); void clear(); @@ -16,7 +16,7 @@ void moveBy (double x,double y); // move to relative Position void positionBBox(); void calcBBoxSize(); - void setRect (const QRect &); // set dimensions + void setRect (const QRectF &); // set dimensions int getBorder(); FrameType getFrameType (); QString getFrameTypeName (); @@ -26,7 +26,7 @@ protected: FrameType type; - Q3CanvasRectangle* rectFrame; + QGraphicsRectItem * rectFrame; int border; // distance text - frame }; #endif diff -r 5db8dfd30ea2 -r c2a05fa925a1 headingobj.cpp --- a/headingobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/headingobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -10,9 +10,9 @@ init (); } -HeadingObj::HeadingObj(Q3Canvas* c) :MapObj(c) +HeadingObj::HeadingObj(QGraphicsScene *s) :MapObj(s) { -// cout << "Const HeadingObj\n"; +// cout << "Const HeadingObj (s)\n"; init (); } @@ -44,8 +44,8 @@ { MapObj::move(x,y); - int h; // height of a textline - int ho; // offset of height while drawing all lines + qreal h; // height of a textline + qreal ho; // offset of height while drawing all lines if (!textline.isEmpty() ) h=textline.first()->boundingRect().height(); @@ -54,7 +54,7 @@ ho=0; for (int i=0; imove(x,y+ho); + textline.at(i)->setPos(x,y+ho); ho=ho+h; } } @@ -73,8 +73,8 @@ void HeadingObj::calcBBoxSize() { - int w=0; - int h=0; + qreal w=0; + qreal h=0; // Using Backspace an empty heading might easily be created, then there // would be textline.first()==NULL This can be worked around by the following, but // then no selection would be visible, thus we prevent it in ::setText() @@ -87,18 +87,17 @@ w=textline.at(i)->boundingRect().width(); } } - bbox.setSize (QSize(w,h)); + bbox.setSize (QSizeF(w,h)); } -Q3CanvasText* HeadingObj::newLine(QString s) +QGraphicsTextItem* HeadingObj::newLine(QString s) { - Q3CanvasText *t; - t = new Q3CanvasText(canvas); + QGraphicsTextItem *t=scene->addText(""); t->setFont (font); - t->setColor (color); - t->setZ(Z_TEXT); - t->setText(s); - t->setTextFlags(Qt::AlignLeft); + t->setZValue(Z_TEXT); + t->setDefaultTextColor(color); + t->setPlainText(s); + //t->setTextFlags(Qt::AlignLeft); t->show(); return t; } @@ -221,7 +220,7 @@ { color=c; for (int i=0; isetColor(c); + textline.at(i)->setDefaultTextColor(c); } } @@ -240,12 +239,12 @@ textline.at(i)->hide(); } -int HeadingObj::getHeight () +qreal HeadingObj::getHeight () { return bbox.height(); } -int HeadingObj::getWidth() +qreal HeadingObj::getWidth() { return bbox.width(); } diff -r 5db8dfd30ea2 -r c2a05fa925a1 headingobj.h --- a/headingobj.h Thu Nov 23 16:18:26 2006 +0000 +++ b/headingobj.h Fri Dec 08 20:18:56 2006 +0000 @@ -6,7 +6,7 @@ class HeadingObj:public MapObj { public: HeadingObj(); - HeadingObj(Q3Canvas*); + HeadingObj(QGraphicsScene*); virtual ~HeadingObj(); virtual void init(); virtual void copy(HeadingObj*); @@ -15,7 +15,7 @@ virtual void positionBBox(); virtual void calcBBoxSize(); private: - Q3CanvasText* newLine(QString); // generate new textline + QGraphicsTextItem* newLine(QString); // generate new textline public: virtual void setText(QString); virtual QString text(); @@ -24,13 +24,13 @@ virtual void setColor(QColor); virtual QColor getColor(); virtual void setVisibility(bool); - virtual int getHeight(); - virtual int getWidth(); + virtual qreal getHeight(); + virtual qreal getWidth(); protected: QString heading; int textwidth; // width for formatting text - QList textline; // a part of e.g. the parabel + QList textline; // a part of e.g. the parabel QColor color; QFont font; }; diff -r 5db8dfd30ea2 -r c2a05fa925a1 imageobj.cpp --- a/imageobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/imageobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -1,16 +1,17 @@ #include "imageobj.h" -//Added by qt3to4: -#include +#include "mapobj.h" ///////////////////////////////////////////////////////////////// // ImageObj ///////////////////////////////////////////////////////////////// -ImageObj::ImageObj( Q3Canvas *canvas ) - : Q3CanvasRectangle( canvas ) +ImageObj::ImageObj( QGraphicsScene *scene) : QGraphicsPixmapItem (NULL,scene ) { -// cout << "Const ImageObj (canvas)\n"; - setZ(Z_ICON); - type=undef; +// cout << "Const ImageObj (scene)\n"; + + setShapeMode (QGraphicsPixmapItem::BoundingRectShape); + setZValue(Z_ICON); + mapScene=scene; + hide(); } ImageObj::~ImageObj() @@ -20,13 +21,9 @@ void ImageObj::copy(ImageObj* other) { - setSize (other->width(), other->height() ); setVisibility (other->isVisible() ); - type=other->type; -// if (type==qimage) - image=other->image; -// if (type==qpixmap) - pixmap=other->pixmap; + setPixmap (other->QGraphicsPixmapItem::pixmap()); + setPos (other->pos()); } void ImageObj::setVisibility (bool v) @@ -39,64 +36,24 @@ void ImageObj::save(const QString &fn, const char *format) { - switch (type) - { - case undef: qWarning("Warning: ImageObj::save() type=undef");break; - case qimage: image.save (fn,format,-1);break; - case qpixmap: pixmap.save (fn,format,-1);break; - } + pixmap().save (fn,format,-1); } bool ImageObj::load (const QString &fn) { - if (!image.load( fn) ) - //cout << "Fatal Error in ImageObj::load ("< -#include -#include -//Added by qt3to4: -#include +#include +#include -#include "mapobj.h" - -enum ImageType {qimage,qpixmap,undef}; - -class ImageObj: public Q3CanvasRectangle +class ImageObj: public QGraphicsPixmapItem { public: - ImageObj( Q3Canvas *canvas ); + ImageObj( QGraphicsScene *); ~ImageObj(); - virtual void copy (ImageObj*); - virtual void setVisibility(bool); + void copy (ImageObj*); + void setVisibility(bool); void save (const QString &, const char *); bool load (const QString &); - bool load (QPixmap); - void setImage(QImage img); - QPixmap getPixmap(); -protected: - void drawShape( QPainter & ); + bool load (const QPixmap &); private: - QImage image; - QPixmap pixmap; - ImageType type; + QGraphicsScene *mapScene; }; #endif diff -r 5db8dfd30ea2 -r c2a05fa925a1 linkablemapobj.cpp --- a/linkablemapobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/linkablemapobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -4,10 +4,6 @@ #include "branchobj.h" #include "mapeditor.h" -//Added by qt3to4: -#include - - ///////////////////////////////////////////////////////////////// // LinkableMapObj ///////////////////////////////////////////////////////////////// @@ -18,13 +14,13 @@ init (); } -LinkableMapObj::LinkableMapObj(Q3Canvas* c) :MapObj(c) +LinkableMapObj::LinkableMapObj(QGraphicsScene* s) :MapObj(s) { -// cout << "Const LinkableMapObj\n"; +// cout << "Const LinkableMapObj (s)\n"; init (); } -LinkableMapObj::LinkableMapObj (LinkableMapObj* lmo) : MapObj (lmo->canvas) +LinkableMapObj::LinkableMapObj (LinkableMapObj* lmo) : MapObj (lmo->scene) { copy (lmo); } @@ -49,11 +45,9 @@ break; case StylePolyLine: delete (p); - delete (l); break; case StylePolyParabel: delete (p); - while (!segment.isEmpty()) delete segment.takeFirst(); break; default: break; @@ -67,8 +61,8 @@ childObj=NULL; parObj=NULL; parObjTmpBuf=NULL; - parPos=QPoint(0,0); - childPos=QPoint(0,0); + parPos=QPointF(0,0); + childPos=QPointF(0,0); link2ParPos=false; l=NULL; orientation=OrientUndef; @@ -77,18 +71,18 @@ style=StyleUndef; linkpos=LinkBottom; arcsegs=13; - Q3PointArray pa(arcsegs*2+2); - bottomline=new Q3CanvasLine(canvas); - bottomline->setPen( QPen(linkcolor, 1) ); - bottomline->setZ(Z_LINK); +// FIXME instead of linkcolor pen.color() could be used + pen.setWidth (1); + pen.setColor (linkcolor); + pen.setCapStyle ( Qt::RoundCap ); + bottomline=scene->addLine(QLineF(1,1,1,1),pen); + bottomline->setZValue(Z_LINK); bottomline->show(); // Prepare showing the selection of a MapObj - selbox = new Q3CanvasRectangle (canvas); - selbox->setZ(Z_SELBOX); - selbox->setBrush( QColor(255,255,0) ); - selbox->setPen( QPen(QColor(255,255,0) )); + selbox = scene->addRect(QRectF(0,0,0,0), QPen(QColor(255,255,0) ), QColor(255,255,0)); + selbox->setZValue(Z_SELBOX); selbox->hide(); selected=false; @@ -97,12 +91,12 @@ topPad=botPad=leftPad=rightPad=0; // initialize frame - frame = new FrameObj (canvas); + frame = new FrameObj (scene); repositionRequest=false; // Rel Positions - relPos=QPoint(0,0); + relPos=QPointF(0,0); useRelPos=false; useOrientation=true; } @@ -129,7 +123,7 @@ mapEditor=parObj->getMapEditor(); } -void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPoint,int) +void LinkableMapObj::setParObjTmp(LinkableMapObj*,QPointF,int) { } @@ -161,7 +155,7 @@ } } -void LinkableMapObj::setRelPos(const QPoint &p) +void LinkableMapObj::setRelPos(const QPointF &p) { relPos=p; if (parObj) @@ -174,23 +168,23 @@ } } -QPoint LinkableMapObj::getRelPos() +QPointF LinkableMapObj::getRelPos() { - if (!parObj) return QPoint(); + if (!parObj) return QPointF(); return relPos; } -int LinkableMapObj::getTopPad() +qreal LinkableMapObj::getTopPad() { return topPad; } -int LinkableMapObj::getLeftPad() +qreal LinkableMapObj::getLeftPad() { return leftPad; } -int LinkableMapObj::getRightPad() +qreal LinkableMapObj::getRightPad() { return rightPad; } @@ -234,29 +228,25 @@ if (childObj!=NULL && parObj != NULL) { - int i; - Q3CanvasLine* cl; + QGraphicsLineItem *cl; switch (style) { case StyleUndef: bottomline->hide(); break; case StyleLine: - l = new Q3CanvasLine(canvas); - l->setPen( QPen(linkcolor, 1) ); - l->setZ(Z_LINK); + l = scene->addLine(QLineF(1,1,1,1),pen); + l->setZValue(Z_LINK); if (visible) l->show(); else l->hide(); break; case StyleParabel: - for (i=0;isetPen( QPen(linkcolor, 1) ); - cl->setPoints( i*5,0,i*10,100); - cl->setZ(Z_LINK); + cl = scene->addLine(QLineF(i*5,0,i*10,100),pen); + cl->setZValue(Z_LINK); if (visible) cl->show(); else @@ -266,28 +256,17 @@ pa0.resize (arcsegs+1); break; case StylePolyLine: - p = new Q3CanvasPolygon(canvas); - p->setBrush( linkcolor ); - p->setZ(Z_LINK); + p =scene->addPolygon(QPolygonF(),pen,linkcolor); + p->setZValue(Z_LINK); if (visible) p->show(); else p->hide(); pa0.resize (3); - // TODO a bit awkward: draw the lines additionally to polygon, to avoid - // missing pixels, when polygon is extremly flat - l = new Q3CanvasLine(canvas); - l->setPen( QPen(linkcolor, 1) ); - l->setZ(Z_LINK); - if (visible) - l->show(); - else - l->hide(); break; case StylePolyParabel: - p = new Q3CanvasPolygon(canvas); - p->setBrush( linkcolor ); - p->setZ(Z_LINK); + p = scene->addPolygon(QPolygonF(),pen,linkcolor); + p->setZValue(Z_LINK); if (visible) p->show(); else @@ -295,22 +274,6 @@ pa0.resize (arcsegs*2+2); pa1.resize (arcsegs+1); pa2.resize (arcsegs+1); - - // TODO a bit awkward: draw the lines additionally - // to polygon, to avoid missing pixels, - // if polygon is extremly flat - for (i=0;isetPen( QPen(linkcolor, 1) ); - cl->setPoints( 5*i,0,i*10,100); - cl->setZ(Z_LINK); - if (visible) - cl->show(); - else - cl->hide(); - segment.append(cl); - } break; default: break; @@ -357,24 +320,22 @@ void LinkableMapObj::setLinkColor(QColor col) { linkcolor=col; - bottomline->setPen( QPen(linkcolor, 1) ); + pen.setColor(col); + bottomline->setPen( pen ); switch (style) { case StyleLine: - l->setPen( QPen(col,1)); + l->setPen( pen); break; case StyleParabel: for (int i=0; isetPen( QPen(col,1)); + segment.at(i)->setPen( pen); break; case StylePolyLine: p->setBrush( QBrush(col)); - l->setPen( QPen(col,1)); break; case StylePolyParabel: p->setBrush( QBrush(col)); - for (int i=0; isetPen( QPen(col,1)); break; default: break; @@ -430,11 +391,8 @@ break; case StylePolyLine: if (p) p->show(); - if (l) l->show(); break; case StylePolyParabel: - for (int i=0; ishow(); if (p) p->show(); break; default: @@ -454,11 +412,8 @@ break; case StylePolyLine: if (p) p->hide(); - if (l) l->hide(); break; case StylePolyParabel: - for (int i=0; ihide(); if (p) p->hide(); break; default: @@ -484,7 +439,7 @@ else { // calc orientation depending on position rel to parent - if (absPos.x() < QPoint(parObj->getChildPos() ).x() ) + if (absPos.x() < QPointF(parObj->getChildPos() ).x() ) orientation=OrientLeftOfCenter; else orientation=OrientRightOfCenter; @@ -527,12 +482,12 @@ double p2x,p2y; // Set P2 Before setting if (!link2ParPos) { - p2x=QPoint( parObj->getChildPos() ).x(); // P1, we have to look at - p2y=QPoint( parObj->getChildPos() ).y(); // orientation + p2x=QPointF( parObj->getChildPos() ).x(); // P1, we have to look at + p2y=QPointF( parObj->getChildPos() ).y(); // orientation } else { - p2x=QPoint( parObj->getParPos() ).x(); - p2y=QPoint( parObj->getParPos() ).y(); + p2x=QPointF( parObj->getParPos() ).x(); + p2y=QPointF( parObj->getParPos() ).y(); } setDockPos(); // Call overloaded method @@ -545,10 +500,10 @@ double vy=p2y - p1y; // Draw the horizontal line below heading (from ChildPos to ParPos) - bottomline->setPoints (qRound(childPos.x()), + bottomline->setLine (QLine (qRound(childPos.x()), qRound(childPos.y()), qRound(p1x), - qRound(p1y) ); + qRound(p1y) )); double a; // angle if (vx > -0.000001 && vx < 0.000001) @@ -556,45 +511,38 @@ else a=atan( vy / vx ); // "turning point" for drawing polygonal links - QPoint tp (-qRound(sin (a)*thickness_start), qRound(cos (a)*thickness_start)); + QPointF tp (-qRound(sin (a)*thickness_start), qRound(cos (a)*thickness_start)); // Draw the link switch (style) { case StyleLine: - l->setPoints( qRound (parPos.x()), + l->setLine( QLine(qRound (parPos.x()), qRound(parPos.y()), qRound(p2x), - qRound(p2y) ); + qRound(p2y) )); break; case StyleParabel: parabel (pa0, p1x,p1y,p2x,p2y); for (int i=0; isetPoints( pa0.point(i).x(), pa0.point(i).y(),pa0.point(i+1).x(),pa0.point(i+1).y()); + segment.at(i)->setLine(QLineF( pa0.at(i).x(), pa0.at(i).y(),pa0.at(i+1).x(),pa0.at(i+1).y())); break; case StylePolyLine: - pa0[0]=QPoint (qRound(p2x+tp.x()), qRound(p2y+tp.y())); - pa0[1]=QPoint (qRound(p2x-tp.x()), qRound(p2y-tp.y())); - pa0[2]=QPoint (qRound (parPos.x()), qRound(parPos.y()) ); - p->setPoints (pa0); - // here too, draw line to avoid missing pixels - l->setPoints( qRound (parPos.x()), - qRound(parPos.y()), - qRound(p2x), - qRound(p2y) ); + pa0.clear(); + pa0<setPolygon(QPolygonF (pa0)); break; case StylePolyParabel: parabel (pa1, p1x,p1y,p2x+tp.x(),p2y+tp.y()); parabel (pa2, p1x,p1y,p2x-tp.x(),p2y-tp.y()); + pa0.clear(); for (int i=0;i<=arcsegs;i++) - { - // Combine the arrays to a single one - pa0[i]=pa1[i]; - pa0[i+arcsegs+1]=pa2[arcsegs-i]; - } - p->setPoints (pa0); - for (int i=0; isetPoints( pa1.point(i).x(), pa1.point(i).y(),pa1.point(i+1).x(),pa1.point(i+1).y()); + pa0 << QPointF (pa1.at(i)); + for (int i=0;i<=arcsegs;i++) + pa0 << QPointF (pa2.at(arcsegs-i)); + p->setPolygon(QPolygonF (pa0)); break; default: break; @@ -644,12 +592,12 @@ return lmo; } -QPoint LinkableMapObj::getChildPos() +QPointF LinkableMapObj::getChildPos() { return childPos; } -QPoint LinkableMapObj::getParPos() +QPointF LinkableMapObj::getParPos() { return parPos; } @@ -683,16 +631,16 @@ return mapEditor; } -QPoint LinkableMapObj::getRandPos() +QPointF LinkableMapObj::getRandPos() { // Choose a random position with given distance to parent: double a=rand()%360 * 2 * M_PI / 360; - return QPoint ( (int)( + 150*cos (a)), + return QPointF ( (int)( + 150*cos (a)), (int)( + 150*sin (a))); } /* -void LinkableMapObj::alignRelativeTo (QPoint ref) +void LinkableMapObj::alignRelativeTo (QPointF ref) { // Overloaded, only called for BO, FIO, ... // FIXME not needed? @@ -702,7 +650,7 @@ void LinkableMapObj::reposition() { cout << "LMO::reposition\n"; - // FIXME not needed? Is overloaded in BranchObj... + // FIXME LMO::reposition not needed? Is overloaded in BranchObj... /* if (depth==0) { @@ -710,14 +658,14 @@ // all upper LMOs have to change, too. calcBBoxSizeWithChilds(); - alignRelativeTo ( QPoint (absPos.x(), + alignRelativeTo ( QPointF (absPos.x(), absPos.y()-(bboxTotal.height()-bbox.height())/2) ); } else { // This is only important for moving branches: // For editing a branch it isn't called... cout << " reposition to abs "<setX (clickBox.x() ); - selbox->setY (clickBox.y() ); - selbox->setSize (clickBox.width(), clickBox.height() ); + selbox->setRect (clickBox); } void LinkableMapObj::select() @@ -785,7 +731,7 @@ setVisibility (visible); } -void LinkableMapObj::parabel (Q3PointArray &ya, double p1x, double p1y, double p2x, double p2y) +void LinkableMapObj::parabel (QPolygonF &ya, double p1x, double p1y, double p2x, double p2y) { double vx=p2x - p1x; // V=P2-P1 @@ -802,13 +748,13 @@ else m=(vy / (vx*vx)); dx=vx/(arcsegs); - int i; - ya.setPoint (0,QPoint (qRound(p1x),qRound(p1y))); - for (i=1;i<=arcsegs;i++) + ya.clear(); + ya< + #define MAX_DEPTH 999 @@ -25,7 +24,7 @@ Q_OBJECT public: LinkableMapObj (); - LinkableMapObj (Q3Canvas*); + LinkableMapObj (QGraphicsScene*); LinkableMapObj (LinkableMapObj*); ~LinkableMapObj (); virtual void delLink(); @@ -33,20 +32,20 @@ virtual void copy (LinkableMapObj*); void setChildObj (LinkableMapObj*); virtual void setParObj (LinkableMapObj*); - virtual void setParObjTmp (LinkableMapObj*,QPoint,int); // Only for moving Obj around + virtual void setParObjTmp (LinkableMapObj*,QPointF,int); // Only for moving Obj around virtual void unsetParObjTmp(); // reuse original ParObj virtual bool hasParObjTmp(); virtual void setUseRelPos (const bool&); virtual void setRelPos(); // set relPos to current parentPos - virtual void setRelPos(const QPoint&); - virtual QPoint getRelPos(); + virtual void setRelPos(const QPointF&); + virtual QPointF getRelPos(); virtual void setUseOrientation (const bool &); - virtual int getTopPad(); - virtual int getLeftPad(); - virtual int getRightPad(); + virtual qreal getTopPad(); + virtual qreal getLeftPad(); + virtual qreal getRightPad(); LinkStyle getDefLinkStyle(); void setLinkStyle(LinkStyle); LinkStyle getLinkStyle(); @@ -70,71 +69,72 @@ LinkableMapObj* getParObj(); // returns pointer to toObj virtual LinkableMapObj* findObjBySelect(QString s); // find obj by selectstring virtual void setDockPos()=0; // sets childPos and parPos - QPoint getChildPos(); // returns pos where childs dock - QPoint getParPos(); // returns pos where parents dock + QPointF getChildPos(); // returns pos where childs dock + QPointF getParPos(); // returns pos where parents dock LinkOrient getOrientation(); // get orientation virtual int getDepth(); // return depth virtual void setMapEditor(MapEditor*); // set MapEditor (needed in LMO::updateNoteFlag) virtual MapEditor* getMapEditor(); // get MapEditor (usually from parent); - virtual QPoint getRandPos(); // make randomised position + virtual QPointF getRandPos(); // make randomised position - //virtual void alignRelativeTo(const QPoint ); + //virtual void alignRelativeTo(const QPointF ); virtual void reposition(); virtual void requestReposition(); // do reposition after next user event virtual void forceReposition(); // to force a reposition now (outside // of mapeditor e.g. in noteeditor virtual bool repositionRequested(); - //virtual QRect getTotalBBox(); // return BBox including childs - //virtual QRect getBBoxSizeWithChilds();// return size of BBox including childs + //virtual QRectF getTotalBBox(); // return BBox including childs + //virtual QRectF getBBoxSizeWithChilds();// return size of BBox including childs virtual void calcBBoxSizeWithChilds()=0;// calc size of BBox including childs recursivly virtual void setSelBox(); virtual void select(); virtual void unselect(); virtual QString getSelectString()=0; - //virtual QString saveToDir (const QString&,const QString&, const QPoint&);// Save data to XML + //virtual QString saveToDir (const QString&,const QString&, const QPointF&);// Save data to XML protected: - void parabel(Q3PointArray &,double,double,double,double); // Create Parabel connecting two points + void parabel(QPolygonF &,double,double,double,double); // Create Parabel connecting two points QString getLinkAttr(); - QPoint childPos; - QPoint parPos; + QPointF childPos; + QPointF parPos; bool link2ParPos; // While moving around, sometimes link to parent MapEditor* mapEditor; // for updateNoteFlag() and toggleScroll() LinkOrient orientation; - int linkwidth; // width of a link + qreal linkwidth; // width of a link int depth; // depth: undef=-1 mapCenter=0 branch=1..n - QRect bboxTotal; // bounding box including childs + QRectF bboxTotal; // bounding box including childs LinkableMapObj* childObj; LinkableMapObj* parObj; LinkableMapObj* parObjTmpBuf; // temporary buffer the original parent - int bottomlineY; // vertical offset of dockpos to pos + qreal bottomlineY; // vertical offset of dockpos to pos int thickness_start; // for StylePoly* LinkStyle style; // Current style LinkPos linkpos; // Link at bottom of object or middle of height QColor linkcolor; // Link color - Q3CanvasLine* l; // line style - Q3CanvasPolygon* p; // poly styles + QPen pen; + QGraphicsLineItem* l; // line style + QGraphicsPolygonItem* p; // poly styles int arcsegs; // arc: number of segments - QList segment; // a part of e.g. the parabel - Q3PointArray pa0; // For drawing of PolyParabel and PolyLine - Q3PointArray pa1; // For drawing of PolyParabel - Q3PointArray pa2; // For drawing of PolyParabel - Q3CanvasLine* bottomline; // on bottom of BBox + QList segment; // a part of e.g. the parabel + QPolygonF pa0; // For drawing of PolyParabel and PolyLine + QPolygonF pa1; // For drawing of PolyParabel + QPolygonF pa2; // For drawing of PolyParabel + QGraphicsLineItem* bottomline; // on bottom of BBox bool repositionRequest; // bool selected; // Used for marking the selection bool hideLinkUnselected; // to hide links if unselected - Q3CanvasRectangle* selbox; + QGraphicsRectItem* selbox; FrameObj *frame; // frame around object - int topPad, botPad, + qreal topPad, botPad, leftPad, rightPad; // padding within bbox - QPoint relPos; // position relative to childPos of parent + QPointF relPos; // position relative to childPos of parent bool useRelPos; bool useOrientation; }; diff -r 5db8dfd30ea2 -r c2a05fa925a1 mainwindow.cpp --- a/mainwindow.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/mainwindow.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -169,9 +169,10 @@ // Save Settings settings.setValue ( "/mainwindow/geometry/size", size() ); settings.setValue ( "/mainwindow/geometry/pos", pos() ); - settings.setValue ("/mainwindow/state",saveState(0)); + settings.setValue ("/mainwindow/view/AntiAlias",actionViewToggleAntiAlias->isOn()); + settings.setValue ("/mainwindow/view/SmoothPixmapTransform",actionViewToggleSmoothPixmapTransform->isOn()); settings.setValue( "/version/version", vymVersion ); settings.setValue( "/version/builddate", vymBuildDate ); @@ -891,6 +892,12 @@ formatMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackColor() ) ); actionFormatBackColor=a; + + a= new QAction( pix, tr( "Set &Background image" )+QString("..."), this ); + a->setStatusTip (tr( "Set Background image" )); + formatMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT( formatSelectBackImage() ) ); + actionFormatBackImage=a; } // View Actions @@ -946,14 +953,30 @@ connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleHistory() ) ); actionViewToggleHistoryWindow=a; + a = new QAction(tr( "Antialiasing","View action" ),this ); + a->setStatusTip ( tr( "Antialiasing" )); + a->setToggleAction(true); + a->setOn (settings.value("/mainwindow/view/AntiAlias",true).toBool()); + viewMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleAntiAlias() ) ); + actionViewToggleAntiAlias=a; + + a = new QAction(tr( "Smooth pixmap transformations","View action" ),this ); + a->setStatusTip (a->text()); + a->setToggleAction(true); + a->setOn (settings.value("/mainwindow/view/SmoothPixmapTransformation",true).toBool()); + viewMenu->addAction (a); + connect( a, SIGNAL( triggered() ), this, SLOT(windowToggleSmoothPixmap() ) ); + actionViewToggleSmoothPixmapTransform=a; + a = new QAction(tr( "Next Window","View action" ), this); - a->setStatusTip ( tr( "&Next Window" ) ); + a->setStatusTip (a->text()); a->setShortcut (Qt::ALT + Qt::Key_N ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(windowNextEditor() ) ); a = new QAction (tr( "Previous Window","View action" ), this ); - a->setStatusTip (tr( "&Previous Window" )); + a->setStatusTip (a->text()); a->setShortcut (Qt::ALT + Qt::Key_P ); viewMenu->addAction (a); connect( a, SIGNAL( triggered() ), this, SLOT(windowPreviousEditor() ) ); @@ -1041,7 +1064,7 @@ standardFlagsDefault->setName ("standardFlagsDef"); standardFlagsDefault->setToolBar (tb); - fo->load(QPixmap(flagsPath+"flag-exclamationmark.png")); + fo->load(flagsPath+"flag-exclamationmark.png"); fo->setName ("exclamationmark"); fo->setGroup("standard-mark"); QAction *a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1053,7 +1076,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); // makes deep copy - fo->load(QPixmap(flagsPath+"flag-questionmark.png")); + fo->load(flagsPath+"flag-questionmark.png"); fo->setName("questionmark"); fo->setGroup("standard-mark"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1065,7 +1088,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-hook-green.png")); + fo->load(flagsPath+"flag-hook-green.png"); fo->setName("hook-green"); fo->setGroup("standard-hook"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1077,7 +1100,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-cross-red.png")); + fo->load(flagsPath+"flag-cross-red.png"); fo->setName("cross-red"); fo->setGroup("standard-hook"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1089,7 +1112,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-stopsign.png")); + fo->load(flagsPath+"flag-stopsign.png"); fo->setName("stopsign"); a=new QAction (fo->getPixmap(),fo->getName(),this); tb->addAction (a); @@ -1100,7 +1123,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-smiley-good.png")); + fo->load(flagsPath+"flag-smiley-good.png"); fo->setName("smiley-good"); fo->setGroup("standard-smiley"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1112,7 +1135,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-smiley-sad.png")); + fo->load(flagsPath+"flag-smiley-sad.png"); fo->setName("smiley-sad"); fo->setGroup("standard-smiley"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1124,7 +1147,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-smiley-omg.png")); + fo->load(flagsPath+"flag-smiley-omg.png"); // Original omg.png (in KDE emoticons) fo->setName("smiley-omg"); fo->setGroup("standard-smiley"); @@ -1137,7 +1160,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-kalarm.png")); + fo->load(flagsPath+"flag-kalarm.png"); fo->setName("clock"); a=new QAction (fo->getPixmap(),fo->getName(),this); tb->addAction (a); @@ -1148,7 +1171,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-phone.png")); + fo->load(flagsPath+"flag-phone.png"); fo->setName("phone"); a=new QAction (fo->getPixmap(),fo->getName(),this); tb->addAction (a); @@ -1159,7 +1182,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-lamp.png")); + fo->load(flagsPath+"flag-lamp.png"); fo->setName("lamp"); a=new QAction (fo->getPixmap(),fo->getName(),this); tb->addAction (a); @@ -1170,7 +1193,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-arrow-up.png")); + fo->load(flagsPath+"flag-arrow-up.png"); fo->setName("arrow-up"); fo->setGroup("standard-arrow"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1182,7 +1205,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-arrow-down.png")); + fo->load(flagsPath+"flag-arrow-down.png"); fo->setName("arrow-down"); fo->setGroup("standard-arrow"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1194,7 +1217,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-arrow-2up.png")); + fo->load(flagsPath+"flag-arrow-2up.png"); fo->setName("2arrow-up"); fo->setGroup("standard-arrow"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1206,7 +1229,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-arrow-2down.png")); + fo->load(flagsPath+"flag-arrow-2down.png"); fo->setName("2arrow-down"); fo->setGroup("standard-arrow"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1218,7 +1241,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-thumb-up.png")); + fo->load(flagsPath+"flag-thumb-up.png"); fo->setName("thumb-up"); fo->setGroup("standard-thumb"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1230,7 +1253,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-thumb-down.png")); + fo->load(flagsPath+"flag-thumb-down.png"); fo->setName("thumb-down"); fo->setGroup("standard-thumb"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1242,7 +1265,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-rose.png")); + fo->load(flagsPath+"flag-rose.png"); fo->setName("rose"); a=new QAction (fo->getPixmap(),fo->getName(),this); tb->addAction (a); @@ -1253,7 +1276,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-heart.png")); + fo->load(flagsPath+"flag-heart.png"); fo->setName("heart"); a=new QAction (fo->getPixmap(),fo->getName(),this); tb->addAction (a); @@ -1263,7 +1286,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-present.png")); + fo->load(flagsPath+"flag-present.png"); fo->setName("present"); a=new QAction (fo->getPixmap(),fo->getName(),this); tb->addAction (a); @@ -1274,7 +1297,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-flash.png")); + fo->load(flagsPath+"flag-flash.png"); fo->setName("flash"); a=new QAction (fo->getPixmap(),fo->getName(),this); tb->addAction (a); @@ -1285,7 +1308,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-info.png")); + fo->load(flagsPath+"flag-info.png"); // Original: xsldbg_output.png fo->setName("info"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1297,7 +1320,7 @@ connect (a, SIGNAL( triggered() ), this, SLOT( standardFlagChanged() ) ); standardFlagsDefault->addFlag (fo); - fo->load(QPixmap(flagsPath+"flag-lifebelt.png")); + fo->load(flagsPath+"flag-lifebelt.png"); // Original khelpcenter.png fo->setName("lifebelt"); a=new QAction (fo->getPixmap(),fo->getName(),this); @@ -1507,6 +1530,7 @@ actionFormatLinkColorHint->addTo( canvasContextMenu ); actionFormatLinkColor->addTo( canvasContextMenu ); actionFormatBackColor->addTo( canvasContextMenu ); + actionFormatBackImage->addTo( canvasContextMenu ); // Menu for last opened files // Create actions @@ -1620,12 +1644,15 @@ void Main::fileNew() { QString fn="unnamed"; - MapEditor* medit = new MapEditor ( NULL); - tabWidget->addTab (medit,fn); - tabWidget->showPage(medit); - medit->viewport()->setFocus(); + MapEditor* me = new MapEditor ( NULL); + tabWidget->addTab (me,fn); + tabWidget->showPage(me); + me->viewport()->setFocus(); + me->setAntiAlias (actionViewToggleAntiAlias->isOn()); + me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); + // For the very first map we do not have flagrows yet... - medit->select("mc:"); + me->select("mc:"); } ErrorCode Main::fileLoad(QString fn, const LoadMode &lmode) @@ -1692,6 +1719,8 @@ tabWidget->addTab (me,fn); tabIndex=tabWidget->indexOf (me); tabWidget->setCurrentPage (tabIndex); + me->setAntiAlias (actionViewToggleAntiAlias->isOn()); + me->setSmoothPixmap(actionViewToggleSmoothPixmapTransform->isOn()); } // Check, if file exists (important for creating new files @@ -2629,7 +2658,7 @@ if (ok) { #if defined(Q_OS_MACX) - p = currentMapEditor()->mapToGlobal( currentMapEditor()->worldMatrix().map( p)); + p=currentMapEditor()->mapTo (this,p); QDialog *d =new QDialog(NULL); QLineEdit *le=new QLineEdit (d); d->setWindowFlags (Qt::FramelessWindowHint); @@ -2645,7 +2674,7 @@ delete (d); editHeadingFinished(); #else - p = currentMapEditor()->mapTo(this, currentMapEditor()->worldMatrix().map( p)); + p=currentMapEditor()->mapTo (this,p); lineedit->setGeometry(p.x(),p.y(),230,25); lineedit->setText(s); lineedit->setCursorPosition(1); @@ -3011,6 +3040,12 @@ currentMapEditor()->selectMapBackgroundColor(); } +void Main::formatSelectBackImage() +{ + if (currentMapEditor()) + currentMapEditor()->selectMapBackgroundImage(); +} + void Main::formatSelectLinkColor() { if (currentMapEditor()) @@ -3058,7 +3093,7 @@ { QMatrix m; m.reset(); - currentMapEditor()->setWorldMatrix( m ); + currentMapEditor()->setMatrix( m ); currentMapEditor()->setViewCenter(); currentMapEditor()->adjustCanvasSize(); } @@ -3068,9 +3103,9 @@ { if (currentMapEditor()) { - QMatrix m = currentMapEditor()->worldMatrix(); + QMatrix m = currentMapEditor()->matrix(); m.scale( 1.25, 1.25 ); - currentMapEditor()->setWorldMatrix( m ); + currentMapEditor()->setMatrix( m ); currentMapEditor()->setViewCenter(); currentMapEditor()->adjustCanvasSize(); } @@ -3080,9 +3115,9 @@ { if (currentMapEditor()) { - QMatrix m = currentMapEditor()->worldMatrix(); + QMatrix m = currentMapEditor()->matrix(); m.scale( 0.8, 0.8 ); - currentMapEditor()->setWorldMatrix( m ); + currentMapEditor()->setMatrix( m ); currentMapEditor()->setViewCenter(); currentMapEditor()->adjustCanvasSize(); } @@ -3142,6 +3177,31 @@ } +void Main::windowToggleAntiAlias() +{ + bool b=actionViewToggleAntiAlias->isOn(); + MapEditor *me; + for (int i=0;icount();i++) + { + + me=(MapEditor*)tabWidget->page(i); + me->setAntiAlias(b); + } + +} + +void Main::windowToggleSmoothPixmap() +{ + bool b=actionViewToggleSmoothPixmapTransform->isOn(); + MapEditor *me; + for (int i=0;icount();i++) + { + + me=(MapEditor*)tabWidget->page(i); + me->setSmoothPixmap(b); + } +} + void Main::updateHistory(SimpleSettings &undoSet) { historyWindow->update (undoSet); @@ -3457,12 +3517,12 @@ } QString docpath=docdir.path()+"/"+docname; + QStringList args; Process *pdfProc = new Process(); - pdfProc->clearArguments(); - pdfProc->addArgument( settings.value("/mainwindow/readerPDF").toString()); - pdfProc->addArgument( docpath); - - if ( !pdfProc->start() ) + args <start( settings.value("/mainwindow/readerPDF").toString()); + if ( !pdfProc->waitForStarted() ) { // error handling QMessageBox::warning(0, diff -r 5db8dfd30ea2 -r c2a05fa925a1 mainwindow.h --- a/mainwindow.h Thu Nov 23 16:18:26 2006 +0000 +++ b/mainwindow.h Fri Dec 08 20:18:56 2006 +0000 @@ -143,6 +143,7 @@ void formatLinkStylePolyLine(); void formatLinkStylePolyParabel(); void formatSelectBackColor(); + void formatSelectBackImage(); void formatSelectLinkColor(); void formatToggleLinkColorHint(); void formatFrameNone(); @@ -163,6 +164,8 @@ void windowToggleNoteEditor(); void windowToggleHistory(); void updateHistory(SimpleSettings &); + void windowToggleAntiAlias(); + void windowToggleSmoothPixmap(); void updateNoteFlag(); void updateActions(); ModMode getModMode(); @@ -249,6 +252,7 @@ QAction* actionFormatColorSubtree; QAction* actionFormatLinkColorHint; QAction* actionFormatBackColor; + QAction* actionFormatBackImage; QAction* actionFormatLinkColor; QAction *actionFormatIncludeImagesVer; QAction *actionFormatIncludeImagesHor; @@ -271,6 +275,8 @@ QAction *actionViewToggleNoteEditor; QAction *actionViewToggleHistoryWindow; + QAction *actionViewToggleAntiAlias; + QAction *actionViewToggleSmoothPixmapTransform; QAction* actionSettingsAutoEdit; QAction* actionSettingsAutoSelectHeading; diff -r 5db8dfd30ea2 -r c2a05fa925a1 mapcenterobj.cpp --- a/mapcenterobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/mapcenterobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -12,9 +12,9 @@ init(); } -MapCenterObj::MapCenterObj(Q3Canvas* c) : BranchObj (c) +MapCenterObj::MapCenterObj(QGraphicsScene* s) : BranchObj (s) { -// cout << "Const MapCenterObj canvas="< +#include +#include +#include #include #include @@ -53,30 +57,34 @@ /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// -MapEditor::MapEditor( - QWidget* parent, const char* name, Qt::WFlags f) : - Q3CanvasView(parent,name,f), urlOperator(0), imageBuffer(0) +MapEditor::MapEditor( QWidget* parent) : + QGraphicsView(parent), urlOperator(0), imageBuffer(0) { //cout << "Constructor ME "<setAcceptDrops(true); - mapCanvas = new Q3Canvas(width(),height()); - mapCanvas->setAdvancePeriod(30); - mapCanvas->setBackgroundColor (Qt::white); - - setCanvas (mapCanvas); + mapScene= new QGraphicsScene(parent); + //mapScene= new QGraphicsScene(QRectF(0,0,width(),height()), parent); + mapScene->setBackgroundBrush (QBrush(Qt::white, Qt::SolidPattern)); + + + setScene (mapScene); + /* FIXME not needed in QT4? + // Maybe check QAbstractScrollArea... // Always show scroll bars (automatic would flicker sometimes) - setVScrollBarMode ( Q3ScrollView::AlwaysOn ); - setHScrollBarMode ( Q3ScrollView::AlwaysOn ); - - mapCenter = new MapCenterObj(mapCanvas); + setVScrollBarMode ( QScrollView::AlwaysOn ); + setHScrollBarMode ( QScrollView::AlwaysOn ); + */ + + mapCenter = new MapCenterObj(mapScene); mapCenter->setVisibility (true); mapCenter->setMapEditor (this); mapCenter->setHeading (tr("New Map","Heading of mapcenter in new map")); - mapCenter->move(mapCanvas->width()/2-mapCenter->width()/2,mapCanvas->height()/2-mapCenter->height()/2); + //mapCenter->move(mapScene->width()/2-mapCenter->width()/2,mapScene->height()/2-mapCenter->height()/2); + mapCenter->move(0,0); printer=NULL; @@ -157,60 +165,64 @@ return mapCenter; } -Q3Canvas* MapEditor::getCanvas() +QGraphicsScene * MapEditor::getScene() { - return mapCanvas; + return mapScene; } void MapEditor::adjustCanvasSize() { - // To adjust the canvas to map, viewport size and position, we have to + +/* FIXME QT4 probably not needed any longer! + + // To adjust the scene to map, viewport size and position, we have to // do some coordinate magic... // // Get rectangle of (scroll-)view. - // We want to be in canvas coords, so + // We want to be in scene coords, so // we map. Important if view is zoomed... - QRect view = inverseWorldMatrix().mapRect( QRect( contentsX(), contentsY(), + QRectF view = inverseWorldMatrix().mapRect( QRectF( contentsX(), contentsY(), visibleWidth(), visibleHeight()) ); - // Now we need the bounding box of view AND map to calc the correct canvas size. + // Now we need the bounding box of view AND map to calc the correct scene size. // Why? Because if the map itself is moved out of view, the view has to be enlarged // to avoid jumping aroung... - QRect map=mapCenter->getTotalBBox(); + QRectF map=mapCenter->getTotalBBox(); // right edge - left edge int cw= max(map.x() + map.width(), view.x() + view.width()) - min(map.x(), view.x()); int ch= max(map.y() + map.height(), view.y() + view.height()) - min(map.y(), view.y()); - if ( (cw!=mapCanvas->width()) || (ch!=mapCanvas->height()) || - !mapCanvas->onCanvas (map.topLeft()) || !mapCanvas->onCanvas (map.bottomRight()) + if ( (cw!=mapScene->width()) || (ch!=mapScene->height()) || + !mapScene->onCanvas (map.topLeft()) || !mapScene->onCanvas (map.bottomRight()) ) { - // move the map on canvas (in order to not move it on screen) this is neccessary - // a) if topleft corner of canvas is left or above topleft corner of view and also left of + // move the map on scene (in order to not move it on screen) this is neccessary + // a) if topleft corner of scene is left or above topleft corner of view and also left of // above topleft corner of map. E.g. if map is completly inside view, but it would be possible - // to scroll to an empty area of canvas to the left. - // b) if topleft corner of map left of or above topleft of canvas + // to scroll to an empty area of scene to the left. + // b) if topleft corner of map left of or above topleft of scene int dx=0; int dy=0; - if (cw > mapCanvas->width() ) + if (cw > mapScene->width() ) { if (map.x()<0) dx=-map.x(); } - if (cw < mapCanvas->width() ) + if (cw < mapScene->width() ) dx=-min (view.x(),map.x()); - if (ch > mapCanvas->height() ) + if (ch > mapScene->height() ) { if (map.y()<0) dy=-map.y(); } - if (ch < mapCanvas->height() ) + if (ch < mapScene->height() ) { dy=-min (view.y(),map.y()); } // We really have to resize now. Let's go... - mapCanvas->resize (cw,ch); + // FIXME old code mapScene->resize (cw,ch); + mapScene->setSceneRect (QRectFF(0,0,cw,ch)); if ( (dx!=0) || (dy!=0) ) { mapCenter->moveAllBy(dx,dy); @@ -221,6 +233,8 @@ scrollBy (dx,dy); } } + + */ } bool MapEditor::isRepositionBlocked() @@ -257,12 +271,12 @@ d.mkdir (tmpMapDir); } -QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPoint &offset, LinkableMapObj *saveSel) +QString MapEditor::saveToDir(const QString &tmpdir, const QString &prefix, bool writeflags, const QPointF &offset, LinkableMapObj *saveSel) { // tmpdir temporary directory to which data will be written // prefix mapname, which will be appended to images etc. // writeflags Only write flags for "real" save of map, not undo - // offset offset of bbox of whole map in canvas. + // offset offset of bbox of whole map in scene. // Needed for XML export // Save Header @@ -293,7 +307,7 @@ mapAttr+= attribut("author",mapCenter->getAuthor()) + attribut("comment",mapCenter->getComment()) + attribut("date",mapCenter->getDate()) + - attribut("backgroundColor", mapCanvas->backgroundColor().name() ) + + attribut("backgroundColor", mapScene->backgroundBrush().color().name() ) + attribut("linkStyle", ls ) + attribut("linkColor", defLinkColor.name() ) + attribut("defXLinkColor", defXLinkColor.name() ) + @@ -307,7 +321,7 @@ // Reset the counters before saving // TODO constr. of FIO creates lots of objects, better do this in some other way... - FloatImageObj (mapCanvas).resetSaveCounter(); + FloatImageObj (mapScene).resetSaveCounter(); // Build xml recursivly if (!saveSel || typeid (*saveSel) == typeid (MapCenterObj)) @@ -447,7 +461,7 @@ // Save depending on how much needs to be saved if (saveSel) - backupXML=saveToDir (bakMapDir,mapName+"-",false, QPoint (),saveSel); + backupXML=saveToDir (bakMapDir,mapName+"-",false, QPointF (),saveSel); QString undoCommand=""; if (savemode==UndoCommand) @@ -496,8 +510,8 @@ if (saveSel) cout << " saveSel="<getSelectString().ascii()<updateHistory (undoSet); setChanged(); - mainWindow->updateHistory (undoSet); updateActions(); } @@ -1136,9 +1150,9 @@ QString saveFile; if (savemode==CompleteMap || selection==NULL) - saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),NULL); + saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),NULL); else - saveFile=saveToDir (fileDir,mapName+"-",true,QPoint(),selection); + saveFile=saveToDir (fileDir,mapName+"-",true,QPointF(),selection); if (!saveStringToDisk(fileDir+fname,saveFile)) return 1; @@ -1172,7 +1186,7 @@ printer->setPrinterName (settings.value("/mainwindow/printerName",printer->printerName()).toString()); } - QRect totalBBox=mapCenter->getTotalBBox(); + QRectF totalBBox=mapCenter->getTotalBBox(); // Try to set orientation automagically // Note: Interpretation of generated postscript is amibiguous, if @@ -1201,15 +1215,18 @@ // Handle sizes of map and paper: // - // setWindow defines which part of the canvas will be transformed + // setWindow defines which part of the scene will be transformed // setViewport defines area on paper in device coordinates (dpi) // e.g. (0,50,700,700) is upper part on A4 // see also /usr/lib/qt3/doc/html/coordsys.html - double paperAspect = (double)printer->width() / (double)printer->height(); + Q3PaintDeviceMetrics metrics (printer); + + double paperAspect = (double)metrics.width() / (double)metrics.height(); double mapAspect = (double)totalBBox.width() / (double)totalBBox.height(); - QRect mapRect=totalBBox; + QRectF mapRect=totalBBox; +/* FIXME todo for QT4 Q3CanvasRectangle *frame=NULL; Q3CanvasText *footerFN=NULL; Q3CanvasText *footerDate=NULL; @@ -1221,32 +1238,31 @@ // Print frame around map mapRect.setRect (totalBBox.x()-10, totalBBox.y()-10, totalBBox.width()+20, totalBBox.height()+20); - frame=new Q3CanvasRectangle (mapRect,mapCanvas); + frame=new Q3CanvasRectangle (mapRect,mapScene); frame->setBrush (QColor(Qt::white)); frame->setPen (QColor(Qt::black)); frame->setZ(0); frame->show(); } - /* TODO remove after testing - QCanvasLine *l=new QCanvasLine (mapCanvas); - l->setPoints (0,0,mapRect.width(),mapRect.height()); - l->setPen (QPen(QColor(black), 1)); - l->setZ (200); - l->show(); - */ + // TODO remove after testing + //QCanvasLine *l=new QCanvasLine (mapScene); + //l->setPoints (0,0,mapRect.width(),mapRect.height()); + //l->setPen (QPen(QColor(black), 1)); + //l->setZ (200); + //l->show(); if (printFooter) { // Print footer below map QFont font; font.setPointSize(10); - footerFN=new Q3CanvasText (mapCanvas); + footerFN=new Q3CanvasText (mapScene); footerFN->setText ("VYM - " + fileName); footerFN->setFont(font); footerFN->move (mapRect.x(), mapRect.y() + mapRect.height() ); footerFN->setZ(Z_TEXT); footerFN->show(); - footerDate=new Q3CanvasText (mapCanvas); + footerDate=new Q3CanvasText (mapScene); footerDate->setText (QDate::currentDate().toString(Qt::TextDate)); footerDate->setFont(font); footerDate->move (mapRect.x()+mapRect.width()-footerDate->boundingRect().width(), mapRect.y() + mapRect.height() ); @@ -1258,19 +1274,21 @@ { pp.setWindow (mapRect); } +*/ if (mapAspect>=paperAspect) { // Fit horizontally to paper width - pp.setViewport(0,0, printer->width(),(int)(printer->width()/mapAspect) ); + pp.setViewport(0,0, metrics.width(),(int)(metrics.width()/mapAspect) ); } else { // Fit vertically to paper height - pp.setViewport(0,0,(int)(printer->height()*mapAspect),printer->height()); + pp.setViewport(0,0,(int)(metrics.height()*mapAspect),metrics.height()); } - mapCanvas->drawArea(mapRect, &pp); // draw Canvas to printer - + mapScene->render(&pp); // draw scene to printer + +/* // Delete Frame and footer if (footerFN) { @@ -1278,6 +1296,7 @@ delete (footerDate); } if (frame) delete (frame); +*/ // Restore selection if (oldselection) @@ -1291,9 +1310,20 @@ } } +void MapEditor::setAntiAlias (bool b) +{ + setRenderHint(QPainter::Antialiasing,b); +} + +void MapEditor::setSmoothPixmap(bool b) +{ + setRenderHint(QPainter::SmoothPixmapTransform,b); +} + QPixmap MapEditor::getPixmap() { - QRect mapRect=mapCenter->getTotalBBox(); +/* FIXME not ported yet to QT4 + QRectF mapRect=mapCenter->getTotalBBox(); QPixmap pix (mapRect.size()); QPainter pp (&pix); @@ -1307,7 +1337,7 @@ pp.setWindow (mapRect); - mapCanvas->drawArea(mapRect, &pp); // draw Canvas to painter + mapScene->drawArea(mapRect, &pp); // draw scene to painter // Restore selection @@ -1318,6 +1348,8 @@ } return pix; +*/ +return QPixmap(); } void MapEditor::setHideTmpMode (HideTmpMode mode) @@ -1326,7 +1358,7 @@ mapCenter->setHideTmp (hidemode); mapCenter->reposition(); adjustCanvasSize(); - canvas()->update(); + scene()->update(); } HideTmpMode MapEditor::getHideTmpMode() @@ -1424,7 +1456,7 @@ { // write to directory QString clipfile="part"; - QString saveFile=saveToDir (fileDir,clipfile+"-",true,QPoint(),selection); + QString saveFile=saveToDir (fileDir,clipfile+"-",true,QPointF(),selection); QFile file; file.setName ( clipboardDir + "/"+clipfile+".xml"); @@ -1505,8 +1537,8 @@ undoSet.setEntry ("/history/curStep",QString::number(curStep)); undoSet.writeSettings(histPath); + mainWindow->updateHistory (undoSet); updateActions(); - mainWindow->updateHistory (undoSet); /* TODO remove testing cout << "ME::redo() end\n"; @@ -1747,11 +1779,11 @@ { if (selection) { - QString ps=qpointToString (selection->getAbsPos()); + QString ps=qpointfToString (selection->getAbsPos()); QString s=selection->getSelectString(); saveState( s, "move "+ps, - s, "move "+qpointToString (QPoint (x,y)), + s, "move "+qpointfToString (QPointF (x,y)), QString("Move %1 to %2").arg(getName(selection)).arg(ps)); selection->move(x,y); mapCenter->reposition(); @@ -1766,11 +1798,11 @@ typeid(*selection) == typeid(MapCenterObj) || typeid(*selection) == typeid (FloatImageObj))) { - QString ps=qpointToString (selection->getRelPos()); + QString ps=qpointfToString (selection->getRelPos()); QString s=selection->getSelectString(); saveState( s, "moveRel "+ps, - s, "moveRel "+qpointToString (QPoint (x,y)), + s, "moveRel "+qpointfToString (QPointF (x,y)), QString("Move %1 to relativ position %2").arg(getName(selection)).arg(ps)); ((OrnamentedObj*)selection)->move2RelPos (x,y); mapCenter->reposition(); @@ -1822,9 +1854,7 @@ { ok=true; ensureSelectionVisible(); - p = ((BranchObj*)selection)->getAbsPos(); - p.setX (p.x() - contentsX()); - p.setY (p.y() - contentsY() + ((BranchObj*)selection)->height()/2); + p=mapFromScene(selection->getAbsPos()); return ((BranchObj*)selection)->getHeading(); } ok=false; @@ -1967,7 +1997,7 @@ // We accept no MapCenterObj here, so we _have_ a parent { BranchObj* bo = (BranchObj*) selection; - QPoint p=bo->getRelPos(); + QPointF p=bo->getRelPos(); BranchObj *parbo=(BranchObj*)(selection->getParObj()); @@ -2443,29 +2473,67 @@ } } +void MapEditor::selectMapBackgroundImage () +{ + Q3FileDialog *fd=new Q3FileDialog( this); + fd->setMode (Q3FileDialog::ExistingFile); + fd->addFilter (QString (tr("Images") + " (*.png *.bmp *.xbm *.jpg *.png *.xpm *.gif *.pnm)")); + ImagePreview *p =new ImagePreview (fd); + fd->setContentsPreviewEnabled( TRUE ); + fd->setContentsPreview( p, p ); + fd->setPreviewMode( Q3FileDialog::Contents ); + fd->setCaption(vymName+" - " +tr("Load background image")); + fd->setDir (lastImageDir); + fd->show(); + + if ( fd->exec() == QDialog::Accepted ) + { + // FIXME in QT4 use: lastImageDir=fd->directory(); + lastImageDir=QDir (fd->dirPath()); + setMapBackgroundImage (fd->selectedFile()); + } +} + +void MapEditor::setMapBackgroundImage (const QString &fn) +{ + QColor oldcol=mapScene->backgroundBrush().color(); + /* + saveState( + selection, + QString ("setMapBackgroundImage (%1)").arg(oldcol.name()), + selection, + QString ("setMapBackgroundImage (%1)").arg(col.name()), + QString("Set background color of map to %1").arg(col.name())); + */ + cout << "Trying to load "<setBackgroundBrush(brush); +} + void MapEditor::selectMapBackgroundColor() { - QColor col = QColorDialog::getColor( mapCanvas->backgroundColor(), this ); + QColor col = QColorDialog::getColor( mapScene->backgroundBrush().color(), this ); if ( !col.isValid() ) return; - setBackgroundColor( col ); + setMapBackgroundColor( col ); } void MapEditor::setMapBackgroundColor(QColor col) { - QColor oldcol=mapCanvas->backgroundColor(); + QColor oldcol=mapScene->backgroundBrush().color(); saveState( selection, QString ("setMapBackgroundColor (%1)").arg(oldcol.name()), selection, QString ("setMapBackgroundColor (%1)").arg(col.name()), QString("Set background color of map to %1").arg(col.name())); - mapCanvas->setBackgroundColor (col); + mapScene->setBackgroundBrush(col); } QColor MapEditor::getMapBackgroundColor() { - return mapCanvas->backgroundColor(); + return mapScene->backgroundBrush().color(); } QColor MapEditor::getCurrentHeadingColor() @@ -2557,9 +2625,10 @@ void MapEditor::setViewCenter() { - // transform to CanvasView Coord: - QPoint p=worldMatrix().map(movingCenter); - center ( p.x(), p.y()); + // transform to sceneView Coord: + QPointF p=matrix().map(movingCenter); + //FIXME not ported yet to QT4 (center ist TextStream there) + //center ( p.x(), p.y()); } @@ -2756,7 +2825,7 @@ updateActions(); mapCenter->reposition(); adjustCanvasSize(); - canvas()->update(); + scene()->update(); } } } @@ -2778,7 +2847,7 @@ updateActions(); mapCenter->reposition(); adjustCanvasSize(); - canvas()->update(); + scene()->update(); } } @@ -2802,7 +2871,7 @@ updateActions(); mapCenter->reposition(); adjustCanvasSize(); - canvas()->update(); + scene()->update(); } } @@ -2848,7 +2917,7 @@ { BranchObj* bo=(BranchObj*)selection; BranchObj* par=(BranchObj*)(bo->getParObj()); - QPoint p=bo->getRelPos(); + QPointF p=bo->getRelPos(); saveStateChangingPart( selection->getParObj(), selection, @@ -2892,11 +2961,7 @@ // Calc some stats QString stats; - int i=0; - Q3CanvasItemList l=canvas()->allItems(); - for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) - i++; - stats+=QString ("%1 items on canvas\n").arg (i,6); + stats+=tr("%1 items on map\n","Info about map").arg (mapScene->items().size(),6); uint b=0; uint f=0; @@ -3109,7 +3174,7 @@ ); bo->toggleScroll(); adjustCanvasSize(); - canvas()->update(); + scene()->update(); } } @@ -3171,7 +3236,7 @@ mapCenter->reposition(); adjustCanvasSize(); - canvas()->update(); + scene()->update(); } delete (p); delete (fd); @@ -3335,7 +3400,7 @@ importDirInt (bo,QDir(fd->selectedFile()) ); mapCenter->reposition(); adjustCanvasSize(); - canvas()->update(); + scene()->update(); } } } @@ -3386,17 +3451,6 @@ void MapEditor::testFunction() { - cout << "MapEditor::testFunction() called\n"; - - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj)) ) - { - BranchObj* bo=(BranchObj*)selection; - cout << bo->getHeading().ascii() <<" is scrolled: "<isScrolled()<calcBBoxSizeWithChilds(); - QRect totalBBox=mapCenter->getTotalBBox(); - QRect mapRect=totalBBox; + QRectF totalBBox=mapCenter->getTotalBBox(); + QRectF mapRect=totalBBox; QCanvasRectangle *frame=NULL; cout << " map has =("<setBrush (QColor(white)); frame->setPen (QColor(black)); - frame->setZ(0); + frame->setZValue(0); frame->show(); } else @@ -3442,32 +3496,35 @@ if (selection) { LinkableMapObj* lmo= dynamic_cast (selection); - QPoint p; + QPointF p; if (selection->getOrientation() == OrientLeftOfCenter) - p= worldMatrix().map(QPoint (lmo->x(),lmo->y())); - else - p= worldMatrix().map(QPoint (lmo->x()+lmo->width(),lmo->y()+lmo->height())); - ensureVisible (p.x(), p.y() ); + p= matrix().map(QPointF (lmo->x(),lmo->y())); + else + p= matrix().map(QPointF (lmo->x()+lmo->width(),lmo->y()+lmo->height())); + ensureVisible (QRectF(p.x(), p.y(),0,0 )); + } } void MapEditor::updateViewCenter() { +/* FIXME still to port to QT4 inverseworldmatrix // Update movingCenter, so that we can zoom comfortably later - QRect rc = QRect( contentsX(), contentsY(), + QRectF rc = QRectF( contentsX(), contentsY(), visibleWidth(), visibleHeight() ); - QRect canvasRect = inverseWorldMatrix().mapRect(rc); + QRectF canvasRect = inverseWorldMatrix().mapRect(rc); movingCenter.setX((canvasRect.right() + canvasRect.left())/2); movingCenter.setY((canvasRect.top() + canvasRect.bottom())/2); + */ } -void MapEditor::contentsContextMenuEvent ( QContextMenuEvent * e ) +void MapEditor::contextMenuEvent ( QContextMenuEvent * e ) { // Lineedits are already closed by preceding // mouseEvent, we don't need to close here. - QPoint p = inverseWorldMatrix().map(e->pos()); + QPointF p = mapToScene(e->pos()); LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL); if (lmo) @@ -3499,7 +3556,7 @@ } } else { // No MapObj found, we are on the Canvas itself - // Context Menu on Canvas + // Context Menu on scene updateActions(); canvasContextMenu->popup(e->globalPos() ); } @@ -3534,7 +3591,7 @@ setCursor (Qt::ArrowCursor); } -void MapEditor::contentsMousePressEvent(QMouseEvent* e) +void MapEditor::mousePressEvent(QMouseEvent* e) { // Ignore right clicks, these will go to context menus if (e->button() == Qt::RightButton ) @@ -3543,7 +3600,7 @@ return; } - QPoint p = inverseWorldMatrix().map(e->pos()); + QPointF p = mapToScene(e->pos()); LinkableMapObj* lmo=mapCenter->findMapObj(p, NULL); e->accept(); @@ -3602,7 +3659,7 @@ { drawingLink=true; linkingObj_src=bo_begin; - tmpXLink=new XLinkObj (mapCanvas); + tmpXLink=new XLinkObj (mapScene); tmpXLink->setBegin (bo_begin); tmpXLink->setEnd (p); tmpXLink->setColor(defXLinkColor); @@ -3649,27 +3706,31 @@ toggleScroll(); updateActions(); } else - { // No MapObj found, we are on the Canvas itself - // Left Button move Pos of CanvasView + { // No MapObj found, we are on the scene itself + // Left Button move Pos of sceneView if (e->button() == Qt::LeftButton ) { movingObj=NULL; // move Content not Obj movingObj_start=e->globalPos(); - movingCont_start=QPoint (contentsX(), contentsY() ); - movingVec=QPoint(0,0); + // FIXME not ported to QT4 yet (move canvasView) + //movingCont_start=QPointF (contentsX(), contentsY() ); + movingCont_start=QPointF ( + horizontalScrollBar()->value(), + verticalScrollBar()->value()); + movingVec=QPointF(0,0); setCursor(HandOpenCursor); } } } -void MapEditor::contentsMouseMoveEvent(QMouseEvent* e) +void MapEditor::mouseMoveEvent(QMouseEvent* e) { - QPoint p = inverseWorldMatrix().map(e->pos()); + QPointF p = mapToScene(e->pos()); // Move the selected MapObj if ( selection && movingObj) { - // To avoid jumping of the CanvasView, only + // To avoid jumping of the sceneView, only // ensureSelectionVisible, if not tmp linked if (!selection->hasParObjTmp()) ensureSelectionVisible (); @@ -3691,7 +3752,7 @@ FloatObj *fo=(FloatObj*)selection; fo->move (p.x() -movingObj_start.x(), p.y()-movingObj_start.y() ); fo->setRelPos(); - fo->reposition(); + fo->updateLink(); //no need for reposition, if we update link here // Relink float to new mapcenter or branch, if shift is pressed // Only relink, if selection really has a new parent @@ -3703,7 +3764,8 @@ { if (typeid(*fo) == typeid(FloatImageObj)) { - //TODO undocom + //FIXME undocom for relinking of floats + //saveStateComplete(QString("Relink %1 to %2").arg(getName(fo)).arg(getName(lmo) ) ); FloatImageObj *fio=(FloatImageObj*)(fo); ((BranchObj*)(lmo))->addFloatImage (fio); @@ -3769,7 +3831,7 @@ } // no FloatImageObj - canvas()->update(); + scene()->update(); return; } // selection && moving_obj @@ -3780,22 +3842,25 @@ tmpXLink->updateXLink(); } - // Move CanvasView - if (!movingObj && !pickingColor &&!drawingLink) + // Move sceneView + //if (!movingObj && !pickingColor &&!drawingLink && e->button() == Qt::LeftButton ) + if (e->buttons() == Qt::LeftButton ) { - QPoint p=e->globalPos(); + QPointF p=e->globalPos(); movingVec.setX(-p.x() + movingObj_start.x() ); movingVec.setY(-p.y() + movingObj_start.y() ); - setContentsPos( movingCont_start.x() + movingVec.x(), - movingCont_start.y() + movingVec.y()); - - updateViewCenter(); + // FIXME not ported to QT4 yet (move canvasView) + //setContentsPos( movingCont_start.x() + movingVec.x(), + //movingCont_start.y() + movingVec.y(); + horizontalScrollBar()->setSliderPosition((int)( movingCont_start.x()+movingVec.x() )); + verticalScrollBar()->setSliderPosition((int)( movingCont_start.y()+movingVec.y() ) ); } } -void MapEditor::contentsMouseReleaseEvent(QMouseEvent* e) +void MapEditor::mouseReleaseEvent(QMouseEvent* e) { + QPointF p = mapToScene(e->pos()); LinkableMapObj *dst; // Have we been picking color? if (pickingColor) @@ -3803,7 +3868,7 @@ pickingColor=false; setCursor (Qt::ArrowCursor); // Check if we are over another branch - dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL); + dst=mapCenter->findMapObj(p, NULL); if (dst && selection) { if (e->state() & Qt::ShiftModifier) @@ -3825,7 +3890,7 @@ { drawingLink=false; // Check if we are over another branch - dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), NULL); + dst=mapCenter->findMapObj(p, NULL); if (dst && selection) { tmpXLink->setEnd ( ((BranchObj*)(dst)) ); @@ -3847,8 +3912,8 @@ { // Moved FloatObj. Maybe we need to reposition FloatImageObj *fo=(FloatImageObj*)selection; - QString pold=qpointToString(movingObj_orgRelPos); - QString pnow=qpointToString(fo->getRelPos()); + QString pold=qpointfToString(movingObj_orgRelPos); + QString pnow=qpointfToString(fo->getRelPos()); saveState( selection, "moveRel "+pold, @@ -3863,7 +3928,7 @@ // Check if we are over another branch, but ignore // any found LMOs, which are FloatObjs - dst=mapCenter->findMapObj(inverseWorldMatrix().map(e->pos() ), + dst=mapCenter->findMapObj(mapToScene(e->pos() ), ((LinkableMapObj*)selection) ); if (dst && (typeid(*dst)!=typeid(BranchObj) && typeid(*dst)!=typeid(MapCenterObj))) @@ -3878,7 +3943,7 @@ { // A branch was moved // save the position in case we link to mapcenter - QPoint savePos=QPoint (selection->x(),selection->y() ); + QPointF savePos=QPointF (selection->x(),selection->y() ); // Reset the temporary drawn link to the original one ((LinkableMapObj*)selection)->unsetParObjTmp(); @@ -3934,9 +3999,9 @@ // Therefor reposition and then use string of old selection, too mapCenter->reposition(); - QString ps=qpointToString ( ((BranchObj*)selection)->getRelPos() ); + QString ps=qpointfToString ( ((BranchObj*)selection)->getRelPos() ); saveState( - selection->getSelectString(), "moveRel "+qpointToString(movingObj_orgRelPos), + selection->getSelectString(), "moveRel "+qpointfToString(movingObj_orgRelPos), preSelStr, "moveRel "+ps, QString("Move %1 to relative position %2").arg(getName(selection)).arg(ps)); @@ -3944,9 +4009,9 @@ // Draw the original link, before selection was moved around mapCenter->reposition(); } - // Finally resize canvas, if needed + // Finally resize scene, if needed adjustCanvasSize(); - canvas()->update(); + scene()->update(); movingObj=NULL; // Just make sure, that actions are still ok,e.g. the move branch up/down buttons... @@ -3957,11 +4022,11 @@ } -void MapEditor::contentsMouseDoubleClickEvent(QMouseEvent* e) +void MapEditor::mouseDoubleClickEvent(QMouseEvent* e) { if (e->button() == Qt::LeftButton ) { - QPoint p = inverseWorldMatrix().map(e->pos()); + QPointF p = mapToScene(e->pos()); LinkableMapObj *lmo=mapCenter->findMapObj(p, NULL); if (lmo) { // MapObj was found // First select the MapObj than edit heading @@ -3975,74 +4040,57 @@ void MapEditor::resizeEvent (QResizeEvent* e) { - Q3CanvasView::resizeEvent( e ); + QGraphicsView::resizeEvent( e ); adjustCanvasSize(); } void MapEditor::contentsDragEnterEvent(QDragEnterEvent *event) { - if (selection && - (typeid(*selection) == typeid(BranchObj)) || - (typeid(*selection) == typeid(MapCenterObj))) - { - if (event->mimeData()->hasFormat("image/png")) - { - cout <<"found png in dragenterevent\n"; - event->accept(); - return; - } - - if (event->mimeData()->hasFormat("text/uri-list")) - { - cout <<"found uri-list in dragenterevent\n"; - event->accept(); - return; - } - -/* - // If QImageDrag can decode mime type - if (Q3ImageDrag::canDecode(event)) - { - cout << "dragenterevent q3imagedrag\n"; - event->accept(); - return; - } -*/ - // If image are dragged from firefox - if (event->mimeData()->hasFormat("application/x-moz-file-promise-url") && - event->mimeData()->hasFormat("application/x-moz-nativeimage")) { - event->accept(true); - cout << "dragenterevent firefox\n"; - return; - } -/* - // If QUriDrag can decode mime type - if (Q3UriDrag::canDecode(event)) { - event->accept(); - cout << "accepted uri drag\n"; - return; - } + //FIXME not ported to QT4 yet + +// for (unsigned int i=0;event->format(i);i++) // Debug mime type +// cerr << event->format(i) << endl; + + if (selection && + (typeid(*selection) == typeid(BranchObj)) || + (typeid(*selection) == typeid(MapCenterObj))) { + + // If QImageDrag can decode mime type + if (Q3ImageDrag::canDecode(event)) { + event->accept(); + return; + } + + // If image are dragged from firefox + if (event->provides("application/x-moz-file-promise-url") && + event->provides("application/x-moz-nativeimage")) { + event->accept(true); + return; + } + + // If QUriDrag can decode mime type + if (Q3UriDrag::canDecode(event)) { + event->accept(); + return; + } + // If Uri are dragged from firefox - if (event->provides("_NETSCAPE_URL")){ - event->accept(); - cout << "dragenterevent NETSCAPE\n"; - return; - } - - // If QTextDrag can decode mime type - if (Q3TextDrag::canDecode(event)) { - event->accept(); - cout << "dragenterevent textdrag\n"; - return; - } -*/ - } - event->ignore(); + if (event->provides("_NETSCAPE_URL")){ + event->accept(); + return; + } + + // If QTextDrag can decode mime type + if (Q3TextDrag::canDecode(event)) { + event->accept(); + return; + } + + } + event->ignore(); } - - -/* FIXME needed in QT4? bool isUnicode16(const QByteArray &d) +bool isUnicode16(const QByteArray &d) { // TODO: make more precise check for unicode 16. // Guess unicode16 if any of second bytes are zero @@ -4051,17 +4099,16 @@ if (d.at(i*2+1)==0) return true; return false; } -*/ - + void MapEditor::contentsDropEvent(QDropEvent *event) { + //FIXME not ported to QT4 yet if (selection && (typeid(*selection) == typeid(BranchObj)) || (typeid(*selection) == typeid(MapCenterObj))) { bool update=false; QStringList uris; - QList urls; QString heading; @@ -4069,21 +4116,34 @@ { event->acceptProposedAction(); addFloatImageInt(event->mimeData()->imageData().value()); - cout << "Drop png...\n"; - } else if (event->mimeData()->hasFormat("application/x-moz-file-promise-url")&& - event->mimeData()->hasFormat("application/x-moz-nativeimage")) + cout << "accepted drop\n"; + } + + /* + if (event->provides("image/png")) { - cout << "Drop Mozilla...\n"; + QPixmap pix; + if (Q3ImageDrag::decode(event, pix)) + { + addFloatImageInt(pix); + event->accept(); + update=true; + } else + event->ignore(); + + } else if (event->provides("application/x-moz-file-promise-url") && + event->provides("application/x-moz-nativeimage")) + { // Contains url to the img src in unicode16 QByteArray d = event->encodedData("application/x-moz-file-promise-url"); QString url = QString((const QChar*)d.data(),d.size()/2); - //FIXME fetchImage(url); - event->acceptProposedAction(); + fetchImage(url); + event->accept(); update=true; - } else if (event->mimeData()->hasUrls()) - { - urls=event->mimeData()->urls(); - } /*else if (event->provides ("_NETSCAPE_URL")) + } else if (event->provides ("text/uri-list")) + { // Uris provided e.g. by konqueror + Q3UriDrag::decode (event,uris); + } else if (event->provides ("_NETSCAPE_URL")) { // Uris provided by Mozilla QStringList l = QStringList::split("\n", event->encodedData("_NETSCAPE_URL")); uris.append(l[0]); @@ -4118,10 +4178,6 @@ } */ - for (int i=0; i0) { @@ -4165,7 +4221,7 @@ //saveStateComplete("Drop Event"); //TODO undo Command mapCenter->reposition(); adjustCanvasSize(); - canvas()->update(); + scene()->update(); } } } @@ -4177,7 +4233,6 @@ (typeid(*selection) == typeid(MapCenterObj)) ) { BranchObj *bo=((BranchObj*)selection); - qWarning ("Warning: Image added by drop event: no undo/redo so far."); //FIXME XXX saveStateChangingPart(selection,QString("Add floatimage to %1").arg(getName(bo))); //QString fn=fd->selectedFile(); //lastImageDir=fn.left(fn.findRev ("/")); @@ -4186,13 +4241,12 @@ fio->setOriginalFilename("Image added by Drag and Drop"); mapCenter->reposition(); adjustCanvasSize(); - canvas()->update(); + scene()->update(); } } -//void MapEditor::imageDataFetched(const QByteArray &a, Q3NetworkOperation */*nop*/) -/* FIXME not needed in QT4 +void MapEditor::imageDataFetched(const QByteArray &a, Q3NetworkOperation */*nop*/) { if (!imageBuffer) imageBuffer = new QBuffer(); if (!imageBuffer->isOpen()) { @@ -4235,5 +4289,3 @@ this, SLOT(imageDataFetched(const QByteArray &, Q3NetworkOperation *))); urlOperator->get(); } - -*/ diff -r 5db8dfd30ea2 -r c2a05fa925a1 mapeditor.h --- a/mapeditor.h Thu Nov 23 16:18:26 2006 +0000 +++ b/mapeditor.h Fri Dec 08 20:18:56 2006 +0000 @@ -1,8 +1,8 @@ #ifndef MAPEDITOR_H #define MAPEDITOR_H -#include #include +#include #include "mapcenterobj.h" #include "file.h" @@ -10,22 +10,24 @@ #include "selection.h" #include "settings.h" +class Q3NetworkOperation; +class Q3UrlOperator; -class MapEditor : public Q3CanvasView , public xmlObj { +class MapEditor : public QGraphicsView, public xmlObj { Q_OBJECT public: - MapEditor(QWidget* parent=0, const char* name=0, Qt::WFlags f=0); + MapEditor(QWidget* parent=0); ~MapEditor(); MapCenterObj* getMapCenter(); - Q3Canvas* getCanvas(); + QGraphicsScene * getScene(); void adjustCanvasSize();// adjust canvas size to map and scrollview bool isRepositionBlocked(); // block while load or undo private: QString getName(LinkableMapObj*); // Get e.g. heading or filename void makeTmpDirs(); // create temporary directories - QString saveToDir(const QString&,const QString &,bool, const QPoint &,LinkableMapObj*); + QString saveToDir(const QString&,const QString &,bool, const QPointF &,LinkableMapObj*); void saveStateChangingPart (LinkableMapObj *, LinkableMapObj *, const QString &, const QString &); void saveStateRemovingPart (LinkableMapObj *, const QString &); void saveState(LinkableMapObj *, const QString &, LinkableMapObj *, const QString &, const QString &); @@ -37,12 +39,11 @@ void addFloatImageInt(const QPixmap &img); private slots: -//FIXME not needed QT4 void fetchImage(const QString &img); -//FIXME not needed QT4 void imageDataFetched(const QByteArray &, Q3NetworkOperation *); -//FIXME not needed QT4 void imageDataFinished(Q3NetworkOperation *); + void fetchImage(const QString &img); + void imageDataFetched(const QByteArray &, Q3NetworkOperation *); + void imageDataFinished(Q3NetworkOperation *); public: - void toggleHistoryWindow(); bool isDefault(); // false, if map was changed once bool isUnsaved(); // save necessary bool hasChanged(); // undo possible @@ -60,6 +61,8 @@ void setZipped(bool); // save map zipped bool saveZipped(); // 1 if file will be saved zipped void print(); // print canvas + void setAntiAlias (bool); + void setSmoothPixmap(bool); private: QPixmap getPixmap(); void setHideTmpMode (HideTmpMode); // temporary hide stuff @@ -116,6 +119,8 @@ void selectRightBranch(); void selectFirstBranch(); void selectLastBranch(); + void selectMapBackgroundImage(); + void setMapBackgroundImage(const QString &); void selectMapBackgroundColor(); void setMapBackgroundColor(QColor); QColor getMapBackgroundColor(); @@ -180,18 +185,18 @@ protected: void ensureSelectionVisible(); virtual void updateViewCenter(); // needed for zooming - virtual void contentsContextMenuEvent ( QContextMenuEvent *e ); + virtual void contextMenuEvent ( QContextMenuEvent *e ); virtual void keyPressEvent(QKeyEvent*); virtual void keyReleaseEvent(QKeyEvent*); - virtual void contentsMousePressEvent(QMouseEvent*); - virtual void contentsMouseReleaseEvent(QMouseEvent*); - virtual void contentsMouseDoubleClickEvent(QMouseEvent*); - virtual void contentsMouseMoveEvent(QMouseEvent*); + virtual void mousePressEvent(QMouseEvent*); + virtual void mouseReleaseEvent(QMouseEvent*); + virtual void mouseDoubleClickEvent(QMouseEvent*); + virtual void mouseMoveEvent(QMouseEvent*); - virtual void contentsDragEnterEvent(QDragEnterEvent *event); + virtual void contentsDragEnterEvent(QDragEnterEvent *event); virtual void contentsDropEvent(QDropEvent *event); private: - Q3Canvas* mapCanvas; + QGraphicsScene *mapScene; MapCenterObj* mapCenter; bool adjustCanvasRequested; // collect requests until end of user event @@ -217,12 +222,12 @@ LinkableMapObj* selectionLast; // last selection MapObj* movingObj; // moving a MapObj MapObj* linkingObj_src; // part of a link - QPoint movingObj_orgPos; // org. pos of mouse before move - QPoint movingObj_orgRelPos; // org. relative pos of mouse before move - QPoint movingObj_start; // rel. pos of mouse to absPos - QPoint movingCont_start; // inital pos of moving Content or - QPoint movingVec; // how far has Content moved - QPoint movingCenter; // used when zooming + QPointF movingObj_orgPos; // org. pos of mouse before move + QPointF movingObj_orgRelPos; // org. relative pos of mouse before move + QPointF movingObj_start; // rel. pos of mouse to absPos + QPointF movingCont_start; // inital pos of moving Content or + QPointF movingVec; // how far has Content moved + QPointF movingCenter; // used when zooming QPrinter* printer; // Printing bool mapDefault; // Flag if map is untouched diff -r 5db8dfd30ea2 -r c2a05fa925a1 mapobj.cpp --- a/mapobj.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/mapobj.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -6,15 +6,15 @@ ///////////////////////////////////////////////////////////////// MapObj::MapObj () { - //qWarning ( "Const MapObj (): Please set canvas somehow!!!"); - canvas=NULL; + //qWarning ( "Const MapObj (): Please set scene somehow!!!"); + scene=NULL; init (); } -MapObj::MapObj (Q3Canvas* c) +MapObj::MapObj (QGraphicsScene *s) { // cout << "Const MapObj\n"; - canvas=c; + scene=s; init (); } @@ -32,91 +32,101 @@ void MapObj::init () { - absPos=QPoint(0,0); + absPos=QPointF(0,0); visible=true; } void MapObj::copy(MapObj* other) { -// canvas=other->canvas; // already set in constr. of child, use that one... +// scene=other->scene; // already set in constr. of child, use that one... absPos=other->absPos; bbox.setX (other->bbox.x() ); bbox.setY (other->bbox.y() ); - bbox.setSize (QSize(other->bbox.width(), other->bbox.height() ) ); + bbox.setSize (QSizeF(other->bbox.width(), other->bbox.height() ) ); } -Q3Canvas* MapObj::getCanvas() +QGraphicsScene* MapObj::getScene() { - return canvas; + return scene; } -int MapObj::x() +qreal MapObj::x() { return absPos.x(); } -int MapObj::y() +qreal MapObj::y() { return absPos.y(); } -int MapObj::width() +qreal MapObj::width() { return bbox.width(); } -int MapObj::height() +qreal MapObj::height() { return bbox.height(); } -QPoint MapObj::getAbsPos() +QPointF MapObj::getAbsPos() { return absPos; } QString MapObj::getPos() { - return qpointToString(absPos); + return qpointfToString(absPos); } void MapObj::move (double x, double y) { - int xi=static_cast (x); - int yi=static_cast (y); - absPos.setX( xi); - absPos.setY( yi); - bbox.moveTopLeft(QPoint(xi,yi)); - clickBox.moveTopLeft(QPoint(xi,yi)); + absPos.setX( x); + absPos.setY( y); + bbox.moveTo(QPointF(x,y)); + clickBox.moveTo(QPointF(x,y)); +} + +void MapObj::move (QPointF p) +{ + absPos=p; + bbox.moveTo (p); + clickBox.moveTo (p); } void MapObj::moveBy (double x, double y) { - int ix=(int)x; - int iy=(int)y; MapObj::move (x+absPos.x(),y+absPos.y() ); - bbox.moveBy (ix,iy); - clickBox.moveBy (ix,iy); + bbox.moveTo (bbox.x()+x,bbox.y()+y); + clickBox.moveTo (clickBox.x()+x,clickBox.y()+y); } -bool MapObj::inBox(const QPoint &p) +bool MapObj::inBox(const QPointF &p) { +/* FIXME testing QT4 only + cout << "MO::inBox "<= clickBox.left() && p.x() <= clickBox.right() && p.y() <= clickBox.bottom() && p.y() >= clickBox.top() ) return true; return false; } -QRect MapObj::getBBox() +QRectF MapObj::getBBox() { return bbox; } -QRect MapObj::addBBox(QRect r1, QRect r2) +QRectF MapObj::addBBox(QRectF r1, QRectF r2) { - // Find smallest QRect containing given rectangles + // Find smallest QRectF containing given rectangles - QRect n; + QRectF n; // Set left border if (r1.left() <= r2.left() ) n.setLeft(r1.left() ); @@ -143,7 +153,7 @@ return n; } -QSize MapObj::getSize() +QSizeF MapObj::getSize() { return bbox.size(); } diff -r 5db8dfd30ea2 -r c2a05fa925a1 mapobj.h --- a/mapobj.h Thu Nov 23 16:18:26 2006 +0000 +++ b/mapobj.h Fri Dec 08 20:18:56 2006 +0000 @@ -1,7 +1,8 @@ #ifndef MAPOBJ_H #define MAPOBJ_H -#include +#include +#include #include #include "misc.h" @@ -20,33 +21,34 @@ class MapObj:public xmlObj { public: MapObj (); - MapObj (Q3Canvas*); + MapObj (QGraphicsScene*); MapObj (MapObj*); virtual ~MapObj (); virtual void init (); virtual void copy (MapObj*); - virtual Q3Canvas* getCanvas(); - virtual int x(); - virtual int y(); - virtual int width(); - virtual int height(); - virtual QPoint getAbsPos(); + virtual QGraphicsScene* getScene(); + virtual qreal x(); + virtual qreal y(); + virtual qreal width(); + virtual qreal height(); + virtual QPointF getAbsPos(); virtual QString getPos(); // Return position as string (x,y) virtual void move (double x,double y); // move to absolute Position + virtual void move (QPointF p); virtual void moveBy (double x,double y); // move to relative Position - virtual bool inBox(const QPoint&); // Check if Point is within clickbox - virtual QRect getBBox(); // returns bounding box - virtual QRect addBBox(QRect,QRect); // returns bbox which includes both boxes - virtual QSize getSize(); // returns size of bounding box + virtual bool inBox(const QPointF&); // Check if Point is within clickbox + virtual QRectF getBBox(); // returns bounding box + virtual QRectF addBBox(QRectF,QRectF); // returns bbox which includes both boxes + virtual QSizeF getSize(); // returns size of bounding box virtual bool isVisibleObj(); virtual void setVisibility(bool); virtual void positionBBox()=0; virtual void calcBBoxSize()=0; protected: - Q3Canvas* canvas; - QRect bbox; // bounding box of MO itself - QRect clickBox; // area where mouseclicks are found - QPoint absPos; // Position on canvas + QGraphicsScene* scene; + QRectF bbox; // bounding box of MO itself + QRectF clickBox; // area where mouseclicks are found + QPointF absPos; // Position on canvas bool visible; }; diff -r 5db8dfd30ea2 -r c2a05fa925a1 misc.cpp --- a/misc.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/misc.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -11,13 +11,25 @@ return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")"; } +QString qpointfToString (const QPointF &p) +{ +// FIXME check this QT4 + return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")"; +} + ostream &operator<< (ostream &stream, QPoint const &p) { stream << "("<0) - return (float)(M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) ); + return (qreal)(M_PI - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) ); else if (p.x()<0) - return (float)( 2*M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) ); + return (qreal)( 2*M_PI - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) ); else - return (float)( - atan ( (double)(p.x()) / (double)(p.y()) ) ); + return (qreal)( - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) ); } } -QPoint normalise(const QPoint &p) +QPointF normalise(const QPointF &p) { // Calculate normalised position (fixed length) - double px=p.x(); - double py=p.y(); - double x; - double y; - double r=150; + qreal px=p.x(); + qreal py=p.y(); + qreal x; + qreal y; + qreal r=150; if (px==0) { @@ -57,8 +69,8 @@ y=-r; } else { - double sign; - double a; + qreal sign; + qreal a; if (px>0) sign=1; else @@ -87,7 +99,8 @@ return r; } -int max(int a, int b) + +qreal max(qreal a, qreal b) { if (a>b) return a; diff -r 5db8dfd30ea2 -r c2a05fa925a1 misc.h --- a/misc.h Thu Nov 23 16:18:26 2006 +0000 +++ b/misc.h Fri Dec 08 20:18:56 2006 +0000 @@ -10,11 +10,13 @@ ///////////////////////////////////////////////////////////////////////////// QString qpointToString (const QPoint &p); +QString qpointfToString (const QPointF &p); extern ostream &operator<< (ostream &stream, QPoint const &p); -float getAngle(const QPoint &); -QPoint normalise (const QPoint &); +extern ostream &operator<< (ostream &stream, QPointF const &p); +qreal getAngle(const QPointF &); +QPointF normalise (const QPointF &); QString quotemeta(const QString&); -int max (int,int); +qreal max (qreal,qreal); class BranchObj; class MapEditor; diff -r 5db8dfd30ea2 -r c2a05fa925a1 options.cpp --- a/options.cpp Thu Nov 23 16:18:26 2006 +0000 +++ b/options.cpp Fri Dec 08 20:18:56 2006 +0000 @@ -1,7 +1,8 @@ #include "options.h" + #include +#include -#include using namespace std; @@ -16,6 +17,14 @@ active=false; } +Option::Option (const QString &n, const OptionType &t, const QString &s, const QString &l) +{ + sName="-"+s; + lName="--"+l; + type=t; + name=n; +} + void Option::set(const QString &n, const OptionType &t, const QString &s, const QString &l) { sName="-"+s; @@ -40,7 +49,7 @@ { QStringList arglist; int i=0; - while (iargc()) + while ( i < qApp->argc()) { arglist.append (qApp->argv()[i]); i++; @@ -52,37 +61,32 @@ // Work through rest of options bool isFile; - OptionList::iterator itopt; - QStringList::iterator itarg; - itarg=arglist.begin(); - while (itarg!=arglist.end()) + for (i=0; i< arglist.size(); ++i) { isFile=true; - if ((*itarg).left(1)=="-") + if (arglist[i].left(1)=="-") { // Compare given option to all defined options - itopt=optlist.begin(); - while (itopt!=optlist.end()) + for (int j=0; j < optlist.size(); ++j) { - if ((*itarg)==(*itopt).getShort() || - (*itarg)==(*itopt).getLong()) + if (arglist.at(i)==optlist.value(j).getShort() || + arglist.at(i)==optlist.value(j).getLong()) { - (*itopt).setActive(); + optlist[j].setActive(); isFile=false; - if ((*itopt).getType()==StringOption) + if (optlist[j].getType()==StringOption) { - itarg++; - if (itarg==arglist.end()) + i++; + if (i==arglist.size()) { - cout << "Error: argument to option missing\n"; + qWarning ("Error: argument to option missing"); return 1; } - (*itopt).setArg (*itarg); + optlist[j].setArg (arglist[i]); isFile=false; } break; } - itopt++; } if (isFile) { @@ -90,12 +94,16 @@ return 1; } } else - filelist.append (*itarg); - itarg++; + filelist.append (arglist[i]); } return 0; } +void Options::add (Option o) +{ + optlist.append (o); +} + void Options::add (const QString &n, const OptionType &t=SwitchOption, const QString &s="", const QString &l="") { Option o; @@ -125,20 +133,15 @@ bool Options::isOn(const QString &s) { - OptionList::iterator it; - for ( it = optlist.begin(); it != optlist.end(); ++it ) - if ((*it).getName()==s && (*it).isActive() ) + for (int i=0; i -#include -//Added by qt3to4: -#include +#include enum OptionType {SwitchOption,StringOption}; @@ -12,6 +9,7 @@ { public: Option(); + Option(const QString &, const OptionType &, const QString &, const QString &); void set (const QString &, const OptionType &, const QString &, const QString &); QString getName(); QString getShort(); @@ -31,14 +29,12 @@ }; - -typedef Q3ValueList