diff options
-rw-r--r-- | parse-xml.c | 1 | ||||
-rw-r--r-- | qt-ui/divelistview.cpp | 13 | ||||
-rw-r--r-- | qt-ui/divelistview.h | 2 | ||||
-rw-r--r-- | qt-ui/globe.cpp | 7 | ||||
-rw-r--r-- | qt-ui/maintab.cpp | 6 | ||||
-rw-r--r-- | qt-ui/maintab.ui | 3 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 1 | ||||
-rw-r--r-- | qt-ui/models.cpp | 2 | ||||
-rw-r--r-- | qt-ui/profilegraphics.cpp | 17 | ||||
-rw-r--r-- | qt-ui/profilegraphics.h | 2 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 8 | ||||
-rw-r--r-- | xslt/uddf.xslt | 193 |
12 files changed, 218 insertions, 37 deletions
diff --git a/parse-xml.c b/parse-xml.c index 58a9019c9..ba952957f 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -1913,6 +1913,7 @@ static struct xslt_files { { "dives", "MacDive.xslt" }, { "DIVELOGSDATA", "divelogs.xslt" }, { "uddf", "uddf.xslt" }, + { "UDDF", "uddf.xslt" }, { "profile", "udcf.xslt" }, { "Divinglog", "DivingLog.xslt" }, { NULL, } diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index cbd62408b..fd189e926 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -47,16 +47,19 @@ void DiveListView::unselectDives() selectionModel()->clearSelection(); } -void DiveListView::selectDive(struct dive *dive, bool scrollto) +void DiveListView::selectDive(struct dive *dive, bool scrollto, bool toggle) { QSortFilterProxyModel *m = qobject_cast<QSortFilterProxyModel*>(model()); QModelIndexList match = m->match(m->index(0,0), TreeItemDT::NR, dive->number, 1, Qt::MatchRecursive); + QItemSelectionModel::SelectionFlags flags; QModelIndex idx = match.first(); QModelIndex parent = idx.parent(); if (parent.isValid()) expand(parent); - selectionModel()->select( idx, QItemSelectionModel::Select | QItemSelectionModel::Rows); + flags = toggle ? QItemSelectionModel::Toggle : QItemSelectionModel::Select; + flags |= QItemSelectionModel::Rows; + selectionModel()->select( idx, flags); if (scrollto) scrollTo(idx, PositionAtCenter); } @@ -183,6 +186,12 @@ void DiveListView::reloadHeaderActions() setColumnHidden(i, !shown); } s.endGroup(); + } else { + // Skip first QAction item ( static text Visible ) + for(int i = 0; i < model()->columnCount(); i++) { + QString title = QString("%1").arg(model()->headerData(i, Qt::Horizontal).toString()); + header()->actions()[i+1]->setText( title ); + } } } diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h index a9b986f97..c578baa17 100644 --- a/qt-ui/divelistview.h +++ b/qt-ui/divelistview.h @@ -27,7 +27,7 @@ public: void reload(DiveTripModel::Layout layout, bool forceSort = true); bool eventFilter(QObject* , QEvent* ); void unselectDives(); - void selectDive(struct dive *, bool scrollto = false); + void selectDive(struct dive *, bool scrollto = false, bool toggle = false); void contextMenuEvent(QContextMenuEvent *event); public slots: diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 78283e49e..24806d520 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -82,6 +82,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) int idx; struct dive *dive; bool clear = !(QApplication::keyboardModifiers() && Qt::ControlModifier); + bool toggle = !clear; bool first = true; for_each_dive(idx, dive) { long lat_diff, lon_diff; @@ -100,7 +101,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) mainWindow()->dive_list()->unselectDives(); clear = false; } - mainWindow()->dive_list()->selectDive(dive, first); + mainWindow()->dive_list()->selectDive(dive, first, toggle); first = false; } } @@ -129,10 +130,10 @@ void GlobeGPS::reload() place->setCoordinate(dive->longitude.udeg / 1000000.0,dive->latitude.udeg / 1000000.0 , 0, GeoDataCoordinates::Degree); // don't add dive locations twice, unless they are at least 50m apart if (locationMap[QString(dive->location)]) { - GeoDataPoint existingLocation = locationMap[QString(dive->location)]->coordinate(); + GeoDataCoordinates existingLocation = locationMap[QString(dive->location)]->coordinate(); GeoDataLineString segment = GeoDataLineString(); segment.append(existingLocation); - GeoDataPoint newLocation = place->coordinate(); + GeoDataCoordinates newLocation = place->coordinate(); segment.append(newLocation); double dist = segment.length(6371); // the dist is scaled to the radius given - so with 6371km as radius diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index b9b5d0ab7..080ebdf44 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -27,7 +27,11 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), ui->weights->setModel(weightModel); ui->diveNotesMessage->hide(); ui->diveNotesMessage->setCloseButtonVisible(false); - +#ifdef __APPLE__ + setDocumentMode(false); +#else + setDocumentMode(true); +#endif // we start out with the fields read-only; once things are // filled from a dive, they are made writeable ui->location->setReadOnly(true); diff --git a/qt-ui/maintab.ui b/qt-ui/maintab.ui index 55d4f3a54..c05589d20 100644 --- a/qt-ui/maintab.ui +++ b/qt-ui/maintab.ui @@ -16,9 +16,6 @@ <property name="currentIndex"> <number>3</number> </property> - <property name="documentMode"> - <bool>true</bool> - </property> <widget class="QWidget" name="notesTab"> <attribute name="title"> <string>Dive Notes</string> diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index b2baa8c26..ce9aadc62 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -44,6 +44,7 @@ MainWindow::MainWindow() : ui(new Ui::MainWindow()), helpView(0) connect(ui->ListWidget, SIGNAL(currentDiveChanged(int)), this, SLOT(current_dive_changed(int))); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), this, SLOT(readSettings())); connect(PreferencesDialog::instance(), SIGNAL(settingsChanged()), ui->ListWidget, SLOT(update())); + 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); diff --git a/qt-ui/models.cpp b/qt-ui/models.cpp index 045592deb..86773fd52 100644 --- a/qt-ui/models.cpp +++ b/qt-ui/models.cpp @@ -835,7 +835,7 @@ QVariant DiveItem::data(int column, int role) const break; case SORT_ROLE: switch (column) { - case NR: retVal = dive->number; break; + case NR: retVal = (qulonglong) dive->when; break; case DATE: retVal = (qulonglong) dive->when; break; case RATING: retVal = dive->rating; break; case DEPTH: retVal = dive->maxdepth.mm; break; diff --git a/qt-ui/profilegraphics.cpp b/qt-ui/profilegraphics.cpp index cfd155132..164de13ff 100644 --- a/qt-ui/profilegraphics.cpp +++ b/qt-ui/profilegraphics.cpp @@ -179,6 +179,12 @@ void ProfileGraphicsView::mouseMoveEvent(QMouseEvent* event) bool ProfileGraphicsView::eventFilter(QObject* obj, QEvent* event) { + if (event->type() == QEvent::Leave) { + if (toolTip && toolTip->isExpanded()) + toolTip->collapse(); + return true; + } + // This will "Eat" the default tooltip behavior. if (event->type() == QEvent::GraphicsSceneHelp) { event->ignore(); @@ -1324,6 +1330,9 @@ void ToolTipItem::collapse() animation->setStartValue(boundingRect()); animation->setEndValue(QRect(0, 0, ICON_SMALL, ICON_SMALL)); animation->start(QAbstractAnimation::DeleteWhenStopped); + clear(); + + status = COLLAPSED; } void ToolTipItem::expand() @@ -1358,6 +1367,7 @@ void ToolTipItem::expand() animation->setEndValue(nextRectangle); animation->start(QAbstractAnimation::DeleteWhenStopped); + status = EXPANDED; } ToolTipItem::ToolTipItem(QGraphicsItem* parent): QGraphicsPathItem(parent), background(0) @@ -1368,6 +1378,8 @@ ToolTipItem::ToolTipItem(QGraphicsItem* parent): QGraphicsPathItem(parent), back setFlag(ItemIgnoresTransformations); setFlag(ItemIsMovable); + status = COLLAPSED; + updateTitlePosition(); setZValue(99); } @@ -1401,6 +1413,11 @@ void ToolTipItem::updateTitlePosition() } } +bool ToolTipItem::isExpanded() { + return status == EXPANDED; +} + + EventItem::EventItem(QGraphicsItem* parent): QGraphicsPolygonItem(parent) { setFlag(ItemIgnoresTransformations); diff --git a/qt-ui/profilegraphics.h b/qt-ui/profilegraphics.h index b440adf5d..9c1c5dbc1 100644 --- a/qt-ui/profilegraphics.h +++ b/qt-ui/profilegraphics.h @@ -32,6 +32,7 @@ public: void addToolTip(const QString& toolTip, const QIcon& icon = QIcon()); void removeToolTip(const QString& toolTip); void refresh(struct graphics_context* gc, QPointF pos); + bool isExpanded(); public Q_SLOTS: void setRect(const QRectF& rect); @@ -42,6 +43,7 @@ private: QGraphicsPathItem *background; QGraphicsLineItem *separator; QGraphicsSimpleTextItem *title; + Status status; QRectF rectangle; }; diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index 2f82d6d26..cd944ca17 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -59,10 +59,14 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button) QSettings s; s.setValue("webservice_uid", ui->userID->text()); s.sync(); + hide(); + close(); } break; case QDialogButtonBox::RejectRole: - manager->deleteLater(); + // we may want to clean up after ourselves, but this + // makes Subsurface throw a SIGSEGV... + // manager->deleteLater(); reply->deleteLater(); ui->progressBar->setMaximum(1); break; @@ -90,7 +94,7 @@ void SubsurfaceWebServices::startDownload() ui->buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); connect(reply, SIGNAL(finished()), this, SLOT(downloadFinished())); - connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), + connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(downloadError(QNetworkReply::NetworkError))); } diff --git a/xslt/uddf.xslt b/xslt/uddf.xslt index 1d65d2d19..dfffecfb0 100644 --- a/xslt/uddf.xslt +++ b/xslt/uddf.xslt @@ -2,7 +2,7 @@ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:u="http://www.streit.cc/uddf/3.2/" xmlns:u1="http://www.streit.cc/uddf/3.1/" - exclude-result-prefixes="u" + exclude-result-prefixes="u u1" version="1.0"> <xsl:import href="commonTemplates.xsl"/> <xsl:strip-space elements="*"/> @@ -12,11 +12,18 @@ <divelog program="subsurface-import" version="2"> <settings> <divecomputerid deviceid="ffffffff"> - <xsl:apply-templates select="/uddf/generator|/u:uddf/u:generator|/u1:uddf/u1:generator"/> + <xsl:choose> + <xsl:when test="/UDDF/history != ''"> + <xsl:apply-templates select="/UDDF/history"/> + </xsl:when> + <xsl:otherwise> + <xsl:apply-templates select="/uddf/generator|/u:uddf/u:generator|/u1:uddf/u1:generator"/> + </xsl:otherwise> + </xsl:choose> </divecomputerid> </settings> <dives> - <xsl:apply-templates select="/uddf/profiledata/repetitiongroup/dive|/u:uddf/u:profiledata/u:repetitiongroup/u:dive|/u1:uddf/u1:profiledata/u1:repetitiongroup/u1:dive"/> + <xsl:apply-templates select="/uddf/profiledata/repetitiongroup/dive|/u:uddf/u:profiledata/u:repetitiongroup/u:dive|/u1:uddf/u1:profiledata/u1:repetitiongroup/u1:dive|/UDDF/dive"/> </dives> </divelog> </xsl:template> @@ -39,11 +46,24 @@ </xsl:if> </xsl:template> - <xsl:template match="gasdefinitions|u:gasdefinitions|u1:gasdefinitions"> - <xsl:for-each select="mix|u:mix|u1:mix"> + <xsl:template match="modified"> + <xsl:if test="application/name != ''"> + <xsl:attribute name="model"> + <xsl:value-of select="application/name"/> + </xsl:attribute> + </xsl:if> + <xsl:if test="application/version != ''"> + <xsl:attribute name="serial"> + <xsl:value-of select="application/version"/> + </xsl:attribute> + </xsl:if> + </xsl:template> + + <xsl:template match="gasdefinitions|u:gasdefinitions|u1:gasdefinitions|gas_def"> + <xsl:for-each select="mix|u:mix|u1:mix|gas_mix"> <cylinder> <xsl:attribute name="description"> - <xsl:value-of select="name|u:name|u1:name"/> + <xsl:value-of select="name|u:name|u1:name|mixname"/> </xsl:attribute> <xsl:attribute name="o2"> @@ -69,7 +89,7 @@ <dive> <!-- Count the amount of temeprature samples during the dive --> <xsl:variable name="temperatureSamples"> - <xsl:call-template name="temperatureSamples" select="samples/waypoint/temperature|u:samples/u:waypoint/u:temperature|u1:samples/u1:waypoint/u1:temperature"> + <xsl:call-template name="temperatureSamples" select="samples/waypoint/temperature|u:samples/u:waypoint/u:temperature|u1:samples/u1:waypoint/u1:temperature|samples/t"> <xsl:with-param name="units" select="'Kelvin'"/> </xsl:call-template> </xsl:variable> @@ -91,8 +111,74 @@ </xsl:call-template> </xsl:when> </xsl:choose> + <xsl:if test="dive_number != ''"> + <xsl:attribute name="number"> + <xsl:value-of select="dive_number"/> + </xsl:attribute> + </xsl:if> + <xsl:if test="dive_duration != '' and dive_duration != 0"> + <xsl:attribute name="duration"> + <xsl:call-template name="timeConvert"> + <xsl:with-param name="timeSec"> + <xsl:value-of select="dive_duration"/> + </xsl:with-param> + </xsl:call-template> + </xsl:attribute> + </xsl:if> + + <xsl:if test="condition/visibility != '' and condition/visibility != 0"> + <xsl:attribute name="visibility"> + <xsl:value-of select="condition/visibility"/> + </xsl:attribute> + </xsl:if> + + <xsl:if test="condition/air_temp != ''"> + <divetemperature> + <xsl:attribute name="air"> + <xsl:value-of select="concat(format-number(condition/air_temp - 273.15, '0.0'), ' C')"/> + </xsl:attribute> + </divetemperature> + </xsl:if> + + <xsl:if test="dive_site_ref/@ref != ''"> + <location> + <xsl:variable name="ref"> + <xsl:value-of select="dive_site_ref/@ref"/> + </xsl:variable> + <xsl:for-each select="//dive_site[@id=$ref]/geography/location|//dive_site[@id=$ref]/name"> + <xsl:value-of select="."/> + <xsl:if test=". != '' and following-sibling::*[1]/* != ''"> / </xsl:if> + </xsl:for-each> + </location> + </xsl:if> + + <xsl:if test="buddy_ref/@ref != ''"> + <buddy> + <xsl:variable name="ref"> + <xsl:value-of select="buddy_ref/@ref"/> + </xsl:variable> + <xsl:for-each select="//diver[@id=$ref]/personal/first_name|//diver[@id=$ref]/personal/nick_name|//diver[@id=$ref]/personal/family_name"> + <xsl:value-of select="."/> + <xsl:if test=". != '' and (following-sibling::*[1] != '' or following-sibling::*[2] != '')"> / </xsl:if> + </xsl:for-each> + </buddy> + </xsl:if> + + <xsl:if test="note/text != ''"> + <notes> + <xsl:value-of select="note/text"/> + </notes> + </xsl:if> - <xsl:for-each select="lowesttemperature|informationafterdive/lowesttemperature|u:lowesttemperature|u:informationafterdive/u:lowesttemperature|u1:lowesttemperature|u1:informationafterdive/u1:lowesttemperature"> + <xsl:if test="equipment_used/weight_used > 0"> + <weightsystem description="unknown"> + <xsl:attribute name="weight"> + <xsl:value-of select="concat(format-number(equipment_used/weight_used, '0.0'), ' kg')"/> + </xsl:attribute> + </weightsystem> + </xsl:if> + + <xsl:for-each select="lowesttemperature|informationafterdive/lowesttemperature|u:lowesttemperature|u:informationafterdive/u:lowesttemperature|u1:lowesttemperature|u1:informationafterdive/u1:lowesttemperature|condition/water_temp"> <temperature> <xsl:if test="$temperatureSamples > 0 or . != 273.15"> <xsl:attribute name="water"> @@ -104,24 +190,76 @@ <divecomputer deviceid="ffffffff"> <xsl:attribute name="model"> - <xsl:value-of select="/uddf/generator/name|/u:uddf/u:generator/u:name|/u1:uddf/u1:generator/u1:name"/> + <xsl:value-of select="/uddf/generator/name|/u:uddf/u:generator/u:name|/u1:uddf/u1:generator/u1:name|/UDDF/history/modified/application/name"/> </xsl:attribute> </divecomputer> + <xsl:if test="equipment_used/tank_used != ''"> + <xsl:for-each select="equipment_used/tank_used"> + <cylinder> + <xsl:variable name="idx"> + <xsl:value-of select="./tank_ref/@ref"/> + </xsl:variable> + <xsl:attribute name="size"> + <xsl:value-of select="//equipment[@id=$idx]/tank/volume"/> + </xsl:attribute> + <xsl:attribute name="description"> + <xsl:value-of select="//equipment[@id=$idx]/general/name"/> + </xsl:attribute> + <xsl:attribute name="start"> + <xsl:value-of select="concat(substring-before(./pressure_start, '.') div 100000, ' bar')"/> + </xsl:attribute> + <xsl:attribute name="end"> + <xsl:value-of select="concat(substring-before(./pressure_end, '.') div 100000, ' bar')"/> + </xsl:attribute> + </cylinder> + </xsl:for-each> + </xsl:if> + <xsl:apply-templates select="/uddf/gasdefinitions|/u:uddf/u:gasdefinitions|/u1:uddf/u1:gasdefinitions"/> <depth> - <xsl:for-each select="greatestdepth|informationafterdive/greatestdepth|u:greatestdepth|u:informationafterdive/u:greatestdepth|u1:greatestdepth|u1:informationafterdive/u1:greatestdepth"> + <xsl:for-each select="greatestdepth|informationafterdive/greatestdepth|u:greatestdepth|u:informationafterdive/u:greatestdepth|u1:greatestdepth|u1:informationafterdive/u1:greatestdepth|max_depth"> <xsl:attribute name="max"> - <xsl:value-of select="concat(., ' m')"/> + <xsl:value-of select="concat(format-number(., '0.00'), ' m')"/> </xsl:attribute> </xsl:for-each> <xsl:for-each select="averagedepth|informationafterdive/averagedepth|u:averagedepth|u:informationafterdive/u:averagedepth|u1:averagedepth|u1:informationafterdive/u1:averagedepth"> <xsl:attribute name="mean"> - <xsl:value-of select="concat(., ' m')"/> + <xsl:value-of select="concat(format-number(., '0.00'), ' m')"/> </xsl:attribute> </xsl:for-each> </depth> + <!-- Aquadivelog gas switches require more lookups than other UDDF + formats I have seen --> + <xsl:for-each select="samples/switch"> + <xsl:variable name="tank_idx"> + <xsl:value-of select="./@tank"/> + </xsl:variable> + <xsl:variable name="idx"> + <xsl:value-of select="//equipment_used/tank_used[@id=$tank_idx]/gas_ref/@ref"/> + </xsl:variable> + + <event name="gaschange" type="11"> + <xsl:attribute name="time"> + <xsl:call-template name="timeConvert"> + <xsl:with-param name="timeSec"> + <xsl:value-of select="following-sibling::t"/> + </xsl:with-param> + </xsl:call-template> + </xsl:attribute> + + <xsl:attribute name="value"> + <xsl:call-template name="gasConvert"> + <xsl:with-param name="mix"> + <xsl:value-of select="//gas_def/gas_mix[@id=$idx]/o2"/> + </xsl:with-param> + </xsl:call-template> + </xsl:attribute> + </event> + </xsl:for-each> + + <!-- Other gas switches than Aquadivelog --> <xsl:for-each select="samples/waypoint/switchmix|u:samples/u:waypoint/u:switchmix|u1:samples/u1:waypoint/u1:switchmix"> <!-- Index to lookup gas per cent --> <xsl:variable name="idx"> @@ -147,26 +285,33 @@ </event> </xsl:for-each> - <xsl:for-each select="samples/waypoint|u:samples/u:waypoint|u1:samples/u1:waypoint"> + <xsl:for-each select="samples/waypoint|u:samples/u:waypoint|u1:samples/u1:waypoint|samples/d"> <sample> <xsl:attribute name="time"> <xsl:call-template name="timeConvert"> <xsl:with-param name="timeSec"> - <xsl:value-of select="divetime|u:divetime|u1:divetime"/> + <xsl:value-of select="divetime|u:divetime|u1:divetime|preceding-sibling::t[1]"/> </xsl:with-param> </xsl:call-template> </xsl:attribute> - <xsl:if test="depth != ''"> - <xsl:attribute name="depth"> - <xsl:value-of select="concat(depth, ' m')"/> - </xsl:attribute> - </xsl:if> - <xsl:if test="u:depth|u1:depth != ''"> - <xsl:attribute name="depth"> - <xsl:value-of select="concat(u:depth|u1:depth, ' m')"/> - </xsl:attribute> - </xsl:if> + <xsl:choose> + <xsl:when test="depth != ''"> + <xsl:attribute name="depth"> + <xsl:value-of select="concat(format-number(depth, '0.00'), ' m')"/> + </xsl:attribute> + </xsl:when> + <xsl:when test="u:depth|u1:depth != ''"> + <xsl:attribute name="depth"> + <xsl:value-of select="concat(format-number(u:depth|u1:depth, '0.00'), ' m')"/> + </xsl:attribute> + </xsl:when> + <xsl:when test=". != 0"> + <xsl:attribute name="depth"> + <xsl:value-of select="concat(format-number(., '0.00'), ' m')"/> + </xsl:attribute> + </xsl:when> + </xsl:choose> <xsl:if test="temperature != '' and $temperatureSamples > 0"> <xsl:attribute name="temperature"> |