mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-12 13:26:16 +00:00
Work on the tooltips - WIP.
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
This commit is contained in:
parent
76e1436f68
commit
2089c124a5
2 changed files with 15 additions and 29 deletions
|
@ -123,6 +123,7 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent
|
||||||
setScene(new QGraphicsScene());
|
setScene(new QGraphicsScene());
|
||||||
setBackgroundBrush(QColor("#F3F3E6"));
|
setBackgroundBrush(QColor("#F3F3E6"));
|
||||||
scene()->setSceneRect(0,0,1000,1000);
|
scene()->setSceneRect(0,0,1000,1000);
|
||||||
|
scene()->installEventFilter(this);
|
||||||
|
|
||||||
setRenderHint(QPainter::Antialiasing);
|
setRenderHint(QPainter::Antialiasing);
|
||||||
setRenderHint(QPainter::HighQualityAntialiasing);
|
setRenderHint(QPainter::HighQualityAntialiasing);
|
||||||
|
@ -135,6 +136,16 @@ ProfileGraphicsView::ProfileGraphicsView(QWidget* parent) : QGraphicsView(parent
|
||||||
fill_profile_color();
|
fill_profile_color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event)
|
||||||
|
{
|
||||||
|
// This will "Eat" the default tooltip behavior.
|
||||||
|
if (event->type() == QEvent::GraphicsSceneHelp){
|
||||||
|
event->ignore();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return QGraphicsView::eventFilter(obj, event);
|
||||||
|
}
|
||||||
|
|
||||||
static void plot_set_scale(scale_mode_t scale)
|
static void plot_set_scale(scale_mode_t scale)
|
||||||
{
|
{
|
||||||
switch (scale) {
|
switch (scale) {
|
||||||
|
@ -355,8 +366,9 @@ void ProfileGraphicsView::plot_one_event(struct graphics_context *gc, struct plo
|
||||||
ev->flags == SAMPLE_FLAGS_END ? tr("Starts with space!", " end") : "";
|
ev->flags == SAMPLE_FLAGS_END ? tr("Starts with space!", " end") : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
item->setToolTipController(toolTip);
|
//item->setToolTipController(toolTip);
|
||||||
item->addToolTip(name);
|
//item->addToolTip(name);
|
||||||
|
item->setToolTip(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileGraphicsView::plot_depth_profile(struct graphics_context *gc, struct plot_info *pi)
|
void ProfileGraphicsView::plot_depth_profile(struct graphics_context *gc, struct plot_info *pi)
|
||||||
|
@ -809,24 +821,3 @@ EventItem::EventItem(QGraphicsItem* parent): QGraphicsPolygonItem(parent)
|
||||||
ball->setBrush(QBrush(Qt::black));
|
ball->setBrush(QBrush(Qt::black));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
|
||||||
{
|
|
||||||
controller->addToolTip(text, icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
|
||||||
{
|
|
||||||
controller->removeToolTip(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventItem::addToolTip(const QString& t, const QIcon& i)
|
|
||||||
{
|
|
||||||
text = t;
|
|
||||||
icon = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
void EventItem::setToolTipController(ToolTipItem* c)
|
|
||||||
{
|
|
||||||
controller = c;
|
|
||||||
}
|
|
||||||
|
|
|
@ -70,12 +70,6 @@ class EventItem : public QGraphicsPolygonItem
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit EventItem(QGraphicsItem* parent = 0);
|
explicit EventItem(QGraphicsItem* parent = 0);
|
||||||
void addToolTip(const QString& text,const QIcon& icon = QIcon());
|
|
||||||
void setToolTipController(ToolTipItem *controller);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void hoverEnterEvent(QGraphicsSceneHoverEvent* event);
|
|
||||||
void hoverLeaveEvent(QGraphicsSceneHoverEvent* event);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ToolTipItem *controller;
|
ToolTipItem *controller;
|
||||||
|
@ -89,6 +83,7 @@ Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ProfileGraphicsView(QWidget* parent = 0);
|
ProfileGraphicsView(QWidget* parent = 0);
|
||||||
void plot(struct dive *d);
|
void plot(struct dive *d);
|
||||||
|
bool eventFilter(QObject* obj, QEvent* event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
|
Loading…
Add table
Reference in a new issue