[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Sun Apr 11 18:57:56 CEST 2004


CVS commit by staikos: 

Minor move, selection fixlets, and draw the bounding focus rect for a selection
move instead of just the object that is focused.  This will later be changed to
draw the focus rect for each object individually.  Bounds checking for move
operations was added.


  M +19 -7     ksttoplevelview.cpp   1.24
  M +5 -3      kstviewobject.cpp   1.21
  M +7 -5      kstviewobject.h   1.17


--- kdeextragear-2/kst/kst/ksttoplevelview.cpp  #1.23:1.24
@@ -379,11 +379,17 @@ void KstTopLevelView::pressMove(const QP
       p.setRasterOp(Qt::NotROP);
       p.drawWinFocusRect(_prevBand);
-      QRect r = _pressTarget->geometry();
-      r.moveTopLeft(pos - _moveOffset);
+      QRect r;
+      r = _pressTarget->geometry();
+      if (!_selectionList.isEmpty()) {
+        for (KstViewObjectList::Iterator i = _selectionList.begin(); i != _selectionList.end(); ++i) {
+          r = r.unite((*i)->geometry());
+        }
+      }
+      r.moveTopLeft(pos - _moveOffset - _pressTarget->geometry().topLeft() + r.topLeft());
       if (!_geom.contains(r, true)) {
         slideInto(_geom, r);
         // adjust the offset to make smoother mouse
-        if (r.contains(pos)) {
-          _moveOffset = pos - r.topLeft();
+        if (_pressTarget->geometry().contains(pos)) {
+          _moveOffset = pos - _pressTarget->geometry().topLeft();
         }
       }
@@ -437,12 +443,18 @@ void KstTopLevelView::releasePress(const
       QRect obj = _pressTarget->geometry();
       QRect old = obj;
-      obj.moveTopLeft(pos - _moveOffset);
+      if (!_selectionList.isEmpty()) {
+        for (KstViewObjectList::Iterator i = _selectionList.begin(); i != _selectionList.end(); ++i) {
+          obj = obj.unite((*i)->geometry());
+        }
+      }
+      QPoint objOffset = _pressTarget->geometry().topLeft() - obj.topLeft();
+      obj.moveTopLeft(pos - _moveOffset - _pressTarget->geometry().topLeft() + obj.topLeft());
       if (!_geom.contains(obj, true)) {
         slideInto(_geom, obj);
       }
-      _pressTarget->move(obj.topLeft());
+      _pressTarget->move(obj.topLeft() + objOffset);
       for (KstViewObjectList::Iterator i = _selectionList.begin(); i != _selectionList.end(); ++i) {
         if (*i != _pressTarget) {
-          (*i)->move((*i)->geometry().topLeft() + obj.topLeft() - old.topLeft());
+          (*i)->move(_pressTarget->position() + (*i)->geometry().topLeft() - old.topLeft());
         }
       }

--- kdeextragear-2/kst/kst/kstviewobject.cpp  #1.20:1.21
@@ -290,8 +290,10 @@ bool KstViewObject::focused() const {
 
 
-void KstViewObject::recursively(void (KstViewObject::*method)()) {
+void KstViewObject::recursively(void (KstViewObject::*method)(), bool self) {
+  if (self) {
   (this->*method)();
+  }
   for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
-    (*i)->recursively(method);
+    (*i)->recursively(method, true);
   }
 }

--- kdeextragear-2/kst/kst/kstviewobject.h  #1.16:1.17
@@ -86,6 +86,6 @@ class KstViewObject : public KstObject {
     virtual void updateSelection(const QRect& region);
 
-    void recursively(void (KstViewObject::*)());
-    template<class T> void recursively(void (KstViewObject::*)(T), T);
+    void recursively(void (KstViewObject::*)(), bool self = false);
+    template<class T> void recursively(void (KstViewObject::*)(T), T, bool self = false);
 
     virtual bool popupMenu(KPopupMenu *menu, const QPoint& pos, KstViewObjectPtr topParent);
@@ -138,8 +138,10 @@ class KstViewObject : public KstObject {
 
 template<class T>
-void KstViewObject::recursively(void (KstViewObject::*method)(T), T arg) {
+void KstViewObject::recursively(void (KstViewObject::*method)(T), T arg, bool self) {
+  if (self) {
   (this->*method)(arg);
+  }
   for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
-    (*i)->recursively<T>(method, arg);
+    (*i)->recursively<T>(method, arg, true);
   }
 }





More information about the Kst mailing list