[Kst] extragear/graphics/kst/kst

Rick Chern rchern at interchange.ubc.ca
Tue Aug 9 02:54:08 CEST 2005


SVN commit 444154 by rchern:

- Click to select, and double click to edit an object.


 M  +29 -13    ksttoplevelview.cpp  
 M  +1 -0      ksttoplevelview.h  
 M  +2 -1      kstviewellipse.cpp  
 M  +7 -0      kstviewobject.cpp  
 M  +3 -0      kstviewobject.h  
 M  +10 -1     kstviewwidget.cpp  


--- trunk/extragear/graphics/kst/kst/ksttoplevelview.cpp #444153:444154
@@ -224,6 +224,8 @@
     return;
   }
 
+  // TODO: make this work better with the new click selection mode
+  
   KstViewObjectPtr p = findChildOfModeType(pos, true);
   if (p) {
     setCursorFor(pos, p);
@@ -362,7 +364,7 @@
   }
 
   assert(_pressTarget);
-
+  
   if (shift) {
     KstViewObjectList::Iterator it = _selectionList.find(_pressTarget);
 
@@ -385,8 +387,10 @@
     paint(P_PAINT);
 
     return true;
-  }
+  } 
+  
 
+
   _pressDirection = _pressTarget->directionFor(pos);
   if (_pressDirection == 0) {
     _moveOffset = pos - _pressTarget->position();
@@ -400,6 +404,13 @@
     _selectionList.clear();
     recursively<bool>(&KstViewObject::setSelected, false);
   }
+  
+  // single click selects a single object if it is not part of the current list
+  if (!_selectionList.contains(_pressTarget)) {
+    _selectionList.clear();
+    recursively<bool>(&KstViewObject::setSelected, false);
+  }
+  _pressTarget->setSelected(true);
 
   _pressTarget->setFocus(false);
 
@@ -885,6 +896,7 @@
 
 
 void KstTopLevelView::releasePressLayoutMode(const QPoint& pos, bool shift) {
+
   if (_pressTarget) {
     KstApp::inst()->document()->setModified();
     if (_pressDirection == 0) {
@@ -932,18 +944,13 @@
     slideInto(_geom, obj);
   }
       
-  // enhanced layout mode: bring up the properties dialog for the object if the object was not moved
-  if (_selectionList.isEmpty() && !_mouseMoved) {
-    KstApp::inst()->showEditViewObjectDialog(_pressTarget, this);
-  } else {
-    _pressTarget->move(obj.topLeft() + objOffset);
-    for (KstViewObjectList::Iterator i = _selectionList.begin(); i != _selectionList.end(); ++i) {
-      if (*i != _pressTarget) {
-        (*i)->move(_pressTarget->position() + (*i)->geometry().topLeft() - old.topLeft());
-      }
+  _pressTarget->move(obj.topLeft() + objOffset);
+  for (KstViewObjectList::Iterator i = _selectionList.begin(); i != _selectionList.end(); ++i) {
+    if (*i != _pressTarget) {
+      (*i)->move(_pressTarget->position() + (*i)->geometry().topLeft() - old.topLeft());
     }
-    _onGrid = false;
   }
+  _onGrid = false;
 }
 
 
@@ -991,7 +998,7 @@
 
 
 void KstTopLevelView::releasePress(const QPoint& pos, bool shift) { 
-  
+
   if (_activeMouseHandler) {
     _activeMouseHandler->releasePress(pos, shift);
     return;
@@ -1510,5 +1517,14 @@
 }
 
 
+bool KstTopLevelView::handleDoubleClick(const QPoint& pos, bool shift) {
+  handlePress(pos, shift);
+  if (_pressTarget) {
+    _pressTarget->showDialog(this);  
+  }  
+  return true;
+}
+
+
 #include "ksttoplevelview.moc"
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/ksttoplevelview.h #444153:444154
@@ -110,6 +110,7 @@
     void cancelMouseOperations();
     void updateFocus(const QPoint& pos);
     bool handlePress(const QPoint& pos, bool shift = false);
+    bool handleDoubleClick(const QPoint& pos, bool shift = false);
     
     // press move handlers
     void pressMove(const QPoint& pos, bool shift = false);
--- trunk/extragear/graphics/kst/kst/kstviewellipse.cpp #444153:444154
@@ -117,7 +117,8 @@
 
 
 void KstViewEllipse::drawSelectRect(QPainter& p) {
-  KstViewObject::drawFocusRect(p);
+  // draw the 8 hotpoints
+  KstViewObject::drawSelectRect(p);
 }
 
 
--- trunk/extragear/graphics/kst/kst/kstviewobject.cpp #444153:444154
@@ -36,6 +36,7 @@
 #include "kstplotgroup.h"
 #include "kstsettings.h"
 #include "ksttimers.h"
+#include "ksttoplevelview.h"
 #include "kstviewobject.h"
 #include "kstviewobjectfactory.h"
 #include "kstviewwindow.h"
@@ -304,6 +305,7 @@
 void KstViewObject::drawSelectRect(QPainter& p) {
   QPen pen(Qt::black, 2);
   p.setPen(pen);
+  p.setBrush(Qt::NoBrush); 
   QRect r;
   r.setX(_geom.left() + 2);
   r.setY(_geom.top() + 2);
@@ -1461,5 +1463,10 @@
 }
 
 
+void KstViewObject::showDialog(KstTopLevelViewPtr invoker) {
+  KstApp::inst()->showEditViewObjectDialog(this, invoker);
+}
+
+
 #include "kstviewobject.moc"
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstviewobject.h #444153:444154
@@ -32,9 +32,11 @@
 class KPopupMenu;
 class KstViewObject;
 class KstViewWidget;
+class KstTopLevelView;
 typedef KstSharedPtr<KstViewObject> KstViewObjectPtr;
 typedef KstObjectList<KstViewObjectPtr> KstViewObjectList;
 typedef KstViewObjectPtr (*KstViewObjectFactoryMethod)();
+typedef KstSharedPtr<KstTopLevelView> KstTopLevelViewPtr;
 
 // KstPaintType - hints to paint to allow optimizations
 // P_PAINT: Neither 'data' nor 'plot' needs to change
@@ -220,6 +222,7 @@
     virtual void zoomToggle();
     virtual void copyObject();
     virtual void copyObjectQuietly(KstViewObject& parent, const QString& name = QString::null) const;
+    virtual void showDialog(KstTopLevelViewPtr invoker);
 
   protected slots:
     virtual void parentResized();
--- trunk/extragear/graphics/kst/kst/kstviewwidget.cpp #444153:444154
@@ -197,7 +197,7 @@
     return;
   }
 
-  // Layout mode
+  // Layout/graphics mode
   if (e->button() & Qt::LeftButton) {
     if (_view->handlePress(e->pos(), e->state() & Qt::ShiftButton)) {
       //kdDebug() << "   -> Accepting" << endl;
@@ -231,6 +231,15 @@
     }
     return;
   }
+ 
+  // layout/graphics mode 
+  if (e->button() & Qt::LeftButton) {
+    // let the toplevel view handle it
+    if (_view->handleDoubleClick(e->pos(), e->state() & Qt::ShiftButton)) {
+      e->accept();
+      return;  
+    }  
+  }
 
   //kdDebug() << "   -> Passing up" << endl;
   QWidget::mouseDoubleClickEvent(e);


More information about the Kst mailing list