| Hi, I am resending a number of patches I sent earlier which seem to me are still not pushed. Comments or pushes would be appreciated. |
From 10be4f46ca1a16353cedbd4b709bcc2332d69a78 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Mon, 16 Nov 2015 16:10:07 +0100 Subject: [PATCH 1/2] Interpret - as STDOUT on writing xml files
This prepares for the smartrack converter webservice. Signed-off-by: Robert C. Helling <[email protected]> --- subsurface-core/save-xml.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/subsurface-core/save-xml.c b/subsurface-core/save-xml.c index 1668858..eabcf4f 100644 --- a/subsurface-core/save-xml.c +++ b/subsurface-core/save-xml.c @@ -666,12 +666,15 @@ int save_dives_logic(const char *filename, const bool select_only) if (git) return git_save_dives(git, branch, remote, select_only); - try_to_backup(filename); - save_dives_buffer(&buf, select_only); - error = -1; - f = subsurface_fopen(filename, "w"); + if (same_string(filename, "-")) { + f = stdout; + } else { + try_to_backup(filename); + error = -1; + f = subsurface_fopen(filename, "w"); + } if (f) { flush_buffer(&buf, f); error = fclose(f); -- 2.4.9 (Apple Git-60)
From 8836c98e29b80762c43f6131c37bb1ac17bca17f Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Mon, 16 Nov 2015 16:54:01 +0100 Subject: [PATCH 2/2] CGI script wrapper for smtk2ssrf.pl This script should go to the cgi-bin directory of the webserver to proivide conversion of SmarTrack files as a web service. Paths need to be adopted and more html to make it more beautiful should be added. Signed-off-by: Robert C. Helling <[email protected]> --- scripts/smtk2ssrf.pl | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 scripts/smtk2ssrf.pl diff --git a/scripts/smtk2ssrf.pl b/scripts/smtk2ssrf.pl new file mode 100755 index 0000000..a65ebf9 --- /dev/null +++ b/scripts/smtk2ssrf.pl @@ -0,0 +1,42 @@ +#!/usr/bin/env perl + +use CGI; + +# Change this to the correct path to binary. +my $smtk2ssrf = "../build/smtk2ssrf"; + +my $q = CGI->new; + +if ($q->upload("uploaded_file")) { + my $original_filename = $q->param("uploaded_file"); + my $tmp_filename = $q->tmpFileName($original_filename); + my $new_filename = $original_filename; + $new_filename =~ s/.*[\/\\]//; + $new_filename =~ s/\..*$/.ssrf/; + + print "Content-Disposition: attachment; filename=\"$new_filename\"\n"; + print "Content-type: subsurface/xml\n\n"; + system "$smtk2ssrf $tmp_filename -"; +} else { + print "Content-type: text/html\n\n"; + +# Here we could print some header stuff to fit better in the subsurface webspace context. Do do so uncomment +# open (IN, "filename_header.html); +# while (<IN>) { +# print; +# } +# close(IN); + + print $q->start_multipart_form(); + + print $q->h1("Convert Smartrack files to Subsurface"); + + print $q->filefield( -name => "uploaded_file", + -size => 50, + -maxlength => 200); + print $q->submit(); + print $q-end_form(); + +# Here we could print some footer stuff as above + +} -- 2.4.9 (Apple Git-60)
From 88ac4ad982ae8429214f134497cafdb4c4b36822 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Tue, 17 Nov 2015 11:13:08 +0100 Subject: [PATCH] Only close html tags if they were opened before The runtime html table is printed only if printing a verbatim diveplan is disabled. So the closing tags should be printed only in that case. Signed-off-by: Robert C. Helling <[email protected]> --- subsurface-core/planner.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subsurface-core/planner.c b/subsurface-core/planner.c index 9c8b9e9..db1460a 100644 --- a/subsurface-core/planner.c +++ b/subsurface-core/planner.c @@ -776,7 +776,8 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool lastsetpoint = dp->setpoint; lastentered = dp->entered; } while ((dp = nextdp) != NULL); - len += snprintf(buffer + len, sz_buffer - len, "</tbody></table></div>"); + if (!plan_verbatim) + len += snprintf(buffer + len, sz_buffer - len, "</tbody></table></div>"); dive->cns = 0; dive->maxcns = 0; -- 2.4.9 (Apple Git-60)
From e00d8b6fca596e194ee16e571bba2f55a04a820d Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" <[email protected]> Date: Tue, 3 Nov 2015 21:17:50 +0100 Subject: [PATCH] Drag and Drop Images Now that we have the possibility to add images without meaningful time stamps to a dive, we should let the user provide that time offset manually. This patch allowed pictures to be dragged from the image list to the profile. Signed-off-by: Robert C. Helling <[email protected]> --- desktop-widgets/divepicturewidget.cpp | 30 ++++++++++++++++ desktop-widgets/divepicturewidget.h | 3 ++ profile-widget/profilewidget2.cpp | 66 +++++++++++++++++++++++++++++++++++ profile-widget/profilewidget2.h | 4 +++ 4 files changed, 103 insertions(+) diff --git a/desktop-widgets/divepicturewidget.cpp b/desktop-widgets/divepicturewidget.cpp index bed3d3b..daf62c6 100644 --- a/desktop-widgets/divepicturewidget.cpp +++ b/desktop-widgets/divepicturewidget.cpp @@ -14,6 +14,7 @@ #include <mainwindow.h> #include <qthelper.h> #include <QStandardPaths> +#include <QtWidgets> void loadPicture(struct picture *picture) { @@ -98,3 +99,32 @@ void DivePictureWidget::doubleClicked(const QModelIndex &index) QString filePath = model()->data(index, Qt::DisplayPropertyRole).toString(); emit photoDoubleClicked(localFilePath(filePath)); } + + +void DivePictureWidget::mousePressEvent(QMouseEvent *event) +{ + + QPixmap pixmap = model()->data(indexAt(event->pos()), Qt::DecorationRole).value<QPixmap>(); + + QString filename = model()->data(indexAt(event->pos()), Qt::DisplayPropertyRole).toString(); + + QByteArray itemData; + QDataStream dataStream(&itemData, QIODevice::WriteOnly); + dataStream << filename << event->pos(); + + QMimeData *mimeData = new QMimeData; + mimeData->setData("application/x-subsurfaceimagedrop", itemData); + + QDrag *drag = new QDrag(this); + drag->setMimeData(mimeData); + drag->setPixmap(pixmap); + drag->setHotSpot(event->pos() - rectForIndex(indexAt(event->pos())).topLeft()); + + QPixmap tempPixmap = pixmap; + QPainter painter; + painter.begin(&tempPixmap); + painter.fillRect(pixmap.rect(), QColor(127, 127, 127, 127)); + painter.end(); + + drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction); +} diff --git a/desktop-widgets/divepicturewidget.h b/desktop-widgets/divepicturewidget.h index 54f5bb8..f02d6b5 100644 --- a/desktop-widgets/divepicturewidget.h +++ b/desktop-widgets/divepicturewidget.h @@ -23,6 +23,9 @@ class DivePictureWidget : public QListView { Q_OBJECT public: DivePictureWidget(QWidget *parent); +protected: + void mousePressEvent(QMouseEvent *event) Q_DECL_OVERRIDE; + signals: void photoDoubleClicked(const QString filePath); private diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp index 6538185..550f2b2 100644 --- a/profile-widget/profilewidget2.cpp +++ b/profile-widget/profilewidget2.cpp @@ -16,6 +16,7 @@ #include "divepicturemodel.h" #include "maintab.h" #include "diveplanner.h" +#include "divelist.h" #include <libdivecomputer/parser.h> #include <QScrollBar> @@ -30,6 +31,7 @@ #endif #include "mainwindow.h" #include "preferences/preferencesdialog.h" +#include <QtWidgets> /* This is the global 'Item position' variable. * it should tell you where to position things up @@ -123,6 +125,8 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent), scene()->installEventFilter(this); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(settingsChanged())); QAction *action = NULL; + setAcceptDrops(true); + #define ADD_ACTION(SHORTCUT, Slot) \ action = new QAction(this); \ action->setShortcut(SHORTCUT); \ @@ -1840,3 +1844,65 @@ void ProfileWidget2::plotPictures() pictures.push_back(item); } } + +void ProfileWidget2::dropEvent(QDropEvent *event) +{ + if (event->mimeData()->hasFormat("application/x-subsurfaceimagedrop")) { + QByteArray itemData = event->mimeData()->data("application/x-subsurfaceimagedrop"); + QDataStream dataStream(&itemData, QIODevice::ReadOnly); + + QString filename; + QPoint offset; + dataStream >> filename >> offset; + + QPointF mappedPos = mapToScene(event->pos()); + + FOR_EACH_PICTURE(current_dive) { + if (QString(picture->filename) == filename) { + picture->offset.seconds = timeAxis->valueAt(mappedPos); + mark_divelist_changed(true); + break; + } + } + copy_dive(current_dive, &displayed_dive); + DivePictureModel::instance()->updateDivePictures(); + + + if (event->source() == this) { + event->setDropAction(Qt::MoveAction); + event->accept(); + } else { + event->acceptProposedAction(); + } + } else { + event->ignore(); + } +} + +void ProfileWidget2::dragEnterEvent(QDragEnterEvent *event) +{ + if (event->mimeData()->hasFormat("application/x-subsurfaceimagedrop")) { + if (event->source() == this) { + event->setDropAction(Qt::MoveAction); + event->accept(); + } else { + event->acceptProposedAction(); + } + } else { + event->ignore(); + } +} + +void ProfileWidget2::dragMoveEvent(QDragMoveEvent *event) +{ + if (event->mimeData()->hasFormat("application/x-subsurfaceimagedrop")) { + if (event->source() == this) { + event->setDropAction(Qt::MoveAction); + event->accept(); + } else { + event->acceptProposedAction(); + } + } else { + event->ignore(); + } +} diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h index ce3fda0..4142822 100644 --- a/profile-widget/profilewidget2.h +++ b/profile-widget/profilewidget2.h @@ -134,6 +134,10 @@ protected: virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event); + void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE; + void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE; + void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE; + private: /*methods*/ void fixBackgroundPos(); -- 1.9.5 (Apple Git-50.3)
Best Robert -- .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO Robert C. Helling Elite Master Course Theoretical and Mathematical Physics Scientific Coordinator Ludwig Maximilians Universitaet Muenchen, Dept. Physik Phone: +49 89 2180-4523 Theresienstr. 39, rm. B339 http://www.atdotde.de Enhance your privacy, use cryptography! My PGP keys have fingerprints A9D1 A01D 13A5 31FA 6515 BB44 0820 367C 36BC 0C1D and DCED 37B6 251C 7861 270D 5613 95C7 9D32 9A8D 9B8F |
signature.asc
Description: Message signed with OpenPGP using GPGMail
_______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
