[Kst] extragear/graphics/kst/src/libkstapp
George Staikos
staikos at kde.org
Thu May 25 15:06:38 CEST 2006
SVN commit 544591 by staikos:
Revert commit 541977
This code does not belong in KstViewObject, should not be a virtual function,
should take const references as parameters, should use a const iterator, should
not use iVariables, and should be a const function. If anything in there
prevents fixing constness, it's probably pointing to another issue elsewhere.
Anyway, all this belongs in the view, not in each object.
REOPEN: 127536
M +35 -2 ksttoplevelview.cpp
M +0 -38 kstviewobject.cpp
M +0 -2 kstviewobject.h
--- trunk/extragear/graphics/kst/src/libkstapp/ksttoplevelview.cpp #544590:544591
@@ -707,8 +707,41 @@
int iXMin = STICKY_THRESHOLD;
int iYMin = STICKY_THRESHOLD;
- snapToBorders(&iXMin, &iYMin, _selectionList, _pressTarget, r);
+ // check for "sticky" borders
+ for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+ if (_selectionList.find(*i) == _selectionList.end() && _pressTarget != *i) {
+ const QRect rect((*i)->geometry());
+ int overlapLo = r.top() > rect.top() ? r.top() : rect.top();
+ int overlapHi = r.bottom() < rect.bottom() ? r.bottom() : rect.bottom();
+ if (overlapHi - overlapLo > 0) {
+ if (labs(r.left() - rect.left()) < labs(iXMin)) {
+ iXMin = r.left() - rect.left();
+ } else if (labs(r.left() - rect.right()) < labs(iXMin)) {
+ iXMin = r.left() - rect.right();
+ } else if (labs(r.right() - rect.left()) < labs(iXMin)) {
+ iXMin = r.right() - rect.left();
+ } else if (labs(r.right() - rect.right()) < labs(iXMin)) {
+ iXMin = r.right() - rect.right();
+ }
+ }
+
+ overlapLo = r.left() > rect.left() ? r.left() : rect.left();
+ overlapHi = r.right() < rect.right() ? r.right() : rect.right();
+ if (overlapHi - overlapLo > 0) {
+ if (labs(r.top() - rect.top()) < labs(iYMin)) {
+ iYMin = r.top() - rect.top();
+ } else if (labs(r.top() - rect.bottom()) < labs(iYMin)) {
+ iYMin = r.top() - rect.bottom();
+ } else if (labs(r.bottom() - rect.top()) < labs(iYMin)) {
+ iYMin = r.bottom() - rect.top();
+ } else if (labs(r.bottom() - rect.bottom()) < labs(iYMin)) {
+ iYMin = r.bottom() - rect.bottom();
+ }
+ }
+ }
+ }
+
if (labs(iXMin) < STICKY_THRESHOLD) {
_moveOffsetSticky.setX(iXMin);
topLeft.setX(topLeft.x() - iXMin);
@@ -718,7 +751,7 @@
topLeft.setY(topLeft.y() - iYMin);
}
- r.moveTopLeft(topLeft);
+ r.moveTopLeft(topLeft);
if (!_geom.contains(r, true)) {
slideInto(_geom, r);
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewobject.cpp #544590:544591
@@ -463,44 +463,6 @@
}
-void KstViewObject::snapToBorders(int *iXMin, int *iYMin, KstViewObjectList &selectionList, KstViewObjectPtr &pressTarget, const QRect &r) {
- for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
- (*i)->snapToBorders(iXMin, iYMin, selectionList, pressTarget, r);
- if (selectionList.find(*i) == selectionList.end() && pressTarget != *i) {
- const QRect rect((*i)->geometry());
-
- int overlapLo = r.top() > rect.top() ? r.top() : rect.top();
- int overlapHi = r.bottom() < rect.bottom() ? r.bottom() : rect.bottom();
- if (overlapHi - overlapLo > 0) {
- if (labs(r.left() - rect.left()) < labs(*iXMin)) {
- *iXMin = r.left() - rect.left();
- } else if (labs(r.left() - rect.right()) < labs(*iXMin)) {
- *iXMin = r.left() - rect.right();
- } else if (labs(r.right() - rect.left()) < labs(*iXMin)) {
- *iXMin = r.right() - rect.left();
- } else if (labs(r.right() - rect.right()) < labs(*iXMin)) {
- *iXMin = r.right() - rect.right();
- }
- }
-
- overlapLo = r.left() > rect.left() ? r.left() : rect.left();
- overlapHi = r.right() < rect.right() ? r.right() : rect.right();
- if (overlapHi - overlapLo > 0) {
- if (labs(r.top() - rect.top()) < labs(*iYMin)) {
- *iYMin = r.top() - rect.top();
- } else if (labs(r.top() - rect.bottom()) < labs(*iYMin)) {
- *iYMin = r.top() - rect.bottom();
- } else if (labs(r.bottom() - rect.top()) < labs(*iYMin)) {
- *iYMin = r.bottom() - rect.top();
- } else if (labs(r.bottom() - rect.bottom()) < labs(*iYMin)) {
- *iYMin = r.bottom() - rect.bottom();
- }
- }
- }
- }
-}
-
-
void KstViewObject::appendChild(KstViewObjectPtr obj, bool keepAspect) {
obj->_parent = this;
_children.append(obj);
--- trunk/extragear/graphics/kst/src/libkstapp/kstviewobject.h #544590:544591
@@ -118,8 +118,6 @@
virtual bool maintainAspect() const;
virtual void setMaintainAspect(bool maintain);
- virtual void snapToBorders(int *iXMin, int *iYMin, KstViewObjectList &selectionList, KstViewObjectPtr &pressTarget, const QRect &r);
-
virtual void appendChild(KstViewObjectPtr obj, bool keepAspect = false);
virtual void prependChild(KstViewObjectPtr obj, bool keepAspect = false);
virtual bool removeChild(KstViewObjectPtr obj, bool recursive = false);
More information about the Kst
mailing list