diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-04-17 12:21:39 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-04-17 08:46:29 -0700 |
commit | 55d010bad839b503cbfa759498d18690f4a809ae (patch) | |
tree | 9139b3108d7eefa8a6a0b73cd109a93b02812e66 /qt-gui.cpp | |
parent | 95984628302bee02af3e82ac305b5e3bb4842533 (diff) | |
download | subsurface-55d010bad839b503cbfa759498d18690f4a809ae.tar.gz |
Moved code around to make possible to compile the C part alone.
The C code should be compilable without the need to compile the Gui part,
too. This is expecially good for unit testing as we can test all the
algorithms without a window appearing out of nowhere.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-gui.cpp')
-rw-r--r-- | qt-gui.cpp | 139 |
1 files changed, 0 insertions, 139 deletions
diff --git a/qt-gui.cpp b/qt-gui.cpp index a3b8b44b6..934589f8d 100644 --- a/qt-gui.cpp +++ b/qt-gui.cpp @@ -9,8 +9,6 @@ #include <sys/time.h> #include <ctype.h> -#include <libxslt/documents.h> - #include "dive.h" #include "divelist.h" #include "display.h" @@ -45,11 +43,6 @@ // this will create a warning when executing lupdate #define translate(_context, arg) gettextFromC::instance()->tr(arg) -const char *default_dive_computer_vendor; -const char *default_dive_computer_product; -const char *default_dive_computer_device; -DiveComputerList dcList; - static QApplication *application = NULL; static MainWindow *window = NULL; @@ -197,34 +190,6 @@ const QString get_dc_nickname(const char *model, uint32_t deviceid) return model; } -void set_dc_nickname(struct dive *dive) -{ - if (!dive) - return; - - struct divecomputer *dc = &dive->dc; - - while (dc) { - if (dc->model && *dc->model && dc->deviceid && - !dcList.getExact(dc->model, dc->deviceid)) { - // we don't have this one, yet - const DiveComputerNode *existNode = dcList.get(dc->model); - if (existNode) { - // we already have this model but a different deviceid - QString simpleNick(dc->model); - if (dc->deviceid == 0) - simpleNick.append(" (unknown deviceid)"); - else - simpleNick.append(" (").append(QString::number(dc->deviceid, 16)).append(")"); - dcList.addDC(dc->model, dc->deviceid, simpleNick); - } else { - dcList.addDC(dc->model, dc->deviceid); - } - } - dc = dc->next; - } -} - QString get_depth_string(int mm, bool showunit, bool showdecimal) { if (prefs.units.length == units::METERS) { @@ -358,55 +323,6 @@ double get_screen_dpi() return mydesk->physicalDpiX(); } -int is_default_dive_computer(const char *vendor, const char *product) -{ - return default_dive_computer_vendor && !strcmp(vendor, default_dive_computer_vendor) && - default_dive_computer_product && !strcmp(product, default_dive_computer_product); -} - -int is_default_dive_computer_device(const char *name) -{ - return default_dive_computer_device && !strcmp(name, default_dive_computer_device); -} - -void set_default_dive_computer(const char *vendor, const char *product) -{ - QSettings s; - - if (!vendor || !*vendor) - return; - if (!product || !*product) - return; - if (is_default_dive_computer(vendor, product)) - return; - if (default_dive_computer_vendor) - free((void *)default_dive_computer_vendor); - if (default_dive_computer_product) - free((void *)default_dive_computer_product); - default_dive_computer_vendor = strdup(vendor); - default_dive_computer_product = strdup(product); - s.beginGroup("DiveComputer"); - s.setValue("dive_computer_vendor", vendor); - s.setValue("dive_computer_product", product); - s.endGroup(); -} - -void set_default_dive_computer_device(const char *name) -{ - QSettings s; - - if (!name || !*name) - return; - if (is_default_dive_computer_device(name)) - return; - if (default_dive_computer_device) - free((void *)default_dive_computer_device); - default_dive_computer_device = strdup(name); - s.beginGroup("DiveComputer"); - s.setValue("dive_computer_device", name); - s.endGroup(); -} - QString getSubsurfaceDataPath(QString folderToFind) { QString execdir; @@ -440,28 +356,6 @@ QString getSubsurfaceDataPath(QString folderToFind) return QString(""); } -void create_device_node(const char *model, uint32_t deviceid, const char *serial, const char *firmware, const char *nickname) -{ - dcList.addDC(model, deviceid, nickname, serial, firmware); -} - -bool compareDC(const DiveComputerNode &a, const DiveComputerNode &b) -{ - return a.deviceId < b.deviceId; -} - -void call_for_each_dc(void *f, void (*callback)(void *, const char *, uint32_t, - const char *, const char *, const char *)) -{ - QList<DiveComputerNode> values = dcList.dcMap.values(); - qSort(values.begin(), values.end(), compareDC); - for (int i = 0; i < values.size(); i++) { - const DiveComputerNode *node = &values.at(i); - callback(f, node->model.toUtf8().data(), node->deviceId, node->nickName.toUtf8().data(), - node->serialNumber.toUtf8().data(), node->firmware.toUtf8().data()); - } -} - int gettimezoneoffset() { QDateTime dt1 = QDateTime::currentDateTime(); @@ -530,36 +424,3 @@ QString get_trip_date_string(timestamp_t when, int nr) .arg(monthname(tm.tm_mon)) .arg(tm.tm_year + 1900); } - -static xmlDocPtr get_stylesheet_doc(const xmlChar *uri, xmlDictPtr, int, void *, xsltLoadType) -{ - QFile f(QLatin1String(":/xslt/") + (const char *)uri); - if (!f.open(QIODevice::ReadOnly)) - return NULL; - - /* Load and parse the data */ - QByteArray source = f.readAll(); - - xmlDocPtr doc = xmlParseMemory(source, source.size()); - return doc; -} - -xsltStylesheetPtr get_stylesheet(const char *name) -{ - // this needs to be done only once, but doesn't hurt to run every time - xsltSetLoaderFunc(get_stylesheet_doc); - - // get main document: - xmlDocPtr doc = get_stylesheet_doc((const xmlChar *)name, NULL, 0, NULL, XSLT_LOAD_START); - if (!doc) - return NULL; - - // xsltSetGenericErrorFunc(stderr, NULL); - xsltStylesheetPtr xslt = xsltParseStylesheetDoc(doc); - if (!xslt) { - xmlFreeDoc(doc); - return NULL; - } - - return xslt; -} |