mirror of
https://github.com/subsurface/subsurface.git
synced 2024-12-03 15:43:09 +00:00
Added a bit of documentation on how to use the ToolTips & removed 2 bad-api methods
Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
d590cb9519
commit
df01a5d35f
2 changed files with 31 additions and 16 deletions
|
@ -598,17 +598,6 @@ void ProfileGraphicsView::plot_text(struct graphics_context *gc, text_render_opt
|
||||||
scene()->addItem(item);
|
scene()->addItem(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileGraphicsView::addToolTip(const QString& text, const QIcon& icon)
|
|
||||||
{
|
|
||||||
toolTip->addToolTip(text, icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProfileGraphicsView::removeToolTip(const QString& text)
|
|
||||||
{
|
|
||||||
toolTip->removeToolTip(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ProfileGraphicsView::resizeEvent(QResizeEvent *event)
|
void ProfileGraphicsView::resizeEvent(QResizeEvent *event)
|
||||||
{
|
{
|
||||||
// Fits the scene's rectangle on the view.
|
// Fits the scene's rectangle on the view.
|
||||||
|
|
|
@ -10,7 +10,33 @@ struct graphics_context;
|
||||||
struct plot_info;
|
struct plot_info;
|
||||||
typedef struct text_render_options text_render_options_t;
|
typedef struct text_render_options text_render_options_t;
|
||||||
|
|
||||||
class ToolTipItem :public QObject, public QGraphicsPathItem {
|
/**!
|
||||||
|
*
|
||||||
|
* Hookay, so, if you wanna extend the ToolTips that are displayed
|
||||||
|
* in the Profile Graph, there's one 'toolTip' widget already on it,
|
||||||
|
* you can just pass it to your Reimplementation of QGraphiscItem
|
||||||
|
* and do the following:
|
||||||
|
*
|
||||||
|
* EventItem::setController(ToolTipItem *c)
|
||||||
|
* {
|
||||||
|
* controller = c;
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* void EventItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event)
|
||||||
|
* {
|
||||||
|
* controller->addToolTip(text, icon);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* void EventItem::hoverLeaveEvent(QGraphicsSceneHoverEvent* event)
|
||||||
|
* {
|
||||||
|
* controller->removeToolTip(text);
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* Remember to removeToolTip when you don't want it to be displayed.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
class ToolTipItem :public QObject, public QGraphicsPathItem
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
void updateTitlePosition();
|
void updateTitlePosition();
|
||||||
Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect)
|
Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect)
|
||||||
|
@ -40,7 +66,8 @@ private:
|
||||||
QRectF rectangle;
|
QRectF rectangle;
|
||||||
};
|
};
|
||||||
|
|
||||||
class EventItem : public QGraphicsPolygonItem{
|
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 addToolTip(const QString& text,const QIcon& icon = QIcon());
|
||||||
|
@ -56,13 +83,12 @@ private:
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ProfileGraphicsView : public QGraphicsView {
|
class ProfileGraphicsView : public QGraphicsView
|
||||||
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ProfileGraphicsView(QWidget* parent = 0);
|
ProfileGraphicsView(QWidget* parent = 0);
|
||||||
void plot(struct dive *d);
|
void plot(struct dive *d);
|
||||||
void addToolTip(const QString& text, const QIcon& icon = QIcon());
|
|
||||||
void removeToolTip(const QString& text);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
|
Loading…
Reference in a new issue