SVN commit 1191706 by majewsky: Kill StateDB class and CanvasItem::{load,save}State. Instead, the positions of all items are saved/restored, because positions of moving objects is the only thing which load/saveState was used for. M +0 -5 canvasitem.h M +0 -11 floater.cpp M +0 -2 floater.h M +11 -22 game.cpp M +1 -5 game.h D statedb.h --- trunk/KDE/kdegames/kolf/canvasitem.h #1191705:1191706 @@ -30,7 +30,6 @@ class Ball; class KConfigGroup; -class StateDB; class KolfGame; class CanvasItem @@ -40,16 +39,12 @@ virtual ~CanvasItem() {} ///load your settings from the KConfigGroup, which represents a course. virtual void load(KConfigGroup *) {} - ///load a point if you wish. Rarely necessary. - virtual void loadState(StateDB * /*db*/) {} ///returns a bool that is true if your item needs to load after other items virtual bool loadLast() const { return false; } ///called if the item is made by user while editing, with the item that was selected on the hole; virtual void selectedItem(QGraphicsItem * /*item*/) {} ///save your settings. virtual void save(KConfigGroup *cfg); - ///save a point if you wish. Rarely necessary. - virtual void saveState(StateDB * /*db*/) {} ///called for information when shot started virtual void shotStarted() {} ///called right before any items are saved. --- trunk/KDE/kdegames/kolf/floater.cpp #1191705:1191706 @@ -235,17 +235,6 @@ game->updateHighlighter(); } -void Floater::saveState(StateDB *db) -{ - db->setPoint(pos()); -} - -void Floater::loadState(StateDB *db) -{ - const QPointF diff = db->point() - pos(); - moveBy(diff.x(), diff.y()); -} - void Floater::save(KConfigGroup *cfgGroup) { cfgGroup->writeEntry("speed", speed); --- trunk/KDE/kdegames/kolf/floater.h #1191705:1191706 @@ -60,8 +60,6 @@ Floater(QGraphicsItem * parent); virtual bool collision(Ball *ball, long int id) { Bridge::collision(ball, id); return false; } - virtual void saveState(StateDB *db); - virtual void loadState(StateDB *db); virtual void save(KConfigGroup *cfgGroup); virtual void load(KConfigGroup *cfgGroup); virtual bool loadLast() const { return true; } --- trunk/KDE/kdegames/kolf/game.cpp #1191705:1191706 @@ -1085,16 +1085,6 @@ return true; } -void Cup::saveState(StateDB *db) -{ - db->setPoint(pos()); -} - -void Cup::loadState(StateDB *db) -{ - setPos(db->point()); -} - bool Cup::collision(Ball *ball, long int /*id*/) { bool wasCenter = false; @@ -2970,16 +2960,14 @@ void KolfGame::recreateStateList() { - stateDB.clear(); - - QList::const_iterator item; - for (item = items.constBegin(); item != items.constEnd(); ++item) + savedState.clear(); + foreach (QGraphicsItem* item, items) { - CanvasItem *citem = dynamic_cast(*item); + CanvasItem* citem = dynamic_cast(item); if (citem) { - stateDB.setName(makeStateGroup(citem->curId(), citem->name())); - citem->saveState(&stateDB); + const QString key = makeStateGroup(citem->curId(), citem->name()); + savedState.insert(key, item->pos()); } } @@ -2998,14 +2986,15 @@ void KolfGame::loadStateList() { - QList::const_iterator item; - for (item = items.constBegin(); item != items.constEnd(); ++item) + foreach (QGraphicsItem* item, items) { - CanvasItem *citem = dynamic_cast(*item); + CanvasItem* citem = dynamic_cast(item); if (citem) { - stateDB.setName(makeStateGroup(citem->curId(), citem->name())); - citem->loadState(&stateDB); + const QString key = makeStateGroup(citem->curId(), citem->name()); + const QPointF currentPos = item->pos(); + const QPointF posDiff = savedState.value(key, currentPos) - currentPos; + citem->moveBy(posDiff.x(), posDiff.y()); } } --- trunk/KDE/kdegames/kolf/game.h #1191705:1191706 @@ -24,7 +24,6 @@ #include #include "ball.h" -#include "statedb.h" #include "tagaro/scene.h" @@ -266,9 +265,6 @@ Cup(QGraphicsItem *parent); virtual bool place(Ball *ball, bool wasCenter); - - virtual void saveState(StateDB *db); - virtual void loadState(StateDB *db); virtual bool canBeMovedByOthers() const { return true; } virtual bool collision(Ball *ball, long int id); @@ -932,7 +928,7 @@ bool m_ignoreEvents; HoleInfo holeInfo; - StateDB stateDB; + QMap savedState; BallStateList ballStateList; void loadStateList();