Revision: 7639
          http://skim-app.svn.sourceforge.net/skim-app/?rev=7639&view=rev
Author:   hofman
Date:     2012-02-13 12:35:38 +0000 (Mon, 13 Feb 2012)
Log Message:
-----------
hidden preference to customize note table columns

Modified Paths:
--------------
    trunk/Dutch.lproj/Localizable.strings
    trunk/English.lproj/Localizable.strings
    trunk/French.lproj/Localizable.strings
    trunk/German.lproj/Localizable.strings
    trunk/Italian.lproj/Localizable.strings
    trunk/Japanese.lproj/Localizable.strings
    trunk/SKMainWindowController.m
    trunk/SKMainWindowController_UI.m
    trunk/SKNotesDocument.m
    trunk/Spanish.lproj/Localizable.strings
    trunk/pl.lproj/Localizable.strings
    trunk/ru.lproj/Localizable.strings
    trunk/zh_TW.lproj/Localizable.strings

Modified: trunk/Dutch.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/English.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/French.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/German.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/Italian.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/Japanese.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m      2012-02-12 21:35:29 UTC (rev 7638)
+++ trunk/SKMainWindowController.m      2012-02-13 12:35:38 UTC (rev 7639)
@@ -102,6 +102,7 @@
 #import "NSScreen_SKExtensions.h"
 #import "PDFView_SKExtensions.h"
 #import "NSScanner_SKExtensions.h"
+#import "SKCenteredTextFieldCell.h"
 
 #define MULTIPLICATION_SIGN_CHARACTER 0x00d7
 
@@ -114,9 +115,11 @@
 #define THUMBNAILS_KEY              @"thumbnails"
 #define SNAPSHOTS_KEY               @"snapshots"
 
-#define PAGE_COLUMNID  @"page"
-#define NOTE_COLUMNID  @"note"
-#define COLOR_COLUMNID @"color"
+#define PAGE_COLUMNID   @"page"
+#define NOTE_COLUMNID   @"note"
+#define COLOR_COLUMNID  @"color"
+#define AUTHOR_COLUMNID @"author"
+#define DATE_COLUMNID   @"date"
 
 #define RELEVANCE_COLUMNID  @"relevance"
 #define RESULTS_COLUMNID    @"results"
@@ -155,8 +158,10 @@
 
 #define SKUsesDrawersKey @"SKUsesDrawers"
 
-#define SKDisplayNoteBoundsKey @"SKDisplayNoteBounds" 
+#define SKDisplayNoteBoundsKey @"SKDisplayNoteBounds"
 
