diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2013-05-17 22:01:41 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-05-17 22:01:41 -0700 |
commit | f3f7bf51fa1dbe9cdb859e1a45b20c108613275b (patch) | |
tree | a28814b4d3d59ff26b41ecfe71670c03fe2ce71d /qt-ui/profilegraphics.h | |
parent | 082ec43eeabe92c7d65d3ab0f189e8fb43016f35 (diff) | |
parent | 56dbb7c2ff697a393f5051e2b5363bd4c0f2bb6e (diff) | |
download | subsurface-f3f7bf51fa1dbe9cdb859e1a45b20c108613275b.tar.gz |
Merge branch 'Qt'
After the 3.1 release it is time to shift the focus on the Qt effort - and
the best way to do this is to merge the changes in the Qt branch into
master.
Linus was extremely nice and did a merge for me. I decided to do my own
merge instead (which by accident actually based on a different version of
the Qt branch) and then used his merge to double check what I was doing.
I resolved a few things differently but overall what we did was very much
the same (and I say this with pride since Linus is a professional git
merger)
Here's his merge commit message:
This is a rough and tumble merge of the Qt branch into 'master',
trying to sort out the conflicts as best as I could.
There were two major kinds of conflicts:
- the Makefile changes, in particular the split of the single
Makefile into Rules.mk and Configure.mk, along with the obvious Qt
build changes themselves.
Those changes conflicted with some of the updates done in mainline
wrt "release" targets and some helper macros ($(NAME) etc).
Resolved by largely taking the Qt branch versions, and then editing
in the most obvious parts of the Makefile updates from mainline.
NOTE! The script/get_version shell script was made to just fail
silently on not finding a git repository, which avoided having to
take some particularly ugly Makefile changes.
- Various random updates in mainline to support things like dive tags.
The conflicts were mainly to the gtk GUI parts, which obviously
looked different afterwards. I fixed things up to look like the
newer code, but since the gtk files themselves are actually dead in
the Qt branch, this is largely irrelevant.
NOTE! This does *NOT* introduce the equivalent Qt functionality.
The fields are there in the code now, but there's no Qt UI for the
whole dive tag stuff etc.
This seems to compile for me (although I have to force
"QMAKE=qmake-qt4" on f19), and results in a Linux binary that seems to
work, but it is otherwise largely untested.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profilegraphics.h')
-rw-r--r-- | qt-ui/profilegraphics.h | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h new file mode 100644 index 000000000..453b8cf03 --- /dev/null +++ b/qt-ui/profilegraphics.h @@ -0,0 +1,110 @@ +#ifndef PROFILEGRAPHICS_H +#define PROFILEGRAPHICS_H + +#include "../display.h" +#include <QGraphicsView> +#include <QGraphicsItem> +#include <QIcon> + +struct text_render_options; +struct graphics_context; +struct plot_info; +typedef struct text_render_options text_render_options_t; + +/* To use a tooltip, simply ->setToolTip on the QGraphicsItem that you want + * or, if it's a "global" tooltip, set it on the mouseMoveEvent of the ProfileGraphicsView. + */ +class ToolTipItem :public QObject, public QGraphicsPathItem +{ + Q_OBJECT + void updateTitlePosition(); + Q_PROPERTY(QRectF rect READ boundingRect WRITE setRect) + +public: + enum Status{COLLAPSED, EXPANDED}; + enum {ICON_SMALL = 16, ICON_MEDIUM = 24, ICON_BIG = 32, SPACING=4}; + + explicit ToolTipItem(QGraphicsItem* parent = 0); + + void collapse(); + void expand(); + void clear(); + void addToolTip(const QString& toolTip, const QIcon& icon = QIcon()); + void removeToolTip(const QString& toolTip); + void refresh(struct graphics_context* gc, QPointF pos); + +public Q_SLOTS: + void setRect(const QRectF& rect); + +private: + typedef QPair<QGraphicsPixmapItem*, QGraphicsSimpleTextItem*> ToolTip; + QMap<QString, ToolTip > toolTips; + QGraphicsPathItem *background; + QGraphicsLineItem *separator; + QGraphicsSimpleTextItem *title; + + QRectF rectangle; +}; + +class EventItem : public QGraphicsPolygonItem +{ +public: + explicit EventItem(QGraphicsItem* parent = 0); + +private: + ToolTipItem *controller; + QString text; + QIcon icon; +}; + +class ProfileGraphicsView : public QGraphicsView +{ +Q_OBJECT +public: + ProfileGraphicsView(QWidget* parent = 0); + void plot(struct dive *d); + bool eventFilter(QObject* obj, QEvent* event); + void clear(); + +protected: + void resizeEvent(QResizeEvent *event); + void mouseMoveEvent(QMouseEvent* event); + void wheelEvent(QWheelEvent* event); + void showEvent(QShowEvent* event); + +private: + void plot_depth_profile(); + QGraphicsSimpleTextItem* plot_text(text_render_options_t *tro, const QPointF& pos, const QString &text, QGraphicsItem *parent = 0); + void plot_events(struct divecomputer *dc); + void plot_one_event(struct event *event); + void plot_temperature_profile(); + void plot_cylinder_pressure(struct dive *dive, struct divecomputer *dc); + void plot_temperature_text(); + void plot_single_temp_text(int sec, int mkelvin); + void plot_depth_text(); + void plot_text_samples(); + void plot_depth_sample(struct plot_data *entry, text_render_options_t *tro); + void plot_cylinder_pressure_text(); + void plot_pressure_value(int mbar, int sec, double xalign, double yalign); + void plot_deco_text(); + void plot_pp_gas_profile(); + void plot_pp_text(); + void plot_depth_scale(); + + QColor get_sac_color(int sac, int avg_sac); + + QPen defaultPen; + QBrush defaultBrush; + ToolTipItem *toolTip; + graphics_context gc; + struct dive *dive; + int zoomLevel; + + // Top Level Items. + QGraphicsItem* profileGrid; + QGraphicsItem* timeMarkers; + QGraphicsItem* depthMarkers; + QGraphicsItem* diveComputer; +}; + +#endif |