summaryrefslogtreecommitdiffstats
path: root/qt-ui/profilegraphics.cpp
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-06-10 19:02:06 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-10 20:59:58 -0700
commit939246acda95807bca2ed5ce536a0aae2ea8586c (patch)
treefcac4a4df481d36dd0b83bb935213b4b0c9e1185 /qt-ui/profilegraphics.cpp
parentb4835badb6addf8385b7800c673b25789089ea84 (diff)
downloadsubsurface-939246acda95807bca2ed5ce536a0aae2ea8586c.tar.gz
Added a simple "TextEditor" in the graph, for a plan mode.
Added a simple TextEditor in the graph for the 'Dive Plan' mode, this text editor is very simple, so the user can double click on 'depth' or 'duration' to set the depth or duration of the dive. Since this was a test, only 'duration' was done, and I'll add duration on the next commit. Signed-off-by: Tomaz Canabrava <tcanabrava@kde.org>
Diffstat (limited to 'qt-ui/profilegraphics.cpp')
-rw-r--r--qt-ui/profilegraphics.cpp37
1 files changed, 36 insertions, 1 deletions
diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp
index 816a61827..852a83fe6 100644
--- a/qt-ui/profilegraphics.cpp
+++ b/qt-ui/profilegraphics.cpp
@@ -1,4 +1,6 @@
#include "profilegraphics.h"
+#include "mainwindow.h"
+#include "divelistview.h"
#include <QGraphicsScene>
#include <QResizeEvent>
@@ -12,6 +14,7 @@
#include <QPropertyAnimation>
#include <QGraphicsSceneHoverEvent>
#include <QMouseEvent>
+#include <qtextdocument.h>
#include "../color.h"
#include "../display.h"
@@ -255,6 +258,8 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
return;
}
+ // best place to put the focus stealer code.
+ setFocusProxy(mainWindow()->dive_list());
scene()->setSceneRect(0,0, viewport()->width()-50, viewport()->height()-50);
toolTip = new ToolTipItem();
@@ -330,12 +335,18 @@ void ProfileGraphicsView::plot(struct dive *d, bool forceRedraw)
// The Time ruler should be right after the DiveComputer:
timeMarkers->setPos(0, diveComputer->y());
+ if(mode == PLAN){
+ timeEditor = new GraphicsTextEditor();
+ timeEditor->setPlainText(" Set Duration: 10 minutes");
+ timeEditor->setPos(profile_grid_area.width() + timeMarkers->boundingRect().width(), timeMarkers->y());
+ timeEditor->document();
+ scene()->addItem(timeEditor);
+ }
if (PP_GRAPHS_ENABLED) {
plot_pp_gas_profile();
plot_pp_text();
}
-
/* now shift the translation back by half the margin;
* this way we can draw the vertical scales on both sides */
//cairo_translate(gc->cr, -drawing_area->x / 2.0, 0);
@@ -1481,3 +1492,27 @@ EventItem::EventItem(QGraphicsItem* parent): QGraphicsPolygonItem(parent)
ball->setBrush(QBrush(Qt::black));
}
+
+GraphicsTextEditor::GraphicsTextEditor(QGraphicsItem* parent): QGraphicsTextItem(parent)
+{
+
+}
+
+void GraphicsTextEditor::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
+{
+ // Remove the proxy filter so we can focus here.
+ mainWindow()->graphics()->setFocusProxy(0);
+ setTextInteractionFlags(Qt::TextEditorInteraction | Qt::TextEditable);
+}
+
+void GraphicsTextEditor::keyReleaseEvent(QKeyEvent* event)
+{
+ if (event->key() == Qt::Key_Enter || event->key() == Qt::Key_Return){
+ setTextInteractionFlags(Qt::NoTextInteraction);
+ emit editingFinished( toPlainText() );
+ mainWindow()->graphics()->setFocusProxy(mainWindow()->dive_list());
+ return;
+ }
+ emit textChanged( toPlainText() );
+ QGraphicsTextItem::keyReleaseEvent(event);
+}