adium 4841:7ea32918cafc: Expand groups after the contact list is...

commits at adium.im commits at adium.im
Sat Jun 2 18:46:37 UTC 2012


details:	http://hg.adium.im/adium/rev/7ea32918cafc
revision:	4841:7ea32918cafc
branch:		(none)
author:		Frank Dowsett <wixardy at adium.im>
date:		Sat Jun 02 14:45:40 2012 -0400

Expand groups after the contact list is filtered to avoid showing all contacts when they aren't needed.
Subject: adium 4842:eca4d076d7ef: Letting the contact list window draw itself fixes #16018.

details:	http://hg.adium.im/adium/rev/eca4d076d7ef
revision:	4842:eca4d076d7ef
branch:		(none)
author:		Frank Dowsett <wixardy at adium.im>
date:		Sat Jun 02 14:45:44 2012 -0400

Letting the contact list window draw itself fixes #16018.

diffs (85 lines):

diff -r 26c6b254cb38 -r eca4d076d7ef Source/AIListWindowController.m
--- a/Source/AIListWindowController.m	Sat Jun 02 10:51:31 2012 -0400
+++ b/Source/AIListWindowController.m	Sat Jun 02 14:45:44 2012 -0400
@@ -1557,7 +1557,7 @@
 			
 			[[targetView window] setFrame:NSMakeRect(NSMinX(windowFrame), NSMinY(windowFrame) - NSHeight([filterBarView bounds]),
 													 NSWidth(windowFrame), NSHeight(windowFrame) + NSHeight([filterBarView bounds]))
-								  display:NO
+								  display:YES
 								  animate:NO];
 			
 			targetFrame = [targetView frame];
@@ -1692,6 +1692,24 @@
 	return YES;
 }
 
+- (void)expandGroupsForFiltering:(BOOL)state
+{
+	BOOL modified = NO;
+	for (AIListObject *listObject in [self.contactList containedObjects]) {
+		if ([listObject isKindOfClass:[AIListGroup class]] &&
+			((!state && [listObject boolValueForProperty:@"ExpandedByFiltering"]) ||
+			(state && [(AIListGroup *)listObject isExpanded] == NO))) {
+			[listObject setValue:[NSNumber numberWithBool:state] forProperty:@"ExpandedByFiltering" notify:NotifyNever];
+			modified = YES;
+		}
+	}
+	
+	filterBarExpandedGroups = state;
+	
+	if (modified)
+		[contactListView reloadData];
+}
+
 /*!
  * @brief Filter contacts from the search field
  *
@@ -1703,35 +1721,8 @@
 	if (![sender isKindOfClass:[NSSearchField class]])
 		return;
 	
-	if (!filterBarExpandedGroups && ![[sender stringValue] isEqualToString:@""]) {
-        BOOL modified = NO;
-        for (AIListObject *listObject in [self.contactList containedObjects]) {
-            if ([listObject isKindOfClass:[AIListGroup class]] && [(AIListGroup *)listObject isExpanded] == NO) {
-                [listObject setValue:[NSNumber numberWithBool:YES] forProperty:@"ExpandedByFiltering" notify:NotifyNever];
-                modified = YES;
-            }
-        }
-        
-        filterBarExpandedGroups = YES;
-        
-        if (modified) {
-            [contactListView reloadData];
-        }
-    } else if (filterBarExpandedGroups && [[sender stringValue] isEqualToString:@""]) {
-        BOOL modified = NO;
-        for (AIListObject *listObject in [self.contactList containedObjects]) {
-            if ([listObject isKindOfClass:[AIListGroup class]] && [listObject boolValueForProperty:@"ExpandedByFiltering"]) {
-                [listObject setValue:[NSNumber numberWithBool:NO] forProperty:@"ExpandedByFiltering" notify:NotifyNever];
-                modified = YES;
-            }
-        }
-        
-        filterBarExpandedGroups = NO;
-        
-        if (modified) {
-            [contactListView reloadData];
-        }
-    }
+	if (filterBarExpandedGroups && [[sender stringValue] isEqualToString:@""])
+		[self expandGroupsForFiltering:NO];
 	
 	if ([[AIContactHidingController sharedController] filterContacts:[sender stringValue]]) {
 		// Select the first contact; we're guaranteed at least one visible contact.
@@ -1751,6 +1742,9 @@
 																								   brightness:0.99f
 																										alpha:1.0f]];
 	}
+	
+	if (!filterBarExpandedGroups && ![[sender stringValue] isEqualToString:@""])
+		[self expandGroupsForFiltering:YES];
 }
 
 /*!




More information about the commits mailing list