Changeset 3314 for trunk/macosx/InfoWindowController.m
- Timestamp:
- Oct 7, 2007, 12:24:26 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/InfoWindowController.m
r3310 r3314 63 63 - (void) updateInfoOptions; 64 64 65 - (NSView *) tabViewForTag: (int) tag; 65 66 - (NSArray *) peerSortDescriptors; 66 67 … … 68 69 69 70 @implementation InfoWindowController 71 72 - (id) init 73 { 74 return [super initWithWindowNibName: @"InfoWindow"]; 75 } 70 76 71 77 - (void) awakeFromNib … … 77 83 NSPanel * window = (NSPanel *)[self window]; 78 84 79 /*[window setFrameAutosaveName: @"InspectorWindowFrame"]; 80 [window setFrameUsingName: @"InspectorWindowFrame"];*/ 85 float windowHeight = [window frame].size.height; 86 87 [window setFrameAutosaveName: @"InspectorWindow"]; 88 [window setFrameUsingName: @"InspectorWindow"]; 89 90 NSRect windowRect = [window frame]; 91 windowRect.origin.y -= windowHeight - windowRect.size.height; 92 windowRect.size.height = windowHeight; 93 [window setFrame: windowRect display: NO]; 81 94 82 95 [window setBecomesKeyOnlyIfNeeded: YES]; … … 147 160 - (void) dealloc 148 161 { 162 #warning not called? 163 float viewHeight = [[self tabViewForTag: fCurrentTabTag] frame].size.height; 164 165 //save resizeable view height 149 166 if (fCurrentTabTag == TAB_PEERS_TAG || fCurrentTabTag == TAB_FILES_TAG) 150 { 151 NSView * view = fCurrentTabTag == TAB_PEERS_TAG ? fPeersView : fFilesView; 152 [[NSUserDefaults standardUserDefaults] setFloat: [view frame].size.height forKey: @"InspectorContentHeight"]; 153 } 167 [[NSUserDefaults standardUserDefaults] setFloat: viewHeight forKey: @"InspectorContentHeight"]; 154 168 155 169 [[NSNotificationCenter defaultCenter] removeObserver: self]; … … 812 826 813 827 //get old view 814 NSView * oldView; 815 switch (oldTabTag) 816 { 817 case TAB_INFO_TAG: 818 oldView = fInfoView; 819 break; 820 case TAB_ACTIVITY_TAG: 821 oldView = fActivityView; 822 break; 823 case TAB_PEERS_TAG: 824 oldView = fPeersView; 825 break; 826 case TAB_FILES_TAG: 827 oldView = fFilesView; 828 break; 829 case TAB_OPTIONS_TAG: 830 oldView = fOptionsView; 831 break; 832 } 833 828 NSView * oldView = [self tabViewForTag: oldTabTag]; 834 829 [oldView setHidden: YES]; 835 830 [oldView removeFromSuperview]; … … 1008 1003 } 1009 1004 1010 - (NSArray *) peerSortDescriptors1011 {1012 NSMutableArray * descriptors = [NSMutableArray arrayWithCapacity: 2];1013 1014 NSArray * oldDescriptors = [fPeerTable sortDescriptors];1015 BOOL useSecond = YES, asc = YES;1016 if ([oldDescriptors count] > 0)1017 {1018 NSSortDescriptor * descriptor = [oldDescriptors objectAtIndex: 0];1019 [descriptors addObject: descriptor];1020 1021 if ((useSecond = ![[descriptor key] isEqualToString: @"IP"]))1022 asc = [descriptor ascending];1023 }1024 1025 //sort by IP after primary sort1026 if (useSecond)1027 {1028 NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc1029 selector: @selector(compareIP:)];1030 [descriptors addObject: secondDescriptor];1031 [secondDescriptor release];1032 }1033 1034 return descriptors;1035 }1036 1037 1005 - (int) outlineView: (NSOutlineView *) outlineView numberOfChildrenOfItem: (id) item 1038 1006 { … … 1368 1336 1369 1337 @end 1338 1339 @implementation InfoWindowController (Private) 1340 1341 - (NSView *) tabViewForTag: (int) tag 1342 { 1343 switch (tag) 1344 { 1345 case TAB_INFO_TAG: 1346 return fInfoView; 1347 case TAB_ACTIVITY_TAG: 1348 return fActivityView; 1349 case TAB_PEERS_TAG: 1350 return fPeersView; 1351 case TAB_FILES_TAG: 1352 return fFilesView; 1353 case TAB_OPTIONS_TAG: 1354 return fOptionsView; 1355 default: 1356 return nil; 1357 } 1358 } 1359 1360 - (NSArray *) peerSortDescriptors 1361 { 1362 NSMutableArray * descriptors = [NSMutableArray arrayWithCapacity: 2]; 1363 1364 NSArray * oldDescriptors = [fPeerTable sortDescriptors]; 1365 BOOL useSecond = YES, asc = YES; 1366 if ([oldDescriptors count] > 0) 1367 { 1368 NSSortDescriptor * descriptor = [oldDescriptors objectAtIndex: 0]; 1369 [descriptors addObject: descriptor]; 1370 1371 if ((useSecond = ![[descriptor key] isEqualToString: @"IP"])) 1372 asc = [descriptor ascending]; 1373 } 1374 1375 //sort by IP after primary sort 1376 if (useSecond) 1377 { 1378 NSSortDescriptor * secondDescriptor = [[NSSortDescriptor alloc] initWithKey: @"IP" ascending: asc 1379 selector: @selector(compareIP:)]; 1380 [descriptors addObject: secondDescriptor]; 1381 [secondDescriptor release]; 1382 } 1383 1384 return descriptors; 1385 } 1386 1387 @end
Note: See TracChangeset
for help on using the changeset viewer.