From: robertl Date: Fri, 31 Jul 2009 18:32:32 +0000 (+0000) Subject: Khai and I iterate on upgrade process, he tweaks track filters, others, I X-Git-Tag: archive/raspbian/1.10.0+ds-2+rpi1~1^2~199^2~189 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=d9ed99c603abc3b231f77c1eb047967c1f8a9af0;p=gpsbabel.git Khai and I iterate on upgrade process, he tweaks track filters, others, I do some general cleanup. --- diff --git a/gui/babeldata.h b/gui/babeldata.h index 8320c39cd..dae04c227 100644 --- a/gui/babeldata.h +++ b/gui/babeldata.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: babeldata.h,v 1.1 2009/07/05 21:14:56 robertl Exp $ +// $Id: babeldata.h,v 1.2 2009/07/31 18:32:32 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -52,7 +52,9 @@ public: debugLevel(-1), inputBrowse(QString()), outputBrowse(QString()), - previewGmap(false) + previewGmap(false), + upgradeCheckMethod(0), + upgradeCheckTime(QDateTime(QDate(2001, 1, 1), QTime(0, 0))) { }; @@ -92,6 +94,8 @@ public: sg.addVarSetting(new StringSetting("app.outputBrowse", outputBrowse)); sg.addVarSetting(new BoolSetting("app.previewGmap", previewGmap)); + sg.addVarSetting(new IntSetting("app.upgradeCheckMethod", upgradeCheckMethod)); + sg.addVarSetting(new DateTimeSetting("app.upgradeCheckTime", upgradeCheckTime)); } static const int noType; @@ -124,6 +128,8 @@ public: QString inputBrowse, outputBrowse; bool previewGmap; + int upgradeCheckMethod; + QDateTime upgradeCheckTime; }; diff --git a/gui/filterdata.cpp b/gui/filterdata.cpp index 9eed46f2b..dfae9ab80 100644 --- a/gui/filterdata.cpp +++ b/gui/filterdata.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: filterdata.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $ +// $Id: filterdata.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -88,7 +88,29 @@ QStringList TrackFilterData::makeOptionString() if (speed) s += ",speed"; if (pack) s += ",pack"; if (merge) s += ",merge"; - if (split && (pack || merge)) s += ",split"; + if (split && (pack || merge)) { + s += ",split"; + if (splitTime > 0) + s += QString("=%1%2").arg(splitTime).arg("mhd"[splitTimeUnit]); + } + if (splitDist > 0) { + double d = splitDist; + char u = ' '; + if (splitDistUnit == 0) { // ft. + d /= 5280.0; u = 'm'; + } + else if (splitDistUnit == 1) { //m + d /= 1000.0; u = 'k'; + } + else if (splitDistUnit == 2) { //km + u = 'k'; + } + else if (splitDistUnit == 3) { //m + u = 'm'; + } + s += QString(",sdistance=%1%2").arg(d).arg(u); + } + if (start) s += QString(",start=%1").arg(optionDate(startTime, TZ)); if (stop) s += QString(",stop=%1").arg(optionDate(stopTime, TZ)); if (move) s += QString(",move=%1d%2h%3m%4s").arg(days).arg(hours).arg(mins).arg(secs); diff --git a/gui/filterdata.h b/gui/filterdata.h index 38493e2ff..d6eb852d1 100644 --- a/gui/filterdata.h +++ b/gui/filterdata.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: filterdata.h,v 1.1 2009/07/05 21:14:56 robertl Exp $ +// $Id: filterdata.h,v 1.2 2009/07/31 18:32:32 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -61,7 +61,9 @@ class TrackFilterData: public FilterData { stop(false), pack(false), merge(false), split(false), GPSFixes(false), GPSFixesVal(0), - course(false), speed(false) + course(false), speed(false), + splitTime(0), splitTimeUnit(0), + splitDist(0), splitDistUnit(0) { titleString = "ACTIVE LOG #%Y%m%d"; stopTime = QDateTime::currentDateTime(); @@ -91,6 +93,10 @@ class TrackFilterData: public FilterData { sg.addVarSetting(new IntSetting("trks.secs", secs)); sg.addVarSetting(new BoolSetting("trks.title", title)); sg.addVarSetting(new StringSetting("trks.titleString", titleString)); + sg.addVarSetting(new IntSetting("trks.splitTime", splitTime)); + sg.addVarSetting(new IntSetting("trks.splitTimeUnit", splitTimeUnit)); + sg.addVarSetting(new IntSetting("trks.splitDist", splitDist)); + sg.addVarSetting(new IntSetting("trks.splitDistUnit", splitDistUnit)); } virtual QStringList makeOptionString(); @@ -108,6 +114,8 @@ class TrackFilterData: public FilterData { bool pack, merge, split, GPSFixes; int GPSFixesVal; bool course, speed; + int splitTime, splitTimeUnit; + int splitDist, splitDistUnit; }; //------------------------------------------------------------------------ diff --git a/gui/filterwidgets.cpp b/gui/filterwidgets.cpp index c54a5557a..3faf009b6 100644 --- a/gui/filterwidgets.cpp +++ b/gui/filterwidgets.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: filterwidgets.cpp,v 1.1 2009/07/05 21:14:56 robertl Exp $ +// $Id: filterwidgets.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -41,6 +41,7 @@ TrackWidget::TrackWidget(QWidget *parent, TrackFilterData &tfd): FilterWidget(pa addCheckEnabler(ui.GPSFixesCheck, ui.GPSFixesCombo); connect(ui.mergeCheck, SIGNAL(clicked()) , this, SLOT(mergeCheckX())); + connect(ui.splitCheck, SIGNAL(clicked()) , this, SLOT(OtherCheckX())); connect(ui.packCheck, SIGNAL(clicked()), this, SLOT(packCheckX())); connect(ui.startCheck, SIGNAL(clicked()), this, SLOT(OtherCheckX())); connect(ui.stopCheck, SIGNAL(clicked()), this, SLOT(OtherCheckX())); @@ -65,12 +66,16 @@ TrackWidget::TrackWidget(QWidget *parent, TrackFilterData &tfd): FilterWidget(pa fopts << new IntSpinFilterOption(tfd.hours, ui.hoursSpin); fopts << new IntSpinFilterOption(tfd.mins, ui.minsSpin); fopts << new IntSpinFilterOption(tfd.secs, ui.secsSpin); + fopts << new IntSpinFilterOption(tfd.splitTime, ui.splitTimeSpin, 0, 1000); + fopts << new IntSpinFilterOption(tfd.splitDist, ui.splitDistSpin, 0, 5280); fopts << new DateTimeFilterOption(tfd.startTime, ui.startEdit); fopts << new DateTimeFilterOption(tfd.stopTime, ui.stopEdit); fopts << new StringFilterOption(tfd.titleString, ui.titleText); fopts << new ComboFilterOption(tfd.GPSFixesVal, ui.GPSFixesCombo); + fopts << new ComboFilterOption(tfd.splitTimeUnit, ui.splitTimeCombo); + fopts << new ComboFilterOption(tfd.splitDistUnit, ui.splitDistCombo); setWidgetValues(); checkChecks(); } @@ -80,7 +85,13 @@ void TrackWidget::OtherCheckX() { ui.TZCheck->setEnabled(ui.stopCheck->isChecked() || ui.startCheck->isChecked()); ui.splitCheck->setEnabled(ui.mergeCheck->isChecked() || ui.packCheck->isChecked()); + bool bb = ui.packCheck->isChecked() &&ui.splitCheck->isChecked(); + ui.splitTimeSpin->setEnabled(bb); + ui.splitTimeCombo->setEnabled(bb); + //ui.splitDistSpin->setEnabled(bb); + //ui.splitDistCombo->setEnabled(bb); } + //------------------------------------------------------------------------ void TrackWidget::mergeCheckX() { diff --git a/gui/mainwindow.cpp b/gui/mainwindow.cpp index beacd8064..8913080aa 100644 --- a/gui/mainwindow.cpp +++ b/gui/mainwindow.cpp @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: mainwindow.cpp,v 1.1 2009/07/31 17:59:58 robertl Exp $ +// $Id: mainwindow.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -149,7 +149,6 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) connect(ui.actionQuit, SIGNAL(triggered()), this, SLOT(closeActionX())); connect(ui.actionHelp, SIGNAL(triggered()), this, SLOT(helpActionX())); connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(aboutActionX())); - connect(ui.actionCheckForUpgrade, SIGNAL(triggered()), this, SLOT(checkForUpgradeX())); connect(ui.inputFormatCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(inputFormatChanged(int))); @@ -188,8 +187,16 @@ MainWindow::MainWindow(QWidget* parent): QMainWindow(parent) //--- Restore from registry restoreSettings(); + upgrade = new UpgradeCheck(); + upgrade->checkForUpgrade(babelVersion, bd.upgradeCheckMethod, bd.upgradeCheckTime); } +//------------------------------------------------------------------------ +MainWindow::~MainWindow() +{ + if (upgrade) + delete upgrade; +} //------------------------------------------------------------------------ void MainWindow::loadDeviceNameCombos() { @@ -758,8 +765,8 @@ void MainWindow::applyActionX() // Ideally, expost this in the UI. For now, just split the track // if we've no recorded fixes for > 5 mins and we've moved > 300 meters. - args << "-x"; - args << "track,pack,sdistance=0.3k,split=5m"; + //args << "-x"; + //args << "track,pack,sdistance=0.3k,split=5m"; args << "-o"; args << "gpx"; @@ -792,14 +799,19 @@ void MainWindow::applyActionX() //------------------------------------------------------------------------ void MainWindow::closeActionX() { + QDateTime wt= upgrade->getUpgradeWarningTime(); + if (wt.isValid()) { + bd.upgradeCheckTime = wt; + } saveSettings(); + delete upgrade; + upgrade = 0; qApp->exit(0); } //------------------------------------------------------------------------ void MainWindow::closeEvent(QCloseEvent*) { - fprintf(stderr, "Close happened\n"); closeActionX(); } //------------------------------------------------------------------------ @@ -878,12 +890,6 @@ void MainWindow::helpActionX() { ShowHelp("gpsbabel.html"); } -void MainWindow::checkForUpgradeX() -{ - Upgrade *foo = new Upgrade(this); - foo->show(); - foo->checkForUpgrade(); -} //------------------------------------------------------------------------ void MainWindow::filtersClicked() { diff --git a/gui/mainwindow.h b/gui/mainwindow.h index 31efd6654..be1ff2a49 100644 --- a/gui/mainwindow.h +++ b/gui/mainwindow.h @@ -1,5 +1,5 @@ // -*- C++ -*- -// $Id: mainwindow.h,v 1.1 2009/07/31 17:59:58 robertl Exp $ +// $Id: mainwindow.h,v 1.2 2009/07/31 18:32:32 robertl Exp $ //------------------------------------------------------------------------ // // Copyright (C) 2009 S. Khai Mong . @@ -26,6 +26,7 @@ #include "format.h" #include "filterdata.h" #include "babeldata.h" +#include "upgrade.h" class MainWindow: public QMainWindow { Q_OBJECT @@ -33,14 +34,14 @@ class MainWindow: public QMainWindow { public: MainWindow(QWidget* parent); - QString getBabelVersion(void) {return babelVersion;} + ~MainWindow(); private: Ui_MainWindow ui; QList formatList; + QString babelVersion; QPixmap lights[4]; QStringList charSets; - QString babelVersion; AllFiltersData filterData; BabelData bd; bool fmtChgInterlock; @@ -74,6 +75,7 @@ private: void updateFilterStatus(); void setWidgetValues(); void getWidgetValues(); + UpgradeCheck *upgrade; protected: void closeEvent(QCloseEvent*); @@ -93,7 +95,6 @@ protected: void applyActionX(); void aboutActionX(); void helpActionX(); - void checkForUpgradeX(); void closeActionX(); void filtersClicked(); void resetFormatDefaults(); diff --git a/gui/mainwinui.ui b/gui/mainwinui.ui index 6204585d9..aae6063ed 100644 --- a/gui/mainwinui.ui +++ b/gui/mainwinui.ui @@ -618,7 +618,7 @@ 0 0 674 - 22 + 26 @@ -634,7 +634,6 @@ - @@ -655,11 +654,6 @@ Quit - - - Check for Upgrade - - diff --git a/gui/setup.exe b/gui/setup.exe deleted file mode 100755 index 0dbefbf2e..000000000 Binary files a/gui/setup.exe and /dev/null differ diff --git a/gui/trackui.ui b/gui/trackui.ui index d5515ea25..3c4f20e96 100644 --- a/gui/trackui.ui +++ b/gui/trackui.ui @@ -6,8 +6,8 @@ 0 0 - 533 - 251 + 558 + 218 @@ -19,7 +19,7 @@ - + @@ -51,7 +51,7 @@ If this value contains a percent (%) character, it is treated as a format string - + the title of the new track is composed of the start time of the track appended to this value. @@ -72,8 +72,8 @@ This option changes the time of all trackpoints. This might be useful if your tr - - + + @@ -84,6 +84,10 @@ This option changes the time of all trackpoints. This might be useful if your tr + + + + @@ -94,6 +98,10 @@ This option changes the time of all trackpoints. This might be useful if your tr + + + + @@ -104,6 +112,10 @@ This option changes the time of all trackpoints. This might be useful if your tr + + + + @@ -235,6 +247,77 @@ If the input has multiple tracks, pack them together before splitting them back + + + + + + If nonzero, the track will be split if the time between two points is greater than this parameter. If zero, the track will be split by date. + + + 500 + + + + + + + + mins + + + + + hrs + + + + + days + + + + + + + + + + + + If nonzero, the input track will be split into several tracks if the distance between successive track points is greater than the distance given as a parameter. + + + 5280 + + + + + + + + ft + + + + + m + + + + + km + + + + + mi + + + + + + @@ -337,7 +420,7 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo - 83 + 1 20 @@ -350,8 +433,8 @@ This option computes (or recomputes) a value for the GPS heading at each trackpo - 20 - 25 + 10 + 2 diff --git a/gui/upgrade.cpp b/gui/upgrade.cpp index 4ba06e630..799cfe03d 100644 --- a/gui/upgrade.cpp +++ b/gui/upgrade.cpp @@ -1,3 +1,5 @@ +// -*- C++ -*- +// $Id: upgrade.cpp,v 1.2 2009/07/31 18:32:32 robertl Exp $ /* Copyright (C) 2009 Robert Lipe, robertlipe@gpsbabel.org @@ -19,58 +21,66 @@ #include "upgrade.h" -#include "mainwindow.h" -#include "ui_upgrade.h" #include -#include #include -#include #include -#include -#include -#include -Upgrade::Upgrade(QWidget *parent) : - QDialog(parent), - m_ui(new Ui::Upgrade) +//static const bool testing = true; +static const bool testing = false; + +static int versionAsNumber(const QString &s) { - m_ui->setupUi(this); + QStringList list = s.split("."); + return (list[0].toInt()<<16 | list[1].toInt() << 8 | list[2].toInt() ); } -Upgrade::~Upgrade() +UpgradeCheck::UpgradeCheck(QWidget *parent) : + QObject(parent), + http(0) { - delete m_ui; } -void Upgrade::changeEvent(QEvent *e) +UpgradeCheck::~UpgradeCheck() { - QDialog::changeEvent(e); - switch (e->type()) { - case QEvent::LanguageChange: - m_ui->retranslateUi(this); - break; - default: - break; - } + if (http) { + http->clearPendingRequests(); + http->abort(); + delete http; + http = 0; + } } -Upgrade::updateStatus Upgrade::checkForUpgrade() +void UpgradeCheck::changeEvent(QEvent *) { - http = new QHttp; +} + +UpgradeCheck::updateStatus UpgradeCheck::checkForUpgrade(const QString ¤tVersion, + int checkMethod, + const QDateTime &lastCheckTime) +{ + this->currentVersion = currentVersion; + this->upgradeCheckMethod = checkMethod; + QDateTime soonestCheckTime = lastCheckTime.addDays(1); + if (!testing && QDateTime::currentDateTime() < soonestCheckTime) { + // Not time to check yet. + return UpgradeCheck::updateUnknown; + } + http = new QHttp; + connect(http, SIGNAL(requestFinished(int, bool)), this, SLOT(httpRequestFinished(int, bool))); connect(http, SIGNAL(responseHeaderReceived(const QHttpResponseHeader &)), this, SLOT(readResponseHeader(const QHttpResponseHeader &))); - + http->setHost("www.gpsbabel.org"); httpRequestId = http->get("/updates.xml"); - - return Upgrade::updateUnknown; + + return UpgradeCheck::updateUnknown; } -void Upgrade::readResponseHeader(const QHttpResponseHeader &responseHeader) +void UpgradeCheck::readResponseHeader(const QHttpResponseHeader &responseHeader) { switch (responseHeader.statusCode()) { case 200: // Ok @@ -78,57 +88,67 @@ void Upgrade::readResponseHeader(const QHttpResponseHeader &responseHeader) case 302: // Found case 303: // See Other case 307: // Temporary Redirect - // these are not error conditions - break; - + // these are not error conditions + break; + default: - QMessageBox::information(this, tr("HTTP"), - tr("Download failed: %1.") - .arg(responseHeader.reasonPhrase())); - httpRequestAborted = true; - http->abort(); - } + QMessageBox::information(0, tr("HTTP"), + tr("Download failed: %1.") + .arg(responseHeader.reasonPhrase())); + httpRequestAborted = true; + http->abort(); + } } -void Upgrade::httpRequestFinished(int requestId, bool error) +void UpgradeCheck::httpRequestFinished(int requestId, bool error) { - if(error or requestId != httpRequestId) { + if (http == 0 || error) + return; + + if (requestId != httpRequestId) return; - } QString oresponse(http->readAll()); + QDomDocument document; - if (!document.setContent(oresponse)) { + if (!document.setContent(oresponse)) return; - } - QString response("snore"); + QString response; + + if (testing) + currentVersion = "1.3.1"; // for testing - QString currentVersion = "1.3.6"; // FIXME: Work with Khai to pry this out of MainWindow bool allowBeta = false; // TODO: come from prefs or current version... + int currentVersionNum = versionAsNumber(currentVersion); + QDomNodeList upgrades = document.elementsByTagName("update"); - + for (unsigned int i = 0; i < upgrades.length(); i++) { QDomNode upgradeNode = upgrades.item(i); QDomElement upgrade = upgradeNode.toElement(); - + QString updateVersion = upgrade.attribute("version"); bool updateIsBeta = upgrade.attribute("type") == "beta"; bool updateIsMajor = upgrade.attribute("type") == "major"; bool updateCandidate = updateIsMajor || (updateIsBeta && allowBeta); + int updateVersionNum = versionAsNumber(updateVersion); + + if(updateVersionNum > currentVersionNum && updateCandidate) { + response = tr("
A new version of GPSBabel is available
" + "Your version is %1
" + "The latest version is %2
") + .arg(currentVersion) + .arg(updateVersion); - if(updateVersion > currentVersion && updateCandidate) { - response = "A new version of GPSBabel is available
"; - response += "Your version is " + currentVersion + "
";; - response += "The latest version is " + updateVersion + "
";; break; } } - - // FIXME: this doesn't actually write into the UI's text browser... - m_ui->textBrowser->setText(response); - - //QMessageBox::information(this, tr("Finished"), response); - + if (response.length()) { + QMessageBox::information(0, tr("Upgrade"), response); + upgradeWarningTime = QDateTime(QDateTime::currentDateTime()); + } + delete http; + http = 0; } diff --git a/gui/upgrade.h b/gui/upgrade.h index 7754c7e54..6b7681b1e 100644 --- a/gui/upgrade.h +++ b/gui/upgrade.h @@ -21,20 +21,17 @@ #include -#include "ui_upgrade.h" +#include +#include class QHttp; class QHttpResponseHeader; -namespace Ui { - class Upgrade; -} - -class Upgrade : public QDialog { +class UpgradeCheck : public QObject { Q_OBJECT public: - Upgrade(QWidget *parent = 0); - ~Upgrade(); + UpgradeCheck(QWidget *parent = 0); + ~UpgradeCheck(); typedef enum { updateUnknown, @@ -42,21 +39,28 @@ public: updateNeeded, } updateStatus; - Upgrade::updateStatus checkForUpgrade(void); + UpgradeCheck::updateStatus checkForUpgrade(const QString &babelVersion, + int upgradeCheckMethod, + const QDateTime &lastCheckTime); + QDateTime getUpgradeWarningTime() { + return upgradeWarningTime; + } protected: void changeEvent(QEvent *e); -private: -// Ui::Upgrade *m_ui; - Ui_Upgrade *m_ui; + private: + QString currentVersion; + int upgradeCheckMethod; QHttp *http; int httpRequestId; bool httpRequestAborted; QString latestVersion; + QDateTime upgradeWarningTime; // invalid time if this object never issued. private slots: void httpRequestFinished(int requestId, bool error); + // void httpStateChanged(int state); void readResponseHeader(const QHttpResponseHeader &responseHeader);