mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Desktop/remember DCs: remember dive computers that were used
The algorithm tries to keep the order of the buttons the same. So if a dive computer was used that's already remembered, don't reorder the buttons. But if a new dive computer is used, add it as the first one and move the others back, potentially dropping the oldest one. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
e2ee8c57df
commit
99261775ce
2 changed files with 45 additions and 0 deletions
|
@ -331,6 +331,8 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
|
||||||
qPrefDiveComputer::set_product(data->product());
|
qPrefDiveComputer::set_product(data->product());
|
||||||
qPrefDiveComputer::set_device(data->devName());
|
qPrefDiveComputer::set_device(data->devName());
|
||||||
|
|
||||||
|
updateRememberedDCs();
|
||||||
|
|
||||||
#if defined(BT_SUPPORT)
|
#if defined(BT_SUPPORT)
|
||||||
qPrefDiveComputer::set_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL);
|
qPrefDiveComputer::set_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL);
|
||||||
#endif
|
#endif
|
||||||
|
@ -353,6 +355,48 @@ void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DownloadFromDCWidget::updateRememberedDCs()
|
||||||
|
{
|
||||||
|
QString current = qPrefDiveComputer::vendor() + " - " + qPrefDiveComputer::product();
|
||||||
|
QStringList dcs = {
|
||||||
|
qPrefDiveComputer::vendor1() + " - " + qPrefDiveComputer::product1(),
|
||||||
|
qPrefDiveComputer::vendor2() + " - " + qPrefDiveComputer::product2(),
|
||||||
|
qPrefDiveComputer::vendor3() + " - " + qPrefDiveComputer::product3(),
|
||||||
|
qPrefDiveComputer::vendor4() + " - " + qPrefDiveComputer::product4()
|
||||||
|
};
|
||||||
|
if (dcs.contains(current))
|
||||||
|
// already in the list
|
||||||
|
return;
|
||||||
|
// add the current one as the first remembered one and drop the 4th one
|
||||||
|
// don't get confused by 0-based and 1-based indices!
|
||||||
|
if (dcs[2] != " - ") {
|
||||||
|
qPrefDiveComputer::set_vendor4(qPrefDiveComputer::vendor3());
|
||||||
|
qPrefDiveComputer::set_product4(qPrefDiveComputer::product3());
|
||||||
|
qPrefDiveComputer::set_device4(qPrefDiveComputer::device3());
|
||||||
|
ui.DC4->setText(dcs[2]);
|
||||||
|
ui.DC4->setVisible(true);
|
||||||
|
}
|
||||||
|
if (dcs[1] != " - ") {
|
||||||
|
qPrefDiveComputer::set_vendor3(qPrefDiveComputer::vendor2());
|
||||||
|
qPrefDiveComputer::set_product3(qPrefDiveComputer::product2());
|
||||||
|
qPrefDiveComputer::set_device3(qPrefDiveComputer::device2());
|
||||||
|
ui.DC3->setText(dcs[1]);
|
||||||
|
ui.DC3->setVisible(true);
|
||||||
|
}
|
||||||
|
if (dcs[0] != " - ") {
|
||||||
|
qPrefDiveComputer::set_vendor2(qPrefDiveComputer::vendor1());
|
||||||
|
qPrefDiveComputer::set_product2(qPrefDiveComputer::product1());
|
||||||
|
qPrefDiveComputer::set_device2(qPrefDiveComputer::device1());
|
||||||
|
ui.DC2->setText(dcs[0]);
|
||||||
|
ui.DC2->setVisible(true);
|
||||||
|
}
|
||||||
|
qPrefDiveComputer::set_vendor1(qPrefDiveComputer::vendor());
|
||||||
|
qPrefDiveComputer::set_product1(qPrefDiveComputer::product());
|
||||||
|
qPrefDiveComputer::set_device1(qPrefDiveComputer::device());
|
||||||
|
ui.DC1->setText(current);
|
||||||
|
ui.DC1->setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
bool DownloadFromDCWidget::preferDownloaded()
|
bool DownloadFromDCWidget::preferDownloaded()
|
||||||
{
|
{
|
||||||
return ui.preferDownloaded->isChecked();
|
return ui.preferDownloaded->isChecked();
|
||||||
|
|
|
@ -59,6 +59,7 @@ private:
|
||||||
void markChildrenAsDisabled();
|
void markChildrenAsDisabled();
|
||||||
void markChildrenAsEnabled();
|
void markChildrenAsEnabled();
|
||||||
void updateDeviceEnabled();
|
void updateDeviceEnabled();
|
||||||
|
void updateRememberedDCs();
|
||||||
|
|
||||||
QStringListModel vendorModel;
|
QStringListModel vendorModel;
|
||||||
QStringListModel productModel;
|
QStringListModel productModel;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue