summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-03-09 10:59:31 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-03-09 08:50:54 -0700
commit24c5b2e3c1bda349c208a94cf8c17fa17af971db (patch)
treec54f66a6d36d3d43d74b84e9119fc4c507a36b7e /qt-ui
parentb6bbfdcc5f1d90d00ccc0244e5e9792558d25abd (diff)
downloadsubsurface-24c5b2e3c1bda349c208a94cf8c17fa17af971db.tar.gz
Code Cleanup ( that fix 2 bugs )
This code cleanup fixes the two issues that I raised on my last e-mail. hurrah. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/maintab.cpp2
-rw-r--r--qt-ui/profile/profilewidget2.cpp16
-rw-r--r--qt-ui/profile/profilewidget2.h1
-rw-r--r--qt-ui/profile/ruleritem.cpp42
-rw-r--r--qt-ui/profile/ruleritem.h6
5 files changed, 18 insertions, 49 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp
index c2acaa700..847cf5ec7 100644
--- a/qt-ui/maintab.cpp
+++ b/qt-ui/maintab.cpp
@@ -671,6 +671,8 @@ void MainTab::acceptChanges()
editMode = NONE;
MainWindow::instance()->refreshDisplay();
MainWindow::instance()->dive_list()->selectDive(i, true);
+ MainWindow::instance()->graphics()->replot();
+
} else {
editMode = NONE;
MainWindow::instance()->dive_list()->rememberSelection();
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index 3b8a3d18a..d78b42057 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -209,6 +209,13 @@ void ProfileWidget2::setupItemOnScene()
heartBeatAxis->setLinesVisible(true);
}
+void ProfileWidget2::replot()
+{
+ int diveId = dataModel->id();
+ dataModel->clear();
+ plotDives(QList<dive *>() << getDiveById(diveId));
+}
+
void ProfileWidget2::setupItemSizes()
{
// Scene is *always* (double) 100 / 100.
@@ -431,9 +438,7 @@ void ProfileWidget2::settingsChanged()
}
if (s.value("zoomed_plot").toBool() != isPlotZoomed) {
isPlotZoomed = s.value("zoomed_plot").toBool();
- int diveId = dataModel->id();
- dataModel->clear();
- plotDives(QList<dive *>() << getDiveById(diveId));
+ replot();
}
if (currentState == PROFILE) {
@@ -681,8 +686,5 @@ void ProfileWidget2::changeGas()
fixup_dive(d);
MainWindow::instance()->information()->updateDiveInfo(selected_dive);
mark_divelist_changed(true);
- // force the redraw of the dive.
- //TODO: find a way to make this do not need a full redraw
- dataModel->clear();
- plotDives(QList<dive *>() << getDiveById(diveId));
+ replot();
}
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index c22d2b151..5d4e98dfc 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -64,6 +64,7 @@ public:
ProfileWidget2(QWidget *parent = 0);
void plotDives(QList<dive *> dives);
+ void replot();
virtual bool eventFilter(QObject *, QEvent *);
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
diff --git a/qt-ui/profile/ruleritem.cpp b/qt-ui/profile/ruleritem.cpp
index a21a9a04a..99a04438f 100644
--- a/qt-ui/profile/ruleritem.cpp
+++ b/qt-ui/profile/ruleritem.cpp
@@ -16,10 +16,10 @@
RulerNodeItem2::RulerNodeItem2() : entry(NULL), ruler(NULL)
{
memset(&pInfo, 0, sizeof(pInfo));
- setRect(QRect(QPoint(-8, 8), QPoint(8, -8)));
+ setRect(-8, -8, 16, 16);
setBrush(QColor(0xff, 0, 0, 127));
- setPen(QColor("#FF0000"));
- setFlag(QGraphicsItem::ItemIsMovable);
+ setPen(QColor(Qt::red));
+ setFlag(ItemIsMovable);
setFlag(ItemSendsGeometryChanges);
setFlag(ItemIgnoresTransformations);
}
@@ -59,8 +59,7 @@ QVariant RulerNodeItem2::itemChange(GraphicsItemChange change, const QVariant &v
{
if (change == ItemPositionHasChanged) {
recalculate();
- if (ruler != NULL)
- ruler->recalculate();
+ ruler->recalculate();
}
return QGraphicsEllipseItem::itemChange(change, value);
}
@@ -97,7 +96,7 @@ void RulerItem2::recalculate()
startPoint = tmp;
}
QLineF line(startPoint, endPoint);
-
+ setLine(line);
compare_samples(source->entry, dest->entry, buffer, 500, 1);
text = QString(buffer);
@@ -127,37 +126,6 @@ RulerNodeItem2 *RulerItem2::destNode() const
return dest;
}
-void RulerItem2::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
-{
- Q_UNUSED(option);
- Q_UNUSED(widget);
- QLineF line(startPoint, endPoint);
- painter->setPen(QColor(Qt::black));
- painter->setBrush(Qt::NoBrush);
- painter->drawLine(line);
-}
-
-QRectF RulerItem2::boundingRect() const
-{
- return shape().controlPointRect();
-}
-
-QPainterPath RulerItem2::shape() const
-{
- QPainterPath path;
- QLineF line(startPoint, endPoint);
- QLineF line_n = line.normalVector();
- line_n.setLength(height);
- if (paint_direction == 1)
- line_n.setAngle(line_n.angle() + 180);
- path.moveTo(startPoint);
- path.lineTo(line_n.p2());
- path.lineTo(line_n.p2() + QPointF(line.dx(), line.dy()));
- path.lineTo(endPoint);
- path.lineTo(startPoint);
- return path;
-}
-
void RulerItem2::setPlotInfo(plot_info info)
{
pInfo = info;
diff --git a/qt-ui/profile/ruleritem.h b/qt-ui/profile/ruleritem.h
index 61eda1ed3..6ab86f44b 100644
--- a/qt-ui/profile/ruleritem.h
+++ b/qt-ui/profile/ruleritem.h
@@ -31,8 +31,7 @@ private:
DiveCartesianAxis *depthAxis;
};
-class RulerItem2 : public QGraphicsObject {
- Q_OBJECT
+class RulerItem2 : public QGraphicsLineItem {
public:
explicit RulerItem2();
void recalculate();
@@ -40,9 +39,6 @@ public:
void setPlotInfo(struct plot_info pInfo);
RulerNodeItem2 *sourceNode() const;
RulerNodeItem2 *destNode() const;
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
- QRectF boundingRect() const;
- QPainterPath shape() const;
void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth);
private: