profile: activate dragging of tooltipitem
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
ea96b9909f
commit
489aafe4b3
@ -120,7 +120,8 @@ void ProfileView::clear()
|
||||
profileScene->clear();
|
||||
//handles.clear();
|
||||
//gases.clear();
|
||||
tooltip.reset();
|
||||
if (tooltip)
|
||||
tooltip->setVisible(false);
|
||||
empty = true;
|
||||
d = nullptr;
|
||||
dc = 0;
|
||||
@ -259,6 +260,11 @@ void ProfileView::wheelEvent(QWheelEvent *event)
|
||||
|
||||
void ProfileView::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
// Handle dragging of items
|
||||
ChartView::mousePressEvent(event);
|
||||
if (event->isAccepted())
|
||||
return;
|
||||
|
||||
panning = true;
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
panStart(pos.x(), pos.y());
|
||||
@ -266,8 +272,10 @@ void ProfileView::mousePressEvent(QMouseEvent *event)
|
||||
event->accept();
|
||||
}
|
||||
|
||||
void ProfileView::mouseReleaseEvent(QMouseEvent *)
|
||||
void ProfileView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
ChartView::mouseReleaseEvent(event);
|
||||
|
||||
if (panning) {
|
||||
panning = false;
|
||||
unsetCursor();
|
||||
@ -280,6 +288,8 @@ void ProfileView::mouseReleaseEvent(QMouseEvent *)
|
||||
|
||||
void ProfileView::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
ChartView::mouseMoveEvent(event);
|
||||
|
||||
QPointF pos = mapToScene(event->pos());
|
||||
if (panning)
|
||||
pan(pos.x(), pos.y());
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include "core/membuffer.h"
|
||||
#include "core/profile.h"
|
||||
#include "core/qthelper.h" // for decoMode
|
||||
#include "core/settings/qPrefDisplay.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <QApplication>
|
||||
@ -37,12 +38,16 @@ static QFont makeFont(double dpr)
|
||||
ToolTipItem::ToolTipItem(ChartView &view, double dpr) :
|
||||
ChartRectItem(view, ProfileZValue::ToolTipItem,
|
||||
QPen(tooltipBorderColor, tooltipBorder),
|
||||
QBrush(tooltipColor), tooltipBorderRadius),
|
||||
QBrush(tooltipColor), tooltipBorderRadius,
|
||||
true),
|
||||
font(makeFont(dpr)),
|
||||
fm(font),
|
||||
fontHeight(fm.height())
|
||||
{
|
||||
title = stringToPixmap(ProfileTranslations::tr("Information"));
|
||||
|
||||
QPointF pos = qPrefDisplay::tooltip_position();
|
||||
setPos(pos);
|
||||
}
|
||||
|
||||
QPixmap ToolTipItem::stringToPixmap(const QString &str) const
|
||||
@ -157,3 +162,8 @@ void ToolTipItem::update(const dive *d, double dpr, int time, const plot_info &p
|
||||
}
|
||||
setTextureDirty();
|
||||
}
|
||||
|
||||
void ToolTipItem::stopDrag(QPointF pos)
|
||||
{
|
||||
qPrefDisplay::set_tooltip_position(pos);
|
||||
}
|
||||
|
||||
@ -22,6 +22,8 @@ private:
|
||||
double width, height;
|
||||
|
||||
QPixmap stringToPixmap(const QString &s) const;
|
||||
|
||||
void stopDrag(QPointF pos) override;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -41,6 +41,10 @@ void ChartItem::setPos(QPointF)
|
||||
{
|
||||
}
|
||||
|
||||
void ChartItem::stopDrag(QPointF pos)
|
||||
{
|
||||
}
|
||||
|
||||
static int round_up(double f)
|
||||
{
|
||||
return static_cast<int>(ceil(f));
|
||||
|
||||
@ -31,6 +31,7 @@ public:
|
||||
virtual ~ChartItem(); // Attention: must only be called by render thread.
|
||||
QRectF getRect() const;
|
||||
virtual void setPos(QPointF pos); // Called when dragging the item
|
||||
virtual void stopDrag(QPointF pos); // Called when dragging the item finished
|
||||
protected:
|
||||
ChartItem(ChartView &v, size_t z, bool dragable = false);
|
||||
QSizeF sceneSize() const;
|
||||
|
||||
@ -282,6 +282,8 @@ void ChartView::mousePressEvent(QMouseEvent *event)
|
||||
void ChartView::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
if (draggedItem) {
|
||||
QPointF pos = event->localPos();
|
||||
draggedItem->stopDrag(pos);
|
||||
draggedItem.reset();
|
||||
ungrabMouse();
|
||||
event->accept();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user