mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 03:21:04 +00:00
Restore the selected cells in reload column
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@9046 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
695d12c014
commit
15ee05af34
1 changed files with 41 additions and 0 deletions
|
@ -1024,6 +1024,10 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
- (void)reloadColumn: (int)column
|
||||
{
|
||||
id bc;
|
||||
NSArray *selectedCells;
|
||||
NSMatrix *matrix;
|
||||
int i, count, max;
|
||||
int *selectedIndexes = NULL;
|
||||
|
||||
#if defined NSBTRACE_reloadColumn || defined NSBTRACE_all
|
||||
fprintf(stderr, "NSBrowser - (void)reloadColumn: %d\n", column);
|
||||
|
@ -1049,10 +1053,47 @@ static float scrollerWidth; // == [NSScroller scrollerWidth]
|
|||
return;
|
||||
}
|
||||
|
||||
// Save the index of the previously selected cells
|
||||
matrix = [self matrixInColumn: column];
|
||||
selectedCells = [matrix selectedCells];
|
||||
count = [selectedCells count];
|
||||
if (count > 0)
|
||||
{
|
||||
selectedIndexes = NSZoneMalloc (NSDefaultMallocZone (),
|
||||
sizeof (int) * count);
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
NSCell *cell = [selectedCells objectAtIndex: i];
|
||||
int sRow, sColumn;
|
||||
|
||||
[matrix getRow: &sRow column: &sColumn ofCell: cell];
|
||||
selectedIndexes[i] = sRow;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Perform the data load
|
||||
[self _performLoadOfColumn: column];
|
||||
[self _adjustMatrixOfColumn: column];
|
||||
|
||||
// Restore the selected cells
|
||||
if (count > 0)
|
||||
{
|
||||
matrix = [self matrixInColumn: column];
|
||||
max = [matrix numberOfRows];
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
// Abort when it stops making sense
|
||||
if (selectedIndexes[i] > max)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
[matrix selectCellAtRow: selectedIndexes[i] column: 0];
|
||||
}
|
||||
NSZoneFree (NSDefaultMallocZone (), selectedIndexes);
|
||||
}
|
||||
|
||||
// set last column loaded
|
||||
[self setLastColumn: column];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue