Download progress label in FeedsView

This commit is contained in:
Jaidyn Ann 2021-02-18 23:16:45 -06:00
parent b8111b7a22
commit 4a5c3b9898
6 changed files with 34 additions and 0 deletions

View File

@ -79,6 +79,7 @@ App::MessageReceived(BMessage* msg)
}
case kFeedsEdited:
case kProgress:
case kDownloadStart:
{
fMainWindow->PostMessage(msg);
break;

View File

@ -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));

View File

@ -16,6 +16,7 @@ enum
{
kEnqueueFeed = 'fenq',
kClearQueue = 'frmq',
kDownloadStart = 'fdst',
kDownloadComplete = 'fdlc',
kDownloadFail = 'fdlf',
kParseComplete = 'fpec',

View File

@ -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);
}

View File

@ -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;
};

View File

@ -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;