Revision: 27342
          http://sourceforge.net/p/bibdesk/svn/27342
Author:   hofman
Date:     2022-04-02 17:02:47 +0000 (Sat, 02 Apr 2022)
Log Message:
-----------
Display note fields in main table using icons in headers and cell and tool tips

Modified Paths:
--------------
    trunk/bibdesk/BDSKMainTableView.m

Modified: trunk/bibdesk/BDSKMainTableView.m
===================================================================
--- trunk/bibdesk/BDSKMainTableView.m   2022-04-02 09:54:26 UTC (rev 27341)
+++ trunk/bibdesk/BDSKMainTableView.m   2022-04-02 17:02:47 UTC (rev 27342)
@@ -252,9 +252,15 @@
     else
         [headerCell setStringValue:[self headerTitleForField:identifier]];
     
-    if (columnType != BDSKColumnTypeText && columnType != 
BDSKColumnTypeLinkedFile && columnType != BDSKColumnTypeRelevance) {
-        NSView *view = [self makeViewForTableColumn:tc owner:[self delegate]];
-        [tc setWidth:fmax(16.0, fmax([view fittingSize].width, [headerCell 
cellSize].width))];
+    if (columnType == BDSKColumnTypeURL) {
+        [tc setWidth:fmax(16.0, fmax([self rowHeight], ceil([headerCell 
cellSize].width)))];
+    } else if (columnType == BDSKColumnTypeText || columnType == 
BDSKColumnTypeRelevance) {
+        [tc setWidth:fmax(100.0, ceil([headerCell cellSize].width))];
+    } else {
+        NSTableCellView *view = [self makeViewForTableColumn:tc owner:[self 
delegate]];
+        if (columnType == BDSKColumnTypeLinkedFile)
+            [[view textField] setObjectValue:[NSString 
stringWithFormat:NSLocalizedString(@"%ld items", @""), 2L]];
+        [tc setWidth:fmax(16.0, fmax([view fittingSize].width, 
ceil([headerCell cellSize].width)))];
     }
 
     return tc;
@@ -350,17 +356,21 @@
     static NSDictionary *cellImageCache = nil;
     
     if (cellImageCache == nil) {
-        NSMutableDictionary *tmpDict = [[NSMutableDictionary alloc] init];
+        NSImage *text = [[NSWorkspace sharedWorkspace] 
iconForFileType:NSFileTypeForHFSTypeCode(kClippingTextTypeIcon)];
+        NSMutableDictionary *tmpDict = [[NSMutableDictionary alloc] 
initWithObjectsAndKeys:text, BDSKAbstractString, text, BDSKAnnoteString, text, 
BDSKRssDescriptionString, nil];
         NSDictionary *imagePaths = [[NSUserDefaults standardUserDefaults] 
objectForKey:BDSKTableCellImagesKey];
         [imagePaths enumerateKeysAndObjectsUsingBlock:^(NSString *key, 
NSString *imagePath, BOOL *stop){
-            NSImage *image;
-            if ([imagePath isKindOfClass:[NSString class]] &&
-                [[NSFileManager defaultManager] fileExistsAtPath:imagePath] &&
-                (image = [[NSImage alloc] initWithContentsOfFile:imagePath])) {
-                if ([[[imagePath lastPathComponent] 
stringByDeletingPathExtension] hasSuffix:@"Template"])
-                    [image setTemplate:YES];
-                [tmpDict setObject:image forKey:key];
-                [image release];
+            if ([imagePath isKindOfClass:[NSString class]]) {
+                NSImage *image;
+                if ([imagePath isEqualToString:@""]) {
+                    [tmpDict removeObjectForKey:key];
+                } else if ([[NSFileManager defaultManager] 
fileExistsAtPath:imagePath] &&
+                    (image = [[NSImage alloc] 
initWithContentsOfFile:imagePath])) {
+                    if ([[[imagePath lastPathComponent] 
stringByDeletingPathExtension] hasSuffix:@"Template"])
+                        [image setTemplate:YES];
+                    [tmpDict setObject:image forKey:key];
+                    [image release];
+                }
             }
         }];
         cellImageCache = [tmpDict copy];
@@ -466,14 +476,14 @@
         
         path = [NSBezierPath bezierPath];
         [path moveToPoint:NSMakePoint(2.5, 2.5)];
-        [path appendBezierPathWithArcFromPoint:NSMakePoint(2.5, 1.5) 
toPoint:NSMakePoint(width - 2.5, 1.5) radius:x - 4.0];
-        [path appendBezierPathWithArcFromPoint:NSMakePoint(width - 2.5, 1.5) 
toPoint:NSMakePoint(width - 2.5, 2.0 * x + 0.5) radius:x - 4.0];
+        [path lineToPoint:NSMakePoint(2.5, 1.5)];
+        [path lineToPoint:NSMakePoint(width - 2.5, 1.5)];
         [path lineToPoint:NSMakePoint(width - 2.5, 2.0 * x + 1.0)];
         [path lineToPoint:NSMakePoint(2.0 * x, width - 1.5)];
-        [path appendBezierPathWithArcFromPoint:NSMakePoint(2.5, width - 1.5) 
toPoint:NSMakePoint(2.5, 1.5) radius:x - 4.0];
+        [path lineToPoint:NSMakePoint(2.5, width - 1.5)];
         [path closePath];
         [path moveToPoint:NSMakePoint(width - 2.5, 2.0 * x + 0.5)];
-        [path appendBezierPathWithArcFromPoint:NSMakePoint(2.0 * x - 0.5, 2.0 
* x + 0.5) toPoint:NSMakePoint(2.0 * x - 0.5, width - 1.5) radius:x - 4.0];
+        [path lineToPoint:NSMakePoint(2.0 * x - 0.5, 2.0 * x + 0.5)];
         [path lineToPoint:NSMakePoint(2.0 * x - 0.5, width - 1.5)];
         NSImage *file = [[[NSImage alloc] initBitmapWithSize:size 
drawingHandler:^(NSRect rect){
             [path stroke];
@@ -480,6 +490,61 @@
         }] autorelease];
         [file setTemplate:YES];
         
+        path = [NSBezierPath bezierPath];
+        [path moveToPoint:NSMakePoint(1.5, 2.5)];
+        [path appendBezierPathWithArcFromPoint:NSMakePoint(1.5, 1.5) 
toPoint:NSMakePoint(width - 1.5, 1.5) radius:1.0];
+        [path appendBezierPathWithArcFromPoint:NSMakePoint(width - 1.5, 1.5) 
toPoint:NSMakePoint(width - 1.5, 2.0 * x + 0.5) radius:1.0];
+        [path lineToPoint:NSMakePoint(width - 1.5, 2.0 * x + 1.0)];
+        [path lineToPoint:NSMakePoint(2.0 * x + 1.0, width - 1.5)];
+        [path appendBezierPathWithArcFromPoint:NSMakePoint(1.5, width - 1.5) 
toPoint:NSMakePoint(1.5, 1.5) radius:1.0];
+        [path closePath];
+        [path moveToPoint:NSMakePoint(width - 1.5, 2.0 * x + 0.5)];
+        [path appendBezierPathWithArcFromPoint:NSMakePoint(2.0 * x + 0.5, 2.0 
* x + 0.5) toPoint:NSMakePoint(2.0 * x + 0.5, width - 1.5) radius:1.0];
+        [path lineToPoint:NSMakePoint(2.0 * x + 0.5, width - 1.5)];
+        [path moveToPoint:NSMakePoint(4.0, x + 3.5)];
+        [path lineToPoint:NSMakePoint(width - 4.0, x + 3.5)];
+        [path moveToPoint:NSMakePoint(4.0, x + 1.5)];
+        [path lineToPoint:NSMakePoint(width - 4.0, x + 1.5)];
+        [path moveToPoint:NSMakePoint(4.0, x - 0.5)];
+        [path lineToPoint:NSMakePoint(width - 4.0, x - 0.5)];
+        NSImage *abstract = [[[NSImage alloc] initBitmapWithSize:size 
drawingHandler:^(NSRect rect){
+            [path stroke];
+        }] autorelease];
+        [abstract setTemplate:YES];
+        
+        path = [NSBezierPath bezierPath];
+        [path moveToPoint:NSMakePoint(x, x - 0.5)];
+        [path lineToPoint:NSMakePoint(x, 1.5)];
+        [path lineToPoint:NSMakePoint(2 * x - 2.0, x - 0.5)];
+        [path appendBezierPathWithArcFromPoint:NSMakePoint(width - 1.5, x - 
0.5) toPoint:NSMakePoint(width - 1.5, width - 1.5) radius:2.0];
+        [path appendBezierPathWithArcFromPoint:NSMakePoint(width - 1.5, width 
- 1.5) toPoint:NSMakePoint(1.5, width - 1.5) radius:2.0];
+        [path appendBezierPathWithArcFromPoint:NSMakePoint(1.5, width - 1.5) 
toPoint:NSMakePoint(1.5, x - 0.5) radius:2.0];
+        [path appendBezierPathWithArcFromPoint:NSMakePoint(1.5, x - 0.5) 
toPoint:NSMakePoint(width - 1.5, x - 0.5) radius:2.0];
+        [path closePath];
+        [path moveToPoint:NSMakePoint(4.0, 2.0 * x + 1.5)];
+        [path lineToPoint:NSMakePoint(width - 4.0, 2.0 * x + 1.5)];
+        [path moveToPoint:NSMakePoint(4.0, 2.0 * x - 0.5)];
+        [path lineToPoint:NSMakePoint(width - 4.0, 2.0 * x - 0.5)];
+        [path moveToPoint:NSMakePoint(4.0, 2.0 * x - 2.5)];
+        [path lineToPoint:NSMakePoint(width - 4.0, 2.0 * x - 2.5)];
+        NSImage *annote = [[[NSImage alloc] initBitmapWithSize:size 
drawingHandler:^(NSRect rect){
+            [path stroke];
+        }] autorelease];
+        [annote setTemplate:YES];
+        
+        path = [NSBezierPath bezierPathWithOvalInRect:NSMakeRect(x - 3.0, x - 
3.0, x - 1.0, x - 1.0)];
+        [path moveToPoint:NSMakePoint(2.0 * x, x - 3.0)];
+        [path appendBezierPathWithArcWithCenter:NSMakePoint(x - 3.0, x - 3.0) 
radius:x + 3.0 startAngle:0.0 endAngle:90.0];
+        [path appendBezierPathWithArcWithCenter:NSMakePoint(x - 3.0, x - 3.0) 
radius:x + 1.0 startAngle:90.0 endAngle:0.0 clockwise:YES];
+        [path closePath];
+        [path moveToPoint:NSMakePoint(2.0 * x + 4.0, x - 3.0)];
+        [path appendBezierPathWithArcWithCenter:NSMakePoint(x - 3.0, x - 3.0) 
radius:x + 7.0 startAngle:0.0 endAngle:90.0];
+        [path appendBezierPathWithArcWithCenter:NSMakePoint(x - 3.0, x - 3.0) 
radius:x + 5.0 startAngle:90.0 endAngle:0.0 clockwise:YES];
+        NSImage *rss = [[[NSImage alloc] initBitmapWithSize:size 
drawingHandler:^(NSRect rect){
+            [path fill];
+        }] autorelease];
+        [rss setTemplate:YES];
+        
         NSImage *doi = [[[NSImage alloc] initBitmapWithSize:size 
drawingHandler:^(NSRect rect){
             [[NSColor colorWithSRGBRed:1.0 green:0.7 blue:0.0 alpha:1.0] 
setFill];
             [NSBezierPath setDefaultLineWidth:0.3 * x];
@@ -513,7 +578,7 @@
             }
         }] autorelease];
         
-               NSMutableDictionary *tmpDict = [[NSMutableDictionary alloc] 
initWithObjectsAndKeys:file, BDSKLocalUrlString, paperclip, 
BDSKLocalFileString, url, BDSKRemoteURLString, crossref, BDSKCrossrefString, 
color, BDSKColorString, color, BDSKColorLabelString, import, 
BDSKImportOrderString, doi, BDSKDoiString, citeseer, BDSKCiteseerUrlString, 
nil];
+               NSMutableDictionary *tmpDict = [[NSMutableDictionary alloc] 
initWithObjectsAndKeys:file, BDSKLocalUrlString, paperclip, 
BDSKLocalFileString, url, BDSKRemoteURLString, crossref, BDSKCrossrefString, 
color, BDSKColorString, color, BDSKColorLabelString, import, 
BDSKImportOrderString, doi, BDSKDoiString, citeseer, BDSKCiteseerUrlString, 
abstract, BDSKAbstractString, annote, BDSKAnnoteString, rss, 
BDSKRssDescriptionString, nil];
         NSDictionary *imagePaths = [[NSUserDefaults standardUserDefaults] 
objectForKey:BDSKTableHeaderImagesKey];
         [imagePaths enumerateKeysAndObjectsUsingBlock:^(NSString *key, 
NSString *imagePath, BOOL *stop){
             if ([imagePath isKindOfClass:[NSString class]]) {
@@ -565,7 +630,8 @@
 - (void)columnsMenuAddTableColumn:(id)sender{
     // first we fill the popup
        BDSKTypeManager *typeMan = [BDSKTypeManager sharedManager];
-    NSArray *colNames = [typeMan allFieldNamesIncluding:[NSArray 
arrayWithObjects:BDSKPubTypeString, BDSKCiteKeyString, BDSKPubDateString, 
BDSKDateAddedString, BDSKDateModifiedString, BDSKFirstAuthorString, 
BDSKSecondAuthorString, BDSKThirdAuthorString, BDSKLastAuthorString, 
BDSKFirstAuthorEditorString, BDSKSecondAuthorEditorString, 
BDSKThirdAuthorEditorString, BDSKAuthorEditorString, 
BDSKLastAuthorEditorString, BDSKItemNumberString, BDSKContainerString, 
BDSKCrossrefString, BDSKLocalFileString, BDSKRemoteURLString, 
BDSKColorLabelString, nil]
+    NSArray *colNames = [typeMan allFieldNamesIncluding:[NSArray 
arrayWithObjects:BDSKPubTypeString, BDSKCiteKeyString, BDSKPubDateString, 
BDSKDateAddedString, BDSKDateModifiedString, BDSKFirstAuthorString, 
BDSKSecondAuthorString, BDSKThirdAuthorString, BDSKLastAuthorString, 
BDSKFirstAuthorEditorString, BDSKSecondAuthorEditorString, 
BDSKThirdAuthorEditorString, BDSKAuthorEditorString, 
BDSKLastAuthorEditorString, BDSKItemNumberString, BDSKContainerString, 
BDSKCrossrefString, BDSKLocalFileString, BDSKRemoteURLString, 
BDSKColorLabelString,
+        BDSKAbstractString, BDSKAnnoteString, BDSKRssDescriptionString, nil]
                                               excluding:[self 
tableColumnIdentifiers]];
     
     BDSKFieldSheetController *addFieldController = [BDSKFieldSheetController 
fieldSheetControllerWithChoosableFields:colNames

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



_______________________________________________
Bibdesk-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bibdesk-commit

Reply via email to