#2593 Add a Filter field to the Message Log window
This commit is contained in:
parent
42f63a63d3
commit
1eaf271510
|
@ -49,7 +49,7 @@
|
|||
<characters key="NS.bytes">View</characters>
|
||||
</object>
|
||||
<string key="NSWindowContentMaxSize">{1.79769e+308, 1.79769e+308}</string>
|
||||
<string key="NSWindowContentMinSize">{400, 200}</string>
|
||||
<string key="NSWindowContentMinSize">{550, 200}</string>
|
||||
<object class="NSView" key="NSWindowView" id="459370864">
|
||||
<reference key="NSNextResponder"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
|
@ -289,8 +289,8 @@ DAFAEHwfhKBotGqdJ8GQcR4H0bp+n4f57H3IFtIFPAAHkgZ7oHqIAH8gIAAADwEAAAMAAAABAA4AAAEB
|
|||
AAMAAAABAA4AAAECAAMAAAAEAAADtgEDAAMAAAABAAUAAAEGAAMAAAABAAIAAAERAAQAAAABAAAACAES
|
||||
AAMAAAABAAEAAAEVAAMAAAABAAQAAAEWAAMAAAABAA4AAAEXAAQAAAABAAAC8wEcAAMAAAABAAEAAAE9
|
||||
AAMAAAABAAIAAAFSAAMAAAABAAEAAAFTAAMAAAAEAAADvodzAAcAAChAAAADxgAAAAAACAAIAAgACAAB
|
||||
AAEAAQABAAAoQGFwcGwCAAAAbW50clJHQiBYWVogB9kACAAcABIAFQAlYWNzcEFQUEwAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1hcHBs3I/AbWL5WZxN0yqjSRKHkAAAAAAAAAAAAAAAAAAA
|
||||
AAEAAQABAAAoQGFwcGwCAAAAbW50clJHQiBYWVogB9oAAQACABMAGwAYYWNzcEFQUEwAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAPbWAAEAAAAA0y1hcHBsM0rDtfvrRSELp7Z5kxaTHQAAAAAAAAAAAAAAAAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAARclhZWgAAAVAAAAAUZ1hZWgAAAWQAAAAUYlhZWgAAAXgAAAAUd3RwdAAA
|
||||
AYwAAAAUY2hhZAAAAaAAAAAsclRSQwAAAcwAAAgMZ1RSQwAACdgAAAgMYlRSQwAAEeQAAAgMYWFyZwAA
|
||||
GfAAAAAgYWFnZwAAGhAAAAAgYWFiZwAAGjAAAAAgdmNndAAAGlAAAAYSbmRpbgAAIGQAAAY+ZGVzYwAA
|
||||
|
@ -460,7 +460,7 @@ AOhkYURLAAAACAAAAOhwbFBMAAAACAAAAOhlblVTAAAACAAAAOhuYk5PAAAACAAAAOhmckZSAAAACAAA
|
|||
AOhwdEJSAAAACAAAAOhwdFBUAAAACAAAAOh6aENOAAAACAAAAOhlc0VTAAAACAAAAOhqYUpQAAAACAAA
|
||||
AOhydVJVAAAACAAAAOhzdlNFAAAACAAAAOh6aFRXAAAACAAAAOhkZURFAAAACAAAAOhmaUZJAAAACAAA
|
||||
AOhpdElUAAAACAAAAOhrb0tSAAAACAAAAOgAaQBNAGEAY21tb2QAAAAAAAAGEAAAnGoAAAAAv9ORgAAA
|
||||
AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
||||
AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAxMAA</bytes>
|
||||
</object>
|
||||
<string key="NSCacheWindowColorSpace">NSCalibratedRGBColorSpace</string>
|
||||
<int key="NSCacheWindowBPS">8</int>
|
||||
|
@ -707,12 +707,79 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<reference key="NSCornerView" ref="670526996"/>
|
||||
<bytes key="NSScrollAmts">AAAAAAAAAABBgAAAQYAAAA</bytes>
|
||||
</object>
|
||||
<object class="NSSearchField" id="619449639">
|
||||
<reference key="NSNextResponder" ref="459370864"/>
|
||||
<int key="NSvFlags">289</int>
|
||||
<string key="NSFrame">{{351, 7}, {150, 22}}</string>
|
||||
<reference key="NSSuperview" ref="459370864"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSSearchFieldCell" key="NSCell" id="788421673">
|
||||
<int key="NSCellFlags">343014976</int>
|
||||
<int key="NSCellFlags2">268436544</int>
|
||||
<string key="NSContents"/>
|
||||
<reference key="NSSupport" ref="42108294"/>
|
||||
<string key="NSPlaceholderString">Filter</string>
|
||||
<reference key="NSControlView" ref="619449639"/>
|
||||
<bool key="NSDrawsBackground">YES</bool>
|
||||
<int key="NSTextBezelStyle">1</int>
|
||||
<object class="NSColor" key="NSBackgroundColor">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">textBackgroundColor</string>
|
||||
<reference key="NSColor" ref="67741002"/>
|
||||
</object>
|
||||
<reference key="NSTextColor" ref="854986610"/>
|
||||
<object class="NSButtonCell" key="NSSearchButtonCell">
|
||||
<int key="NSCellFlags">130560</int>
|
||||
<int key="NSCellFlags2">0</int>
|
||||
<string key="NSContents">search</string>
|
||||
<reference key="NSControlView" ref="619449639"/>
|
||||
<string key="NSAction">_searchFieldSearch:</string>
|
||||
<reference key="NSTarget" ref="788421673"/>
|
||||
<int key="NSButtonFlags">138690815</int>
|
||||
<int key="NSButtonFlags2">0</int>
|
||||
<string key="NSKeyEquivalent"/>
|
||||
<int key="NSPeriodicDelay">400</int>
|
||||
<int key="NSPeriodicInterval">75</int>
|
||||
</object>
|
||||
<object class="NSButtonCell" key="NSCancelButtonCell">
|
||||
<int key="NSCellFlags">130560</int>
|
||||
<int key="NSCellFlags2">0</int>
|
||||
<string key="NSContents">clear</string>
|
||||
<object class="NSMutableArray" key="NSAccessibilityOverriddenAttributes">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSMutableDictionary">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>AXDescription</string>
|
||||
<string>NSAccessibilityEncodedAttributesValueType</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>cancel</string>
|
||||
<integer value="1"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<reference key="NSControlView" ref="619449639"/>
|
||||
<string key="NSAction">_searchFieldCancel:</string>
|
||||
<reference key="NSTarget" ref="788421673"/>
|
||||
<int key="NSButtonFlags">138690815</int>
|
||||
<int key="NSButtonFlags2">0</int>
|
||||
<string key="NSKeyEquivalent"/>
|
||||
<int key="NSPeriodicDelay">400</int>
|
||||
<int key="NSPeriodicInterval">75</int>
|
||||
</object>
|
||||
<int key="NSMaximumRecents">255</int>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{611, 328}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
</object>
|
||||
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
|
||||
<string key="NSMinSize">{400, 222}</string>
|
||||
<string key="NSMinSize">{550, 222}</string>
|
||||
<string key="NSMaxSize">{1.79769e+308, 1.79769e+308}</string>
|
||||
</object>
|
||||
</object>
|
||||
|
@ -807,6 +874,22 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
</object>
|
||||
<int key="connectionID">71</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">fFilterField</string>
|
||||
<reference key="source" ref="135867518"/>
|
||||
<reference key="destination" ref="619449639"/>
|
||||
</object>
|
||||
<int key="connectionID">74</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">changeFilter:</string>
|
||||
<reference key="source" ref="135867518"/>
|
||||
<reference key="destination" ref="619449639"/>
|
||||
</object>
|
||||
<int key="connectionID">75</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
|
@ -854,6 +937,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<reference ref="539084345"/>
|
||||
<reference ref="945411764"/>
|
||||
<reference ref="104571253"/>
|
||||
<reference ref="619449639"/>
|
||||
</object>
|
||||
<reference key="parent" ref="905673783"/>
|
||||
</object>
|
||||
|
@ -1033,6 +1117,20 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<reference key="object" ref="652441767"/>
|
||||
<reference key="parent" ref="155009194"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">72</int>
|
||||
<reference key="object" ref="619449639"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="788421673"/>
|
||||
</object>
|
||||
<reference key="parent" ref="459370864"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">73</int>
|
||||
<reference key="object" ref="788421673"/>
|
||||
<reference key="parent" ref="619449639"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
|
@ -1096,6 +1194,8 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<string>66.IBShouldRemoveOnLegacySave</string>
|
||||
<string>68.IBPluginDependency</string>
|
||||
<string>69.IBPluginDependency</string>
|
||||
<string>72.IBPluginDependency</string>
|
||||
<string>73.IBPluginDependency</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
|
@ -1136,7 +1236,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<boolean value="NO"/>
|
||||
<integer value="1"/>
|
||||
<string>{3.40282e+38, 3.40282e+38}</string>
|
||||
<string>{400, 200}</string>
|
||||
<string>{550, 200}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<integer value="1"/>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
|
@ -1156,6 +1256,8 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<integer value="1"/>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
|
@ -1174,7 +1276,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">71</int>
|
||||
<int key="maxID">75</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
|
@ -1194,6 +1296,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>changeFilter:</string>
|
||||
<string>changeLevel:</string>
|
||||
<string>clearLog:</string>
|
||||
<string>writeToFile:</string>
|
||||
|
@ -1203,6 +1306,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
<string>id</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
|
@ -1210,6 +1314,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<object class="NSArray" key="dict.sortedKeys">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>fClearButton</string>
|
||||
<string>fFilterField</string>
|
||||
<string>fLevelButton</string>
|
||||
<string>fMessageTable</string>
|
||||
<string>fSaveButton</string>
|
||||
|
@ -1217,6 +1322,7 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSButton</string>
|
||||
<string>NSSearchField</string>
|
||||
<string>NSPopUpButton</string>
|
||||
<string>NSTableView</string>
|
||||
<string>NSButton</string>
|
||||
|
@ -1824,6 +1930,22 @@ AAAAAAAAAAAAAAAAAAB0ZXh0AAAAAENvcHlyaWdodCBBcHBsZSwgSW5jLiwgMjAwOQA</bytes>
|
|||
<string key="minorKey">AppKit.framework/Headers/NSScroller.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NSSearchField</string>
|
||||
<string key="superclassName">NSTextField</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBFrameworkSource</string>
|
||||
<string key="minorKey">AppKit.framework/Headers/NSSearchField.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NSSearchFieldCell</string>
|
||||
<string key="superclassName">NSTextFieldCell</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBFrameworkSource</string>
|
||||
<string key="minorKey">AppKit.framework/Headers/NSSearchFieldCell.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NSTableColumn</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
IBOutlet NSPopUpButton * fLevelButton;
|
||||
IBOutlet NSButton * fSaveButton, * fClearButton;
|
||||
IBOutlet NSSearchField * fFilterField;
|
||||
|
||||
NSMutableArray * fMessages, * fDisplayedMessages;
|
||||
|
||||
|
@ -43,6 +44,7 @@
|
|||
- (void) updateLog: (NSTimer *) timer;
|
||||
|
||||
- (void) changeLevel: (id) sender;
|
||||
- (void) changeFilter: (id) sender;
|
||||
- (void) clearLog: (id) sender;
|
||||
|
||||
- (void) writeToFile: (id) sender;
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
@interface MessageWindowController (Private)
|
||||
|
||||
- (void) resizeColumn;
|
||||
- (BOOL) shouldIncludeMessageForFilter: (NSString *) filterString message: (NSDictionary *) message;
|
||||
- (NSString *) stringForMessage: (NSDictionary *) message;
|
||||
|
||||
@end
|
||||
|
@ -113,9 +114,14 @@
|
|||
|
||||
NSRect clearButtonFrame = [fClearButton frame];
|
||||
clearButtonFrame.size.width = MAX(clearButtonFrame.size.width + 10.0, saveButtonFrame.size.width);
|
||||
clearButtonFrame.origin.x -= clearButtonFrame.size.width - oldClearButtonWidth;
|
||||
clearButtonFrame.origin.x -= NSWidth(clearButtonFrame) - oldClearButtonWidth;
|
||||
[fClearButton setFrame: clearButtonFrame];
|
||||
|
||||
[[fFilterField cell] setPlaceholderString: NSLocalizedString(@"Filter", "Message window -> filter field")];
|
||||
NSRect filterButtonFrame = [fFilterField frame];
|
||||
filterButtonFrame.origin.x -= NSWidth(clearButtonFrame) - oldClearButtonWidth;
|
||||
[fFilterField setFrame: filterButtonFrame];
|
||||
|
||||
fAttributes = [[[[[fMessageTable tableColumnWithIdentifier: @"Message"] dataCell] attributedStringValue]
|
||||
attributesAtIndex: 0 effectiveRange: NULL] retain];
|
||||
|
||||
|
@ -173,6 +179,8 @@
|
|||
|| [scroller knobProportion] == 1.0;
|
||||
|
||||
const NSInteger maxLevel = [[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"];
|
||||
NSString * filterString = [fFilterField stringValue];
|
||||
|
||||
BOOL changed = NO;
|
||||
|
||||
for (tr_msg_list * currentMessage = messages; currentMessage != NULL; currentMessage = currentMessage->next)
|
||||
|
@ -193,7 +201,7 @@
|
|||
|
||||
[fMessages addObject: message];
|
||||
|
||||
if (currentMessage->level <= maxLevel)
|
||||
if (currentMessage->level <= maxLevel && [self shouldIncludeMessageForFilter: filterString message: message])
|
||||
{
|
||||
[fDisplayedMessages addObject: message];
|
||||
changed = YES;
|
||||
|
@ -339,16 +347,40 @@
|
|||
|
||||
[[NSUserDefaults standardUserDefaults] setInteger: level forKey: @"MessageLevel"];
|
||||
|
||||
if (level == TR_MSG_DBG) //all messages at this level
|
||||
[fDisplayedMessages setArray: fMessages];
|
||||
else
|
||||
NSString * filterString = [fFilterField stringValue];
|
||||
|
||||
[fDisplayedMessages removeAllObjects];
|
||||
for (NSDictionary * message in fMessages)
|
||||
if ([[message objectForKey: @"Level"] integerValue] <= level
|
||||
&& [self shouldIncludeMessageForFilter: filterString message: message])
|
||||
[fDisplayedMessages addObject: message];
|
||||
|
||||
[fDisplayedMessages sortUsingDescriptors: [fMessageTable sortDescriptors]];
|
||||
|
||||
[fMessageTable reloadData];
|
||||
|
||||
if ([fDisplayedMessages count] > 0)
|
||||
{
|
||||
[fDisplayedMessages removeAllObjects];
|
||||
for (NSDictionary * message in fMessages)
|
||||
if ([[message objectForKey: @"Level"] integerValue] <= level)
|
||||
[fDisplayedMessages addObject: message];
|
||||
[fMessageTable deselectAll: self];
|
||||
[fMessageTable scrollRowToVisible: [fMessageTable numberOfRows]-1];
|
||||
}
|
||||
|
||||
[fLock unlock];
|
||||
}
|
||||
|
||||
- (void) changeFilter: (id) sender
|
||||
{
|
||||
[fLock lock];
|
||||
|
||||
const NSInteger level = [[NSUserDefaults standardUserDefaults] integerForKey: @"MessageLevel"];
|
||||
NSString * filterString = [fFilterField stringValue];
|
||||
|
||||
[fDisplayedMessages removeAllObjects];
|
||||
for (NSDictionary * message in fMessages)
|
||||
if ([[message objectForKey: @"Level"] integerValue] <= level
|
||||
&& [self shouldIncludeMessageForFilter: filterString message: message])
|
||||
[fDisplayedMessages addObject: message];
|
||||
|
||||
[fDisplayedMessages sortUsingDescriptors: [fMessageTable sortDescriptors]];
|
||||
|
||||
[fMessageTable reloadData];
|
||||
|
@ -429,6 +461,16 @@
|
|||
NSMakeRange(0, [fMessageTable numberOfRows])]];
|
||||
}
|
||||
|
||||
- (BOOL) shouldIncludeMessageForFilter: (NSString *) filterString message: (NSDictionary *) message
|
||||
{
|
||||
if ([filterString isEqualToString: @""])
|
||||
return YES;
|
||||
|
||||
const NSStringCompareOptions searchOptions = NSCaseInsensitiveSearch | NSDiacriticInsensitiveSearch;
|
||||
return [[message objectForKey: @"Name"] rangeOfString: filterString options: searchOptions].location != NSNotFound
|
||||
|| [[message objectForKey: @"Message"] rangeOfString: filterString options: searchOptions].location != NSNotFound;
|
||||
}
|
||||
|
||||
- (NSString *) stringForMessage: (NSDictionary *) message
|
||||
{
|
||||
NSString * levelString;
|
||||
|
|
Loading…
Reference in New Issue