[haiku-webkit-commits] r346 - webkit/trunk/WebKit/haiku/WebPositive

  • From: webkit@xxxxxxxxxxxxxxx
  • To: haiku-webkit-commits@xxxxxxxxxxxxx
  • Date: Tue, 23 Mar 2010 15:11:29 +0000

Author: stippi
Date: Tue Mar 23 15:11:29 2010
New Revision: 346
URL: http://mmlr.dyndns.org/changeset/346

Log:
* An unfinished download is no longer considered finished, just because it isn't
  currently in progress anymore.
* Added feature to remove "missing" downloads, i.e. those for which no
  corresponding file exists.

Modified:
   webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp
   webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.h

Modified: webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp    Tue Mar 23 
14:48:58 2010        (r345)
+++ webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.cpp    Tue Mar 23 
15:11:29 2010        (r346)
@@ -58,6 +58,7 @@
        INIT = 'init',
        OPEN_DOWNLOADS_FOLDER = 'odnf',
        REMOVE_FINISHED_DOWNLOADS = 'rmfd',
+       REMOVE_MISSING_DOWNLOADS = 'rmmd',
        OPEN_DOWNLOAD = 'opdn',
        RESTART_DOWNLOAD = 'rsdn',
        CANCEL_DOWNLOAD = 'cndn',
@@ -112,6 +113,11 @@
                        Invalidate();
                }
        }
+       
+       bool IsIconDimmed() const
+       {
+               return fDimmedIcon;
+       }
 
        status_t SaveSettings(BMessage* archive)
        {
@@ -408,6 +414,16 @@
                return fURL;
        }
 
+       bool IsMissing() const
+       {
+               return fIconView->IsIconDimmed();
+       }
+
+       bool IsFinished() const
+       {
+               return !fDownload && fStatusBar->CurrentValue() == 100;
+       }
+
        void DownloadFinished()
        {
                fDownload = NULL;
@@ -549,12 +565,17 @@
                new BMessage(REMOVE_FINISHED_DOWNLOADS));
        fRemoveFinishedButton->SetEnabled(false);
 
+       fRemoveMissingButton = new BButton("Remove missing",
+               new BMessage(REMOVE_MISSING_DOWNLOADS));
+       fRemoveMissingButton->SetEnabled(false);
+
        AddChild(BGroupLayoutBuilder(B_VERTICAL)
                .Add(menuBar)
                .Add(scrollView)
                .Add(new BSeparatorView(B_HORIZONTAL, B_PLAIN_BORDER))
                .Add(BGroupLayoutBuilder(B_HORIZONTAL)
                        .AddGlue()
+                       .Add(fRemoveMissingButton)
                        .Add(fRemoveFinishedButton)
                        .SetInsets(5, 5, 5, 5)
                )
@@ -624,6 +645,9 @@
                case REMOVE_FINISHED_DOWNLOADS:
                        _RemoveFinishedDownloads();
                        break;
+               case REMOVE_MISSING_DOWNLOADS:
+                       _RemoveMissingDownloads();
+                       break;
                case SAVE_SETTINGS:
                        _SaveSettings();
                        break;
@@ -660,6 +684,7 @@
        download->Start(BPath(fDownloadPath.String()));
 
        int32 finishedCount = 0;
+       int32 missingCount = 0;
        int32 index = 0;
        for (int32 i = fDownloadViewsLayout->CountItems() - 1;
                        BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); 
i--) {
@@ -671,10 +696,15 @@
                        index = i;
                        view->RemoveSelf();
                        delete view;
-               } else if (!view->Download())
+                       continue;
+               }
+               if (view->IsFinished())
                        finishedCount++;
+               if (view->IsMissing())
+                       missingCount++;
        }
        fRemoveFinishedButton->SetEnabled(finishedCount > 0);
+       fRemoveMissingButton->SetEnabled(missingCount > 0);
        DownloadProgressView* view = new DownloadProgressView(download);
        if (!view->Init())
                return;
@@ -691,19 +721,25 @@
 DownloadWindow::_DownloadFinished(BWebDownload* download)
 {
        int32 finishedCount = 0;
+       int32 missingCount = 0;
        for (int32 i = 0;
                        BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); 
i++) {
                DownloadProgressView* view = 
dynamic_cast<DownloadProgressView*>(
                        item->View());
                if (!view)
                        continue;
-               if (view->Download() == download) {
+               if (download && view->Download() == download) {
                        view->DownloadFinished();
                        finishedCount++;
-               } else if (!view->Download())
+                       continue;
+               }
+               if (view->IsFinished())
                        finishedCount++;
+               if (view->IsMissing())
+                       missingCount++;
        }
        fRemoveFinishedButton->SetEnabled(finishedCount > 0);
+       fRemoveMissingButton->SetEnabled(missingCount > 0);
        if (download)
                _SaveSettings();
 }
@@ -718,7 +754,7 @@
                        item->View());
                if (!view)
                        continue;
-               if (!view->Download()) {
+               if (view->IsFinished()) {
                        view->RemoveSelf();
                        delete view;
                }
@@ -729,6 +765,25 @@
 
 
 void
+DownloadWindow::_RemoveMissingDownloads()
+{
+       for (int32 i = fDownloadViewsLayout->CountItems() - 1;
+                       BLayoutItem* item = fDownloadViewsLayout->ItemAt(i); 
i--) {
+               DownloadProgressView* view = 
dynamic_cast<DownloadProgressView*>(
+                       item->View());
+               if (!view)
+                       continue;
+               if (view->IsMissing()) {
+                       view->RemoveSelf();
+                       delete view;
+               }
+       }
+       fRemoveMissingButton->SetEnabled(false);
+       _SaveSettings();
+}
+
+
+void
 DownloadWindow::_SaveSettings()
 {
        BFile file;

Modified: webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.h
==============================================================================
--- webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.h      Tue Mar 23 
14:48:58 2010        (r345)
+++ webkit/trunk/WebKit/haiku/WebPositive/DownloadWindow.h      Tue Mar 23 
15:11:29 2010        (r346)
@@ -51,6 +51,7 @@
                        void                            
_DownloadStarted(BWebDownload* download);
                        void                            
_DownloadFinished(BWebDownload* download);
                        void                            
_RemoveFinishedDownloads();
+                       void                            
_RemoveMissingDownloads();
                        void                            _SaveSettings();
                        void                            _LoadSettings();
                        bool                            
_OpenSettingsFile(BFile& file, uint32 mode);
@@ -58,6 +59,7 @@
 private:
                        BGroupLayout*           fDownloadViewsLayout;
                        BButton*                        fRemoveFinishedButton;
+                       BButton*                        fRemoveMissingButton;
                        BString                         fDownloadPath;
 };
 

Other related posts:

  • » [haiku-webkit-commits] r346 - webkit/trunk/WebKit/haiku/WebPositive - webkit