[Kst] branches/work/kst/portto4/kst/src/libkstapp

Barth Netterfield netterfield at astro.utoronto.ca
Sat Mar 27 00:47:22 CET 2010


SVN commit 1107837 by netterfield:

In which the status bar coordinates and the datamode icon are convinced to update
when new data shows up....



 M  +7 -1      mainwindow.cpp  
 M  +2 -0      mainwindow.h  
 M  +29 -10    plotrenderitem.cpp  
 M  +2 -1      plotrenderitem.h  


--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.cpp #1107836:1107837
@@ -1012,6 +1012,10 @@
 
 
 void MainWindow::createStatusBar() {
+  _messageLabel = new QLabel(statusBar());
+  statusBar()->addWidget(_messageLabel);
+  setStatusMessage(tr("Ready"));
+
   _progressBar = new QProgressBar(statusBar());
   _progressBar->hide();
   statusBar()->addPermanentWidget(_progressBar);
@@ -1022,9 +1026,11 @@
   connect(_debugDialog, SIGNAL(notifyOfError()), dn, SLOT(reanimate()));
   connect(_debugDialog, SIGNAL(notifyAllClear()), dn, SLOT(close()));
   statusBar()->addPermanentWidget(dn);
-  statusBar()->showMessage(tr("Ready"));
 }
 
+void MainWindow::setStatusMessage(QString message) {
+  _messageLabel->setText(message);
+}
 
 QProgressBar *MainWindow::progressBar() const {
   return _progressBar;
--- branches/work/kst/portto4/kst/src/libkstapp/mainwindow.h #1107836:1107837
@@ -51,6 +51,7 @@
     QProgressBar *progressBar() const;
     bool initFromCommandLine();
     bool isDataMode() { return _dataMode; }
+    void setStatusMessage(QString message);
 
   public Q_SLOTS:
     void showDataManager();
@@ -154,6 +155,7 @@
     AboutDialog* _aboutDialog;
 
     QPointer<QProgressBar> _progressBar;
+    QLabel *_messageLabel;
 
     bool _dataMode;
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #1107836:1107837
@@ -22,7 +22,6 @@
 
 #include <QTime>
 #include <QMenu>
-#include <QStatusBar>
 #include <QMainWindow>
 #include <QGraphicsSceneHoverEvent>
 #include <QGraphicsSceneMouseEvent>
@@ -264,6 +263,10 @@
 
   painter->restore();
 
+  if (!parentView()->isPrinting()) {
+    processHoverMoveEvent(_hoverPos);
+  }
+
   paintReferencePoint(painter);
   paintHighlightPoint(painter);
 
@@ -508,6 +511,7 @@
 
 //FIXME: store event or pos, and re-call this when window is redrawn
 void PlotRenderItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) {
+
   ViewItem::hoverMoveEvent(event);
 
   if (parentView()->viewMode() != View::Data) {
@@ -515,7 +519,8 @@
     return;
   }
 
-  const QPointF p = event->pos();
+  QPointF p = event->pos();
+  _hoverPos = p;
   const Qt::KeyboardModifiers modifiers = QApplication::keyboardModifiers();
   if (modifiers & Qt::ShiftModifier) {
     _lastPos = p;
@@ -531,9 +536,21 @@
     update(); //FIXME should optimize instead of redrawing entire curve!
   } else {
     resetSelectionRect();
-    updateCursor(event->pos());
+    updateCursor(p);
   }
-  const QPointF point = plotItem()->mapToProjection(event->pos());
+
+  processHoverMoveEvent(p);
+
+  if (kstApp->mainWindow()->isDataMode()) update();
+}
+
+void PlotRenderItem::processHoverMoveEvent(const QPointF &p) {
+
+  if (p.isNull()) {
+    return;
+  }
+
+  const QPointF point = plotItem()->mapToProjection(p);
   if (kstApp->mainWindow()->isDataMode()) {
     highlightNearestDataPoint(point);
   } else {
@@ -544,7 +561,7 @@
     if (_referencePointMode) {
       message += QString(" [Offset: %1, %2]").arg(QString::number(point.x() - _referencePoint.x(), 'G')).arg(QString::number(point.y() - _referencePoint.y()));
     }
-    kstApp->mainWindow()->statusBar()->showMessage(message);
+    kstApp->mainWindow()->setStatusMessage(message);
   }
 }
 
@@ -569,6 +586,7 @@
 
     foreach(RelationPtr relation, relationList()) {
       if (Curve* curve = kst_cast<Curve>(relation)) {
+        //FIXME: set dxPerPix to something sensible!
         int index = curve->getIndexNearXY(position.x(), 0, position.y());
         curve->point(index, x, y);
         distance = fabs(position.y() - y);
@@ -597,16 +615,15 @@
                    arg(QString::number(matchedPoint.x() - _referencePoint.x(), 'G')).
                    arg(QString::number(matchedPoint.y() - _referencePoint.y()));
       }
-      kstApp->mainWindow()->statusBar()->showMessage(message);
+      kstApp->mainWindow()->setStatusMessage(message);
       _highlightPointActive = true;
       _highlightPoint = QPointF(matchedPoint.x(), matchedPoint.y());
-      update();
     } else if (!imageName.isEmpty()) {
       QString message = imageName + QString(" (%1, %2, %3)").
                         arg(plotItem()->xAxis()->statusBarString(position.x())).
                         arg(QString::number(position.y())).
                         arg(QString::number(imageZ, 'G'));
-      kstApp->mainWindow()->statusBar()->showMessage(message);
+      kstApp->mainWindow()->setStatusMessage(message);
     }
   }
 }
@@ -627,12 +644,14 @@
   QString message = QString("(%1, %2)").
                     arg(plotItem()->xAxis()->statusBarString(p.x())).
                     arg(QString::number(p.y()));
-  kstApp->mainWindow()->statusBar()->showMessage(message);
+  kstApp->mainWindow()->setStatusMessage(message);
 }
 
 void PlotRenderItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) {
   ViewItem::hoverLeaveEvent(event);
 
+  _hoverPos = QPointF(0,0);
+
   _highlightPointActive = false;
 
   if (parentView()->viewMode() != View::Data) {
@@ -645,7 +664,7 @@
 
   updateCursor(event->pos());
 
-  kstApp->mainWindow()->statusBar()->showMessage(QString());
+  kstApp->mainWindow()->setStatusMessage(QString());
 }
 
 
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #1107836:1107837
@@ -114,10 +114,11 @@
 
     void highlightNearestDataPoint(const QPointF& position);
     void setReferencePoint(const QPointF& point);
-
+    void processHoverMoveEvent(const QPointF& p);
   private:
     RenderType _type;
     QPointF _lastPos;
+    QPointF _hoverPos;
     bool _referencePointMode;
     QPointF _referencePoint;
     bool _highlightPointActive;


More information about the Kst mailing list