From 10316c1a2e8448e5dd93a1d10c7e039115864925 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 19 Feb 2010 14:43:01 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20the=20chance=20to=20the=20user-defi?= =?UTF-8?q?ned=20Content=20Filter=20Editor=20to=20specify=20whether=20the?= =?UTF-8?q?=20leading=20=20placeholder=20should=20be=20suppressed?= =?UTF-8?q?=20or=20not=20in=20order=20to=20be=20able=20to=20write=20a=20fi?= =?UTF-8?q?lter=20like=20"LENGTH($CURRENT=5FFIELD)>${}"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/TableContent.m | 55 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 17 deletions(-) (limited to 'Source/TableContent.m') diff --git a/Source/TableContent.m b/Source/TableContent.m index 50bcfd9f..da6577cb 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -809,6 +809,10 @@ NSUInteger numberOfArguments = [[filter objectForKey:@"NumberOfArguments"] integerValue]; + BOOL suppressLeadingTablePlaceholder = NO; + if([filter objectForKey:@"SuppressLeadingFieldPlaceholder"]) + suppressLeadingTablePlaceholder = YES; + // argument if Filter requires only one argument NSMutableString *argument = [[NSMutableString alloc] initWithString:[argumentField stringValue]]; @@ -870,24 +874,41 @@ } // Construct the filter string according the required number of arguments - if (numberOfArguments == 2) { - filterString = [NSString stringWithFormat:@"%@ %@", - [[fieldField titleOfSelectedItem] backtickQuotedString], - [NSString stringWithFormat:clause, - [self escapeFilterArgument:firstBetweenArgument againstClause:clause], - [self escapeFilterArgument:secondBetweenArgument againstClause:clause]]]; - } else if (numberOfArguments == 1) { - filterString = [NSString stringWithFormat:@"%@ %@", - [[fieldField titleOfSelectedItem] backtickQuotedString], - [NSString stringWithFormat:clause, [self escapeFilterArgument:argument againstClause:clause]]]; + + if(suppressLeadingTablePlaceholder) { + if (numberOfArguments == 2) { + filterString = [NSString stringWithFormat:clause, + [self escapeFilterArgument:firstBetweenArgument againstClause:clause], + [self escapeFilterArgument:secondBetweenArgument againstClause:clause]]; + } else if (numberOfArguments == 1) { + filterString = [NSString stringWithFormat:clause, [self escapeFilterArgument:argument againstClause:clause]]; + } else { + filterString = [NSString stringWithString:[filter objectForKey:@"Clause"]]; + if(numberOfArguments > 2) { + NSLog(@"Filter with more than 2 arguments is not yet supported."); + NSBeep(); + } + } } else { - filterString = [NSString stringWithFormat:@"%@ %@", - [[fieldField titleOfSelectedItem] backtickQuotedString], - [filter objectForKey:@"Clause"]]; - if(numberOfArguments > 2) { - NSLog(@"Filter with more than 2 arguments is not yet supported."); - NSBeep(); - } + if (numberOfArguments == 2) { + filterString = [NSString stringWithFormat:@"%@ %@", + [[fieldField titleOfSelectedItem] backtickQuotedString], + [NSString stringWithFormat:clause, + [self escapeFilterArgument:firstBetweenArgument againstClause:clause], + [self escapeFilterArgument:secondBetweenArgument againstClause:clause]]]; + } else if (numberOfArguments == 1) { + filterString = [NSString stringWithFormat:@"%@ %@", + [[fieldField titleOfSelectedItem] backtickQuotedString], + [NSString stringWithFormat:clause, [self escapeFilterArgument:argument againstClause:clause]]]; + } else { + filterString = [NSString stringWithFormat:@"%@ %@", + [[fieldField titleOfSelectedItem] backtickQuotedString], + [filter objectForKey:@"Clause"]]; + if(numberOfArguments > 2) { + NSLog(@"Filter with more than 2 arguments is not yet supported."); + NSBeep(); + } + } } [argument release]; -- cgit v1.2.3