Skip to content
Browse files

Many fixes and improvements. Still lot to do. Working on the table he…

…ader click.
  • Loading branch information...
1 parent b4b2e20 commit 2c88a6090354945b7ae5d25df60ffa3b3b5ca73d svnuser committed Oct 14, 2009
View
2 CSVDocument/CSVColumn.h
@@ -17,11 +17,13 @@
@interface CSVColumn : NSObject {
NSString *name; // the name to display
NSString *key; // a unique key
+ NSString *type; // type of the values (NSString, NSNumber, NSDate) TODO: implement!
BOOL active;
}
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *key;
+@property (nonatomic, copy) NSString *type;
@property (nonatomic, assign, getter=isActive) BOOL active;
View
14 CSVDocument/CSVColumn.m
@@ -11,10 +11,21 @@
@implementation CSVColumn
-@synthesize key, active;
+@synthesize key;
@dynamic name;
+@synthesize type;
+@synthesize active;
+- (id) init
+{
+ self = [super init];
+ if (self) {
+ self.type = @"NSString";
+ }
+ return self;
+}
+
+ (id) columnWithKey:(NSString *)newKey
{
CSVColumn *column = [[[self alloc] init] autorelease];
@@ -27,6 +38,7 @@ - (void) dealloc
{
self.key = nil;
self.name = nil;
+ self.type = nil;
[super dealloc];
}
View
10 CSVDocument/CSVDocument.h
@@ -25,10 +25,9 @@
id <CSVDocumentDelegate> delegate;
NSString *separator;
- NSMutableArray *headerRows; // array full of CSVRow header rows
NSMutableArray *rows;
NSNumber *numRows;
-
+
#ifndef IPHONE
CSVRowController *rowController;
#endif
@@ -48,15 +47,14 @@
@property (nonatomic, assign) id delegate;
@property (nonatomic, retain) NSString *separator;
-@property (nonatomic, retain) NSMutableArray *headerRows;
@property (nonatomic, retain) NSMutableArray *rows;
@property (nonatomic, copy) NSNumber *numRows;
#ifndef IPHONE
@property (nonatomic, retain) CSVRowController *rowController;
#endif
@property (nonatomic, retain) NSArray *columns;
-@property (nonatomic, readonly) NSDictionary *columnDict;
+@property (nonatomic, readonly, retain) NSDictionary *columnDict;
@property (nonatomic, assign) BOOL parseSuccessful;
@property (nonatomic, assign) BOOL autoDetectSeparator;
@@ -80,7 +78,6 @@
// column handling
- (void) addColumn:(CSVColumn *) newColumn;
- (BOOL) isFirstColumnKey:(NSString *)columnKey;
-- (void) setHeaderRow:(CSVRow *)newHeaderRow;
- (BOOL) hasColumnKey:(NSString *)columnKey;
- (void) setColumnOrderByKeys:(NSArray *)newOrderKeys;
@@ -92,6 +89,9 @@
// row handling
- (CSVRow *) rowAtIndex:(NSUInteger)rowIndex;
+- (void) changeNumHeaderRows:(NSUInteger)newNum;
+- (void) rearrangeRows;
+- (void) row:(CSVRow *)thisRow didBecomeHeaderRow:(BOOL)itDid;
@end
View
151 CSVDocument/CSVDocument.m
@@ -16,6 +16,8 @@
@interface CSVDocument ()
+@property (nonatomic, readwrite, retain) NSDictionary *columnDict;
+
- (void) setColumnDict:(NSDictionary *)newColumnDict;
- (void) notifyDelegateOfParsedRow:(CSVRow *)newRow;
@@ -35,12 +37,11 @@ @implementation CSVDocument
#endif
@synthesize parseSuccessful;
@synthesize autoDetectSeparator;
-@synthesize headerRows;
@synthesize mustAbortImport;
@synthesize didAbortImport;
@synthesize reportEveryRowParsed;
@synthesize columns;
-@dynamic numHeaderRows;
+@synthesize numHeaderRows;
- (id) init
@@ -75,74 +76,13 @@ - (void) dealloc
#ifndef IPHONE
self.rowController = nil;
#endif
- self.headerRows = nil;
[super dealloc];
}
#pragma mark -
-#pragma mark KVC
-- (void) setColumnDict:(NSDictionary *)newColumnDict
-{
- if (newColumnDict != columnDict) {
- [columnDict release];
- columnDict = [newColumnDict retain];
- }
-}
-
-- (NSUInteger) numHeaderRows
-{
- return numHeaderRows;
-}
-- (void) setNumHeaderRows:(NSUInteger)newNum
-{
- // MOVE all current header rows to the body
- if ([headerRows count] > 0) {
- for (CSVRow *hr in headerRows) {
-#ifdef IPHONE
- [rows insertObject:hr atIndex:0];
-#else
- [rowController insertObject:hr atArrangedObjectIndex:0];
-#endif
- hr.isHeaderRow = NO;
- [headerRows removeObject:hr];
- }
- }
-
- // COPY data from the first x rows to the header and remove the rows from the body
- if (newNum > 0) {
- NSUInteger i;
- for (i = 0; i < newNum; i++) {
- if ([rows count] > i) {
-#ifdef IPHONE
- [self setHeaderRow:[rows objectAtIndex:i]];
- [rows removeObjectAtIndex:i];
-#else
- [self setHeaderRow:[[rowController arrangedObjects] objectAtIndex:i]];
- [rowController removeObjectAtArrangedObjectIndex:i];
-#endif
- }
- }
- }
-
- // update num rows
- [self setNumRowsWithInt:[rows count]];
-
- numHeaderRows = newNum;
-}
-
-- (void) setNumRowsWithInt:(NSInteger)num_rows
-{
- [self willChangeValueForKey:@"numRows"];
- self.numRows = [NSNumber numberWithInt:num_rows];
- [self didChangeValueForKey:@"numRows"];
-}
-#pragma mark -
-
-
-
#pragma mark Parsing
- (NSUInteger) numRowsToExpect:(NSString *)string
{
@@ -345,17 +285,16 @@ - (BOOL) parseCSVString:(NSString *)string maxRows:(NSUInteger)maxRows error:(NS
}
- // one row scanned - add to our header and body arrays and save the columns
+ // one row scanned - add to our array, save the columns and report to delegate if desired
+ [rows addObject:newRow];
+
if (num_rows >= numHeaderRows) {
- [rows addObject:newRow];
-
- // report to delegate if desired
if (sendRowUpdateToDelegate) {
[self performSelectorOnMainThread:@selector(notifyDelegateOfParsedRow:) withObject:newRow waitUntilDone:NO];
}
}
else {
- [self setHeaderRow:newRow];
+ newRow.headerRow = YES;
}
num_rows++;
@@ -415,19 +354,12 @@ - (NSString *) stringInFormat:(PPStringFormat *)format withColumns:(NSArray *)co
format = [PPStringFormat csvFormat];
}
-
// extract keys from column objects
NSMutableArray *columnKeys = [NSMutableArray arrayWithCapacity:[columnArray count]];
for (CSVColumn *column in columnArray) {
[columnKeys addObject:column.key];
}
- // get header row
-// NSArray *headerRows = nil;
-// if (headerFlag && (nil != headerRow)) {
-// headerRows = [NSArray arrayWithObject:headerRow];
-// }
-
// get desired row indexes if not given
if (nil == rowIndexes) {
if (NSNotFound == [rowController selectionIndex]) {
@@ -440,9 +372,8 @@ - (NSString *) stringInFormat:(PPStringFormat *)format withColumns:(NSArray *)co
}
NSArray *exportRows = [[rowController arrangedObjects] objectsAtIndexes:rowIndexes];
-
// get the string from the formatter
- return [format stringForRows:exportRows headerRows:headerRows withKeys:columnKeys];
+ return [format stringForRows:exportRows includeHeaderRows:headerFlag withColumnKeys:columnKeys];
}
#endif
#pragma mark -
@@ -482,20 +413,6 @@ - (BOOL) isFirstColumnKey:(NSString *)columnKey
return NO;
}
-- (void) setHeaderRow:(CSVRow *)newHeaderRow
-{
- if (newHeaderRow ) {
- newHeaderRow.isHeaderRow = YES;
- [headerRows addObject:newHeaderRow];
-
- // update column names (if they don't yet have a name)
- for (CSVColumn *column in columns) {
- if (!column.name) {
- column.name = [newHeaderRow valueForColumn:column];
- }
- }
- }
-}
- (BOOL) hasColumnKey:(NSString *)columnKey
{
@@ -551,7 +468,59 @@ - (void) setHeaderActive:(BOOL)active forColumnKey:(NSString *)columnKey
#pragma mark Row Handling
- (CSVRow *) rowAtIndex:(NSUInteger)rowIndex
{
+#ifdef IPHONE
return [rows objectAtIndex:rowIndex];
+#else
+ return [[rowController arrangedObjects] objectAtIndex:rowIndex];
+#endif
+}
+
+- (void) changeNumHeaderRows:(NSUInteger)newNum
+{
+ NSUInteger i;
+ NSUInteger max = (newNum > numHeaderRows) ? newNum : numHeaderRows;
+ NSUInteger num_rows = [rows count];
+
+ for (i = 0; i < max; i++) {
+ if (num_rows > i) {
+ CSVRow *row = [self rowAtIndex:i];
+ [row changeHeaderRow:(i < newNum)];
+ }
+ }
+
+ [self rearrangeRows];
+ self.numHeaderRows = newNum;
+}
+
+- (void) rearrangeRows
+{
+#ifdef IPHONE
+ // TODO: rearrange on iPhone!
+#else
+ [rowController rearrangeObjects];
+#endif
+}
+
+- (void) setNumRowsWithInt:(NSInteger)num_rows
+{
+ [self willChangeValueForKey:@"numRows"];
+ self.numRows = [NSNumber numberWithInt:num_rows];
+ [self didChangeValueForKey:@"numRows"];
+}
+
+- (void) row:(CSVRow *)thisRow didBecomeHeaderRow:(BOOL)itDid
+{
+ if (itDid) {
+ numHeaderRows += 1;
+ }
+ else {
+ numHeaderRows -= 1;
+ }
+
+ [self rearrangeRows];
+ if ([delegate respondsToSelector:@selector(csvDocument:didChangeRowOrderToOriginalOrder:)]) {
+ [delegate csvDocument:self didChangeRowOrderToOriginalOrder:NO];
+ }
}
#pragma mark -
View
2 CSVDocument/CSVDocumentDelegate.h
@@ -24,4 +24,6 @@
- (void) csvDocument:(CSVDocument *)document didParseNumRows:(NSUInteger)num_parsed;
- (void) csvDocument:(CSVDocument *)document didParseRow:(CSVRow *)row;
+- (void) csvDocument:(CSVDocument *)document didChangeRowOrderToOriginalOrder:(BOOL)isOriginalOrder;
+
@end
View
8 CSVDocument/CSVRow.h
@@ -21,12 +21,14 @@
@interface CSVRow : NSObject <NSCopying> {
CSVDocument *document;
NSMutableDictionary *rowValues;
- BOOL isHeaderRow;
+ BOOL headerRow;
+ NSUInteger headerRowPosition; // starts at 1 (uppermost row)
}
@property (nonatomic, assign) CSVDocument *document;
@property (nonatomic, copy) NSMutableDictionary *rowValues;
-@property (nonatomic, assign) BOOL isHeaderRow;
+@property (nonatomic, assign, getter=isHeaderRow) BOOL headerRow;
+@property (nonatomic, assign) NSUInteger headerRowPosition;
+ (id) rowForDocument:(CSVDocument *)forDocument;
+ (id) rowFromDict:(NSMutableDictionary *)dict forDocument:(CSVDocument *)forDocument;
@@ -44,5 +46,7 @@
- (void) setValue:(id)value forColumn:(CSVColumn *)column;
- (void) setValue:(id)value forColumnKey:(NSString *)key;
+- (void) changeHeaderRow:(BOOL)isHeader; // changes the header row status without telling the document - only the document should use this!
+
@end
View
38 CSVDocument/CSVRow.m
@@ -14,9 +14,12 @@
@implementation CSVRow
+static NSUInteger highestHeaderRowPos = 0;
+
@synthesize document;
@synthesize rowValues;
-@synthesize isHeaderRow;
+@dynamic headerRow;
+@synthesize headerRowPosition;
+ (id) rowForDocument:(CSVDocument *)forDocument
@@ -43,6 +46,7 @@ - (id) init
self = [super init];
if (self) {
rowValues = [[NSMutableDictionary alloc] init]; // done manually to prevent copying the new object (self.rowValues is a COPY property)
+ headerRowPosition = UINT_MAX;
}
return self;
@@ -68,6 +72,38 @@ - (void) dealloc
+#pragma mark KVC
+- (BOOL) isHeaderRow
+{
+ return headerRow;
+}
+- (void) setHeaderRow:(BOOL)isHeader
+{
+ if (isHeader != headerRow) {
+ [self changeHeaderRow:isHeader];
+ [document row:self didBecomeHeaderRow:headerRow];
+ }
+}
+
+- (void) changeHeaderRow:(BOOL)isHeader
+{
+ // this _silently_ changes the headerRow flag, only use from ourself or self.document!
+ [self willChangeValueForKey:@"headerRow"];
+ headerRow = isHeader;
+ [self didChangeValueForKey:@"headerRow"];
+
+ if (headerRow) {
+ highestHeaderRowPos += 1;
+ self.headerRowPosition = highestHeaderRowPos;
+ }
+ else {
+ self.headerRowPosition = UINT_MAX;
+ }
+}
+#pragma mark -
+
+
+
#pragma mark Returning Column Values
- (NSArray *) valuesForColumns:(NSArray *)columns
{
View
2 CSVDocument/CSVRowController.h
@@ -14,9 +14,11 @@
@interface CSVRowController : NSArrayController {
CSVDocument *document;
+ NSSortDescriptor *headerSortDescriptor;
}
@property (nonatomic, assign) CSVDocument *document;
+@property (nonatomic, retain) NSSortDescriptor *headerSortDescriptor;
@end
View
54 CSVDocument/CSVRowController.m
@@ -15,7 +15,61 @@
@implementation CSVRowController
@synthesize document;
+@dynamic headerSortDescriptor;
+
+- (id) initWithContent:(id)content
+{
+ self = [super initWithContent:content];
+ if (self) {
+ [self setSortDescriptors:nil];
+ }
+ return self;
+}
+
+- (void) dealloc
+{
+ self.headerSortDescriptor = nil;
+
+ [super dealloc];
+}
+#pragma mark -
+
+
+
+#pragma mark KVC
+- (NSSortDescriptor *) headerSortDescriptor
+{
+ if (nil == headerSortDescriptor) {
+ self.headerSortDescriptor = [[[NSSortDescriptor alloc] initWithKey:@"headerRowPosition" ascending:YES] autorelease];
+ }
+ return headerSortDescriptor;
+}
+- (void) setHeaderSortDescriptor:(NSSortDescriptor *)newDescriptor
+{
+ if (newDescriptor != headerSortDescriptor) {
+ [headerSortDescriptor release];
+ headerSortDescriptor = [newDescriptor retain];
+ }
+}
+#pragma mark -
+
+
+
+#pragma mark Sorting
+- (void) setSortDescriptors:(NSArray *)newSortDescriptors
+{
+ NSMutableArray *newDesc = [NSMutableArray arrayWithObject:self.headerSortDescriptor]; // keeps the header rows on top
+ if (nil != newSortDescriptors) {
+ [newDesc addObjectsFromArray:newSortDescriptors];
+ }
+ [super setSortDescriptors:[[newDesc copy] autorelease]];
+}
+#pragma mark -
+
+
+
+#pragma mark Objects
- (id) newObject
{
return [[CSVRow rowForDocument:document] retain];
View
2,957 CSVManipulator.xcodeproj/pp.pbxuser
506 additions, 2,451 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
138 CSVManipulator.xcodeproj/pp.perspectivev3
@@ -270,6 +270,7 @@
<string>2A37F4AAFDCFA73011CA2CEA</string>
<string>2A37F4ABFDCFA73011CA2CEA</string>
<string>EE9E14C21043DA5D00554687</string>
+ <string>EE64B59F1049D9C5000DF5D2</string>
<string>EE1512230D7F04910092C02F</string>
<string>2A37F4B8FDCFA73011CA2CEA</string>
<string>2A37F4C3FDCFA73011CA2CEA</string>
@@ -278,7 +279,8 @@
<key>PBXSmartGroupTreeModuleOutlineStateSelectionKey</key>
<array>
<array>
- <integer>9</integer>
+ <integer>36</integer>
+ <integer>30</integer>
<integer>1</integer>
<integer>0</integer>
</array>
@@ -303,7 +305,7 @@
<real>235</real>
</array>
<key>RubberWindowFrame</key>
- <string>140 102 1430 926 0 0 1680 1028 </string>
+ <string>118 102 1430 926 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>PBXSmartGroupTreeModule</string>
@@ -321,19 +323,19 @@
<key>PBXProjectModuleGUID</key>
<string>EEF027910D6D8015000532A4</string>
<key>PBXProjectModuleLabel</key>
- <string>CSVWindowController.m</string>
+ <string>DataTableHeaderView.m</string>
<key>PBXSplitModuleInNavigatorKey</key>
<dict>
<key>Split0</key>
<dict>
<key>PBXProjectModuleGUID</key>
<string>EEF027920D6D8015000532A4</string>
<key>PBXProjectModuleLabel</key>
- <string>CSVWindowController.m</string>
+ <string>DataTableHeaderView.m</string>
<key>_historyCapacity</key>
<integer>0</integer>
<key>bookmark</key>
- <string>EE219F71107F932100E28D4D</string>
+ <string>EEF073D710863EC800C05DE9</string>
<key>history</key>
<array>
<string>EECAA3C10D803E5200AE2D4A</string>
@@ -343,7 +345,6 @@
<string>EEE8F5260F13DBE80081E83D</string>
<string>EE9E112F1042D26300554687</string>
<string>EE9E11301042D26300554687</string>
- <string>EE9E1BDA10457EF500554687</string>
<string>EE9E24081048283F00554687</string>
<string>EE9E241410482B3300554687</string>
<string>EE64B60C1049E8A1000DF5D2</string>
@@ -353,37 +354,40 @@
<string>EE64B714104AADA2000DF5D2</string>
<string>EE64B715104AADA2000DF5D2</string>
<string>EE64B88A104AB914000DF5D2</string>
- <string>EE64B89E104ABE30000DF5D2</string>
<string>EE64B8F1104AC0BF000DF5D2</string>
- <string>EE64B905104AC1BA000DF5D2</string>
- <string>EE64B91E104AC4E4000DF5D2</string>
<string>EECDB98B104AC66700260BC7</string>
<string>EECDB98C104AC66700260BC7</string>
<string>EECDB98D104AC66700260BC7</string>
<string>EECDBB8D104DA80900260BC7</string>
- <string>EECDBB8E104DA80900260BC7</string>
<string>EE219E59107F71C000E28D4D</string>
- <string>EE219E72107F724200E28D4D</string>
- <string>EE219E74107F724200E28D4D</string>
- <string>EE219E89107F732A00E28D4D</string>
- <string>EE219E8C107F732A00E28D4D</string>
- <string>EE219EAE107F820500E28D4D</string>
- <string>EE219EAF107F820500E28D4D</string>
- <string>EE219EB1107F820500E28D4D</string>
- <string>EE219EB2107F820500E28D4D</string>
- <string>EE219EB3107F820500E28D4D</string>
- <string>EE219ED6107F859F00E28D4D</string>
- <string>EE219EE8107F86B100E28D4D</string>
- <string>EE219F10107F8A2200E28D4D</string>
- <string>EE219F32107F8EAC00E28D4D</string>
- <string>EE219F33107F8EAC00E28D4D</string>
- <string>EE219F34107F8EAC00E28D4D</string>
- <string>EE219F35107F8EAC00E28D4D</string>
- <string>EE219F37107F8EAC00E28D4D</string>
- <string>EE219F58107F918600E28D4D</string>
- <string>EE219F6A107F931600E28D4D</string>
- <string>EE219F6B107F931600E28D4D</string>
- <string>EE219F6C107F931600E28D4D</string>
+ <string>EEF0713F108608EF00C05DE9</string>
+ <string>EEF0715410860BCE00C05DE9</string>
+ <string>EEF0715510860BCE00C05DE9</string>
+ <string>EEF071691086102700C05DE9</string>
+ <string>EEF0716A1086102700C05DE9</string>
+ <string>EEF071D51086164200C05DE9</string>
+ <string>EEF071F5108618B000C05DE9</string>
+ <string>EEF071F6108618B000C05DE9</string>
+ <string>EEF0720B10861CB100C05DE9</string>
+ <string>EEF0720D10861CB100C05DE9</string>
+ <string>EEF0720E10861CB100C05DE9</string>
+ <string>EEF0720F10861CB100C05DE9</string>
+ <string>EEF0724B1086225A00C05DE9</string>
+ <string>EEF0724C1086225A00C05DE9</string>
+ <string>EEF0724D1086225A00C05DE9</string>
+ <string>EEF072851086275100C05DE9</string>
+ <string>EEF072A010862AAB00C05DE9</string>
+ <string>EEF072A110862AAB00C05DE9</string>
+ <string>EEF072AD10862B2900C05DE9</string>
+ <string>EEF072BF10862B8A00C05DE9</string>
+ <string>EEF072F2108630B900C05DE9</string>
+ <string>EEF072F4108630B900C05DE9</string>
+ <string>EEF07359108634CE00C05DE9</string>
+ <string>EEF073621086351600C05DE9</string>
+ <string>EEF0737B1086376200C05DE9</string>
+ <string>EEF073831086383400C05DE9</string>
+ <string>EEF073D510863EC800C05DE9</string>
+ <string>EEF073D610863EC800C05DE9</string>
</array>
</dict>
<key>SplitCount</key>
@@ -399,7 +403,7 @@
<key>Frame</key>
<string>{{0, 0}, {1151, 880}}</string>
<key>RubberWindowFrame</key>
- <string>140 102 1430 926 0 0 1680 1028 </string>
+ <string>118 102 1430 926 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>PBXNavigatorGroup</string>
@@ -422,7 +426,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{10, 27}, {1123, -27}}</string>
+ <string>{{10, 27}, {1151, -27}}</string>
</dict>
<key>Module</key>
<string>XCDetailModule</string>
@@ -440,7 +444,7 @@
<key>Frame</key>
<string>{{10, 27}, {1151, -27}}</string>
<key>RubberWindowFrame</key>
- <string>140 102 1430 926 0 0 1680 1028 </string>
+ <string>118 102 1430 926 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>PBXProjectFindModule</string>
@@ -455,11 +459,11 @@
<key>PBXCVSModuleTreeModuleColumnWidthsKey</key>
<array>
<real>200</real>
- <real>56.66162109375</real>
+ <real>56</real>
<real>63</real>
<real>60</real>
<real>63</real>
- <real>139.556640625</real>
+ <real>139</real>
</array>
<key>PBXCVSModuleTreeModuleColumnsKey</key>
<array>
@@ -499,7 +503,7 @@
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{{10, 27}, {1128, -27}}</string>
+ <string>{{10, 27}, {1151, -27}}</string>
</dict>
<key>Module</key>
<string>PBXBuildResultsModule</string>
@@ -527,11 +531,11 @@
</array>
<key>TableOfContents</key>
<array>
- <string>EE219E42107F6F3500E28D4D</string>
+ <string>EEF070F81085B2DA00C05DE9</string>
<string>1CA23ED40692098700951B8B</string>
- <string>EE219E43107F6F3500E28D4D</string>
+ <string>EEF070F91085B2DA00C05DE9</string>
<string>EEF027910D6D8015000532A4</string>
- <string>EE219E44107F6F3500E28D4D</string>
+ <string>EEF070FA1085B2DA00C05DE9</string>
<string>1CA23EDF0692099D00951B8B</string>
<string>1CA23EE00692099D00951B8B</string>
<string>1CA23EE10692099D00951B8B</string>
@@ -549,6 +553,7 @@
<string>NSToolbarSeparatorItem</string>
<string>active-combo-popup</string>
<string>NSToolbarFlexibleSpaceItem</string>
+ <string>debugger-enable-breakpoints</string>
<string>build-and-go</string>
<string>go</string>
<string>NSToolbarFlexibleSpaceItem</string>
@@ -679,14 +684,14 @@
</array>
<key>TableOfContents</key>
<array>
- <string>EE219E77107F724200E28D4D</string>
+ <string>EEF07110108602A000C05DE9</string>
<string>1CCC7628064C1048000F2A68</string>
<string>1CCC7629064C1048000F2A68</string>
- <string>EE219E78107F724200E28D4D</string>
- <string>EE219E79107F724200E28D4D</string>
- <string>EE219E7A107F724200E28D4D</string>
- <string>EE219E7B107F724200E28D4D</string>
- <string>EE219E7C107F724200E28D4D</string>
+ <string>EEF07111108602A000C05DE9</string>
+ <string>EEF07112108602A000C05DE9</string>
+ <string>EEF07113108602A000C05DE9</string>
+ <string>EEF07114108602A000C05DE9</string>
+ <string>EEF027910D6D8015000532A4</string>
</array>
<key>ToolbarConfigUserDefaultsMinorVersion</key>
<string>2</string>
@@ -718,13 +723,13 @@
<integer>5</integer>
<key>WindowOrderList</key>
<array>
- <string>EE219F72107F932100E28D4D</string>
- <string>EE219E96107F736F00E28D4D</string>
- <string>EE219E97107F736F00E28D4D</string>
+ <string>EEF071321086083800C05DE9</string>
+ <string>EEF07116108602A000C05DE9</string>
+ <string>EEF07117108602A000C05DE9</string>
<string>/Users/pp/Cocoa/CSVManipulator/CSVManipulator.xcodeproj</string>
</array>
<key>WindowString</key>
- <string>140 102 1430 926 0 0 1680 1028 </string>
+ <string>118 102 1430 926 0 0 1680 1028 </string>
<key>WindowToolsV3</key>
<array>
<dict>
@@ -1509,33 +1514,40 @@
<string>597 125 616 374 0 0 1280 1002 </string>
</dict>
<dict>
+ <key>FirstTimeWindowDisplayed</key>
+ <false/>
<key>Identifier</key>
<string>windowTool.refactoring</string>
<key>IncludeInToolsMenu</key>
<integer>0</integer>
+ <key>IsVertical</key>
+ <true/>
<key>Layout</key>
<array>
<dict>
<key>Dock</key>
<array>
<dict>
- <key>BecomeActive</key>
- <integer>1</integer>
+ <key>ContentConfiguration</key>
+ <dict>
+ <key>PBXProjectModuleGUID</key>
+ <string>EEF071311086083800C05DE9</string>
+ </dict>
<key>GeometryConfiguration</key>
<dict>
<key>Frame</key>
- <string>{0, 0}, {500, 335}</string>
+ <string>{{0, 0}, {679, 340}}</string>
<key>RubberWindowFrame</key>
- <string>{0, 0}, {500, 335}</string>
+ <string>161 624 679 381 0 0 1680 1028 </string>
</dict>
<key>Module</key>
<string>XCRefactoringModule</string>
<key>Proportion</key>
- <string>100%</string>
+ <string>340pt</string>
</dict>
</array>
<key>Proportion</key>
- <string>100%</string>
+ <string>340pt</string>
</dict>
</array>
<key>Name</key>
@@ -1544,8 +1556,20 @@
<array>
<string>XCRefactoringModule</string>
</array>
+ <key>StatusbarIsVisible</key>
+ <true/>
+ <key>TableOfContents</key>
+ <array>
+ <string>EEF071321086083800C05DE9</string>
+ <string>EEF071331086083800C05DE9</string>
+ <string>EEF071311086083800C05DE9</string>
+ </array>
<key>WindowString</key>
- <string>200 200 500 356 0 0 1920 1200 </string>
+ <string>161 624 679 381 0 0 1680 1028 </string>
+ <key>WindowToolGUID</key>
+ <string>EEF071321086083800C05DE9</string>
+ <key>WindowToolIsVisible</key>
+ <false/>
</dict>
</array>
</dict>
View
6 CSVManipulator.xcodeproj/project.pbxproj
@@ -38,6 +38,7 @@
EEC9006A0DD04898006716F9 /* CSVManipulatorIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = EEC900690DD04898006716F9 /* CSVManipulatorIcon.icns */; };
EEE8F3B50F13AA720081E83D /* CSVWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = EEE8F3B40F13AA720081E83D /* CSVWindowController.m */; };
EEE8FA460F1523B70081E83D /* AppController.m in Sources */ = {isa = PBXBuildFile; fileRef = EEE8FA450F1523B70081E83D /* AppController.m */; };
+ EEF072F01086302800C05DE9 /* DataTableHeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = EEF072EF1086302700C05DE9 /* DataTableHeaderView.m */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -101,6 +102,8 @@
EEE8F3B40F13AA720081E83D /* CSVWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSVWindowController.m; sourceTree = "<group>"; };
EEE8FA440F1523B70081E83D /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
EEE8FA450F1523B70081E83D /* AppController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppController.m; sourceTree = "<group>"; };
+ EEF072EE1086302700C05DE9 /* DataTableHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataTableHeaderView.h; sourceTree = "<group>"; };
+ EEF072EF1086302700C05DE9 /* DataTableHeaderView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DataTableHeaderView.m; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -221,6 +224,8 @@
EE0D3A290D6F02350009A7B2 /* DataTableView.m */,
EE15121C0D7F048D0092C02F /* DataTableColumn.h */,
EE15121D0D7F048D0092C02F /* DataTableColumn.m */,
+ EEF072EE1086302700C05DE9 /* DataTableHeaderView.h */,
+ EEF072EF1086302700C05DE9 /* DataTableHeaderView.m */,
EE15121E0D7F048D0092C02F /* DataTableHeaderCell.h */,
EE15121F0D7F048D0092C02F /* DataTableHeaderCell.m */,
EE219ED3107F849100E28D4D /* DataTableCell.h */,
@@ -353,6 +358,7 @@
EE64B6F9104A9648000DF5D2 /* PPStringFormatEntity.m in Sources */,
EE64B6FE104A9761000DF5D2 /* PPStringFormatRow.m in Sources */,
EE219ED5107F849100E28D4D /* DataTableCell.m in Sources */,
+ EEF072F01086302800C05DE9 /* DataTableHeaderView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
17 CSVWindowController.m
@@ -123,7 +123,8 @@ - (IBAction) restoreOriginalOrder:(id)sender;
- (void) didRestoreOriginalOrder
{
[mainTable setSortDescriptors:nil];
- [mainTable reallySetSortDescriptorsWithColumn:nil]; // necessary since we have overridden setSortDescriptors:
+ [mainTable setSortDescriptorsWithColumn:nil]; // necessary since we have overridden setSortDescriptors:
+ [[mainTable headerView] setNeedsDisplay:YES];
}
#pragma mark -
@@ -136,6 +137,7 @@ - (void) redefineTable
for (NSTableColumn *oldColumn in [mainTable tableColumns]) {
[[oldColumn headerCell] unbind:@"stringValue"];
[[oldColumn headerCell] unbind:@"checked"];
+ [[oldColumn dataCell] unbind:@"titleCell"];
[oldColumn unbind:@"value"];
[mainTable removeTableColumn:oldColumn];
}
@@ -151,7 +153,7 @@ - (void) redefineTable
[firstTableColumn setIdentifier:@"_isHeaderRowColumn"];
[firstTableColumn setDataCell:firstDataCell];
[firstTableColumn setWidth:firstColumnWidth];
- [firstTableColumn setResizable:NO];
+ firstTableColumn.resizingMask = NSTableColumnNoResizing;
[[firstTableColumn headerCell] setTitle:@"H"];
[[firstTableColumn headerCell] setShowsCheckbox:NO];
@@ -183,11 +185,11 @@ - (void) redefineTable
for (DataTableColumn *tableColumn in [mainTable tableColumns]) {
NSString *key = [tableColumn identifier];
- // first column
+ // first column with checkboxes
if ([@"_isHeaderRowColumn" isEqualToString:key]) {
[tableColumn bind:@"value"
toObject:document.csvDocument.rowController
- withKeyPath:@"arrangedObjects.isHeaderRow"
+ withKeyPath:@"arrangedObjects.headerRow"
options:nil];
}
@@ -201,7 +203,7 @@ - (void) redefineTable
// also bind column header
[[tableColumn headerCell] bind:@"stringValue"
toObject:document.csvDocument.columnDict
- withKeyPath:[NSString stringWithFormat:@"%@.name", key]
+ withKeyPath:[NSString stringWithFormat:@"%@.type", key]
options:nil];
[[tableColumn headerCell] bind:@"checked"
toObject:document.csvDocument.columnDict
@@ -231,6 +233,7 @@ - (void) tableViewSelectionDidChange:(NSNotification *)notification
}
}
+/*
- (void) tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn
{
if (mainTable == tableView) {
@@ -254,12 +257,12 @@ - (void) tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *
// hit the column header title
else {
// TODO: Improve
- [(DataTableView *)tableView reallySetSortDescriptorsWithColumn:(DataTableColumn *)tableColumn];
+ [(DataTableView *)tableView setSortDescriptorsWithColumn:(DataTableColumn *)tableColumn];
[document setDataIsAtOriginalOrder:NO];
}
}
}
-
+// */
- (void) tableView:(NSTableView *)tableView didDragTableColumn:(NSTableColumn *)tableColumn
{
if(mainTable == tableView) {
View
3 DataTable/DataTableCell.h
@@ -10,9 +10,10 @@
@interface DataTableCell : NSTextFieldCell {
-
+ BOOL isTitleCell;
}
+@property (nonatomic, assign) BOOL isTitleCell;
+ (DataTableCell *) cell;
View
8 DataTable/DataTableCell.m
@@ -11,6 +11,8 @@
@implementation DataTableCell
+@synthesize isTitleCell;
+
- (id) init
{
@@ -33,8 +35,10 @@ + (DataTableCell *) cell
- (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
// highlight background if it's a header row
- if (NO) {
-
+ if (isTitleCell) {
+ NSColor *bgColor = [NSColor redColor];
+ [bgColor setFill];
+ NSRectFill(cellFrame);
}
[super drawWithFrame:cellFrame inView:controlView];
View
1 DataTable/DataTableColumn.h
@@ -17,6 +17,7 @@
@property (nonatomic, retain) DataTableHeaderCell *headerCell;
+ (DataTableColumn *) column;
+- (BOOL) handlesClickAtPoint:(NSPoint)point;
@end
View
8 DataTable/DataTableColumn.m
@@ -41,4 +41,12 @@ - (void) dealloc
#pragma mark -
+
+#pragma mark Events
+- (BOOL) handlesClickAtPoint:(NSPoint)point
+{
+ return NO;
+}
+
+
@end
View
1 DataTable/DataTableHeaderCell.h
@@ -23,6 +23,7 @@
@property (nonatomic, assign, getter=isChecked) BOOL checked;
@property (nonatomic, retain) NSButtonCell *headerCheckbox;
@property (nonatomic, retain) NSTextFieldCell *headerTextfield;
+@property (nonatomic, readonly) BOOL sortAscending;
-(void) setSortAscending:(BOOL)ascending priority:(NSUInteger)priority; // needed to show sort state of the column
View
10 DataTable/DataTableHeaderCell.m
@@ -15,6 +15,7 @@ @implementation DataTableHeaderCell
@synthesize checked;
@synthesize headerCheckbox;
@synthesize headerTextfield;
+@synthesize sortAscending;
- (id) init
@@ -81,12 +82,12 @@ - (void) setChecked:(BOOL)flag
#pragma mark Mouse and state tracking
-/*
-- (BOOL) startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView
+- (NSUInteger) hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView
{
- NSLog(@"start");
+ // TODO: Return if we're interested
+ return [super hitTestForEvent:event inRect:cellFrame ofView:controlView];
}
-
+/*
- (void) stopTracking:(NSPoint)lastPoint at:(NSPoint)stopPoint inView:(NSView *)controlView mouseIsUp:(BOOL)flag
{
NSLog(@"1");
@@ -171,7 +172,6 @@ - (void) drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
textFrame.size.width -= 20 + sortIndicator.size.width;
}
[headerTextfield drawWithFrame:textFrame inView:controlView];
-
[self drawSortIndicatorWithFrame:cellFrame inView:controlView ascending:sortAscending priority:sortPriority];
}
View
16 DataTable/DataTableHeaderView.h
@@ -0,0 +1,16 @@
+//
+// DataTableHeaderView.h
+// CSVManipulator
+//
+// Created by Pascal Pfiffner on 14.10.09.
+// Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+
+
+@interface DataTableHeaderView : NSTableHeaderView {
+
+}
+
+@end
View
42 DataTable/DataTableHeaderView.m
@@ -0,0 +1,42 @@
+//
+// DataTableHeaderView.m
+// CSVManipulator
+//
+// Created by Pascal Pfiffner on 14.10.09.
+// Copyright 2009 __MyCompanyName__. All rights reserved.
+//
+
+#import "DataTableHeaderView.h"
+#import "DataTableView.h"
+#import "DataTableColumn.h"
+
+
+@implementation DataTableHeaderView
+
+
+- (void) mouseDown:(NSEvent *)theEvent
+{
+ NSPoint localPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ NSInteger colIndex = [self columnAtPoint:localPoint];
+
+ // ask the column whether it wants to handle the click
+ DataTableView *myTable = (DataTableView *)[self tableView];
+ NSArray *allColumns = [myTable tableColumns];
+
+ if ([allColumns count] > colIndex) {
+ DataTableColumn *column = [allColumns objectAtIndex:colIndex];
+ NSRect columnRect = [myTable rectOfColumn:colIndex];
+ // TODO: Working here
+ NSLog(@"--> %i at %@", [[column headerCell] hitTestForEvent:theEvent inRect:columnRect ofView:self], NSStringFromRect(columnRect));
+ if ([column handlesClickAtPoint:localPoint]) {
+
+ return;
+ }
+ }
+
+ // not interested, let the header handle the click
+ [super mouseDown:theEvent];
+}
+
+
+@end
View
3 DataTable/DataTableView.h
@@ -15,8 +15,7 @@
NSArray *sortDescriptorsArray;
}
-- (void) setSortDescriptors:(NSArray *) array;
-- (void) reallySetSortDescriptorsWithColumn:(DataTableColumn *)tableColumn;
+- (void) setSortDescriptorsWithColumn:(DataTableColumn *)tableColumn;
@end
View
48 DataTable/DataTableView.m
@@ -9,48 +9,62 @@
#import "DataTableView.h"
#import "MyDocument.h"
#import "DataTableColumn.h"
+#import "DataTableHeaderView.h"
#import "DataTableHeaderCell.h"
@implementation DataTableView
+#pragma mark Generic
+- (void) dealloc
+{
+ [sortDescriptorsArray release];
+
+ [super dealloc];
+}
+#pragma mark -
+
+
#pragma mark Tasks
+- (void) awakeFromNib
+{
+ // exchange the header view
+ if (nil != [self headerView]) {
+ NSRect frame = [[self headerView] frame];
+ DataTableHeaderView *newHeader = [[[DataTableHeaderView alloc] initWithFrame:frame] autorelease];
+ [self setHeaderView:newHeader];
+ }
+}
+
// this controls sorting - overridden since we don't want the table to re-sort when we click the checkbox in the header, we...
- (void) setSortDescriptors:(NSArray *) array
{
- if(sortDescriptorsArray != array) {
+ if (sortDescriptorsArray != array) {
[sortDescriptorsArray release];
sortDescriptorsArray = [array retain];
}
}
// ...call the super implementation ourselves whenever necessary
-- (void) reallySetSortDescriptorsWithColumn:(DataTableColumn *)tableColumn
+- (void) setSortDescriptorsWithColumn:(DataTableColumn *)tableColumn
{
[super setSortDescriptors:sortDescriptorsArray];
- // TODO: don't sort headerRows, keep them in the same order
-
// make the header cell indicate sort status
- BOOL ascending = [[sortDescriptorsArray objectAtIndex:0] ascending];
+ BOOL ascending = NO;
for (DataTableColumn *column in [self tableColumns]) {
- NSUInteger priority = (column == tableColumn) ? 0 : 1;
- [column.headerCell setSortAscending:ascending priority:priority];
+ ascending = column.headerCell.sortAscending;
+ if (column == tableColumn) {
+ [column.headerCell setSortAscending:!ascending priority:0];
+ }
+ else {
+ [column.headerCell setSortAscending:ascending priority:1];
+ }
}
}
#pragma mark -
-
-#pragma mark Generic
-- (void) dealloc
-{
- [sortDescriptorsArray release];
-
- [super dealloc];
-}
-
-
@end
View
59 English.lproj/MyDocument.xib
@@ -12,7 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="6"/>
+ <integer value="100021"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -181,8 +181,7 @@
<reference key="NSSuperview" ref="89752285"/>
<reference key="NSTarget" ref="89752285"/>
<string key="NSAction">_doScroller:</string>
- <double key="NSCurValue">37</double>
- <double key="NSPercent">0.19473679999999999</double>
+ <double key="NSPercent">0.99781181619256021</double>
</object>
<object class="NSScroller" id="296744106">
<reference key="NSNextResponder" ref="89752285"/>
@@ -192,7 +191,7 @@
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="89752285"/>
<string key="NSAction">_doScroller:</string>
- <double key="NSPercent">0.57142859999999995</double>
+ <double key="NSPercent">0.99833333333333329</double>
</object>
<object class="NSClipView" id="428654708">
<reference key="NSNextResponder" ref="89752285"/>
@@ -234,8 +233,8 @@
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="406420303">
<int key="NSCellFlags">67239488</int>
- <int key="NSCellFlags2">71304192</int>
- <real value="0.0" key="NSContents"/>
+ <int key="NSCellFlags2">-2076179456</int>
+ <string key="NSContents">0 Rows</string>
<reference key="NSSupport" ref="673817840"/>
<object class="NSNumberFormatter" key="NSFormatter" id="938513733">
<object class="NSMutableDictionary" key="NS.attributes">
@@ -245,7 +244,9 @@
<string>allowsFloats</string>
<string>formatterBehavior</string>
<string>locale</string>
+ <string>negativeFormat</string>
<string>negativeSuffix</string>
+ <string>positiveFormat</string>
<string>positiveSuffix</string>
</object>
<object class="NSMutableArray" key="dict.values">
@@ -255,12 +256,14 @@
<object class="NSLocale" id="483218863">
<string key="NS.identifier"/>
</object>
- <string> Entries</string>
- <string> Entries</string>
+ <string># 'Rows'</string>
+ <string> Rows</string>
+ <string>#' Rows'</string>
+ <string> Rows</string>
</object>
</object>
- <string key="NS.positiveformat">#' Entries'</string>
- <string key="NS.negativeformat">#' Entries'</string>
+ <string key="NS.positiveformat">#' Rows'</string>
+ <string key="NS.negativeformat"># 'Rows'</string>
<nil key="NS.positiveattrs"/>
<nil key="NS.negativeattrs"/>
<nil key="NS.zero"/>
@@ -291,7 +294,7 @@
<bool key="NS.raise.dividebyzero">YES</bool>
</object>
<string key="NS.decimal">.</string>
- <string key="NS.thousand">'</string>
+ <string key="NS.thousand">,</string>
<bool key="NS.hasthousands">NO</bool>
<bool key="NS.localized">NO</bool>
<bool key="NS.allowsfloats">YES</bool>
@@ -493,7 +496,7 @@
<bool key="NS.raise.dividebyzero">YES</bool>
</object>
<string key="NS.decimal">.</string>
- <string key="NS.thousand">'</string>
+ <string key="NS.thousand">,</string>
<bool key="NS.hasthousands">NO</bool>
<bool key="NS.localized">NO</bool>
<bool key="NS.allowsfloats">YES</bool>
@@ -541,7 +544,7 @@
<string key="NSWindowContentMaxSize">{4000, 235}</string>
<string key="NSWindowContentMinSize">{400, 235}</string>
<object class="NSView" key="NSWindowView" id="811720722">
- <reference key="NSNextResponder"/>
+ <nil key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -550,7 +553,6 @@
<int key="NSvFlags">289</int>
<string key="NSFrame">{{290, 12}, {96, 32}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="675528196">
<int key="NSCellFlags">67239424</int>
@@ -571,7 +573,6 @@
<int key="NSvFlags">290</int>
<string key="NSFrame">{{18, 159}, {364, 18}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="232843893">
<int key="NSCellFlags">-2080244224</int>
@@ -599,7 +600,6 @@
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 109}, {360, 22}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="708811634">
<int key="NSCellFlags">-1804468671</int>
@@ -627,7 +627,6 @@
<int key="NSvFlags">34</int>
<string key="NSFrame">{{20, 98}, {360, 5}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@@ -650,7 +649,6 @@
<int key="NSvFlags">34</int>
<string key="NSFrame">{{20, 181}, {360, 5}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
@@ -673,7 +671,6 @@
<int key="NSvFlags">292</int>
<string key="NSFrame">{{17, 197}, {101, 17}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="404181999">
<int key="NSCellFlags">68288064</int>
@@ -690,7 +687,6 @@
<int key="NSvFlags">290</int>
<string key="NSFrame">{{20, 48}, {360, 22}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="862304136">
<int key="NSCellFlags">-1804468671</int>
@@ -708,7 +704,6 @@
<int key="NSvFlags">290</int>
<string key="NSFrame">{{120, 191}, {263, 26}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSPopUpButtonCell" key="NSCell" id="956477537">
<int key="NSCellFlags">-2076049856</int>
@@ -792,7 +787,6 @@
<int key="NSvFlags">290</int>
<string key="NSFrame">{{17, 78}, {366, 14}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="958331477">
<int key="NSCellFlags">68288064</int>
@@ -809,7 +803,6 @@
<int key="NSvFlags">290</int>
<string key="NSFrame">{{17, 139}, {366, 14}}</string>
<reference key="NSSuperview" ref="811720722"/>
- <reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="945635971">
<int key="NSCellFlags">68288064</int>
@@ -823,8 +816,6 @@
</object>
</object>
<string key="NSFrameSize">{400, 235}</string>
- <reference key="NSSuperview"/>
- <reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMinSize">{400, 251}</string>
@@ -1148,11 +1139,6 @@
<reference key="parent" ref="89752285"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">100025</int>
- <reference key="object" ref="990262597"/>
- <reference key="parent" ref="89752285"/>
- </object>
- <object class="IBObjectRecord">
<int key="objectID">100026</int>
<reference key="object" ref="427106693"/>
<object class="NSMutableArray" key="children">
@@ -1512,6 +1498,11 @@
<reference key="object" ref="33817122"/>
<reference key="parent" ref="811720722"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">100343</int>
+ <reference key="object" ref="990262597"/>
+ <reference key="parent" ref="89752285"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1524,7 +1515,6 @@
<string>100023.IBPluginDependency</string>
<string>100024.CustomClassName</string>
<string>100024.IBPluginDependency</string>
- <string>100025.IBPluginDependency</string>
<string>100026.IBPluginDependency</string>
<string>100029.IBPluginDependency</string>
<string>100034.CustomClassName</string>
@@ -1612,7 +1602,6 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>PPToolbarButton</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1678,9 +1667,9 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{238, 336}, {600, 500}}</string>
+ <string>{{389, 387}, {600, 500}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{238, 336}, {600, 500}}</string>
+ <string>{{389, 387}, {600, 500}}</string>
<integer value="1"/>
<string>{{383, 256}, {700, 500}}</string>
<integer value="1"/>
@@ -1705,7 +1694,7 @@
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">100342</int>
+ <int key="maxID">100343</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
View
6 FileExport/PPStringFormat.h
@@ -33,10 +33,10 @@
+ (PPStringFormat *) tabFormat;
+ (PPStringFormat *) flatXMLFormat;
-- (NSString *) stringForRows:(NSArray *)csvRows headerRows:(NSArray *)headerRows withKeys:(NSArray *)keys;
+- (NSString *) stringForRows:(NSArray *)csvRows includeHeaderRows:(BOOL)includeHeaderRows withColumnKeys:(NSArray *)keys;
-- (NSString *) headerForKeys:(NSArray *)keys values:(NSArray *)values;
-- (NSString *) rowForKeys:(NSArray *)keys values:(NSArray *)values;
+- (NSString *) headerForColumnKeys:(NSArray *)keys values:(NSArray *)values;
+- (NSString *) rowForColumnKeys:(NSArray *)keys values:(NSArray *)values;
@end
View
28 FileExport/PPStringFormat.m
@@ -49,29 +49,23 @@ - (void) dealloc
#pragma mark Formatting
-- (NSString *) stringForRows:(NSArray *)csvRows headerRows:(NSArray *)headerRows withKeys:(NSArray *)keys;
+- (NSString *) stringForRows:(NSArray *)csvRows includeHeaderRows:(BOOL)includeHeaderRows withColumnKeys:(NSArray *)keys;
{
NSMutableString *string = nil;
- if (nil != csvRows || nil != headerRows) {
+ if (nil != csvRows) {
string = (nil == prefix) ? [NSMutableString string] : [NSMutableString stringWithString:prefix];
- // add header rows if we have any
- if ([headerRows count] > 0) {
- for (CSVRow *row in headerRows) {
- [string appendString:[headerFormat rowForKeys:keys values:[row valuesForColumnKeys:keys]]];
- }
- }
-
- // add rows if there are any
+ // add rows (if there are any)
if ([csvRows count] > 0) {
NSAutoreleasePool *myPool = [[NSAutoreleasePool alloc] init];
NSUInteger i = 0;
for (CSVRow *row in csvRows) {
- [string appendString:[valueFormat rowForKeys:keys values:[row valuesForColumnKeys:keys]]];
-
- i++;
+ if (includeHeaderRows || !row.isHeaderRow) {
+ [string appendString:[valueFormat rowForColumnKeys:keys values:[row valuesForColumnKeys:keys]]];
+ i++;
+ }
// let's clean the pool from time to time
if (0 == i % 50) {
@@ -90,14 +84,14 @@ - (NSString *) stringForRows:(NSArray *)csvRows headerRows:(NSArray *)headerRows
return string;
}
-- (NSString *) headerForKeys:(NSArray *)keys values:(NSArray *)values;
+- (NSString *) headerForColumnKeys:(NSArray *)keys values:(NSArray *)values;
{
- return [headerFormat rowForKeys:keys values:values];
+ return [headerFormat rowForColumnKeys:keys values:values];
}
-- (NSString *) rowForKeys:(NSArray *)keys values:(NSArray *)values;
+- (NSString *) rowForColumnKeys:(NSArray *)keys values:(NSArray *)values;
{
- return [valueFormat rowForKeys:keys values:values];
+ return [valueFormat rowForColumnKeys:keys values:values];
}
#pragma mark -
View
2 FileExport/PPStringFormatEntity.m
@@ -48,7 +48,7 @@ - (NSString *) stringForKeys:(NSArray *)keys values:(NSArray *)values
NSUInteger i = 0;
for (NSString *key in keys) {
id value = [values objectAtIndex:i];
- NSMutableString *formatted = @"";
+ NSMutableString *formatted = [NSMutableString string];
// NSString
if ([value isKindOfClass:[NSString class]] && (nil != stringformat)) {
View
2 FileExport/PPStringFormatRow.h
@@ -26,7 +26,7 @@
+ (PPStringFormatRow *) row;
-- (NSString *) rowForKeys:(NSArray *)keys values:(NSArray *)values;
+- (NSString *) rowForColumnKeys:(NSArray *)keys values:(NSArray *)values;
@end
View
2 FileExport/PPStringFormatRow.m
@@ -47,7 +47,7 @@ - (void) dealloc
#pragma mark Formatting
-- (NSString *) rowForKeys:(NSArray *)keys values:(NSArray *)values
+- (NSString *) rowForColumnKeys:(NSArray *)keys values:(NSArray *)values
{
NSMutableString *string = nil;
if ((nil != keys) && (nil != format)) {
View
54 MyDocument.m
@@ -45,6 +45,7 @@ - (id) init
if (nil != self) {
exportHeaders = YES;
documentLoaded = YES; // will be set to know when we got instantiated by reading from URL
+ dataIsAtOriginalOrder = YES;
self.csvDocument = [CSVDocument csvDocument];
csvDocument.delegate = self;
@@ -149,8 +150,12 @@ - (void) detachStringParsing:(NSString *)string
[detachPool release];
}
+#pragma mark -
+
-- (void) csvDocumentDidParseNumRows:(NSUInteger)num_parsed
+
+#pragma mark CSVDocument Delegate
+- (void) csvDocument:(CSVDocument *)document didParseNumRows:(NSUInteger)num_parsed
{
CGFloat expecting = (numRowsToExpect > 0) ? (CGFloat)numRowsToExpect : 1.0;
CGFloat percentage = (CGFloat)num_parsed / expecting;
@@ -159,16 +164,23 @@ - (void) csvDocumentDidParseNumRows:(NSUInteger)num_parsed
[mainWindowController updateProgressSheetProgress:percentage];
}
-- (void) csvDocumentDidParseString:(CSVDocument *)doc
+- (void) csvDocumentDidParseString:(CSVDocument *)document
{
- NSLog(@"parsed %@ rows, successful? %i", doc.numRows, doc.parseSuccessful);
self.documentLoaded = YES;
[mainWindowController redefineTable];
[mainWindowController hideProgressSheet];
// did we abort?
- [mainWindowController didAbortImport:csvDocument.didAbortImport];
+ [mainWindowController didAbortImport:document.didAbortImport];
+}
+
+- (void) csvDocument:(CSVDocument *)document didChangeRowOrderToOriginalOrder:(BOOL)isOriginalOrder
+{
+ self.dataIsAtOriginalOrder = isOriginalOrder;
+ if (isOriginalOrder) {
+ [mainWindowController didRestoreOriginalOrder];
+ }
}
#pragma mark -
@@ -249,7 +261,7 @@ - (void) removeFromCSVRow:(id)sender
- (void) restoreOriginalOrder
{
[csvDocument.rowController setSortDescriptors:nil];
- [csvDocument.rowController rearrangeObjects];
+ [csvDocument changeNumHeaderRows:0];
[mainWindowController didRestoreOriginalOrder];
self.dataIsAtOriginalOrder = YES;
@@ -312,12 +324,12 @@ - (void) performCalculationWithArgs:(NSDictionary *)args // designed to run i
while (NO == [scanner isAtEnd]) {
NSMutableString *operationString = [NSMutableString string];
NSString *tempString;
- if([scanner scanUpToString:@"$" intoString:&tempString]) {
+ if ([scanner scanUpToString:@"$" intoString:&tempString]) {
[operationString appendString:tempString];
}
// found a Dollar sign "$"
- if([scanner scanString:@"$" intoString:nil]) {
+ if ([scanner scanString:@"$" intoString:nil]) {
[operationString appendString:@"XX"];
[scanner scanInt:&i];
@@ -380,7 +392,7 @@ - (void) performCalculationWithArgs:(NSDictionary *)args // designed to run i
//NSLog(@"evaluation evaluates to: %@ which results in %@", evaluation, result);
// show progress
- if(0 == currentIndex % 20) {
+ if (0 == currentIndex % 20) {
NSNumber *alreadyDone = [NSNumber numberWithDouble:(double)((float)(currentIndex + 1) / (float)numRows) * 100]; // progress bar goes from 0 to 100
[mainWindowController performSelectorOnMainThread:@selector(updateCalculationStatus:)
withObject:alreadyDone // alreadyDone is automatically retained until selector has finished
@@ -448,11 +460,11 @@ - (BOOL) copySelectionToPasteboard:(NSPasteboard *)pboard forTypes:(NSArray *)ty
}
// copy
- if([typesToDeclare count] > 0) {
+ if ([typesToDeclare count] > 0) {
[pboard declareTypes:typesToDeclare owner:self];
walker = [typesToDeclare objectEnumerator];
while(type = [walker nextObject]) {
- if([self copySelectionToPasteboard:pboard type:type]) {
+ if ([self copySelectionToPasteboard:pboard type:type]) {
result = YES;
}
}
@@ -466,43 +478,43 @@ - (BOOL) copySelectionToPasteboard:(NSPasteboard *)pboard type:(NSString *)type
BOOL result = NO;
// we want a file - provide the file extension
- if([type isEqualToString:NSFilesPromisePboardType]) {
+ if ([type isEqualToString:NSFilesPromisePboardType]) {
result = [pboard setPropertyList:[self fileSuffixesForFormat:self.documentFormat] forType:NSFilesPromisePboardType];
}
// we want a filename - only write to file when actually requested (pasteboard:provideDataForType:)
- // else if([type isEqualToString:NSFilenamesPboardType]) {
+ // else if ([type isEqualToString:NSFilenamesPboardType]) {
// result = YES;
// }
// ---
- else if([type isEqualToString:@"SFVNativePBClassesListPBType08"]) {
+ else if ([type isEqualToString:@"SFVNativePBClassesListPBType08"]) {
NSString *string = @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<array>\n <string>SFTTableInfo</string>\n <string>SFWPStorage</string>\n <string>SFTTableInfo</string>\n</array>\n</plist>\n";
result = [pboard setString:string forType:@"SFVNativePBClassesListPBType08"];
}
- else if([type isEqualToString:@"SFVNativePBMetaDataPBType08"]) {
+ else if ([type isEqualToString:@"SFVNativePBMetaDataPBType08"]) {
NSString *string = @"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n <key>SFVHasPrintableText</key>\n <true/>\n <key>SFVHasTable</key>\n <true/>\n <key>SFVHasText</key>\n <true/>\n</dict>\n</plist>\n";
result = [pboard setString:string forType:@"SFVNativePBMetaDataPBType08"];
}
- else if([type isEqualToString:@"SFVNativePBObject08"]) {
+ else if ([type isEqualToString:@"SFVNativePBObject08"]) {
NSString *string = @"<?xml version=\"1.0\"?>\n <ls:copied-data xmlns:sfa=\"http://developer.apple.com/namespaces/sfa\" xmlns:sf=\"http://developer.apple.com/namespaces/sf\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ls=\"http://developer.apple.com/namespaces/ls\" ls:version=\"72007061400\" sfa:ID=\"SFVPasteboardObject-0\" sf:application-name=\"Numbers 1.0.2\">\n <sf:text sfa:ID=\"SFWPStorage-0\" sf:kind=\"cell\" sf:excl=\"Y\" sf:class=\"text-storage\">\n <sf:text-body>\n <sf:layout sf:style=\"tabular-Basic-body-cell-layout-style-id\">\n <sf:p sf:style=\"tabular-Basic-body-cell-paragraph-style-id\">aaa<sf:tab/>bbb<sf:tab/>ccc<sf:br/>\n </sf:p>\n <sf:p sf:style=\"tabular-Basic-body-cell-paragraph-style-id\">111<sf:tab/>222<sf:tab/>333</sf:p>\n </sf:layout>\n </sf:text-body>\n </sf:text>\n </ls:copied-data>";
result = [pboard setString:string forType:@"SFVNativePBObject08"];
}
// ---
// RTF
- else if([type isEqualToString:NSRTFPboardType]) {
+ else if ([type isEqualToString:NSRTFPboardType]) {
NSAttributedString *attributedString = [[[NSAttributedString alloc] initWithString:[self stringInFormat:[PPStringFormat tabFormat] allRows:NO allColumns:NO]] autorelease];
- if(attributedString && [attributedString length] > 0) {
+ if (attributedString && [attributedString length] > 0) {
result = [pboard setData:[attributedString RTFFromRange:NSMakeRange(0, [attributedString length]) documentAttributes:nil] forType:NSRTFPboardType];
}
}
// Plain Text
- else if([type isEqualToString:NSStringPboardType]) {
+ else if ([type isEqualToString:NSStringPboardType]) {
NSString *string = [self stringInFormat:self.documentFormat allRows:NO allColumns:NO];
- if(string && [string length] > 0) {
+ if (string && [string length] > 0) {
result = [pboard setString:string forType:NSStringPboardType];
}
}
@@ -514,10 +526,10 @@ - (void) pasteboard:(NSPasteboard *)pboard provideDataForType:(NSString *)type
{
// We expect that -tableView:namesOfPromisedFilesDroppedAtDestination:forDraggedRowsWithIndexes: will usually be called instead,
// but we implement this method to create a file if NSFilenamesPboardType is ever requested directly
- if([type isEqualToString:NSFilenamesPboardType]) {
+ if ([type isEqualToString:NSFilenamesPboardType]) {
NSURL *myFileURL = [NSURL URLWithString:[@"~/Desktop" stringByExpandingTildeInPath]];
NSError *error;
- if([self writeToURL:myFileURL ofType:nil error:&error]) {
+ if ([self writeToURL:myFileURL ofType:nil error:&error]) {
[pboard setPropertyList:[NSArray arrayWithObject:[myFileURL path]] forType:NSFilenamesPboardType];
}
}

0 comments on commit 2c88a60

Please sign in to comment.
Something went wrong with that request. Please try again.