[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Thu Apr 8 07:52:50 CEST 2004


CVS commit by staikos: 

add a parent pointer, optimize a call, disable selection when not in
layout mode


  M +4 -2      kst2dplot.cpp   1.5
  M +12 -2     ksttoplevelview.cpp   1.20
  M +8 -0      kstviewobject.cpp   1.16
  M +1 -0      kstviewobject.h   1.12


--- kdeextragear-2/kst/kst/kst2dplot.cpp  #1.4:1.5
@@ -52,5 +52,5 @@ bool Kst2DPlot::popupMenu(KPopupMenu *me
   KstViewObject::popupMenu(menu, pos, topLevelParent);
   _view = dynamic_cast<KstTopLevelView*>(topLevelParent.data());
-  if (_view) {
+  if (_view && _parent) {
     menu->insertItem(i18n("Delete"), this, SLOT(deleteObject()));
     return true;
@@ -62,5 +62,7 @@ bool Kst2DPlot::popupMenu(KPopupMenu *me
 
 void Kst2DPlot::deleteObject() {
-  _view->removeChild(this, true);
+  if (_parent) {
+    _parent->removeChild(this);
+  }
   //_view->paint(true);
 }

--- kdeextragear-2/kst/kst/ksttoplevelview.cpp  #1.19:1.20
@@ -195,5 +195,5 @@ bool KstTopLevelView::handlePress(const 
 
   if (_mode != LayoutMode) {
-    _pressTarget = 0;
+    _pressTarget = 0L;
     return false;
   }
@@ -203,5 +203,5 @@ bool KstTopLevelView::handlePress(const 
 
   if (!_focusOn) {
-    _pressTarget = 0;
+    _pressTarget = 0L;
     _cursor.setShape(Qt::ArrowCursor);
     _w->setCursor(_cursor);
@@ -341,4 +341,9 @@ static void slideInto(const QRect& regio
 // Optimize me: can store, for instance, the painter I think
 void KstTopLevelView::pressMove(const QPoint& pos) {
+  if (_mode != LayoutMode) {
+    _pressTarget = 0L;
+    return;
+  }
+
   if (_pressDirection == -1 && _pressTarget) { // menu released
     return;
@@ -391,4 +396,9 @@ void KstTopLevelView::pressMove(const QP
 
 void KstTopLevelView::releasePress(const QPoint& pos) {
+  if (_mode != LayoutMode) {
+    _pressTarget = 0L;
+    return;
+  }
+
   if (_pressDirection == -1 && _pressTarget) { // menu released
     _pressTarget = 0L;

--- kdeextragear-2/kst/kst/kstviewobject.h  #1.11:1.12
@@ -95,4 +95,5 @@ class KstViewObject : public KstObject {
     bool _focus : 1;
     bool _selected : 1;
+    KstViewObjectPtr _parent;
 };
 

--- kdeextragear-2/kst/kst/kstviewobject.cpp  #1.15:1.16
@@ -36,4 +36,5 @@ KstViewObject::KstViewObject(QDomElement
 
 KstViewObject::~KstViewObject() {
+  _parent = 0L;
 }
 
@@ -90,4 +91,5 @@ void KstViewObject::paint(QPainter& p) {
 
 void KstViewObject::appendChild(KstViewObjectPtr obj) {
+  obj->_parent = this;
   _children.append(obj);
 }
@@ -95,4 +97,5 @@ void KstViewObject::appendChild(KstViewO
 
 void KstViewObject::prependChild(KstViewObjectPtr obj) {
+  obj->_parent = this;
   _children.prepend(obj);
 }
@@ -105,4 +108,5 @@ bool KstViewObject::removeChild(KstViewO
       
       if ((*i)->removeChild(obj, true)) {
+        obj->_parent = 0L;
         return true;
       }
@@ -121,8 +125,12 @@ void KstViewObject::insertChildAfter(con
     _children.prepend(obj);
   }
+  obj->_parent = this;
 }
 
 
 void KstViewObject::clearChildren() {
+  for (KstViewObjectList::Iterator i = _children.begin(); i != _children.end(); ++i) {
+    (*i)->_parent = 0L;
+  }
   _children.clear();
 }





More information about the Kst mailing list