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