Download progress label in FeedsView
This commit is contained in:
parent
b8111b7a22
commit
4a5c3b9898
|
@ -79,6 +79,7 @@ App::MessageReceived(BMessage* msg)
|
|||
}
|
||||
case kFeedsEdited:
|
||||
case kProgress:
|
||||
case kDownloadStart:
|
||||
{
|
||||
fMainWindow->PostMessage(msg);
|
||||
break;
|
||||
|
|
|
@ -124,6 +124,10 @@ FeedController::_DownloadLoop(void* ignored)
|
|||
printf( "Downloading feed from %s...\n",
|
||||
feedBuffer->GetXmlUrl().UrlString().String());
|
||||
|
||||
BMessage* downloadInit = new BMessage(kDownloadStart);
|
||||
downloadInit->AddString("feed", feedBuffer->GetTitle());
|
||||
((App*)be_app)->MessageReceived(downloadInit);
|
||||
|
||||
if (feedBuffer->Fetch()) {
|
||||
BMessage* downloaded = new BMessage(kDownloadComplete);
|
||||
downloaded->AddData("feeds", B_RAW_TYPE, feedBuffer, sizeof(Feed));
|
||||
|
|
|
@ -16,6 +16,7 @@ enum
|
|||
{
|
||||
kEnqueueFeed = 'fenq',
|
||||
kClearQueue = 'frmq',
|
||||
kDownloadStart = 'fdst',
|
||||
kDownloadComplete = 'fdlc',
|
||||
kDownloadFail = 'fdlf',
|
||||
kParseComplete = 'fpec',
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <ListView.h>
|
||||
#include <ScrollView.h>
|
||||
#include <SeparatorView.h>
|
||||
#include <StringView.h>
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
|
@ -19,6 +20,7 @@
|
|||
#include "FeedController.h"
|
||||
#include "FeedEditWindow.h"
|
||||
#include "FeedListItem.h"
|
||||
#include "Notifier.h"
|
||||
|
||||
|
||||
FeedsView::FeedsView(const char* name)
|
||||
|
@ -64,6 +66,12 @@ FeedsView::MessageReceived(BMessage* msg)
|
|||
{
|
||||
// _PopulateFeedList();
|
||||
}
|
||||
case kDownloadStart:
|
||||
{
|
||||
BString feedName;
|
||||
if (msg->FindString("feed", &feedName) == B_OK)
|
||||
_UpdateProgress(feedName);
|
||||
}
|
||||
default:
|
||||
{
|
||||
// BWindow::MessageReceived(msg);
|
||||
|
@ -85,6 +93,8 @@ FeedsView::_InitInterface()
|
|||
|
||||
_PopulateFeedList();
|
||||
|
||||
fProgressLabel = new BStringView("progressLabel", "Progress…");
|
||||
|
||||
// Add, Remove, Edit
|
||||
fAddButton = new BButton("addFeed", "+", new BMessage(kFeedsAddButton));
|
||||
fRemoveButton = new BButton("removeFeed", "-", new BMessage(kFeedsRemoveButton));
|
||||
|
@ -122,6 +132,9 @@ FeedsView::_InitInterface()
|
|||
.Add(new BSeparatorView(B_HORIZONTAL))
|
||||
.End()
|
||||
.Add(new BSeparatorView(B_VERTICAL))
|
||||
|
||||
.AddGlue()
|
||||
.Add(fProgressLabel)
|
||||
.AddGlue()
|
||||
|
||||
// Edit button
|
||||
|
@ -174,3 +187,12 @@ FeedsView::_PopulateFeedList()
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
FeedsView::_UpdateProgress(BString feedName)
|
||||
{
|
||||
BString label("Fetching ");
|
||||
label << feedName << "…";
|
||||
fProgressLabel->SetText(label);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
class BMessage;
|
||||
class BListView;
|
||||
class BScrollView;
|
||||
class BStringView;
|
||||
|
||||
|
||||
enum
|
||||
|
@ -38,9 +39,12 @@ private:
|
|||
|
||||
void _PopulateFeedList();
|
||||
|
||||
void _UpdateProgress(BString feedName);
|
||||
|
||||
BButton* fAddButton;
|
||||
BButton* fRemoveButton;
|
||||
BButton* fEditButton;
|
||||
BStringView* fProgressLabel;
|
||||
BListView* fFeedsListView;
|
||||
BScrollView* fFeedsScrollView;
|
||||
};
|
||||
|
|
|
@ -43,6 +43,7 @@ MainWindow::MessageReceived(BMessage *msg)
|
|||
case kFeedsEditButton:
|
||||
case kFeedsSelected:
|
||||
case kFeedsEdited:
|
||||
case kDownloadStart:
|
||||
{
|
||||
fFeedsView->MessageReceived(msg);
|
||||
break;
|
||||
|
@ -54,6 +55,7 @@ MainWindow::MessageReceived(BMessage *msg)
|
|||
}
|
||||
case kProgress:
|
||||
{
|
||||
fFeedsView->MessageReceived(msg);
|
||||
int32 max = 0;
|
||||
int32 current = 0;
|
||||
|
||||
|
|
Ŝarĝante…
Reference in New Issue