mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 13:50:37 +00:00
* Source/NSTableView.m (-_numRows): New quasi private method.
(-noteNumberOfRowsChanged:): Call _numRows instead of data source method. * Source/NSOutlineView.m (-noteNumberOfRowsChanged:): Don't override supers. (-_numRows): Implement. (-collapseItem:collapseChildren:): Remove use of _selectedObjects. (-expandItem:expandChildren:): Ditto. (-_removeChildren:): Ditto. (-initWithFrame:): Don't initialize _selectedObjects. (-initWithCoder:): Ditto. * Headers/AppKit/NSOutlineView.h: Mark _selectedObjects as unused. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24478 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
81252d87b5
commit
7030dbfbb9
3 changed files with 18 additions and 79 deletions
|
@ -42,7 +42,7 @@
|
||||||
NSMapTable *_itemDict;
|
NSMapTable *_itemDict;
|
||||||
NSMutableArray *_items;
|
NSMutableArray *_items;
|
||||||
NSMutableArray *_expandedItems;
|
NSMutableArray *_expandedItems;
|
||||||
NSMutableArray *_selectedItems;
|
NSMutableArray *_selectedItems; /* No longer in use */
|
||||||
NSMapTable *_levelOfItems;
|
NSMapTable *_levelOfItems;
|
||||||
BOOL _autoResizesOutlineColumn;
|
BOOL _autoResizesOutlineColumn;
|
||||||
BOOL _indentationMarkerFollowsCell;
|
BOOL _indentationMarkerFollowsCell;
|
||||||
|
|
|
@ -98,6 +98,7 @@ static NSImage *unexpandable = nil;
|
||||||
- (void) _setObjectValue: (id)value
|
- (void) _setObjectValue: (id)value
|
||||||
forTableColumn: (NSTableColumn *)tb
|
forTableColumn: (NSTableColumn *)tb
|
||||||
row: (int) index;
|
row: (int) index;
|
||||||
|
- (int) _numRows;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// These methods are private...
|
// These methods are private...
|
||||||
|
@ -150,7 +151,6 @@ static NSImage *unexpandable = nil;
|
||||||
64);
|
64);
|
||||||
_items = [[NSMutableArray alloc] init];
|
_items = [[NSMutableArray alloc] init];
|
||||||
_expandedItems = [[NSMutableArray alloc] init];
|
_expandedItems = [[NSMutableArray alloc] init];
|
||||||
_selectedItems = [[NSMutableArray alloc] init];
|
|
||||||
_levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
_levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
NSObjectMapValueCallBacks,
|
NSObjectMapValueCallBacks,
|
||||||
64);
|
64);
|
||||||
|
@ -161,7 +161,6 @@ static NSImage *unexpandable = nil;
|
||||||
{
|
{
|
||||||
RELEASE(_items);
|
RELEASE(_items);
|
||||||
RELEASE(_expandedItems);
|
RELEASE(_expandedItems);
|
||||||
RELEASE(_selectedItems);
|
|
||||||
|
|
||||||
NSFreeMapTable(_itemDict);
|
NSFreeMapTable(_itemDict);
|
||||||
NSFreeMapTable(_levelOfItems);
|
NSFreeMapTable(_levelOfItems);
|
||||||
|
@ -227,7 +226,6 @@ static NSImage *unexpandable = nil;
|
||||||
if ([self isExpandable: item] && [self isItemExpanded: item] && canCollapse)
|
if ([self isExpandable: item] && [self isItemExpanded: item] && canCollapse)
|
||||||
{
|
{
|
||||||
NSMutableDictionary *infoDict = [NSMutableDictionary dictionary];
|
NSMutableDictionary *infoDict = [NSMutableDictionary dictionary];
|
||||||
unsigned int row;
|
|
||||||
|
|
||||||
[infoDict setObject: item forKey: @"NSObject"];
|
[infoDict setObject: item forKey: @"NSObject"];
|
||||||
|
|
||||||
|
@ -237,18 +235,6 @@ static NSImage *unexpandable = nil;
|
||||||
object: self
|
object: self
|
||||||
userInfo: infoDict];
|
userInfo: infoDict];
|
||||||
|
|
||||||
// We save the selection
|
|
||||||
[_selectedItems removeAllObjects];
|
|
||||||
row = [_selectedRows firstIndex];
|
|
||||||
while (row != NSNotFound)
|
|
||||||
{
|
|
||||||
if ([self itemAtRow: row])
|
|
||||||
{
|
|
||||||
[_selectedItems addObject: [self itemAtRow: row]];
|
|
||||||
}
|
|
||||||
row = [_selectedRows indexGreaterThanIndex: row];
|
|
||||||
}
|
|
||||||
|
|
||||||
// collapse...
|
// collapse...
|
||||||
[self _closeItem: item];
|
[self _closeItem: item];
|
||||||
|
|
||||||
|
@ -316,7 +302,6 @@ static NSImage *unexpandable = nil;
|
||||||
if (![self isItemExpanded: item] && canExpand)
|
if (![self isItemExpanded: item] && canExpand)
|
||||||
{
|
{
|
||||||
NSMutableDictionary *infoDict = [NSMutableDictionary dictionary];
|
NSMutableDictionary *infoDict = [NSMutableDictionary dictionary];
|
||||||
unsigned int row;
|
|
||||||
|
|
||||||
[infoDict setObject: item forKey: @"NSObject"];
|
[infoDict setObject: item forKey: @"NSObject"];
|
||||||
|
|
||||||
|
@ -326,18 +311,6 @@ static NSImage *unexpandable = nil;
|
||||||
object: self
|
object: self
|
||||||
userInfo: infoDict];
|
userInfo: infoDict];
|
||||||
|
|
||||||
// We save the selection
|
|
||||||
[_selectedItems removeAllObjects];
|
|
||||||
row = [_selectedRows firstIndex];
|
|
||||||
while (row != NSNotFound)
|
|
||||||
{
|
|
||||||
if ([self itemAtRow: row])
|
|
||||||
{
|
|
||||||
[_selectedItems addObject: [self itemAtRow: row]];
|
|
||||||
}
|
|
||||||
row = [_selectedRows indexGreaterThanIndex: row];
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert the root element, if necessary otherwise insert the
|
// insert the root element, if necessary otherwise insert the
|
||||||
// actual object.
|
// actual object.
|
||||||
[self _openItem: item];
|
[self _openItem: item];
|
||||||
|
@ -617,52 +590,6 @@ static NSImage *unexpandable = nil;
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We override the super class's method.
|
|
||||||
*/
|
|
||||||
- (void) noteNumberOfRowsChanged
|
|
||||||
{
|
|
||||||
_numberOfRows = [_items count];
|
|
||||||
|
|
||||||
if (!_selectingColumns)
|
|
||||||
{
|
|
||||||
int i, count, row;
|
|
||||||
|
|
||||||
/* We restore the selection */
|
|
||||||
[_selectedRows removeAllIndexes];
|
|
||||||
count = [_selectedItems count];
|
|
||||||
|
|
||||||
for (i = 0; i < count; i++)
|
|
||||||
{
|
|
||||||
row = [self rowForItem: [_selectedItems objectAtIndex: i]];
|
|
||||||
|
|
||||||
if (row >= 0 && row < _numberOfRows)
|
|
||||||
{
|
|
||||||
[_selectedRows addIndex: row];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[self setFrame: NSMakeRect (_frame.origin.x,
|
|
||||||
_frame.origin.y,
|
|
||||||
_frame.size.width,
|
|
||||||
(_numberOfRows * _rowHeight) + 1)];
|
|
||||||
|
|
||||||
/* If we are shorter in height than the enclosing clipview, we
|
|
||||||
should redraw us now. */
|
|
||||||
if (_super_view != nil)
|
|
||||||
{
|
|
||||||
NSRect superviewBounds; // Get this *after* [self setFrame:]
|
|
||||||
superviewBounds = [_super_view bounds];
|
|
||||||
if ((superviewBounds.origin.x <= _frame.origin.x)
|
|
||||||
&& (NSMaxY (superviewBounds) >= NSMaxY (_frame)))
|
|
||||||
{
|
|
||||||
[self setNeedsDisplay: YES];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the data source for this outline view.
|
* Sets the data source for this outline view.
|
||||||
*/
|
*/
|
||||||
|
@ -782,7 +709,6 @@ static NSImage *unexpandable = nil;
|
||||||
64);
|
64);
|
||||||
_items = [[NSMutableArray alloc] init];
|
_items = [[NSMutableArray alloc] init];
|
||||||
_expandedItems = [[NSMutableArray alloc] init];
|
_expandedItems = [[NSMutableArray alloc] init];
|
||||||
_selectedItems = [[NSMutableArray alloc] init];
|
|
||||||
_levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
_levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
NSObjectMapValueCallBacks,
|
NSObjectMapValueCallBacks,
|
||||||
64);
|
64);
|
||||||
|
@ -816,7 +742,6 @@ static NSImage *unexpandable = nil;
|
||||||
64);
|
64);
|
||||||
_items = [[NSMutableArray alloc] init];
|
_items = [[NSMutableArray alloc] init];
|
||||||
_expandedItems = [[NSMutableArray alloc] init];
|
_expandedItems = [[NSMutableArray alloc] init];
|
||||||
_selectedItems = [[NSMutableArray alloc] init];
|
|
||||||
_levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
_levelOfItems = NSCreateMapTable(NSObjectMapKeyCallBacks,
|
||||||
NSObjectMapValueCallBacks,
|
NSObjectMapValueCallBacks,
|
||||||
64);
|
64);
|
||||||
|
@ -1709,6 +1634,11 @@ static NSImage *unexpandable = nil;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (int) _numRows
|
||||||
|
{
|
||||||
|
return [_items count];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSOutlineView (TableViewInternalPrivate)
|
@implementation NSOutlineView (TableViewInternalPrivate)
|
||||||
|
@ -1901,7 +1831,6 @@ static NSImage *unexpandable = nil;
|
||||||
NSMapRemove(_itemDict, child);
|
NSMapRemove(_itemDict, child);
|
||||||
[_items removeObject: child];
|
[_items removeObject: child];
|
||||||
[_expandedItems removeObject: child];
|
[_expandedItems removeObject: child];
|
||||||
[_selectedItems removeObject: child];
|
|
||||||
}
|
}
|
||||||
[anarray removeAllObjects];
|
[anarray removeAllObjects];
|
||||||
}
|
}
|
||||||
|
|
|
@ -133,6 +133,7 @@ typedef struct _tableViewFlags
|
||||||
|
|
||||||
- (BOOL) _isCellEditableColumn: (int) columnIndex
|
- (BOOL) _isCellEditableColumn: (int) columnIndex
|
||||||
row: (int) rowIndex;
|
row: (int) rowIndex;
|
||||||
|
- (int) _numRows;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface NSTableView (SelectionHelper)
|
@interface NSTableView (SelectionHelper)
|
||||||
|
@ -4728,7 +4729,7 @@ static BOOL selectContiguousRegion(NSTableView *self,
|
||||||
*/
|
*/
|
||||||
- (void) noteNumberOfRowsChanged
|
- (void) noteNumberOfRowsChanged
|
||||||
{
|
{
|
||||||
_numberOfRows = [_dataSource numberOfRowsInTableView: self];
|
_numberOfRows = [self _numRows];
|
||||||
|
|
||||||
/* If we are selecting rows, we have to check that we have no
|
/* If we are selecting rows, we have to check that we have no
|
||||||
selected rows below the new end of the table */
|
selected rows below the new end of the table */
|
||||||
|
@ -6487,6 +6488,15 @@ static BOOL selectContiguousRegion(NSTableView *self,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Quasi private method called on self from -noteNumberOfRowsChanged
|
||||||
|
* implemented in NSTableView and subclasses
|
||||||
|
* by default returns the DataSource's -numberOfRowsInTableView:
|
||||||
|
*/
|
||||||
|
- (int) _numRows
|
||||||
|
{
|
||||||
|
return [_dataSource numberOfRowsInTableView:self];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) _isDraggingSource
|
- (BOOL) _isDraggingSource
|
||||||
{
|
{
|
||||||
return [_dataSource respondsToSelector:
|
return [_dataSource respondsToSelector:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue