[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [lmi] Can't delete repeatedly from list end in CensusView [Was: swit
From: |
Vaclav Slavik |
Subject: |
Re: [lmi] Can't delete repeatedly from list end in CensusView [Was: switch census view to use wxDataViewCtrl] |
Date: |
Tue, 09 Aug 2011 16:46:11 +0200 |
User-agent: |
Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 |
Hi,
On 2011-08-08 16:21, Greg Chicares wrote:
> Here's another multiple-deletion problem:
> File | New | Census
> Census | Add cell [repeat this a total of six times]
> Ctrl-left_click the first two and the last two cells
> ie, numbers {1, 2, 6, 7}
> Census | Delete cell(s) | Yes
> Now I expect three cells, numbered {1, 2, 3};
> but I observe four cells, numbered {1, 2, 3, 0}.
Please apply the patch below.
Thanks,
Vaclav
---
Fix model notifications in CensusView::UponDeleteCells().
Rows removal notifications were sent incorrectly: they were sent in
ascending order, so the row indices were off after the first
notification. Use RowsDeleted() instead to handle this correctly.
Additionally, Cell number in the 0th column needs to be updated too for
all items after the first deleted one.
---
census_view.cpp | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/census_view.cpp b/census_view.cpp
index 7ee9be8..d5b300d 100644
--- a/census_view.cpp
+++ b/census_view.cpp
@@ -1549,7 +1549,7 @@ void CensusView::UponDeleteCells(wxCommandEvent&)
return;
}
- std::vector<int> erasures;
+ wxArrayInt erasures;
typedef wxDataViewItemArray::const_iterator dvci;
for(dvci i = selection.begin(); i != selection.end(); ++i)
{
@@ -1566,11 +1566,7 @@ void CensusView::UponDeleteCells(wxCommandEvent&)
for(unsigned int j = 0; j < cell_parms().size(); ++j)
{
- if(contains(erasures, j))
- {
- list_model_->RowDeleted(j);
- }
- else
+ if(!contains(erasures, j))
{
expurgated_cell_parms.push_back(cell_parms()[j]);
}
@@ -1580,6 +1576,13 @@ void CensusView::UponDeleteCells(wxCommandEvent&)
// cell_parms().swap(expurgated_cell_parms); // TODO ?? Would this be
better?
cell_parms() = expurgated_cell_parms;
+ // Send notifications about changes to the wxDataViewCtrl model. Two things
+ // changed: some rows were deleted and cell number of some rows shifted
+ // accordingly.
+ list_model_->RowsDeleted(erasures);
+ for(unsigned int j = erasures.front(); j < cell_parms().size(); ++j)
+ list_model_->RowValueChanged(j, CensusViewDataViewModel::Col_CellNum);
+
Update();
document().Modify(true);
}
--
1.7.6
- Re: [lmi] switch census view to use wxDataViewCtrl, (continued)
- Re: [lmi] switch census view to use wxDataViewCtrl, Václav Slavík, 2011/08/02
- Re: [lmi] switch census view to use wxDataViewCtrl, Václav Slavík, 2011/08/02
- Re: [lmi] switch census view to use wxDataViewCtrl, Greg Chicares, 2011/08/03
- Re: [lmi] switch census view to use wxDataViewCtrl, Greg Chicares, 2011/08/03
- [lmi] Can't delete repeatedly from list end in CensusView [Was: switch census view to use wxDataViewCtrl], Greg Chicares, 2011/08/03
- Re: [lmi] Can't delete repeatedly from list end in CensusView [Was: switch census view to use wxDataViewCtrl], Greg Chicares, 2011/08/07
- Re: [lmi] Can't delete repeatedly from list end in CensusView [Was: switch census view to use wxDataViewCtrl], Greg Chicares, 2011/08/08
- Re: [lmi] Can't delete repeatedly from list end in CensusView [Was: switch census view to use wxDataViewCtrl],
Vaclav Slavik <=
- Re: [lmi] Can't delete repeatedly from list end in CensusView [Was: switch census view to use wxDataViewCtrl], Greg Chicares, 2011/08/11
- Re: [lmi] Can't delete repeatedly from list end in CensusView [Was: switch census view to use wxDataViewCtrl], Wendy Boutin, 2011/08/17
- Re: [lmi] Can't delete repeatedly from list end in CensusView [Was: switch census view to use wxDataViewCtrl], Václav Slavík, 2011/08/08
- Re: [lmi] Can't delete repeatedly from list end in CensusView [Was: switch census view to use wxDataViewCtrl], Greg Chicares, 2011/08/08