mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Adapt the ToolTip to work on the new profile
With this patch the tooltip is ready to work on the new profile, we just need to actually use it. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
19585d9a13
commit
40cb57b202
5 changed files with 54 additions and 2 deletions
14
profile.c
14
profile.c
|
@ -1538,6 +1538,20 @@ void get_plot_details(struct graphics_context *gc, int time, char *buf, int bufs
|
|||
plot_string(entry, buf, bufsize, pi->has_ndl);
|
||||
}
|
||||
|
||||
void get_plot_details_new(struct plot_info *pi, int time, char *buf, int bufsize)
|
||||
{
|
||||
struct plot_data *entry = NULL;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < pi->nr; i++) {
|
||||
entry = pi->entry + i;
|
||||
if (entry->sec >= time)
|
||||
break;
|
||||
}
|
||||
if (entry)
|
||||
plot_string(entry, buf, bufsize, pi->has_ndl);
|
||||
}
|
||||
|
||||
/* Compare two plot_data entries and writes the results into a string */
|
||||
void compare_samples(struct plot_data *e1, struct plot_data *e2, char *buf, int bufsize, int sum)
|
||||
{
|
||||
|
|
|
@ -54,6 +54,7 @@ struct plot_data *populate_plot_entries(struct dive *dive, struct divecomputer *
|
|||
struct plot_info *analyze_plot_info(struct plot_info *pi);
|
||||
void create_plot_info_new(struct dive *dive, struct divecomputer *dc, struct plot_info *pi);
|
||||
void calculate_deco_information(struct dive *dive, struct divecomputer *dc, struct plot_info *pi, bool print_mode);
|
||||
void get_plot_details_new(struct plot_info *pi, int time, char *buf, int bufsize);
|
||||
|
||||
struct ev_select {
|
||||
char *ev_name;
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
#include "divetooltipitem.h"
|
||||
#include "divecartesianaxis.h"
|
||||
#include "profile.h"
|
||||
#include <QPropertyAnimation>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QPen>
|
||||
|
@ -176,7 +178,7 @@ void ToolTipItem::updateTitlePosition()
|
|||
}
|
||||
}
|
||||
|
||||
bool ToolTipItem::isExpanded() {
|
||||
bool ToolTipItem::isExpanded() const {
|
||||
return status == EXPANDED;
|
||||
}
|
||||
|
||||
|
@ -207,3 +209,28 @@ void ToolTipItem::readPos()
|
|||
}
|
||||
setPos(value);
|
||||
}
|
||||
|
||||
void ToolTipItem::setPlotInfo(const plot_info& plot)
|
||||
{
|
||||
pInfo = plot;
|
||||
}
|
||||
|
||||
void ToolTipItem::setTimeAxis(DiveCartesianAxis* axis)
|
||||
{
|
||||
timeAxis = axis;
|
||||
}
|
||||
|
||||
void ToolTipItem::refresh(const QPointF& pos)
|
||||
{
|
||||
clear();
|
||||
int time = timeAxis->posAtValue( pos.x() );
|
||||
char buffer[500];
|
||||
get_plot_details_new(&pInfo, time, buffer, 500);
|
||||
addToolTip(QString(buffer));
|
||||
|
||||
QList<QGraphicsItem*> items = scene()->items(pos, Qt::IntersectsItemShape, Qt::DescendingOrder, transform());
|
||||
Q_FOREACH(QGraphicsItem *item, items) {
|
||||
if (!item->toolTip().isEmpty())
|
||||
addToolTip(item->toolTip());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,9 @@
|
|||
#include <QPair>
|
||||
#include <QRectF>
|
||||
#include <QIcon>
|
||||
#include "display.h"
|
||||
|
||||
class DiveCartesianAxis;
|
||||
class QGraphicsLineItem;
|
||||
class QGraphicsSimpleTextItem;
|
||||
class QGraphicsPixmapItem;
|
||||
|
@ -33,10 +35,13 @@ public:
|
|||
void clear();
|
||||
void addToolTip(const QString& toolTip, const QIcon& icon = QIcon());
|
||||
void refresh(struct graphics_context* gc, QPointF pos);
|
||||
bool isExpanded();
|
||||
void refresh(const QPointF& pos);
|
||||
bool isExpanded() const;
|
||||
void persistPos();
|
||||
void readPos();
|
||||
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
|
||||
void setTimeAxis(DiveCartesianAxis *axis);
|
||||
void setPlotInfo(const plot_info& plot);
|
||||
public slots:
|
||||
void setRect(const QRectF& rect);
|
||||
|
||||
|
@ -49,6 +54,8 @@ private:
|
|||
Status status;
|
||||
QRectF rectangle;
|
||||
QRectF nextRectangle;
|
||||
DiveCartesianAxis *timeAxis;
|
||||
plot_info pInfo;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -56,6 +56,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) :
|
|||
setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing | QPainter::SmoothPixmapTransform);
|
||||
setMouseTracking(true);
|
||||
|
||||
toolTipItem->setTimeAxis(timeAxis);
|
||||
scene()->addItem(toolTipItem);
|
||||
|
||||
// Creating the needed items.
|
||||
|
@ -387,6 +388,8 @@ void ProfileWidget2::plotDives(QList<dive*> dives)
|
|||
int maxdepth = get_maxdepth(&pInfo);
|
||||
|
||||
dataModel->setDive(current_dive, pInfo);
|
||||
toolTipItem->setPlotInfo(pInfo);
|
||||
|
||||
// It seems that I'll have a lot of boilerplate setting the model / axis for
|
||||
// each item, I'll mostly like to fix this in the future, but I'll keep at this for now.
|
||||
profileYAxis->setMaximum(maxdepth);
|
||||
|
|
Loading…
Add table
Reference in a new issue