2 * Copyright (C) 2010 Stephan Aßmus <superstippi@gmx.de>
4 * All rights reserved. Distributed under the terms of the MIT License.
6 #ifndef DOWNLOAD_PROGRESS_VIEW_H
7 #define DOWNLOAD_PROGRESS_VIEW_H
10 #include <GroupView.h>
23 SAVE_SETTINGS
= 'svst'
27 class DownloadProgressView
: public BGroupView
{
29 DownloadProgressView(BWebDownload
* download
);
30 DownloadProgressView(const BMessage
* archive
);
32 bool Init(BMessage
* archive
= NULL
);
34 status_t
SaveSettings(BMessage
* archive
);
35 virtual void AttachedToWindow();
36 virtual void DetachedFromWindow();
37 virtual void AllAttached();
39 virtual void Draw(BRect updateRect
);
41 virtual void MessageReceived(BMessage
* message
);
43 void ShowContextMenu(BPoint screenWhere
);
45 BWebDownload
* Download() const;
46 const BString
& URL() const;
47 bool IsMissing() const;
48 bool IsFinished() const;
50 void DownloadFinished();
51 void CancelDownload();
53 static void SpeedVersusEstimatedFinishTogglePulse();
56 void _UpdateStatus(off_t currentSize
,
58 void _UpdateStatusText();
59 void _StartNodeMonitor(const BEntry
& entry
);
60 void _StopNodeMonitor();
64 BStatusBar
* fStatusBar
;
65 BStringView
* fInfoView
;
66 SmallButton
* fTopButton
;
67 SmallButton
* fBottomButton
;
68 BWebDownload
* fDownload
;
74 off_t fLastSpeedReferenceSize
;
75 off_t fEstimatedFinishReferenceSize
;
76 bigtime_t fLastUpdateTime
;
77 bigtime_t fLastSpeedReferenceTime
;
78 bigtime_t fProcessStartTime
;
79 bigtime_t fLastSpeedUpdateTime
;
80 bigtime_t fEstimatedFinishReferenceTime
;
81 static const size_t kBytesPerSecondSlots
= 10;
82 size_t fCurrentBytesPerSecondSlot
;
83 double fBytesPerSecondSlot
[kBytesPerSecondSlots
];
84 double fBytesPerSecond
;
86 static bigtime_t sLastEstimatedFinishSpeedToggleTime
;
87 static bool sShowSpeed
;
90 #endif // DOWNLOAD_PROGRESS_VIEW_H