+#define SKNoteColumnsKey @"SKNoteColumns" 
+
 static void addSideSubview(NSView *view, NSView *contentView, BOOL 
usesDrawers) {
     NSRect rect = [contentView bounds];
     if (usesDrawers == 0) {
@@ -471,6 +476,51 @@
     [noteTypeSheetController setDelegate:self];
     [[rightSideController.noteOutlineView headerView] 
setMenu:[noteTypeSheetController noteTypeMenu]];
     
+    NSArray *columnIDs = [sud stringArrayForKey:SKNoteColumnsKey];
+    if (columnIDs) {
+        if ([columnIDs containsObject:NOTE_COLUMNID] == NO)
+            columnIDs = [[NSArray arrayWithObject:NOTE_COLUMNID] 
arrayByAddingObjectsFromArray:columnIDs];
+        NSOutlineView *ov = rightSideController.noteOutlineView;
+        if ([columnIDs isEqualToArray:[[ov tableColumns] 
valueForKey:@"identifier"]] == NO) {
+            NSInteger column, currentColumn = 0;
+            for (NSString *columnID in columnIDs) {
+                column = [ov columnWithIdentifier:columnID];
+                if (column == -1) {
+                    NSTableColumn *tc = [[[NSTableColumn alloc] 
initWithIdentifier:AUTHOR_COLUMNID] autorelease];
+                    [tc setResizingMask:(NSTableColumnAutoresizingMask | 
NSTableColumnUserResizingMask)];
+                    [tc setMinWidth:16.0];
+                    [tc setMaxWidth:1000.0];
+                    [tc setWidth:32.0];
+                    [tc setDataCell:[[[SKCenteredTextFieldCell alloc] 
initTextCell:@""] autorelease]];
+                    if ([columnID isEqualToString:AUTHOR_COLUMNID]) {
+                        [[tc headerCell] setTitle:NSLocalizedString(@"Author", 
@"Table header title")];
+                        [tc setEditable:YES];
+                        [[tc dataCell] setEditable:YES];
+                    } else if ([columnID isEqualToString:DATE_COLUMNID]) {
+                        [[tc headerCell] setTitle:NSLocalizedString(@"Date", 
@"Table header title")];
+                        [tc setEditable:NO];
+                        NSDateFormatter *formatter = [[[NSDateFormatter alloc] 
init] autorelease];
+                        [formatter 
setFormatterBehavior:NSDateFormatterBehavior10_4];
+                        [formatter setDateStyle:NSDateFormatterShortStyle];
+                        [formatter setTimeStyle:NSDateFormatterNoStyle];
+                        [[tc dataCell] setFormatter:formatter];
+                    } else {
+                        continue;
+                    }
+                    column = [ov numberOfColumns];
+                    [ov addTableColumn:tc];
+                    [ov setAllowsColumnResizing:YES];
+                }
+                if (column > currentColumn)
+                    [ov moveColumn:column toColumn:currentColumn];
+                ++currentColumn;
+            }
+            while (currentColumn < [ov numberOfColumns])
+                [ov removeTableColumn:[[ov tableColumns] lastObject]];
+            [ov sizeToFit];
+        }
+    }
+    
     [rightSideController.noteOutlineView registerForDraggedTypes:[NSArray 
arrayWithObjects:NSColorPboardType, nil]];
     
     [pdfView setTypeSelectHelper:[leftSideController.thumbnailTableView 
typeSelectHelper]];
@@ -2260,7 +2310,8 @@
             if ([[note type] isEqualToString:SKNNoteString] && [keyPath 
isEqualToString:SKNPDFAnnotationBoundsKey])
                 [pdfView resetPDFToolTipRects];
             
-            if ([keyPath isEqualToString:SKNPDFAnnotationBoundsKey] || 
[keyPath isEqualToString:SKNPDFAnnotationStringKey] || [keyPath 
isEqualToString:SKNPDFAnnotationTextKey] || [keyPath 
isEqual:SKNPDFAnnotationColorKey]) {
+            if ([keyPath isEqualToString:SKNPDFAnnotationBoundsKey] || 
[keyPath isEqualToString:SKNPDFAnnotationStringKey] || [keyPath 
isEqualToString:SKNPDFAnnotationTextKey] || [keyPath 
isEqual:SKNPDFAnnotationColorKey] ||
+                ([[NSUserDefaults standardUserDefaults] 
stringArrayForKey:SKNoteColumnsKey] && ([keyPath 
isEqualToString:SKNPDFAnnotationUserNameKey] || [keyPath 
isEqualToString:SKNPDFAnnotationModificationDateKey]))) {
                 [rightSideController.noteArrayController rearrangeObjects];
                 [rightSideController.noteOutlineView reloadData];
             }

Modified: trunk/SKMainWindowController_UI.m
===================================================================
--- trunk/SKMainWindowController_UI.m   2012-02-12 21:35:29 UTC (rev 7638)
+++ trunk/SKMainWindowController_UI.m   2012-02-13 12:35:38 UTC (rev 7639)
@@ -83,6 +83,8 @@
 #define NOTE_COLUMNID   @"note"
 #define TYPE_COLUMNID   @"type"
 #define COLOR_COLUMNID  @"color"
+#define AUTHOR_COLUMNID @"author"
+#define DATE_COLUMNID   @"date"
 #define IMAGE_COLUMNID  @"image"
 
 #define SKLeftSidePaneWidthKey  @"SKLeftSidePaneWidth"
@@ -620,15 +622,22 @@
             return [item type] ? [item color] : nil;
         else if([tcID isEqualToString:PAGE_COLUMNID])
             return [[item page] displayLabel];
+        else if([tcID isEqualToString:AUTHOR_COLUMNID])
+            return [item type] ? [item userName] : nil;
+        else if([tcID isEqualToString:DATE_COLUMNID])
+            return [item type] ? [item modificationDate] : nil;
     }
     return nil;
 }
 
 - (void)outlineView:(NSOutlineView *)ov setObjectValue:(id)object 
forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item{
-    if ([ov isEqual:rightSideController.noteOutlineView]) {
+    if ([ov isEqual:rightSideController.noteOutlineView] && [item type]) {
         if ([[tableColumn identifier] isEqualToString:NOTE_COLUMNID]) {
-            if ([item type] && [object isEqualToString:[item string]] == NO)
+            if ([(object ?: @"") isEqualToString:([item string] ?: @"")] == NO)
                 [item setString:object];
+        } else if ([[tableColumn identifier] isEqualToString:AUTHOR_COLUMNID]) 
{
+            if ([(object ?: @"") isEqualToString:([item userName] ?: @"")] == 
NO)
+                [item setUserName:object];
         }
     }
 }
@@ -676,6 +685,8 @@
             } else {
                 return YES;
             }
+        } else if ([[tableColumn identifier] isEqualToString:AUTHOR_COLUMNID]) 
{
+            return YES;
         }
     }
     return NO;
