aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>2013-09-16 18:04:42 -0300
committerGravatar Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>2013-09-16 22:40:47 -0300
commita8d33f80b0e8da4acb84028be0da8f33b81de0f9 (patch)
treed3813d817fd8407e79f58d68cffb393d8741db3d /qt-ui
parentf5b33dede359dccc31fafa72e0e2550868d8edd2 (diff)
downloadsubsurface-a8d33f80b0e8da4acb84028be0da8f33b81de0f9.tar.gz
implement device probe in C
It's an attempt to build auto-completion for the dive-computers based on unpublished code inside libdivecomputer[1] [1] - http://git.libdivecomputer.org/?p=libdivecomputer.git;a=commitdiff;h=d44053a99435fb9fc1f408fb3f1629a54c938afc Signed-off-by: Danilo Cesar Lemes de Paula <danilo.eu@gmail.com>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/downloadfromdivecomputer.cpp22
-rw-r--r--qt-ui/downloadfromdivecomputer.h1
-rw-r--r--qt-ui/downloadfromdivecomputer.ui6
3 files changed, 26 insertions, 3 deletions
diff --git a/qt-ui/downloadfromdivecomputer.cpp b/qt-ui/downloadfromdivecomputer.cpp
index acdca89d3..52ef77d48 100644
--- a/qt-ui/downloadfromdivecomputer.cpp
+++ b/qt-ui/downloadfromdivecomputer.cpp
@@ -51,6 +51,8 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) :
ui->progressBar->hide();
ui->progressBar->setMinimum(0);
ui->progressBar->setMaximum(100);
+
+ fill_device_list();
fill_computer_list();
vendorModel = new QStringListModel(vendorList);
@@ -63,7 +65,7 @@ DownloadFromDCWidget::DownloadFromDCWidget(QWidget* parent, Qt::WindowFlags f) :
ui->product->setCurrentIndex(ui->product->findText(default_dive_computer_product));
}
if (default_dive_computer_device)
- ui->device->setText(default_dive_computer_device);
+ ui->device->setEditText(default_dive_computer_device);
timer->setInterval(200);
connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressBar()));
@@ -89,6 +91,7 @@ void DownloadFromDCWidget::updateState(states state)
return;
if (state == INITIAL) {
+ fill_device_list();
ui->progressBar->hide();
markChildrenAsEnabled();
timer->stop();
@@ -217,7 +220,7 @@ void DownloadFromDCWidget::on_ok_clicked()
thread->deleteLater();
}
- data.devname = strdup(ui->device->text().toUtf8().data());
+ data.devname = strdup(ui->device->currentText().toUtf8().data());
data.vendor = strdup(ui->vendor->currentText().toUtf8().data());
data.product = strdup(ui->product->currentText().toUtf8().data());
@@ -285,6 +288,21 @@ void DownloadFromDCWidget::markChildrenAsEnabled()
ui->search->setDisabled(false);
}
+static void fillDeviceList(const char *name, void *data)
+{
+ QComboBox *comboBox = (QComboBox *)data;
+ comboBox->addItem(name);
+}
+
+void DownloadFromDCWidget::fill_device_list()
+{
+ int deviceIndex;
+ ui->device->clear();
+ deviceIndex = enumerate_devices(fillDeviceList, ui->device);
+ if (deviceIndex >= 0)
+ ui->device->setCurrentIndex(deviceIndex);
+}
+
DownloadThread::DownloadThread(QObject* parent, device_data_t* data): QThread(parent),
data(data)
{
diff --git a/qt-ui/downloadfromdivecomputer.h b/qt-ui/downloadfromdivecomputer.h
index e10d61b38..bef3d541d 100644
--- a/qt-ui/downloadfromdivecomputer.h
+++ b/qt-ui/downloadfromdivecomputer.h
@@ -65,6 +65,7 @@ private:
QStringListModel *vendorModel;
QStringListModel *productModel;
void fill_computer_list();
+ void fill_device_list();
QTimer *timer;
diff --git a/qt-ui/downloadfromdivecomputer.ui b/qt-ui/downloadfromdivecomputer.ui
index 41f9a4751..72e9c5ea1 100644
--- a/qt-ui/downloadfromdivecomputer.ui
+++ b/qt-ui/downloadfromdivecomputer.ui
@@ -42,7 +42,11 @@
</widget>
</item>
<item row="3" column="0" colspan="2">
- <widget class="QLineEdit" name="device"/>
+ <widget class="QComboBox" name="device">
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
<item row="3" column="2">
<widget class="QToolButton" name="search">