From: Neil T. <nt...@us...> - 2006-09-17 15:41:52
|
Update of /cvsroot/pgsqlformac/QueryTool In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2726 Modified Files: QueryTool.h SqlDocument.m TODO.txt Log Message: Add automatic result column resizing. Index: SqlDocument.m =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/SqlDocument.m,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** SqlDocument.m 4 Sep 2006 14:22:07 -0000 1.23 --- SqlDocument.m 17 Sep 2006 15:41:48 -0000 1.24 *************** *** 356,360 **** [working startAnimation:sender]; [status setStringValue:@"Executing Query"]; ! NSMutableString *result = [[NSMutableString alloc] init]; --- 356,361 ---- [working startAnimation:sender]; [status setStringValue:@"Executing Query"]; ! [window displayIfNeeded]; // this is needed until we convert to threaded queries ! // to make sure the window is updated before the query starts. NSMutableString *result = [[NSMutableString alloc] init]; *************** *** 381,387 **** //NSArray *arrQuery = [toBeRun componentsSeparatedByString:@";"]; ! int x; //for (x = 0; x < [arrQuery count]; x++) ! for (x = 0; x < 1; x++) { //NSString *sql = [arrQuery objectAtIndex:x]; --- 382,388 ---- //NSArray *arrQuery = [toBeRun componentsSeparatedByString:@";"]; ! int xx; //for (x = 0; x < [arrQuery count]; x++) ! for (xx = 0; xx < 1; xx++) { //NSString *sql = [arrQuery objectAtIndex:x]; *************** *** 419,426 **** --- 420,429 ---- } dataSource = [[DataSource alloc] init]; + NSMutableArray *maxDataInColumn = [NSMutableArray arrayWithCapacity:20]; // Raw View if ([rs count] > 0) { + // for each row in the results for (i = 0; i < [rs count]; i++) { *************** *** 432,435 **** --- 435,439 ---- { NSTableColumn *tc = [[NSTableColumn alloc] init]; + // TODO should we set the font here? [tc setIdentifier:[NSString stringWithFormat:@"%d", x]]; [[tc headerCell] setStringValue:[[[[rs itemAtIndex:i] fields] itemAtIndex:x] name]]; *************** *** 441,450 **** --- 445,472 ---- long x = 0; NSMutableDictionary *dict = [dataSource addItem]; + // for each field for (x = 0; x < [[[rs itemAtIndex:i] fields] count]; x++) { + [dict setValue:[[[[rs itemAtIndex:i] fields] itemAtIndex:x] value] forKey:[NSString stringWithFormat:@"%d", x]]; [result appendFormat:@"%-15s ", [[[[[rs itemAtIndex:i] fields] itemAtIndex:x] value] cString]]; + // find longest string for data in a column + NSString *fieldLongestString = [[[[rs itemAtIndex:i] fields] itemAtIndex:x] value]; + if (i == 0) + { + // first row initialize to first row strings. + [maxDataInColumn addObject:fieldLongestString]; + } + else + { + // this is not exact but close enough for now. + if ([[maxDataInColumn objectAtIndex:x] length] < [fieldLongestString length]) + { + // update max string for this column + [maxDataInColumn replaceObjectAtIndex:x withObject:fieldLongestString]; + } + } } [result appendString:@"\n"]; *************** *** 452,457 **** } [rawOutput setString:result]; ! [dataOutput setDataSource:dataSource]; [dataOutput reloadData]; --- 474,504 ---- } [rawOutput setString:result]; ! ! // automatically set the width of the result columns ! int x; ! NSDictionary *attribDict; ! NSArray *columns = [dataOutput tableColumns]; [dataOutput setDataSource:dataSource]; + + for (x = 0; x < [[[rs itemAtIndex:0] fields] count]; x++) + { + NSTableColumn *aColumn = [columns objectAtIndex:x]; + NSCell *aDataCell = [aColumn dataCell]; + NSCell *aHeaderCell = [aColumn headerCell]; + NSFont *aFont = [aDataCell font]; + attribDict = [NSDictionary dictionaryWithObjectsAndKeys: aFont, NSFontAttributeName, nil]; + NSAttributedString *attribString = [[NSAttributedString alloc] initWithString:[maxDataInColumn objectAtIndex:x] attributes:attribDict]; + NSSize textSize = [attribString size]; + [aColumn setMaxWidth:textSize.width+20.0]; + if (textSize.width/5.0 < [aHeaderCell cellSize].width/2.0) + { + [aColumn setMinWidth:[aHeaderCell cellSize].width/2.0]; + } + else + { + [aColumn setMinWidth:textSize.width/5.0]; + } + [aColumn setWidth:textSize.width+10.0]; + } [dataOutput reloadData]; Index: TODO.txt =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/TODO.txt,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** TODO.txt 4 Sep 2006 14:22:07 -0000 1.9 --- TODO.txt 17 Sep 2006 15:41:48 -0000 1.10 *************** *** 4,10 **** TODO - Features, Functions and Warnings (in rough priority order) ======================================= ! - 2006-08-30 Sequence SQL not complete. ! - 2006-09-01 "Query Completed message in main window should show elapsed time and first 30 characters of query. - 2006-08-30 Constraints not tested in unit test pgCocoaDB. --- 4,12 ---- TODO - Features, Functions and Warnings (in rough priority order) ======================================= ! - 2006-09-17 Error message not reset at the beginning of a query. ! - 2006-09-01 Query Completed message in main window should show elapsed time and first 30 characters of query. ! ! - 2006-08-30 Sequence SQL not complete. - 2006-08-30 Constraints not tested in unit test pgCocoaDB. *************** *** 12,20 **** - 2006-06-16 Use function to attempt to cancel a query in pgCocoaDB. Need to change to async queries. ! - 2006-08-26 Add clear and save log function. - 2006-08-26 Add explain query button. ! - 2006-09-01 Add functinality to edit results. - 2006-09-01 Rule schema not complete. --- 14,22 ---- - 2006-06-16 Use function to attempt to cancel a query in pgCocoaDB. Need to change to async queries. ! - 2006-08-26 Add clear and save log function. Do NOT clear log when changing to a different database. - 2006-08-26 Add explain query button. ! - 2006-09-01 Add functionality to edit results. - 2006-09-01 Rule schema not complete. *************** *** 25,29 **** FIXME (Known Errors) ==================== ! 2006-08-26 Function return parameters not correctly determined, see below: CREATE or REPLACE FUNCTION pgcocoa_test_schema.create_time_stamp AS $$ --- 27,31 ---- FIXME (Known Errors) ==================== ! - 2006-08-26 Function return parameters not correctly determined, see below: CREATE or REPLACE FUNCTION pgcocoa_test_schema.create_time_stamp AS $$ *************** *** 36,40 **** - 2006-09-01 "Save As" always saves the query window, should save the log window if the log window is front most. ! 2006-06-22 13:20:17.480 Query Tool for Postgres[5590] -[NSBigMutableString characterAtIndex:] called with out-of-bounds index. For apps linked on Tiger this will raise an exception. For earlier apps it will produce this one-time warning and continue with existing behavior (which is undefined). 2006-06-22 13:20:17.480 Query Tool for Postgres[5590] Exception raised during posting of notification. Ignored. exception: *** -[NSBigMutableString characterAtIndex:]: Range or index out of bounds --- 38,42 ---- - 2006-09-01 "Save As" always saves the query window, should save the log window if the log window is front most. ! - 2006-06-22 13:20:17.480 Query Tool for Postgres[5590] -[NSBigMutableString characterAtIndex:] called with out-of-bounds index. For apps linked on Tiger this will raise an exception. For earlier apps it will produce this one-time warning and continue with existing behavior (which is undefined). 2006-06-22 13:20:17.480 Query Tool for Postgres[5590] Exception raised during posting of notification. Ignored. exception: *** -[NSBigMutableString characterAtIndex:]: Range or index out of bounds *************** *** 42,45 **** --- 44,49 ---- Completed ========= + - 2006-09-17 Data columns in the results table are not resizing. + - 2006-09-01 Refactored user defaults in SQLDocument. Index: QueryTool.h =================================================================== RCS file: /cvsroot/pgsqlformac/QueryTool/QueryTool.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** QueryTool.h 13 Sep 2006 23:13:13 -0000 1.1 --- QueryTool.h 17 Sep 2006 15:41:48 -0000 1.2 *************** *** 12,15 **** // To tell others that parameters are purposely not used and remove compiler warning. #define UNUSED_PARAMETER(x) (void)(x) ! // Global Project Definitions \ No newline at end of file --- 12,15 ---- // To tell others that parameters are purposely not used and remove compiler warning. #define UNUSED_PARAMETER(x) (void)(x) ! // #define UNUSED_PARAMETER(x) // Global Project Definitions \ No newline at end of file |