From 73dca377472fe466ac5b2b2d0ba13ae109863f59 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Fri, 8 Oct 2010 10:32:32 +0000 Subject: =?UTF-8?q?=E2=80=A2=20added=20spatial=20field=20types=20to=20fiel?= =?UTF-8?q?d=20list=20suggestions=20=E2=80=A2=20adjusted=20gui=20validatio?= =?UTF-8?q?n=20for=20geometry=20field=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPTableStructure.m | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'Source') diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index f0556ba8..51f2e458 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -43,6 +43,7 @@ - (BOOL)_isFieldTypeNumeric:(NSString*)aType; - (BOOL)_isFieldTypeDate:(NSString*)aType; - (BOOL)_isFieldTypeString:(NSString*)aType; +- (BOOL)_isFieldTypeGeometry:(NSString*)aType; - (BOOL)_isFieldTypeAllowBinary:(NSString*)aType; @end @@ -123,6 +124,15 @@ @"TIMESTAMP", @"TIME", @"YEAR", + @"--------", + @"GEOMETRY", + @"POINT", + @"LINESTRING", + @"POLYGON", + @"MULTIPOINT", + @"MULTILINESTRING", + @"MULTIPOLYGON", + @"GEOMETRYCOLLECTION", nil] retain]; // Hint: _isFieldTypeDate and _isFieldTypeNumeric must be changed if typeSuggestions was changed! @@ -1822,9 +1832,9 @@ would result in a position change. else if([[aTableColumn identifier] isEqualToString:@"null"]) { [aCell setEnabled:([[theRow objectForKey:@"Key"] isEqualToString:@"PRI"] || [[[theRow objectForKey:@"Extra"] uppercaseString] isEqualToString:@"AUTO_INCREMENT"]) ? NO : YES]; } - // TEXT or BLOB fields don't allow a length + // TEXT, BLOB, date, and GEOMETRY fields don't allow a length else if([[aTableColumn identifier] isEqualToString:@"length"]) { - [aCell setEnabled:([theRowType hasSuffix:@"TEXT"] || [theRowType hasSuffix:@"BLOB"] || [self _isFieldTypeDate:theRowType]) ? NO : YES]; + [aCell setEnabled:([theRowType hasSuffix:@"TEXT"] || [theRowType hasSuffix:@"BLOB"] || [self _isFieldTypeDate:theRowType] || [self _isFieldTypeGeometry:theRowType]) ? NO : YES]; } else { [aCell setEnabled:YES]; @@ -1929,7 +1939,20 @@ would result in a position change. if(![typeSuggestions containsObject:type]) return YES; // for safety reasons - return ([typeSuggestions indexOfObject:type] > 32); + return ([typeSuggestions indexOfObject:type] > 32 && [typeSuggestions indexOfObject:type] < 38); +} + +/** + * Return if aType is a geometry to typeSuggestions's position + * Hint: This must be changed if typeSuggestions was changed! + */ +- (BOOL)_isFieldTypeGeometry:(NSString*)aType +{ + NSString *type = [[aType stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]] uppercaseString]; + + if(![typeSuggestions containsObject:type]) return YES; // for safety reasons + + return ([typeSuggestions indexOfObject:type] > 38); } /** -- cgit v1.2.3