mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: activate dragging of tooltipitem
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
a527415ac9
commit
4c227aba42
6 changed files with 32 additions and 3 deletions
|
@ -122,7 +122,8 @@ void ProfileView::clear()
|
||||||
profileScene->clear();
|
profileScene->clear();
|
||||||
//handles.clear();
|
//handles.clear();
|
||||||
//gases.clear();
|
//gases.clear();
|
||||||
tooltip.reset();
|
if (tooltip)
|
||||||
|
tooltip->setVisible(false);
|
||||||
empty = true;
|
empty = true;
|
||||||
d = nullptr;
|
d = nullptr;
|
||||||
dc = 0;
|
dc = 0;
|
||||||
|
@ -261,6 +262,11 @@ void ProfileView::wheelEvent(QWheelEvent *event)
|
||||||
|
|
||||||
void ProfileView::mousePressEvent(QMouseEvent *event)
|
void ProfileView::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
// Handle dragging of items
|
||||||
|
ChartView::mousePressEvent(event);
|
||||||
|
if (event->isAccepted())
|
||||||
|
return;
|
||||||
|
|
||||||
panning = true;
|
panning = true;
|
||||||
QPointF pos = mapToScene(event->pos());
|
QPointF pos = mapToScene(event->pos());
|
||||||
panStart(pos.x(), pos.y());
|
panStart(pos.x(), pos.y());
|
||||||
|
@ -268,8 +274,10 @@ void ProfileView::mousePressEvent(QMouseEvent *event)
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileView::mouseReleaseEvent(QMouseEvent *)
|
void ProfileView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
ChartView::mouseReleaseEvent(event);
|
||||||
|
|
||||||
if (panning) {
|
if (panning) {
|
||||||
panning = false;
|
panning = false;
|
||||||
unsetCursor();
|
unsetCursor();
|
||||||
|
@ -282,6 +290,8 @@ void ProfileView::mouseReleaseEvent(QMouseEvent *)
|
||||||
|
|
||||||
void ProfileView::mouseMoveEvent(QMouseEvent *event)
|
void ProfileView::mouseMoveEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
|
ChartView::mouseMoveEvent(event);
|
||||||
|
|
||||||
QPointF pos = mapToScene(event->pos());
|
QPointF pos = mapToScene(event->pos());
|
||||||
if (panning)
|
if (panning)
|
||||||
pan(pos.x(), pos.y());
|
pan(pos.x(), pos.y());
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "core/membuffer.h"
|
#include "core/membuffer.h"
|
||||||
#include "core/profile.h"
|
#include "core/profile.h"
|
||||||
#include "core/qthelper.h" // for decoMode
|
#include "core/qthelper.h" // for decoMode
|
||||||
|
#include "core/settings/qPrefDisplay.h"
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
@ -37,12 +38,16 @@ static QFont makeFont(double dpr)
|
||||||
ToolTipItem::ToolTipItem(ChartView &view, double dpr) :
|
ToolTipItem::ToolTipItem(ChartView &view, double dpr) :
|
||||||
ChartRectItem(view, ProfileZValue::ToolTipItem,
|
ChartRectItem(view, ProfileZValue::ToolTipItem,
|
||||||
QPen(tooltipBorderColor, tooltipBorder),
|
QPen(tooltipBorderColor, tooltipBorder),
|
||||||
QBrush(tooltipColor), tooltipBorderRadius),
|
QBrush(tooltipColor), tooltipBorderRadius,
|
||||||
|
true),
|
||||||
font(makeFont(dpr)),
|
font(makeFont(dpr)),
|
||||||
fm(font),
|
fm(font),
|
||||||
fontHeight(fm.height())
|
fontHeight(fm.height())
|
||||||
{
|
{
|
||||||
title = stringToPixmap(ProfileTranslations::tr("Information"));
|
title = stringToPixmap(ProfileTranslations::tr("Information"));
|
||||||
|
|
||||||
|
QPointF pos = qPrefDisplay::tooltip_position();
|
||||||
|
setPos(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap ToolTipItem::stringToPixmap(const QString &str) const
|
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();
|
setTextureDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ToolTipItem::stopDrag(QPointF pos)
|
||||||
|
{
|
||||||
|
qPrefDisplay::set_tooltip_position(pos);
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,8 @@ private:
|
||||||
double width, height;
|
double width, height;
|
||||||
|
|
||||||
QPixmap stringToPixmap(const QString &s) const;
|
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)
|
static int round_up(double f)
|
||||||
{
|
{
|
||||||
return static_cast<int>(ceil(f));
|
return static_cast<int>(ceil(f));
|
||||||
|
|
|
@ -31,6 +31,7 @@ public:
|
||||||
virtual ~ChartItem(); // Attention: must only be called by render thread.
|
virtual ~ChartItem(); // Attention: must only be called by render thread.
|
||||||
QRectF getRect() const;
|
QRectF getRect() const;
|
||||||
virtual void setPos(QPointF pos); // Called when dragging the item
|
virtual void setPos(QPointF pos); // Called when dragging the item
|
||||||
|
virtual void stopDrag(QPointF pos); // Called when dragging the item finished
|
||||||
protected:
|
protected:
|
||||||
ChartItem(ChartView &v, size_t z, bool dragable = false);
|
ChartItem(ChartView &v, size_t z, bool dragable = false);
|
||||||
QSizeF sceneSize() const;
|
QSizeF sceneSize() const;
|
||||||
|
|
|
@ -282,6 +282,8 @@ void ChartView::mousePressEvent(QMouseEvent *event)
|
||||||
void ChartView::mouseReleaseEvent(QMouseEvent *event)
|
void ChartView::mouseReleaseEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (draggedItem) {
|
if (draggedItem) {
|
||||||
|
QPointF pos = event->localPos();
|
||||||
|
draggedItem->stopDrag(pos);
|
||||||
draggedItem.reset();
|
draggedItem.reset();
|
||||||
ungrabMouse();
|
ungrabMouse();
|
||||||
event->accept();
|
event->accept();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue