Show download/parse/failure status in the feeds list
This commit is contained in:
parent
6c63b23491
commit
203058bd58
2
TODO.txt
2
TODO.txt
|
@ -1,5 +1,5 @@
|
|||
Important Features:
|
||||
* Show download progress/failures in FeedView's feedlist
|
||||
* Show progress in FeedView's feedlist as icons
|
||||
* Show in desktray
|
||||
* Make archivable
|
||||
* Get menu working
|
||||
|
|
|
@ -60,8 +60,9 @@ App::MessageReceived(BMessage* msg)
|
|||
fFeedController->MessageReceived(msg);
|
||||
break;
|
||||
}
|
||||
case kEnqueueFeed:
|
||||
case kDownloadComplete:
|
||||
fMainWindow->PostMessage(msg);
|
||||
case kEnqueueFeed:
|
||||
{
|
||||
fNotifier->MessageReceived(msg);
|
||||
fFeedController->MessageReceived(msg);
|
||||
|
@ -83,6 +84,7 @@ App::MessageReceived(BMessage* msg)
|
|||
case kDownloadFail:
|
||||
{
|
||||
fNotifier->MessageReceived(msg);
|
||||
fMainWindow->PostMessage(msg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
|
|
@ -116,7 +116,8 @@ FeedController::_ProcessQueueItem()
|
|||
send_data(fDownloadThread, 0, (void*)buffer, sizeof(Feed));
|
||||
|
||||
BMessage downloadInit = BMessage(kDownloadStart);
|
||||
downloadInit.AddString("feed", buffer->GetTitle());
|
||||
downloadInit.AddString("feed_url", buffer->GetXmlUrl().UrlString());
|
||||
downloadInit.AddString("feed_name", buffer->GetTitle());
|
||||
((App*)be_app)->MessageReceived(&downloadInit);
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +155,7 @@ FeedController::_CheckStatus()
|
|||
case kParseComplete:
|
||||
{
|
||||
BMessage complete = BMessage(kParseComplete);
|
||||
complete.AddString("feed_name", feedBuffer->GetTitle());
|
||||
complete.AddString("feed_url", feedBuffer->GetXmlUrl().UrlString());
|
||||
complete.AddInt32("entry_count", feedBuffer->GetNewEntries().CountItems());
|
||||
((App*)be_app)->MessageReceived(&complete);
|
||||
break;
|
||||
|
|
|
@ -5,18 +5,48 @@
|
|||
|
||||
#include "FeedListItem.h"
|
||||
|
||||
#include <View.h>
|
||||
|
||||
#include "Feed.h"
|
||||
|
||||
|
||||
FeedListItem::FeedListItem(Feed* feed)
|
||||
:
|
||||
BStringItem(feed->GetTitle().String(), 0, false),
|
||||
fStatus(kClearStatus),
|
||||
fFeedUrl(feed->GetXmlUrl()),
|
||||
fFeedPath(feed->GetCachePath())
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FeedListItem::DrawItem(BView* owner, BRect frame, bool complete)
|
||||
{
|
||||
BStringItem::DrawItem(owner, frame, complete);
|
||||
|
||||
owner->MovePenTo(frame.right - 20, frame.top + BaselineOffset());
|
||||
|
||||
switch (fStatus) {
|
||||
case kDownloadingStatus:
|
||||
{
|
||||
owner->DrawString("…");
|
||||
break;
|
||||
}
|
||||
case kParsingStatus:
|
||||
{
|
||||
owner->DrawString("―");
|
||||
break;
|
||||
}
|
||||
case kErrorStatus:
|
||||
{
|
||||
owner->DrawString("X");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BString
|
||||
FeedListItem::GetFeedPath()
|
||||
{
|
||||
|
@ -29,3 +59,12 @@ FeedListItem::GetFeedUrl()
|
|||
{
|
||||
return fFeedUrl;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
FeedListItem::SetStatus(int8 status)
|
||||
{
|
||||
fStatus = status;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -9,20 +9,32 @@
|
|||
#include <StringItem.h>
|
||||
#include <Url.h>
|
||||
|
||||
//class BString;
|
||||
//class BUrl;
|
||||
class Feed;
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
kClearStatus = 0,
|
||||
kDownloadingStatus = 1,
|
||||
kParsingStatus = 2,
|
||||
kErrorStatus = 3
|
||||
};
|
||||
|
||||
|
||||
class FeedListItem : public BStringItem
|
||||
{
|
||||
public:
|
||||
FeedListItem(Feed* feed);
|
||||
|
||||
void DrawItem(BView* owner, BRect frame, bool complete);
|
||||
|
||||
BUrl GetFeedUrl();
|
||||
BString GetFeedPath();
|
||||
|
||||
void SetStatus(int8 status);
|
||||
|
||||
private:
|
||||
int8 fStatus;
|
||||
BUrl fFeedUrl;
|
||||
BString fFeedPath;
|
||||
};
|
||||
|
|
|
@ -65,15 +65,24 @@ FeedsView::MessageReceived(BMessage* msg)
|
|||
}
|
||||
case kDownloadStart:
|
||||
{
|
||||
BString feedName;
|
||||
if (msg->FindString("feed", &feedName) == B_OK)
|
||||
_UpdateProgress(feedName);
|
||||
}
|
||||
default:
|
||||
{
|
||||
// BWindow::MessageReceived(msg);
|
||||
_UpdateProgress(msg, kDownloadingStatus);
|
||||
break;
|
||||
}
|
||||
case kDownloadComplete:
|
||||
{
|
||||
_UpdateProgress(msg, kParsingStatus);
|
||||
break;
|
||||
}
|
||||
case kDownloadFail:
|
||||
case kParseFail:
|
||||
{
|
||||
_UpdateProgress(msg, kErrorStatus);
|
||||
break;
|
||||
}
|
||||
case kParseComplete:
|
||||
{
|
||||
_UpdateProgress(msg, kClearStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,11 +204,27 @@ FeedsView::_PopulateFeedList()
|
|||
|
||||
|
||||
void
|
||||
FeedsView::_UpdateProgress(BString feedName)
|
||||
FeedsView::_UpdateProgress(BMessage* msg, int8 status)
|
||||
{
|
||||
BString label("Fetching ");
|
||||
label << feedName << "…";
|
||||
fProgressLabel->SetText(label);
|
||||
BString feedName, feedUrl;
|
||||
if (msg->FindString("feed_url", &feedUrl) != B_OK)
|
||||
return;
|
||||
if (msg->FindString("feed_name", &feedName) != B_OK)
|
||||
feedName = feedUrl;
|
||||
|
||||
if (status == kDownloadingStatus) {
|
||||
BString label("Fetching ");
|
||||
label << feedName << "…";
|
||||
fProgressLabel->SetText(label);
|
||||
}
|
||||
|
||||
for (int i = 0; i < fFeedsListView->CountItems(); i++) {
|
||||
FeedListItem* item = (FeedListItem*)fFeedsListView->ItemAt(i);
|
||||
if (item->GetFeedUrl().UrlString() == feedUrl) {
|
||||
item->SetStatus(status);
|
||||
fFeedsListView->InvalidateItem(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ private:
|
|||
|
||||
void _PopulateFeedList();
|
||||
|
||||
void _UpdateProgress(BString feedName);
|
||||
void _UpdateProgress(BMessage* msg, int8 status);
|
||||
|
||||
BButton* fAddButton;
|
||||
BButton* fRemoveButton;
|
||||
|
|
Ŝarĝante…
Reference in New Issue