aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--libdivecomputer.h3
-rw-r--r--qt-gui.cpp4
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp5
-rw-r--r--qt-ui/mainwindow.cpp61
-rw-r--r--qt-ui/mainwindow.h3
-rw-r--r--qt-ui/mainwindow.ui14
-rw-r--r--uemis-downloader.c19
8 files changed, 90 insertions, 21 deletions
diff --git a/Makefile b/Makefile
index 664cd973e..b53b772e8 100644
--- a/Makefile
+++ b/Makefile
@@ -70,6 +70,8 @@ SOURCES = \
sha1.c \
statistics.c \
time.c \
+ uemis.c \
+ uemis-downloader.c \
libdivecomputer.c \
qt-gui.cpp \
qthelper.cpp \
diff --git a/libdivecomputer.h b/libdivecomputer.h
index 3cc8bd4b3..4bb0239e9 100644
--- a/libdivecomputer.h
+++ b/libdivecomputer.h
@@ -28,6 +28,7 @@ typedef struct device_data_t {
} device_data_t;
const char *do_libdivecomputer_import(device_data_t *data);
+char *do_uemis_import(const char *mountpath, short force_download);
extern int import_thread_cancelled;
extern const char *progress_bar_text;
@@ -37,4 +38,4 @@ extern double progress_bar_fraction;
}
#endif
-#endif \ No newline at end of file
+#endif
diff --git a/qt-gui.cpp b/qt-gui.cpp
index 2474d407d..eab282dc0 100644
--- a/qt-gui.cpp
+++ b/qt-gui.cpp
@@ -75,6 +75,10 @@ void init_qt_ui(int *argcp, char ***argvp, char *errormessage)
MainWindow *window = new MainWindow();
window->showError(errormessage);
window->show();
+ if (existing_filename && existing_filename[0] != '\0')
+ window->setTitle(MWTF_FILENAME);
+ else
+ window->setTitle(MWTF_DEFAULT);
}
const char *getSetting(QSettings &s, QString name)
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index 37ca2775b..f3cd45c71 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -183,7 +183,10 @@ DownloadThread::DownloadThread(device_data_t* data): data(data)
void DownloadThread::run()
{
DownloadFromDCWidget *dfdcw = DownloadFromDCWidget::instance();
- do_libdivecomputer_import(data);
+ if (!strcmp(data->vendor, "Uemis"))
+ do_uemis_import(data->devname, data->force_download);
+ else
+ do_libdivecomputer_import(data);
process_dives(TRUE, dfdcw->preferDownloaded());
dfdcw->stoppedDownloading();
}
diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp
index fc454ab2f..0655e7a40 100644
--- a/qt-ui/mainwindow.cpp
+++ b/qt-ui/mainwindow.cpp
@@ -86,7 +86,7 @@ void MainWindow::redrawProfile()
void MainWindow::on_actionNew_triggered()
{
- qDebug("actionNew");
+ on_actionClose_triggered();
}
void MainWindow::on_actionOpen_triggered()
@@ -120,6 +120,7 @@ void MainWindow::on_actionOpen_triggered()
char *error = NULL;
parse_file(fileNamePtr.data(), &error);
set_filename(fileNamePtr.data(), TRUE);
+ setTitle(MWTF_FILENAME);
if (error != NULL) {
showError(error);
@@ -164,13 +165,49 @@ void MainWindow::on_actionClose_triggered()
ui->ProfileWidget->clear();
ui->ListWidget->reload(DiveTripModel::TREE);
ui->globe->reload();
+ setTitle(MWTF_DEFAULT);
clear_events();
}
void MainWindow::on_actionImport_triggered()
{
- qDebug("actionImport");
+ QSettings settings;
+ QString lastDir = QDir::homePath();
+
+ settings.beginGroup("FileDialog");
+ if (settings.contains("LastDir"))
+ if (QDir::setCurrent(settings.value("LastDir").toString()))
+ lastDir = settings.value("LastDir").toString();
+ settings.endGroup();
+
+ QStringList fileNames = QFileDialog::getOpenFileNames(this, tr("Import Files"), lastDir, filter());
+ if (!fileNames.size())
+ return; // no selection
+
+ // Keep last open dir
+ QFileInfo fileInfo(fileNames.at(0));
+ settings.beginGroup("FileDialog");
+ settings.setValue("LastDir", fileInfo.dir().path());
+ settings.endGroup();
+
+ QByteArray fileNamePtr;
+ char *error = NULL;
+ for (int i = 0; i < fileNames.size(); ++i) {
+ fileNamePtr = fileNames.at(i).toLocal8Bit();
+ parse_file(fileNamePtr.data(), &error);
+ if (error != NULL) {
+ showError(error);
+ free(error);
+ error = NULL;
+ }
+ }
+ process_dives(FALSE, FALSE);
+
+ ui->InfoWidget->reload();
+ ui->globe->reload();
+ ui->ListWidget->reload(DiveTripModel::TREE);
+ ui->ListWidget->setFocus();
}
void MainWindow::on_actionExportUDDF_triggered()
@@ -295,8 +332,8 @@ void MainWindow::on_actionViewInfo_triggered()
void MainWindow::on_actionViewGlobe_triggered()
{
- ui->infoProfileSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
- ui->mainSplitter->setSizes( BEHAVIOR << COLLAPSED << EXPANDED);
+ ui->mainSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
+ ui->listGlobeSplitter->setSizes(BEHAVIOR << COLLAPSED << EXPANDED);
}
#undef BEHAVIOR
@@ -638,6 +675,7 @@ void MainWindow::file_save_as(void)
if (!filename.isNull() && !filename.isEmpty()) {
save_dives(filename.toUtf8().data());
set_filename(filename.toUtf8().data(), TRUE);
+ setTitle(MWTF_FILENAME);
mark_divelist_changed(FALSE);
}
}
@@ -670,3 +708,18 @@ void MainWindow::showError(QString message)
ui->mainErrorMessage->setMessageType(KMessageWidget::Error);
ui->mainErrorMessage->animatedShow();
}
+
+void MainWindow::setTitle(enum MainWindowTitleFormat format)
+{
+ switch (format) {
+ case MWTF_DEFAULT:
+ setWindowTitle("Subsurface");
+ break;
+ case MWTF_FILENAME:
+ QFile f(existing_filename);
+ QFileInfo fileInfo(f);
+ QString fileName(fileInfo.fileName());
+ setWindowTitle("Subsurface: " + fileName);
+ break;
+ }
+}
diff --git a/qt-ui/mainwindow.h b/qt-ui/mainwindow.h
index 85825958d..bac74689d 100644
--- a/qt-ui/mainwindow.h
+++ b/qt-ui/mainwindow.h
@@ -31,6 +31,8 @@ class MainTab;
class ProfileGraphicsView;
class QTextBrowser;
+enum MainWindowTitleFormat { MWTF_DEFAULT, MWTF_FILENAME };
+
class MainWindow : public QMainWindow
{
Q_OBJECT
@@ -43,6 +45,7 @@ public:
DiveListView *dive_list();
GlobeGPS *globe();
void showError(QString message);
+ void setTitle(enum MainWindowTitleFormat format);
private slots:
diff --git a/qt-ui/mainwindow.ui b/qt-ui/mainwindow.ui
index 1dfb8a27b..b1274b8ea 100644
--- a/qt-ui/mainwindow.ui
+++ b/qt-ui/mainwindow.ui
@@ -103,7 +103,7 @@
<x>0</x>
<y>0</y>
<width>763</width>
- <height>20</height>
+ <height>18</height>
</rect>
</property>
<widget class="QMenu" name="menuFile">
@@ -144,11 +144,11 @@
<property name="title">
<string>View</string>
</property>
+ <addaction name="actionViewAll"/>
<addaction name="actionViewList"/>
<addaction name="actionViewProfile"/>
<addaction name="actionViewInfo"/>
<addaction name="actionViewGlobe"/>
- <addaction name="actionViewAll"/>
<addaction name="separator"/>
<addaction name="actionPreviousDC"/>
<addaction name="actionNextDC"/>
@@ -296,7 +296,7 @@
<string>View List</string>
</property>
<property name="shortcut">
- <string>Ctrl+1</string>
+ <string>Ctrl+2</string>
</property>
</action>
<action name="actionViewProfile">
@@ -304,7 +304,7 @@
<string>View Profile</string>
</property>
<property name="shortcut">
- <string>Ctrl+2</string>
+ <string>Ctrl+3</string>
</property>
</action>
<action name="actionViewInfo">
@@ -312,7 +312,7 @@
<string>View Info</string>
</property>
<property name="shortcut">
- <string>Ctrl+3</string>
+ <string>Ctrl+4</string>
</property>
</action>
<action name="actionViewAll">
@@ -320,7 +320,7 @@
<string>View All</string>
</property>
<property name="shortcut">
- <string>Ctrl+5</string>
+ <string>Ctrl+1</string>
</property>
</action>
<action name="actionPreviousDC">
@@ -367,7 +367,7 @@
<string>View Globe</string>
</property>
<property name="shortcut">
- <string>Ctrl+4</string>
+ <string>Ctrl+5</string>
</property>
</action>
<action name="actionDivePlanner">
diff --git a/uemis-downloader.c b/uemis-downloader.c
index 53d4f6876..ace806f68 100644
--- a/uemis-downloader.c
+++ b/uemis-downloader.c
@@ -19,12 +19,14 @@
#include <string.h>
#include <glib/gi18n.h>
+#include "libdivecomputer.h"
#include "uemis.h"
#include "dive.h"
#include "divelist.h"
#include "display.h"
+#if USE_GTK_UI
#include "display-gtk.h"
-
+#endif
#define ERR_FS_ALMOST_FULL N_("Uemis Zurich: File System is almost full\nDisconnect/reconnect the dive computer\nand click \'Retry\'")
#define ERR_FS_FULL N_("Uemis Zurich: File System is full\nDisconnect/reconnect the dive computer\nand try again")
#define ERR_FS_SHORT_WRITE N_("Short write to req.txt file\nIs the Uemis Zurich plugged in correctly?")
@@ -49,14 +51,17 @@ static int number_of_files;
static char *mbuf = NULL;
static int mbuf_size = 0;
+#if USE_GTK_UI
struct argument_block {
const char *mountpath;
progressbar_t *progress;
gboolean force_download;
};
+#endif
static int nr_divespots = 0;
+#if USE_GTK_UI
static int import_thread_done = 0, import_thread_cancelled;
static const char *progress_bar_text = "";
static double progress_bar_fraction = 0.0;
@@ -73,6 +78,7 @@ static GError *error(const char *fmt, ...)
va_end(args);
return error;
}
+#endif
/* helper function to parse the Uemis data structures */
static void uemis_ts(char *buffer, void *_when)
@@ -752,9 +758,8 @@ static char *uemis_get_divenr(char *deviceidstr)
return strdup(divenr);
}
-static char *do_uemis_download(struct argument_block *args)
+char *do_uemis_import(const char *mountpath, short force_download)
{
- const char *mountpath = args->mountpath;
char *newmax = NULL;
int start, end, i, offset;
uint32_t deviceidnr;
@@ -788,7 +793,7 @@ static char *do_uemis_download(struct argument_block *args)
param_buff[1] = "notempty";
/* if we have an empty divelist or force it, then we start downloading from the
* first dive on the Uemis; otherwise check which was the last dive downloaded */
- if (!args->force_download && dive_table.nr > 0)
+ if (force_download && dive_table.nr > 0)
newmax = uemis_get_divenr(deviceid);
else
newmax = strdup("0");
@@ -881,6 +886,7 @@ bail:
return result;
}
+#if USE_GTK_UI
static void *pthread_wrapper(void *_data)
{
struct argument_block *args = _data;
@@ -922,18 +928,14 @@ GError *uemis_download(const char *mountpath, progressbar_t *progress,
if (!import_thread_cancelled) {
int result;
g_timeout_add(100, timeout_func, dialog);
-#if USE_GTK_UI
update_progressbar(args.progress, progress_bar_fraction);
update_progressbar_text(args.progress, progress_bar_text);
-#endif
result = gtk_dialog_run(dialog);
if (result == GTK_RESPONSE_CANCEL)
import_thread_cancelled = TRUE;
} else {
-#if USE_GTK_UI
update_progressbar(args.progress, progress_bar_fraction);
update_progressbar_text(args.progress, _("Cancelled, exiting cleanly..."));
-#endif
usleep(100000);
}
}
@@ -943,3 +945,4 @@ GError *uemis_download(const char *mountpath, progressbar_t *progress,
return error(retval);
return NULL;
}
+#endif