@@ -700,6 +711,10 @@
                 [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationColorKey ascending:YES 
selector:@selector(colorCompare:)] autorelease] atIndex:0];
             } else if ([tcID isEqualToString:NOTE_COLUMNID]) {
                 [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationStringKey ascending:YES 
selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] 
atIndex:0];
+            } else if ([tcID isEqualToString:AUTHOR_COLUMNID]) {
+                [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationUserNameKey ascending:YES 
selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] 
atIndex:0];
+            } else if ([tcID isEqualToString:DATE_COLUMNID]) {
+                [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationModificationDateKey ascending:YES 
selector:@selector(compare:)] autorelease] atIndex:0];
             }
             sortDescriptors = sds;
             if (oldTableColumn)

Modified: trunk/SKNotesDocument.m
===================================================================
--- trunk/SKNotesDocument.m     2012-02-12 21:35:29 UTC (rev 7638)
+++ trunk/SKNotesDocument.m     2012-02-13 12:35:38 UTC (rev 7639)
@@ -66,6 +66,7 @@
 #import "NSString_SKExtensions.h"
 #import "NSError_SKExtensions.h"
 #import "SKTemplateManager.h"
+#import "SKCenteredTextFieldCell.h"
 
 #define SKNotesDocumentWindowFrameAutosaveName @"SKNotesDocumentWindow"
 
@@ -75,15 +76,19 @@
 
 #define SKLastExportedNotesTypeKey @"SKLastExportedNotesType"
 
+#define SKNoteColumnsKey @"SKNoteColumns" 
+
 #define SKWindowFrameKey @"windowFrame"
 
 #define NOTES_KEY @"notes"
 #define PAGES_KEY @"pages"
 
-#define NOTE_COLUMNID  @"note"
-#define TYPE_COLUMNID  @"type"
-#define COLOR_COLUMNID @"color"
-#define PAGE_COLUMNID  @"page"
+#define NOTE_COLUMNID   @"note"
+#define TYPE_COLUMNID   @"type"
+#define COLOR_COLUMNID  @"color"
+#define PAGE_COLUMNID   @"page"
+#define AUTHOR_COLUMNID @"author"
+#define DATE_COLUMNID   @"date"
 
 @implementation SKNotesDocument
 
@@ -176,6 +181,50 @@
     
     [outlineView setAutoresizesOutlineColumn: NO];
     
