mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
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>
This commit is contained in:
parent
b6bbfdcc5f
commit
24c5b2e3c1
5 changed files with 18 additions and 49 deletions
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Add table
Reference in a new issue