mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive d/l selection UI: Add method to remove unused dives
This tries to relete from the dive list the dives that shouldn't be imported. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
25323c2717
commit
f5f0938d8c
2 changed files with 19 additions and 0 deletions
|
@ -405,6 +405,9 @@ void DownloadFromDCWidget::onDownloadThreadFinished()
|
||||||
|
|
||||||
void DownloadFromDCWidget::on_ok_clicked()
|
void DownloadFromDCWidget::on_ok_clicked()
|
||||||
{
|
{
|
||||||
|
// remove all unselected dives from the dive-list.
|
||||||
|
diveImportedModel->removeUnused();
|
||||||
|
|
||||||
int uniqId, idx;
|
int uniqId, idx;
|
||||||
// remember the last downloaded dive (on most dive computers this will be the chronologically
|
// remember the last downloaded dive (on most dive computers this will be the chronologically
|
||||||
// first new dive) and select it again after processing all the dives
|
// first new dive) and select it again after processing all the dives
|
||||||
|
@ -573,3 +576,18 @@ void DiveImportedModel::setImportedDivesIndexes(int first, int last)
|
||||||
memset(checkStates, true, last-first);
|
memset(checkStates, true, last-first);
|
||||||
endInsertRows();
|
endInsertRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DiveImportedModel::removeUnused() {
|
||||||
|
beginRemoveRows(QModelIndex(), 0, rowCount()-1);
|
||||||
|
endRemoveRows();
|
||||||
|
|
||||||
|
for(int i = lastIndex; i >= firstIndex; i-- ){
|
||||||
|
if(!checkStates[firstIndex - i]) {
|
||||||
|
delete_single_dive(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lastIndex = 0;
|
||||||
|
firstIndex = 0;
|
||||||
|
delete[] checkStates;
|
||||||
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ public:
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
||||||
void setImportedDivesIndexes(int first, int last);
|
void setImportedDivesIndexes(int first, int last);
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
|
void removeUnused();
|
||||||
private:
|
private:
|
||||||
int firstIndex;
|
int firstIndex;
|
||||||
int lastIndex;
|
int lastIndex;
|
||||||
|
|
Loading…
Add table
Reference in a new issue