+    NSArray *columnIDs = [[NSUserDefaults standardUserDefaults] 
stringArrayForKey:SKNoteColumnsKey];
+    if (columnIDs) {
+        if ([columnIDs containsObject:NOTE_COLUMNID] == NO)
+            columnIDs = [[NSArray arrayWithObject:NOTE_COLUMNID] 
arrayByAddingObjectsFromArray:columnIDs];
+        if ([columnIDs isEqualToArray:[[outlineView tableColumns] 
valueForKey:@"identifier"]] == NO) {
+            NSInteger column, currentColumn = 0;
+            for (NSString *columnID in columnIDs) {
+                column = [outlineView columnWithIdentifier:columnID];
+                if (column == -1) {
+                    NSTableColumn *tc = [[[NSTableColumn alloc] 
initWithIdentifier:AUTHOR_COLUMNID] autorelease];
+                    [tc setResizingMask:(NSTableColumnAutoresizingMask | 
NSTableColumnUserResizingMask)];
+                    [tc setMinWidth:16.0];
+                    [tc setMaxWidth:1000.0];
+                    [tc setWidth:32.0];
+                    [tc setDataCell:[[[SKCenteredTextFieldCell alloc] 
initTextCell:@""] autorelease]];
+                    if ([columnID isEqualToString:AUTHOR_COLUMNID]) {
+                        [[tc headerCell] setTitle:NSLocalizedString(@"Author", 
@"Table header title")];
+                        [tc setEditable:YES];
+                        [[tc dataCell] setEditable:YES];
+                    } else if ([columnID isEqualToString:DATE_COLUMNID]) {
+                        [[tc headerCell] setTitle:NSLocalizedString(@"Date", 
@"Table header title")];
+                        [tc setEditable:NO];
+                        NSDateFormatter *formatter = [[[NSDateFormatter alloc] 
init] autorelease];
+                        [formatter 
setFormatterBehavior:NSDateFormatterBehavior10_4];
+                        [formatter setDateStyle:NSDateFormatterShortStyle];
+                        [formatter setTimeStyle:NSDateFormatterNoStyle];
+                        [[tc dataCell] setFormatter:formatter];
+                    } else {
+                        continue;
+                    }
+                    column = [outlineView numberOfColumns];
+                    [outlineView addTableColumn:tc];
+                    [outlineView setAllowsColumnResizing:YES];
+                }
+                if (column > currentColumn)
+                    [outlineView moveColumn:column toColumn:currentColumn];
+                ++currentColumn;
+            }
+            while (currentColumn < [outlineView numberOfColumns])
+                [outlineView removeTableColumn:[[outlineView tableColumns] 
lastObject]];
+            [outlineView sizeToFit];
+        }
+    }
+    
     NSSortDescriptor *indexSortDescriptor = [[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationPageIndexKey ascending:YES] autorelease];
     NSSortDescriptor *stringSortDescriptor = [[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationStringKey ascending:YES 
selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease];
     [arrayController setSortDescriptors:[NSArray 
arrayWithObjects:indexSortDescriptor, stringSortDescriptor, nil]];
@@ -605,6 +654,10 @@
             [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationColorKey ascending:YES 
selector:@selector(colorCompare:)] autorelease] atIndex:0];
         } else if ([tcID isEqualToString:NOTE_COLUMNID]) {
             [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationStringKey ascending:YES 
selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] 
atIndex:0];
+        } else if ([tcID isEqualToString:AUTHOR_COLUMNID]) {
+            [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationUserNameKey ascending:YES 
selector:@selector(localizedCaseInsensitiveNumericCompare:)] autorelease] 
atIndex:0];
+        } else if ([tcID isEqualToString:DATE_COLUMNID]) {
+            [sds insertObject:[[[NSSortDescriptor alloc] 
initWithKey:SKNPDFAnnotationModificationDateKey ascending:YES 
selector:@selector(compare:)] autorelease] atIndex:0];
         } else if ([tcID isEqualToString:PAGE_COLUMNID]) {
             if (oldTableColumn == nil)
                 ascending = NO;

Modified: trunk/Spanish.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/pl.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/ru.lproj/Localizable.strings
===================================================================
(Binary files differ)

Modified: trunk/zh_TW.lproj/Localizable.strings
===================================================================
(Binary files differ)

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to