Revision: 23955
          http://sourceforge.net/p/bibdesk/svn/23955
Author:   hofman
Date:     2019-07-06 21:56:59 +0000 (Sat, 06 Jul 2019)
Log Message:
-----------
support downloads in document fileviews when a single item is selected

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

Modified: trunk/bibdesk/BibDocument_UI.m
===================================================================
--- trunk/bibdesk/BibDocument_UI.m      2019-07-06 21:55:44 UTC (rev 23954)
+++ trunk/bibdesk/BibDocument_UI.m      2019-07-06 21:56:59 UTC (rev 23955)
@@ -302,6 +302,14 @@
     [bottomFileView reloadIcons];
 }
 
+- (void)updateFileViewProgressIndicators {
+    BibItem *item = [[self selectedPublications] firstObject];
+    for (BDSKItemDownload *download in [item downloads]) {
+        [sideFileView updateProgressIndicator:[download progress] 
forURL:[download URL] atIndex:[download index]];
+        [bottomFileView updateProgressIndicator:[download progress] 
forURL:[download URL] atIndex:[download index]];
+    }
+}
+
 #pragma mark Status bar
 
 - (void)setStatus:(NSString *)status {
@@ -1178,8 +1186,14 @@
     [self updatePreviews];
     [groupOutlineView setNeedsDisplay:YES];
     BOOL fileViewEditable = [self isDisplayingFileContentSearch] == NO && 
[self hasGroupTypeSelected:BDSKExternalGroupType] == NO && [[self 
selectedPublications] count] == 1;
+    [sideFileView removeAllProgressIndicators];
     [sideFileView setEditable:fileViewEditable];
-    [bottomFileView setEditable:fileViewEditable]; 
+    [sideFileView setAllowsDownloading:fileViewEditable];
+    [bottomFileView removeAllProgressIndicators];
+    [bottomFileView setEditable:fileViewEditable];
+    [bottomFileView setAllowsDownloading:fileViewEditable];
+    if (fileViewEditable)
+        [self updateFileViewProgressIndicators];
     if (docFlags.controllingFVPreviewPanel || 
docFlags.controllingQLPreviewPanel)
         [self previewURLs:nil];
 }
@@ -1252,6 +1266,28 @@
     }
 }
 
+- (void)handleItemDownloadUpdatedNotification:(NSNotification *)notification{
+    if ([sideFileView allowsDownloading] == NO)
+        return;
+    NSArray *selPubs = [self selectedPublications];
+    if ([selPubs count] == 1 && [selPubs firstObject] == [notification 
object]) {
+        BDSKItemDownload *download = [[notification userInfo] 
objectForKey:BDSKItemDownloadKey];
+        [sideFileView updateProgressIndicator:[download progress] 
forURL:[download URL] atIndex:[download index]];
+        [bottomFileView updateProgressIndicator:[download progress] 
forURL:[download URL] atIndex:[download index]];
+    }
+}
+
+- (void)handleItemDownloadFinishedNotification:(NSNotification *)notification{
+    if ([sideFileView allowsDownloading] == NO)
+        return;
+    NSArray *selPubs = [self selectedPublications];
+    if ([selPubs count] == 1 && [selPubs firstObject] == [notification 
object]) {
+        BDSKItemDownload *download = [[notification userInfo] 
objectForKey:BDSKItemDownloadKey];
+        [sideFileView updateProgressIndicator:[download progress] 
forURL:[download URL] atIndex:[download index]];
+        [bottomFileView removeProgressIndicatorForURL:[download URL] 
atIndex:[download index]];
+    }
+}
+
 - (void)registerForNotifications{
     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
     
@@ -1268,6 +1304,14 @@
                name:BDSKBibItemChangedNotification
              object:nil];
     [nc addObserver:self
+           selector:@selector(handleItemDownloadUpdatedNotification:)
+               name:BDSKItemDownloadUpdatedNotification
+             object:nil];
+    [nc addObserver:self
+           selector:@selector(handleItemDownloadFinishedNotification:)
+               name:BDSKItemDownloadFinishedNotification
+             object:nil];
+    [nc addObserver:self
            selector:@selector(handleBibItemAddDelNotification:)
                name:BDSKDocumentDidAddItemNotification
              object:self];

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