diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | core/btdiscovery.cpp | 73 | ||||
-rw-r--r-- | core/btdiscovery.h | 17 | ||||
-rw-r--r-- | core/downloadfromdcthread.cpp | 11 | ||||
-rw-r--r-- | core/downloadfromdcthread.h | 3 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDivePhotos.cpp | 8 | ||||
-rw-r--r-- | desktop-widgets/tab-widgets/TabDivePhotos.h | 3 | ||||
-rw-r--r-- | mobile-widgets/qml/DownloadFromDiveComputer.qml | 24 | ||||
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 31 | ||||
-rwxr-xr-x | scripts/build.sh | 116 | ||||
-rw-r--r-- | subsurface-mobile-helper.cpp | 9 | ||||
-rw-r--r-- | xslt/subsurfacecsv.xslt | 23 | ||||
-rw-r--r-- | xslt/xml2csv.xslt | 15 | ||||
-rw-r--r-- | xslt/xml2manualcsv.xslt | 67 |
14 files changed, 298 insertions, 104 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ed2e08b7..beb86adbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -397,7 +397,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") install(FILES ${QTTRANSLATIONS} DESTINATION ${RESOURCEDIR}/translations) install(FILES ${CMAKE_SOURCE_DIR}/gpl-2.0.txt DESTINATION ${RESOURCEDIR}) # this is a HACK - if(${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable") + if((${SUBSURFACE_TARGET_EXECUTABLE} MATCHES "DesktopExecutable") AND (NOT NO_PRINTING)) install(DIRECTORY ${Grantlee5_DIR}/../../grantlee DESTINATION ${PLUGINDIR}) endif() # this is a hack - but I don't know how else to find the macdeployqt program if it's not in the PATH diff --git a/core/btdiscovery.cpp b/core/btdiscovery.cpp index 71d6353c5..8a9bedc73 100644 --- a/core/btdiscovery.cpp +++ b/core/btdiscovery.cpp @@ -9,6 +9,47 @@ extern QMap<QString, dc_descriptor_t *> descriptorLookup; BTDiscovery *BTDiscovery::m_instance = NULL; +ConnectionListModel::ConnectionListModel(QObject *parent) : + QAbstractListModel(parent) +{ +} + +QHash <int, QByteArray> ConnectionListModel::roleNames() const +{ + QHash<int, QByteArray> roles; + roles[AddressRole] = "address"; + return roles; +} + +QVariant ConnectionListModel::data(const QModelIndex &index, int role) const +{ + if (index.row() < 0 || index.row() >= m_addresses.count()) + return QVariant(); + if (role != AddressRole) + return QVariant(); + return m_addresses[index.row()]; +} + +QString ConnectionListModel::address(int idx) const +{ + if (idx < 0 || idx >> m_addresses.count()) + return QString(); + return m_addresses[idx]; +} + +int ConnectionListModel::rowCount(const QModelIndex &parent) const +{ + Q_UNUSED(parent) + return m_addresses.count(); +} + +void ConnectionListModel::addAddress(const QString address) +{ + beginInsertRows(QModelIndex(), rowCount(), rowCount()); + m_addresses.append(address); + endInsertRows(); +} + static dc_descriptor_t *getDeviceType(QString btName) // central function to convert a BT name to a Subsurface known vendor/model pair { @@ -19,6 +60,7 @@ static dc_descriptor_t *getDeviceType(QString btName) if (btName.mid(4,2) == "3#") product = "OSTC 3"; else if (btName.mid(4,2) == "3+") product = "OSTC 3+"; else if (btName.mid(4,2) == "s#") product = "OSTC Sport"; + else if (btName.mid(4,2) == "s ") product = "OSTC Sport"; else if (btName.mid(4,2) == "4-") product = "OSTC 4"; else if (btName.mid(4,2) == "2-") product = "OSTC 2N"; // all OSTCs are HW_FAMILY_OSTC_3, so when we do not know, @@ -150,25 +192,28 @@ void BTDiscovery::btDeviceDiscoveredMain(const btPairedDevice &device) dc_descriptor_t *newDC = getDeviceType(device.name); if (newDC) newDevice = dc_descriptor_get_product(newDC); - else + else newDevice = device.name; qDebug() << "Found new device:" << newDevice << device.address; QString vendor; - if (newDC) foreach (vendor, productList.keys()) { - if (productList[vendor].contains(newDevice)) { - qDebug() << "this could be a " + vendor + " " + - (newDevice == "OSTC 3" ? "OSTC family" : newDevice); - btVP.btpdi = device; - btVP.dcDescriptor = newDC; - btVP.vendorIdx = vendorList.indexOf(vendor); - btVP.productIdx = productList[vendor].indexOf(newDevice); - qDebug() << "adding new btDCs entry (detected DC)" << newDevice << btVP.vendorIdx << btVP.productIdx << btVP.btpdi.address;; - btDCs << btVP; - productList[QObject::tr("Paired Bluetooth Devices")].append(device.name + " (" + device.address + ")"); - return; + if (newDC) + foreach (vendor, productList.keys()) { + if (productList[vendor].contains(newDevice)) { + qDebug() << "this could be a " + vendor + " " + + (newDevice == "OSTC 3" ? "OSTC family" : newDevice); + btVP.btpdi = device; + btVP.dcDescriptor = newDC; + btVP.vendorIdx = vendorList.indexOf(vendor); + btVP.productIdx = productList[vendor].indexOf(newDevice); + qDebug() << "adding new btDCs entry (detected DC)" << newDevice << btVP.vendorIdx << btVP.productIdx << btVP.btpdi.address;; + btDCs << btVP; + productList[QObject::tr("Paired Bluetooth Devices")].append(device.name + " (" + device.address + ")"); + connectionListModel.addAddress(device.address + " (" + device.name + ")"); + return; + } } - } + connectionListModel.addAddress(device.address); qDebug() << "Not recognized as dive computer"; } diff --git a/core/btdiscovery.h b/core/btdiscovery.h index 4b4e4b802..71df24f24 100644 --- a/core/btdiscovery.h +++ b/core/btdiscovery.h @@ -5,6 +5,7 @@ #include <QObject> #include <QString> #include <QLoggingCategory> +#include <QAbstractListModel> #if defined(BT_SUPPORT) #include <QBluetoothLocalDevice> #include <QBluetoothDeviceDiscoveryAgent> @@ -17,6 +18,22 @@ #include <QAndroidJniEnvironment> #endif +class ConnectionListModel : public QAbstractListModel { + Q_OBJECT +public: + enum CLMRole { + AddressRole = Qt::UserRole + 1 + }; + ConnectionListModel(QObject *parent = 0); + QHash<int, QByteArray> roleNames() const; + QVariant data(const QModelIndex &index, int role = AddressRole) const; + QString address(int idx) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + void addAddress(const QString address); +private: + QStringList m_addresses; +}; + class BTDiscovery : public QObject { Q_OBJECT diff --git a/core/downloadfromdcthread.cpp b/core/downloadfromdcthread.cpp index 76b314da7..8abc46bcd 100644 --- a/core/downloadfromdcthread.cpp +++ b/core/downloadfromdcthread.cpp @@ -7,6 +7,7 @@ QStringList vendorList; QHash<QString, QStringList> productList; static QHash<QString, QStringList> mobileProductList; // BT, BLE or FTDI supported DCs for mobile QMap<QString, dc_descriptor_t *> descriptorLookup; +ConnectionListModel connectionListModel; static QString str_error(const char *fmt, ...) { @@ -193,6 +194,16 @@ QStringList DCDeviceData::getProductListFromVendor(const QString &vendor) return productList[vendor]; } +int DCDeviceData::getMatchingAddress(const QString &vendor, const QString &product) +{ + for (int i = 0; i < connectionListModel.rowCount(); i++) { + QString address = connectionListModel.address(i); + if (address.contains(product)) + return i; + } + return -1; +} + DCDeviceData * DownloadThread::data() { return m_data; diff --git a/core/downloadfromdcthread.h b/core/downloadfromdcthread.h index fb9c73965..51b2a825f 100644 --- a/core/downloadfromdcthread.h +++ b/core/downloadfromdcthread.h @@ -45,6 +45,8 @@ public: device_data_t* internalData(); Q_INVOKABLE QStringList getProductListFromVendor(const QString& vendor); + Q_INVOKABLE int getMatchingAddress(const QString &vendor, const QString &product); + Q_INVOKABLE int getDetectedVendorIndex(const QString ¤tText); Q_INVOKABLE int getDetectedProductIndex(const QString ¤tVendorText, const QString ¤tProductText); @@ -102,5 +104,6 @@ void fill_computer_list(); extern QStringList vendorList; extern QHash<QString, QStringList> productList; extern QMap<QString, dc_descriptor_t *> descriptorLookup; +extern ConnectionListModel connectionListModel; #endif diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.cpp b/desktop-widgets/tab-widgets/TabDivePhotos.cpp index 143c3a02a..7d6223184 100644 --- a/desktop-widgets/tab-widgets/TabDivePhotos.cpp +++ b/desktop-widgets/tab-widgets/TabDivePhotos.cpp @@ -43,11 +43,11 @@ void TabDivePhotos::clear() void TabDivePhotos::contextMenuEvent(QContextMenuEvent *event) { QMenu popup(this); - popup.addAction(tr("Load image(s) from file(s)"), this, SLOT(addPhotosFromFile)); - popup.addAction(tr("Load image(s) from web"), this, SLOT(addPhotosFromURL)); + popup.addAction(tr("Load image(s) from file(s)"), this, SLOT(addPhotosFromFile())); + popup.addAction(tr("Load image(s) from web"), this, SLOT(addPhotosFromURL())); popup.addSeparator(); - popup.addAction(tr("Delete selected images"), this, SLOT(removeSelectedPhotos)); - popup.addAction(tr("Delete all images"), this, SLOT(removeAllPhotos)); + popup.addAction(tr("Delete selected images"), this, SLOT(removeSelectedPhotos())); + popup.addAction(tr("Delete all images"), this, SLOT(removeAllPhotos())); popup.exec(event->globalPos()); event->accept(); } diff --git a/desktop-widgets/tab-widgets/TabDivePhotos.h b/desktop-widgets/tab-widgets/TabDivePhotos.h index 97f6f86d6..9b711595c 100644 --- a/desktop-widgets/tab-widgets/TabDivePhotos.h +++ b/desktop-widgets/tab-widgets/TabDivePhotos.h @@ -21,12 +21,13 @@ public: protected: void contextMenuEvent(QContextMenuEvent *ev) override; -private: +private slots: void addPhotosFromFile(); void addPhotosFromURL(); void removeAllPhotos(); void removeSelectedPhotos(); +private: Ui::TabDivePhotos *ui; DivePictureModel *divePictureModel; }; diff --git a/mobile-widgets/qml/DownloadFromDiveComputer.qml b/mobile-widgets/qml/DownloadFromDiveComputer.qml index b7f000a46..9086a2e0f 100644 --- a/mobile-widgets/qml/DownloadFromDiveComputer.qml +++ b/mobile-widgets/qml/DownloadFromDiveComputer.qml @@ -26,7 +26,7 @@ Kirigami.Page { deviceData.product : comboProduct.currentText //TODO: make this dynamic? - deviceData.devName : "/tmp/ttyS1" + deviceData.devName : comboConnection.currentText //TODO: Make this the default on the C++ deviceData.bluetoothMode : isBluetooth.checked @@ -82,10 +82,32 @@ Kirigami.Page { Layout.fillWidth: true model: null currentIndex: productidx + onCurrentTextChanged: { + var newIdx = downloadThread.data().getMatchingAddress(comboVendor.currentText, currentText) + if (newIdx != -1) + comboConnection.currentIndex = newIdx + } + onModelChanged: { currentIndex = productidx } } + Kirigami.Label { text: qsTr(" Connection:") } + ComboBox { + id: comboConnection + Layout.fillWidth: true + model: connectionListModel + currentIndex: -1 + onCurrentTextChanged: { + // pattern that matches BT addresses + var btAddr = /[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]:[0-9A-Fa-f][0-9A-Fa-f]/ ; + if (btAddr.test(currentText)) + isBluetooth.checked = true + else + isBluetooth.checked = false + } + } + Kirigami.Label { text: btEnabled ? qsTr("Bluetooth download:") : qsTr("No Bluetooth support detected")} CheckBox { id: isBluetooth diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 5b526362a..5066c589a 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -278,33 +278,46 @@ void QMLManager::saveCloudCredentials() { QSettings s; bool cloudCredentialsChanged = false; + // make sure we only have letters, numbers, and +-_. in password and email address + QRegularExpression regExp("^[a-zA-Z0-9@.+_-]+$"); + QString cloudPwd = cloudPassword(); + QString cloudUser = cloudUserName(); + if (cloudPwd.isEmpty() || !regExp.match(cloudPwd).hasMatch() || !regExp.match(cloudUser).hasMatch()) { + setStartPageText(RED_FONT + tr("Cloud storage email and password can only consist of letters, numbers, and '.', '-', '_', and '+'.") + END_FONT); + return; + } + // use the same simplistic regex as the backend to check email addresses + regExp = QRegularExpression("^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.+_-]+\\.[a-zA-Z0-9]+"); + if (!regExp.match(cloudUser).hasMatch()) { + setStartPageText(RED_FONT + tr("Invalid format for email address") + END_FONT); + return; + } s.beginGroup("CloudStorage"); - s.setValue("email", cloudUserName()); - s.setValue("password", cloudPassword()); + s.setValue("email", cloudUser); + s.setValue("password", cloudPwd); s.sync(); - if (!same_string(prefs.cloud_storage_email, qPrintable(cloudUserName()))) { + if (!same_string(prefs.cloud_storage_email, qPrintable(cloudUser))) { free(prefs.cloud_storage_email); - prefs.cloud_storage_email = strdup(qPrintable(cloudUserName())); + prefs.cloud_storage_email = strdup(qPrintable(cloudUser)); cloudCredentialsChanged = true; } - cloudCredentialsChanged |= !same_string(prefs.cloud_storage_password, qPrintable(cloudPassword())); + cloudCredentialsChanged |= !same_string(prefs.cloud_storage_password, qPrintable(cloudPwd)); if (!cloudCredentialsChanged) { // just go back to the dive list setCredentialStatus(oldStatus()); } - if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPassword()))) { + if (!same_string(prefs.cloud_storage_password, qPrintable(cloudPwd))) { free(prefs.cloud_storage_password); - prefs.cloud_storage_password = strdup(qPrintable(cloudPassword())); + prefs.cloud_storage_password = strdup(qPrintable(cloudPwd)); } - if (cloudUserName().isEmpty() || cloudPassword().isEmpty()) { + if (cloudUser.isEmpty() || cloudPwd.isEmpty()) { setStartPageText(RED_FONT + tr("Please enter valid cloud credentials.") + END_FONT); } else if (cloudCredentialsChanged) { // let's make sure there are no unsaved changes saveChangesLocal(); - free(prefs.userid); prefs.userid = NULL; syncLoadFromCloud(); diff --git a/scripts/build.sh b/scripts/build.sh index 1316b4778..7701b9c60 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -19,6 +19,9 @@ # create a log file of the build exec 1> >(tee build.log) 2>&1 +SRC=$(pwd) +PLATFORM=$(uname) + # in order to build the dependencies on Mac for release builds (to deal with the macosx-version-min for those # call this script with -build-deps if [ "$1" == "-build-deps" ] ; then @@ -26,8 +29,16 @@ if [ "$1" == "-build-deps" ] ; then BUILD_DEPS="1" fi -SRC=$(pwd) -PLATFORM=$(uname) +# unless you build Qt from source (or at least webkit from source, you won't have webkit installed +# -build-with-webkit tells the script that in fact we can assume that webkit is present (it usually +# is still available on Linux distros) +if [ "$1" == "-build-with-webkit" ] ; then + shift + BUILD_WITH_WEBKIT="1" +fi +if [ $PLATFORM = Linux ] ; then + BUILD_WITH_WEBKIT="1" +fi # most of these will only be needed with -build-deps on a Mac CURRENT_LIBZIP="1.2.0" @@ -40,8 +51,18 @@ CURRENT_LIBGIT2="v0.26.0" # Verify that the Xcode Command Line Tools are installed if [ $PLATFORM = Darwin ] ; then - OLDER_MAC="-mmacosx-version-min=10.10 -isysroot/Developer/SDKs/MacOSX10.10.sdk" - OLDER_MAC_CMAKE="-DCMAKE_OSX_DEPLOYMENT_TARGET=10.10 -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.10.sdk/" + if [ -d /Developer/SDKs ] ; then + SDKROOT=/Developer/SDKs + elif [ -d /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs ] ; then + SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs + else + echo "Cannot find SDK sysroot (usually /Developer/SDKs or" + echo "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs)" + exit 1; + fi + BASESDK=$(ls $SDKROOT | grep "MacOSX10\.1.\.sdk" | head -1 | sed -e "s/MacOSX//;s/\.sdk//") + OLDER_MAC="-mmacosx-version-min=${BASESDK} -isysroot${SDKROOT}/MacOSX${BASESDK}.sdk" + OLDER_MAC_CMAKE="-DCMAKE_OSX_DEPLOYMENT_TARGET=${BASESDK} -DCMAKE_OSX_SYSROOT=${SDKROOT}/MacOSX${BASESDK}.sdk/" if [ ! -d /usr/include ] ; then echo "Error: Xcode Command Line Tools are not installed" echo "" @@ -66,15 +87,19 @@ elif [ "$1" = "-both" ] ; then echo "building both Subsurface and Subsurface-mobile in subsurface/build and subsurface/build-mobile, respectively" BUILDS=( "DesktopExecutable" "MobileExecutable" ) BUILDDIRS=( "build" "build-mobile" ) - BUILDGRANTLEE=1 - BUILDMARBLE=1 + if [ "$BUILD_WITH_WEBKIT" = "1" ] ; then + BUILDGRANTLEE=1 + BUILDMARBLE=1 + fi shift else echo "building Subsurface in subsurface/build" BUILDS=( "DesktopExecutable" ) BUILDDIRS=( "build" ) - BUILDGRANTLEE=1 - BUILDMARBLE=1 + if [ "$BUILD_WITH_WEBKIT" = "1" ] ; then + BUILDGRANTLEE=1 + BUILDMARBLE=1 + fi fi if [[ ! -d "subsurface" ]] ; then @@ -201,6 +226,12 @@ if [[ $PLATFORM = Darwin || "$LIBGIT" < "24" ]] ; then cmake $OLDER_MAC_CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DBUILD_EXAMPLES=OFF .. make -j4 make install + else + # we are getting libusb and hidapi from pkg-config and that goes wrong + # or more specifically, the way libdivecomputer references + # the include files goes wrong + pkg-config --exists libusb-1.0 && LIBDC_CFLAGS=-I$(dirname $(pkg-config --cflags libusb-1.0 | sed -e 's/^-I//')) + pkg-config --exists hidapi && LIBDC_CFLAGS="${LIBDC_CFLAGS} -I$(dirname $(pkg-config --cflags hidapi | sed -e 's/^-I//'))" fi LIBGIT_ARGS=" -DLIBGIT2_INCLUDE_DIR=$INSTALL_ROOT/include -DLIBGIT2_LIBRARIES=$INSTALL_ROOT/lib/libgit2.$SH_LIB_EXT " @@ -266,15 +297,46 @@ if [ ! -f ../configure ] ; then autoreconf --install .. autoreconf --install .. fi -CFLAGS="$OLDER_MAC -I$INSTALL_ROOT/include" ../configure --prefix=$INSTALL_ROOT --disable-examples +CFLAGS="$OLDER_MAC -I$INSTALL_ROOT/include $LIBDC_CFLAGS" ../configure --prefix=$INSTALL_ROOT --disable-examples make -j4 make install +if [ $PLATFORM = Darwin ] ; then + if [ -z "$CMAKE_PREFIX_PATH" ] ; then + # qmake in PATH? + libdir=`qmake -query QT_INSTALL_LIBS` + if [ $? -eq 0 ]; then + export CMAKE_PREFIX_PATH=$libdir/cmake + elif [ -d "$HOME/Qt/5.9.1" ] ; then + export CMAKE_PREFIX_PATH=~/Qt/5.9.1/clang_64/lib/cmake + elif [ -d "$HOME/Qt/5.9" ] ; then + export CMAKE_PREFIX_PATH=~/Qt/5.9/clang_64/lib/cmake + elif [ -d "$HOME/Qt/5.8" ] ; then + export CMAKE_PREFIX_PATH=~/Qt/5.8/clang_64/lib/cmake + elif [ -d "$HOME/Qt/5.7" ] ; then + export CMAKE_PREFIX_PATH=~/Qt/5.7/clang_64/lib/cmake + elif [ -d "$HOME/Qt/5.6" ] ; then + export CMAKE_PREFIX_PATH=~/Qt/5.6/clang_64/lib/cmake + elif [ -d "$HOME/Qt/5.5" ] ; then + export CMAKE_PREFIX_PATH=~/Qt/5.5/clang_64/lib/cmake + elif [ -d /usr/local/opt/qt5/lib ] ; then + # Homebrew location for qt5 package + export CMAKE_PREFIX_PATH=/usr/local/opt/qt5/lib/cmake + else + echo "cannot find Qt 5.5 or newer in ~/Qt" + exit 1 + fi + fi +fi + cd $SRC # build libssrfmarblewidget if [ $BUILDMARBLE = 1 ]; then + MARBLE_OPTS="-DMARBLE_INCLUDE_DIR=$INSTALL_ROOT/include \ + -DMARBLE_LIBRARIES=$INSTALL_ROOT/lib/libssrfmarblewidget.$SH_LIB_EXT \ + -DNO_MARBLE=OFF -DNO_USERMANUAL=OFF -DFBSUPPORT=ON" if [ ! -d marble-source ] ; then if [[ $1 = local ]] ; then git clone $SRC/../marble-source marble-source @@ -290,33 +352,6 @@ if [ $BUILDMARBLE = 1 ]; then fi mkdir -p build cd build - if [ $PLATFORM = Darwin ] ; then - if [ -z "$CMAKE_PREFIX_PATH" ] ; then - # qmake in PATH? - libdir=`qmake -query QT_INSTALL_LIBS` - if [ $? -eq 0 ]; then - export CMAKE_PREFIX_PATH=$libdir/cmake - elif [ -d "$HOME/Qt/5.9.1" ] ; then - export CMAKE_PREFIX_PATH=~/Qt/5.9.1/clang_64/lib/cmake - elif [ -d "$HOME/Qt/5.9" ] ; then - export CMAKE_PREFIX_PATH=~/Qt/5.9/clang_64/lib/cmake - elif [ -d "$HOME/Qt/5.8" ] ; then - export CMAKE_PREFIX_PATH=~/Qt/5.8/clang_64/lib/cmake - elif [ -d "$HOME/Qt/5.7" ] ; then - export CMAKE_PREFIX_PATH=~/Qt/5.7/clang_64/lib/cmake - elif [ -d "$HOME/Qt/5.6" ] ; then - export CMAKE_PREFIX_PATH=~/Qt/5.6/clang_64/lib/cmake - elif [ -d "$HOME/Qt/5.5" ] ; then - export CMAKE_PREFIX_PATH=~/Qt/5.5/clang_64/lib/cmake - elif [ -d /usr/local/opt/qt5/lib ] ; then - # Homebrew location for qt5 package - export CMAKE_PREFIX_PATH=/usr/local/opt/qt5/lib/cmake - else - echo "cannot find Qt 5.5 or newer in ~/Qt" - exit 1 - fi - fi - fi cmake $OLDER_MAC_CMAKE -DCMAKE_BUILD_TYPE=Release -DQTONLY=TRUE -DQT5BUILD=ON \ -DCMAKE_INSTALL_PREFIX=$INSTALL_ROOT \ @@ -337,10 +372,13 @@ if [ $BUILDMARBLE = 1 ]; then install_name_tool -id "$INSTALL_ROOT/lib/$NAME" "$INSTALL_ROOT/lib/$NAME" fi fi +else + MARBLE_OPTS="-DNO_MARBLE=ON -DNO_USERMANUAL=ON -DFBSUPPORT=OFF" fi if [ "$BUILDGRANTLEE" = "1" ] ; then # build grantlee + PRINTING="-DNO_PRINTING=OFF" cd $SRC @@ -364,6 +402,8 @@ if [ "$BUILDGRANTLEE" = "1" ] ; then $SRC/grantlee make -j4 make install +else + PRINTING="-DNO_PRINTING=ON" fi @@ -391,10 +431,8 @@ for (( i=0 ; i < ${#BUILDS[@]} ; i++ )) ; do ${LIBGIT_ARGS} \ -DLIBDIVECOMPUTER_INCLUDE_DIR=$INSTALL_ROOT/include \ -DLIBDIVECOMPUTER_LIBRARIES=$INSTALL_ROOT/lib/libdivecomputer.a \ - -DMARBLE_INCLUDE_DIR=$INSTALL_ROOT/include \ - -DMARBLE_LIBRARIES=$INSTALL_ROOT/lib/libssrfmarblewidget.$SH_LIB_EXT \ -DCMAKE_PREFIX_PATH=$CMAKE_PREFIX_PATH \ - -DNO_PRINTING=OFF + $PRINTING $MARBLE_OPTS if [ $PLATFORM = Darwin ] ; then rm -rf Subsurface.app diff --git a/subsurface-mobile-helper.cpp b/subsurface-mobile-helper.cpp index 00c0e2c08..68dd228ba 100644 --- a/subsurface-mobile-helper.cpp +++ b/subsurface-mobile-helper.cpp @@ -75,6 +75,15 @@ void run_ui() ctxt->setContextProperty("diveModel", sortModel); ctxt->setContextProperty("gpsModel", gpsSortModel); ctxt->setContextProperty("vendorList", vendorList); +#if defined(Q_OS_ANDROID) + connectionListModel.addAddress("FTDI"); +#elif defined(Q_OS_LINUX) // since this is in the else, it does NOT include Android + connectionListModel.addAddress("/dev/ttyS0"); + connectionListModel.addAddress("/dev/ttyS1"); + connectionListModel.addAddress("/dev/ttyS2"); + connectionListModel.addAddress("/dev/ttyS3"); +#endif + ctxt->setContextProperty("connectionListModel", &connectionListModel); ctxt->setContextProperty("logModel", MessageHandlerModel::self()); engine.load(QUrl(QStringLiteral("qrc:///qml/main.qml"))); diff --git a/xslt/subsurfacecsv.xslt b/xslt/subsurfacecsv.xslt index 871d70f99..e4c3106bb 100644 --- a/xslt/subsurfacecsv.xslt +++ b/xslt/subsurfacecsv.xslt @@ -134,7 +134,7 @@ <xsl:value-of select="$max"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat(format-number((substring-before($max, ' ') * 0.3048), '#.##'), ' m')"/> + <xsl:value-of select="concat(round(translate(translate($max, translate($max, '0123456789,.', ''), ''), ',', '.') * 0.3048 * 1000) div 1000, ' m')"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> @@ -146,7 +146,7 @@ <xsl:value-of select="$mean"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat(format-number((substring-before($mean, ' ') * 0.3048), '#.##'), ' m')"/> + <xsl:value-of select="concat(round(translate(translate($mean, translate($mean, '0123456789,.', ''), ''), ',', '.') * 0.3048 * 1000) div 1000, ' m')"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> @@ -173,7 +173,7 @@ <xsl:value-of select="$air"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat(format-number((substring-before($air, ' ') - 32) * 5 div 9, '0.0'), ' C')"/> + <xsl:value-of select="concat(format-number((translate(translate($air, translate($air, '0123456789,.', ''), ''), ',', '.') - 32) * 5 div 9, '0.0'), ' C')"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> @@ -185,7 +185,7 @@ <xsl:value-of select="$water"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat(format-number((substring-before($water, ' ') - 32) * 5 div 9, '0.0'), ' C')"/> + <xsl:value-of select="concat(format-number((translate(translate($water, translate($water, '0123456789,.', ''), ''), ',', '.') - 32) * 5 div 9, '0.0'), ' C')"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> @@ -241,7 +241,14 @@ <xsl:value-of select="format-number((translate($size, translate($size, '0123456789', ''), '') * 14.7 div 3440) div 0.035315, '#.#')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="$size"/> + <xsl:choose> + <xsl:when test="$units = 0"> + <xsl:value-of select="$size"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="format-number((translate($size, translate($size, '0123456789', ''), '') * 14.7 div 3000) div 0.035315, '#.#')"/> + </xsl:otherwise> + </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:attribute> @@ -258,7 +265,7 @@ <xsl:value-of select="$start"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat(format-number((substring-before($start, ' ') div 14.5037738007), '#'), ' bar')"/> + <xsl:value-of select="concat(format-number((translate($start, translate($start, '0123456789', ''), '') div 14.5037738007), '#'), ' bar')"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> @@ -270,7 +277,7 @@ <xsl:value-of select="$end"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat(format-number((substring-before($end, ' ') div 14.5037738007), '#'), ' bar')"/> + <xsl:value-of select="concat(format-number((translate($end, translate($end, '0123456789', ''), '') div 14.5037738007), '#'), ' bar')"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> @@ -373,7 +380,7 @@ <xsl:value-of select="$weight"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat(format-number((substring-before($weight, ' ') * 0.453592), '#.##'), ' kg')"/> + <xsl:value-of select="concat(format-number((translate($weight, translate($weight, '0123456789', ''), '') * 0.453592), '#.##'), ' kg')"/> </xsl:otherwise> </xsl:choose> </xsl:attribute> diff --git a/xslt/xml2csv.xslt b/xslt/xml2csv.xslt index 211597325..25f5d8b7c 100644 --- a/xslt/xml2csv.xslt +++ b/xslt/xml2csv.xslt @@ -7,7 +7,14 @@ <xsl:variable name="fs">,</xsl:variable> <xsl:template match="/divelog/dives"> - <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth"', $fs, '"sample temperature"', $fs, '"sample pressure"')"/> + <xsl:choose> + <xsl:when test="$units = 1"> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth (ft)"', $fs, '"sample temperature (F)"', $fs, '"sample pressure (psi)"')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"sample time"', $fs, '"sample depth (m)"', $fs, '"sample temperature (C)"', $fs, '"sample pressure (bar)"')"/> + </xsl:otherwise> + </xsl:choose> <xsl:text> </xsl:text> <xsl:apply-templates select="dive|trip/dive"/> @@ -34,7 +41,7 @@ <xsl:value-of select="$fs"/> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat('"', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, ' ft"')"/> + <xsl:value-of select="concat('"', round((substring-before(@depth, ' ') div 0.3048) * 1000) div 1000, '"')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('"', round(substring-before(@depth, ' ') * 1000) div 1000, '"')"/> @@ -45,7 +52,7 @@ <xsl:if test="@temp != ''"> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat('"', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), ' F"')"/> + <xsl:value-of select="concat('"', format-number((substring-before(@temp, ' ') * 1.8) + 32, '#.#'), '"')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('"', substring-before(@temp, ' '), '"')"/> @@ -57,7 +64,7 @@ <xsl:if test="@pressure != ''"> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat('"', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), ' psi"')"/> + <xsl:value-of select="concat('"', format-number((substring-before(@pressure, ' ') * 14.5037738007), '#'), '"')"/> </xsl:when> <xsl:otherwise> <xsl:value-of select="concat('"', substring-before(@pressure, ' '), '"')"/> diff --git a/xslt/xml2manualcsv.xslt b/xslt/xml2manualcsv.xslt index fcb97b52d..242332756 100644 --- a/xslt/xml2manualcsv.xslt +++ b/xslt/xml2manualcsv.xslt @@ -11,7 +11,14 @@ </xsl:text></xsl:variable> <xsl:template match="/divelog/dives"> - <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"duration"', $fs, '"maxdepth"', $fs, '"avgdepth"', $fs, '"airtemp"', $fs, '"watertemp"', $fs, '"cylinder size"', $fs, '"startpressure"', $fs, '"endpressure"', $fs, '"o2"', $fs, '"he"', $fs, '"location"', $fs, '"gps"', $fs, '"divemaster"', $fs, '"buddy"', $fs, '"suit"', $fs, '"rating"', $fs, '"visibility"', $fs, '"notes"', $fs, '"weight"', $fs, '"tags"')"/> + <xsl:choose> + <xsl:when test="$units = 1"> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"duration"', $fs, '"maxdepth (ft)"', $fs, '"avgdepth (ft)"', $fs, '"airtemp (F)"', $fs, '"watertemp (F)"', $fs, '"cylinder size (cuft)"', $fs, '"startpressure (psi)"', $fs, '"endpressure (psi)"', $fs, '"o2"', $fs, '"he"', $fs, '"location"', $fs, '"gps"', $fs, '"divemaster"', $fs, '"buddy"', $fs, '"suit"', $fs, '"rating"', $fs, '"visibility"', $fs, '"notes"', $fs, '"weight (lbs)"', $fs, '"tags"')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('"dive number"', $fs, '"date"', $fs, '"time"', $fs, '"duration"', $fs, '"maxdepth (m)"', $fs, '"avgdepth (m)"', $fs, '"airtemp (C)"', $fs, '"watertemp (C)"', $fs, '"cylinder size (l)"', $fs, '"startpressure (bar)"', $fs, '"endpressure (bar)"', $fs, '"o2"', $fs, '"he"', $fs, '"location"', $fs, '"gps"', $fs, '"divemaster"', $fs, '"buddy"', $fs, '"suit"', $fs, '"rating"', $fs, '"visibility"', $fs, '"notes"', $fs, '"weight (kg)"', $fs, '"tags"')"/> + </xsl:otherwise> + </xsl:choose> <xsl:text> </xsl:text> <xsl:apply-templates select="dive|trip/dive"/> @@ -71,10 +78,10 @@ <xsl:text>"</xsl:text> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat(format-number((cylinder[1]/@size div 14.7 * 3000) * 0.035315, '#.#'), ' cuft')"/> + <xsl:value-of select="concat(format-number((substring-before(cylinder[1]/@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), '')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="cylinder[1]/@size"/> + <xsl:value-of select="substring-before(cylinder[1]/@size, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> @@ -82,10 +89,17 @@ <xsl:text>"</xsl:text> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ') * 14.5037738007), '#'), ' psi')"/> + <xsl:choose> + <xsl:when test="substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ') > 0"> + <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ') * 14.5037738007), '#'), '')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="''"/> + </xsl:otherwise> + </xsl:choose> </xsl:when> <xsl:otherwise> - <xsl:value-of select="divecomputer[1]/sample[@pressure]/@pressure"/> + <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure]/@pressure, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> @@ -93,10 +107,17 @@ <xsl:text>"</xsl:text> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') * 14.5037738007), '#'), ' psi')"/> + <xsl:choose> + <xsl:when test="substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') > 0"> + <xsl:value-of select="concat(format-number((substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ') * 14.5037738007), '#'), '')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="''"/> + </xsl:otherwise> + </xsl:choose> </xsl:when> <xsl:otherwise> - <xsl:value-of select="divecomputer[1]/sample[@pressure][last()]/@pressure"/> + <xsl:value-of select="substring-before(divecomputer[1]/sample[@pressure][last()]/@pressure, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> @@ -184,10 +205,10 @@ <xsl:if test="weightsystem"> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat(format-number((sum(xt:node-set($trimmedweightlist)/node()) div 0.453592), '#.##'), ' lb')"/> + <xsl:value-of select="concat(format-number((sum(xt:node-set($trimmedweightlist)/node()) div 0.453592), '#.##'), '')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat(sum(xt:node-set($trimmedweightlist)/node()), ' kg')"/> + <xsl:value-of select="concat(sum(xt:node-set($trimmedweightlist)/node()), '')"/> </xsl:otherwise> </xsl:choose> </xsl:if> @@ -206,10 +227,10 @@ <xsl:text>"</xsl:text> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat(format-number((substring-before(@max, ' ') div 0.3048), '#.##'), ' ft')"/> + <xsl:value-of select="concat(format-number((substring-before(@max, ' ') div 0.3048), '#.##'), '')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="@max"/> + <xsl:value-of select="substring-before(@max, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> @@ -217,10 +238,10 @@ <xsl:text>"</xsl:text> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat(format-number((substring-before(@mean, ' ') div 0.3048), '#.##'), ' ft')"/> + <xsl:value-of select="concat(format-number((substring-before(@mean, ' ') div 0.3048), '#.##'), '')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="@mean"/> + <xsl:value-of select="substring-before(@mean, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> @@ -231,11 +252,11 @@ <xsl:choose> <xsl:when test="$units = 1"> <xsl:if test="substring-before(@air, ' ') > 0"> - <xsl:value-of select="concat(format-number((substring-before(@air, ' ') * 1.8) + 32, '0.0'), ' F')"/> + <xsl:value-of select="concat(format-number((substring-before(@air, ' ') * 1.8) + 32, '0.0'), '')"/> </xsl:if> </xsl:when> <xsl:otherwise> - <xsl:value-of select="@air"/> + <xsl:value-of select="substring-before(@air, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> @@ -244,11 +265,11 @@ <xsl:choose> <xsl:when test="$units = 1"> <xsl:if test="substring-before(@water, ' ') > 0"> - <xsl:value-of select="concat(format-number((substring-before(@water, ' ') * 1.8) + 32, '0.0'), ' F')"/> + <xsl:value-of select="concat(format-number((substring-before(@water, ' ') * 1.8) + 32, '0.0'), '')"/> </xsl:if> </xsl:when> <xsl:otherwise> - <xsl:value-of select="@water"/> + <xsl:value-of select="substring-before(@water, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> @@ -258,10 +279,10 @@ <xsl:text>"</xsl:text> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat(format-number((substring-before(@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), ' cuft')"/> + <xsl:value-of select="concat(format-number((substring-before(@size, ' ') div 14.7 * 3000) * 0.035315, '#.#'), '')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="@size"/> + <xsl:value-of select="substring-before(@size, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> @@ -269,10 +290,10 @@ <xsl:text>"</xsl:text> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat(format-number((substring-before(@start, ' ') * 14.5037738007), '#'), ' psi')"/> + <xsl:value-of select="concat(format-number((substring-before(@start, ' ') * 14.5037738007), '#'), '')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="@start"/> + <xsl:value-of select="substring-before(@start, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> @@ -280,10 +301,10 @@ <xsl:text>"</xsl:text> <xsl:choose> <xsl:when test="$units = 1"> - <xsl:value-of select="concat(format-number((substring-before(@end, ' ') * 14.5037738007), '#'), ' psi')"/> + <xsl:value-of select="concat(format-number((substring-before(@end, ' ') * 14.5037738007), '#'), '')"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="@end"/> + <xsl:value-of select="substring-before(@end, ' ')"/> </xsl:otherwise> </xsl:choose> <xsl:text>"</xsl:text> |