aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/mainwindow.cpp1
-rw-r--r--qt-ui/profilegraphics.cpp37
-rw-r--r--qt-ui/profilegraphics.h21
3 files changed, 57 insertions, 2 deletions
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index d432928b4..f40e95751 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -47,7 +47,6 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()), helpView(0)
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ListWidget, SLOT(reloadHeaderActions()));
connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ProfileWidget, SLOT(refresh()));
ui->mainErrorMessage->hide();
- ui->ProfileWidget->setFocusProxy(ui->ListWidget);
ui->ListWidget->reload(DiveTripModel::TREE);
initialUiSetup();
readSettings();
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);
+}
diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h
index a4d943233..c0326ccfa 100644
--- a/qt-ui/profilegraphics.h
+++ b/qt-ui/profilegraphics.h
@@ -5,6 +5,9 @@
#include <QGraphicsView>
#include <QGraphicsItem>
#include <QIcon>
+#include <QDoubleSpinBox>
+#include <QPushButton>
+#include <QGraphicsProxyWidget>
struct text_render_options;
struct graphics_context;
@@ -64,6 +67,20 @@ private:
QIcon icon;
};
+class GraphicsTextEditor : public QGraphicsTextItem{
+ Q_OBJECT
+public:
+ GraphicsTextEditor(QGraphicsItem* parent = 0);
+
+protected:
+ virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
+ virtual void keyReleaseEvent(QKeyEvent* event);
+
+signals:
+ void textChanged(const QString& text);
+ void editingFinished(const QString& text);
+};
+
class ProfileGraphicsView : public QGraphicsView
{
Q_OBJECT
@@ -120,6 +137,10 @@ private:
QGraphicsItem* depthMarkers;
QGraphicsItem* diveComputer;
+ // For 'Plan' mode.:
+ GraphicsTextEditor *depthEditor;
+ GraphicsTextEditor *timeEditor;
+
enum Mode mode;
};