# HG changeset patch # User insilmaril # Date 1209995202 0 # Node ID 0c2d74acf03535e0c09626272ba1fb245d2360ef # Parent cade59622d81665ab22f0f61f24055263da8f02e Some code cleanup and experimental stuff to support animations later diff -r cade59622d81 -r 0c2d74acf035 vymmodel.cpp --- a/vymmodel.cpp Mon May 05 13:46:42 2008 +0000 +++ b/vymmodel.cpp Mon May 05 13:46:42 2008 +0000 @@ -4,6 +4,9 @@ #include "geometry.h" // for addBBox #include "vymmodel.h" + +extern Settings settings; + VymModel::VymModel() { // cout << "Const VymModel\n"; @@ -24,6 +27,15 @@ void VymModel::init () { addMapCenter(); + + // animations + animationUse=settings.readBoolEntry("/animation/use",false); + animationTicks=settings.readNumEntry("/animation/ticks",10); + animationInterval=settings.readNumEntry("/animation/interval",50); + animObjList.clear(); + animationTimer=new QTimer (this); + connect(animationTimer, SIGNAL(timeout()), this, SLOT(animate())); + } void VymModel::setMapEditor(MapEditor *me) @@ -251,9 +263,6 @@ // Move all branches and MapCenters away from lmo // to avoid collisions - // - - QPolygonF pA; QPolygonF pB; @@ -275,6 +284,44 @@ } } +void VymModel::animate() +{ + animationTimer->stop(); + BranchObj *bo; + int i=0; + while (ianimate()) + { + if (i>=0) animObjList.removeAt(i); + } + bo->reposition(); + i++; + } + mapEditor->updateSelection(); + mapScene->update(); + animationTimer->start(); +} + + +void VymModel::startAnimation(const QPointF &start, const QPointF &dest) +{ + BranchObj *bo=getSelectedBranch(); + if (bo && bo->getDepth()>0) + { + AnimPoint ap; + ap.setStart (start); + ap.setDest (dest); + ap.setTicks (animationTicks); + ap.setAnimated (true); + bo->setAnimation (ap); + animObjList.append( bo ); + animationTimer->setSingleShot (true); + animationTimer->start(animationInterval); + } +} + ////////////////////////////////////////////// // Selection related diff -r cade59622d81 -r 0c2d74acf035 vymmodel.h --- a/vymmodel.h Mon May 05 13:46:42 2008 +0000 +++ b/vymmodel.h Mon May 05 13:46:42 2008 +0000 @@ -10,7 +10,9 @@ /*! \brief This will later be divided into Model/View */ -class VymModel{ +class VymModel : public QObject{ + Q_OBJECT + public: VymModel(); ~VymModel (); @@ -49,7 +51,21 @@ QPolygonF shape(BranchObj *bo); //!< Returns arbitrary shape of subtree void moveAway (LinkableMapObj *lmo);//!< Autolayout: Move all out of the way + // Animation **experimental** +private slots: + void animate(); //!< Called by timer to animate stuff +public: + void startAnimation(const QPointF &start, const QPointF &dest); +private: + QTimer *animationTimer; + bool animationUse; + uint animationTicks; + uint animationInterval; + int timerId; // animation timer + QList animObjList;// list with animated objects + ////////////////////////////////////////// Selection related +public: LinkableMapObj* getSelection(); BranchObj* getSelectedBranch(); bool select (const QString &s);