[Kst] kdeextragear-2/kst/kst

George Staikos staikos at kde.org
Tue Dec 23 06:53:59 CET 2003


CVS commit by staikos: 

Add copy action that copies the current data point to the clipboard (but not
the selection).  In data mode, it uses the data mode point.  returns
(NAN,NAN) when there is no current point.  Eventually it should provide a
native mimetype too.


  M +7 -0      kst.cpp   1.62
  M +3 -3      kst.h   1.27
  M +3 -1      kstui.rc   1.11
  M +25 -3     kstview.cpp   1.62
  M +3 -0      kstview.h   1.24


--- kdeextragear-2/kst/kst/kst.cpp  #1.61:1.62
@@ -177,4 +177,6 @@ void KstApp::initActions() {
   KStdAction::preferences(this, SLOT(slotPreferences()), actionCollection());
 
+  KStdAction::copy(this, SLOT(slotCopy()), actionCollection());
+
   /************/
   filePrint = KStdAction::print(  this, SLOT(slotFilePrint()),
@@ -858,4 +860,9 @@ void KstApp::slotSettingsChanged() {
 }
 
+
+void KstApp::slotCopy() {
+  view->copy();
+}
+
 #include "kst.moc"
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kst.h  #1.26:1.27
@@ -201,7 +201,7 @@ public slots:
   void slotViewToolBar();
 
-  //void slotEditCut() {}
-  //void slotEditCopy() {}
-  //void slotEditPaste() {}
+  //void slotCut() {}
+  void slotCopy();
+  //void slotPaste() {}
 
   /** toggles the statusbar */

--- kdeextragear-2/kst/kst/kstui.rc  #1.10:1.11
@@ -1,4 +1,4 @@
 <!DOCTYPE kpartgui>
-<kpartgui version="3" name="kst">
+<kpartgui version="4" name="kst">
 <MenuBar>
   <Menu name="file"><text>&amp;File</text>
@@ -8,4 +8,6 @@
     <!-- Action name="file_new_window"/ -->
   </Menu>
+  <Menu name="edit"><text>&amp;Edit</text>
+  </Menu>
   <Menu name="data"><text>&amp;Data</text>
     <Action name="reload"/>

--- kdeextragear-2/kst/kst/kstview.cpp  #1.61:1.62
@@ -21,8 +21,9 @@
 
 // include files for Qt
-#include <qpainter.h>
-#include <qevent.h>
 #include <qbitmap.h>
 #include <qbrush.h>
+#include <qclipboard.h>
+#include <qevent.h>
+#include <qpainter.h>
 #include <qtabwidget.h>
 
@@ -47,5 +48,5 @@
 /** setup the view widget */
 KstView::KstView(KstApp *parent, const char *name)
-: QWidget(parent, name) {
+: QWidget(parent, name), _copy_x(KST::NOPOINT), _copy_y(KST::NOPOINT) {
 
   setAcceptDrops(true);
@@ -378,4 +379,6 @@ void KstView::updateMouse() {
 
     if (!plot_rect.contains(pos)) {
+      _copy_x = KST::NOPOINT;
+      _copy_y = KST::NOPOINT;
       emit newDataMsg(QString::null);
       return;
@@ -417,4 +420,6 @@ void KstView::updateMouse() {
       if (curve.data()) {
         msg = i18n("%3 (%1, %2)").arg(newxpos).arg(newypos,0,'G').arg(curve->tagName());
+        _copy_x = newxpos;
+        _copy_y = newypos;
         emit newDataMsg(msg);
         return;
@@ -423,5 +428,11 @@ void KstView::updateMouse() {
 
     msg = i18n("(%1, %2)").arg(xpos,0,'G').arg(ypos,0,'G');
+    _copy_x = xpos;
+    _copy_y = ypos;
+  } else {
+    _copy_x = KST::NOPOINT;
+    _copy_y = KST::NOPOINT;
   }
+
   emit newDataMsg(msg);
 }
@@ -1334,4 +1345,15 @@ void KstView::setDataMode(bool on) {
 }
 
+void KstView::copy() {
+  // Don't set the selection because while it does make sense - sort of - it
+  // is far too easy to swipe over Kst while trying to paste a selection
+  // from one window to another.
+
+  // FIXME: we should also provide a custom mime source so that we can
+  //        actually manipulate points of data within Kst.
+  QString msg = i18n("(%1, %2)").arg(_copy_x, 0, 'G').arg(_copy_y, 0, 'G');
+  QApplication::clipboard()->setText(msg);
+}
+
 #include "kstview.moc"
 // vim: ts=2 sw=2 et

--- kdeextragear-2/kst/kst/kstview.h  #1.23:1.24
@@ -97,4 +97,6 @@ public slots:
   void cleanupLayout();
 
+  void copy();
+
 public:
   KstMouse *MouseInfo;
@@ -137,4 +139,5 @@ private:
   KstPlot *_currentPlot;
   QMap<int,QString> _curveIds;
+  double _copy_x, _copy_y;
 
 private slots:





More information about the Kst mailing list