Store feed entries in BObjectLists
This commit is contained in:
parent
ea620f387a
commit
baf09fdd0a
1
TODO.txt
1
TODO.txt
|
@ -13,7 +13,6 @@ Important improvements:
|
||||||
* _Huge_ problem, but I haven't had luck figuring it out yet…
|
* _Huge_ problem, but I haven't had luck figuring it out yet…
|
||||||
* Move from BLists to BObjectLists where possible
|
* Move from BLists to BObjectLists where possible
|
||||||
* Fix background of Feeds List error status icon (it's black, not transparent)
|
* Fix background of Feeds List error status icon (it's black, not transparent)
|
||||||
* Check if arg is a file or not (treat appropriately)
|
|
||||||
* Make UI friendly to whatever font-size you throw at it
|
* Make UI friendly to whatever font-size you throw at it
|
||||||
* Give a max size to the progress label in FeedsView
|
* Give a max size to the progress label in FeedsView
|
||||||
* Make fancy Markdown README
|
* Make fancy Markdown README
|
||||||
|
|
|
@ -32,7 +32,7 @@ AtomFeed::AtomFeed(Feed* feed)
|
||||||
void
|
void
|
||||||
AtomFeed::Parse ()
|
AtomFeed::Parse ()
|
||||||
{
|
{
|
||||||
entries = BList();
|
entries = BObjectList<Entry>();
|
||||||
tinyxml2::XMLDocument xml;
|
tinyxml2::XMLDocument xml;
|
||||||
xml.LoadFile(GetCachePath().String());
|
xml.LoadFile(GetCachePath().String());
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ AtomFeed::ParseEntries(tinyxml2::XMLElement* xfeed)
|
||||||
xentry = xfeed->FirstChildElement("entry");
|
xentry = xfeed->FirstChildElement("entry");
|
||||||
|
|
||||||
int entryCount = xmlCountSiblings(xentry, "entry");
|
int entryCount = xmlCountSiblings(xentry, "entry");
|
||||||
entries = BList(entryCount);
|
entries = BObjectList<Entry>(entryCount);
|
||||||
|
|
||||||
std::cout << "\t-" << entryCount << "-\n";
|
std::cout << "\t-" << entryCount << "-\n";
|
||||||
|
|
||||||
|
|
10
src/Feed.cpp
10
src/Feed.cpp
|
@ -92,8 +92,6 @@ Feed::Feed()
|
||||||
|
|
||||||
Feed::~Feed()
|
Feed::~Feed()
|
||||||
{
|
{
|
||||||
for (int i = entries.CountItems(); i >= 0; i--)
|
|
||||||
delete ((Entry*)entries.RemoveItem(i));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -205,19 +203,19 @@ Feed::AddEntry (Entry* newEntry)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BList
|
BObjectList<Entry>
|
||||||
Feed::GetEntries()
|
Feed::GetEntries()
|
||||||
{
|
{
|
||||||
return entries;
|
return entries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BList
|
BObjectList<Entry>
|
||||||
Feed::GetNewEntries()
|
Feed::GetNewEntries()
|
||||||
{
|
{
|
||||||
BList newEntries;
|
BObjectList<Entry> newEntries;
|
||||||
for (int i = 0; i < entries.CountItems(); i++) {
|
for (int i = 0; i < entries.CountItems(); i++) {
|
||||||
Entry* entry = ((Entry*)entries.ItemAt(i));
|
Entry* entry = entries.ItemAt(i);
|
||||||
if (entry->GetDate() > lastDate)
|
if (entry->GetDate() > lastDate)
|
||||||
newEntries.AddItem(entry);
|
newEntries.AddItem(entry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,13 +8,14 @@
|
||||||
|
|
||||||
#include <tinyxml2.h>
|
#include <tinyxml2.h>
|
||||||
|
|
||||||
|
#include <ObjectList.h>
|
||||||
|
|
||||||
#include "Entry.h"
|
#include "Entry.h"
|
||||||
|
|
||||||
|
|
||||||
class BDateTime;
|
class BDateTime;
|
||||||
class BEntry;
|
class BEntry;
|
||||||
class BString;
|
class BString;
|
||||||
class BList;
|
|
||||||
class BUrl;
|
class BUrl;
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,8 +32,8 @@ public:
|
||||||
|
|
||||||
virtual void Parse();
|
virtual void Parse();
|
||||||
|
|
||||||
BList GetEntries();
|
BObjectList<Entry> GetEntries();
|
||||||
BList GetNewEntries();
|
BObjectList<Entry> GetNewEntries();
|
||||||
|
|
||||||
bool Fetch();
|
bool Fetch();
|
||||||
|
|
||||||
|
@ -72,7 +73,7 @@ protected:
|
||||||
BString hash;
|
BString hash;
|
||||||
BString lastHash;
|
BString lastHash;
|
||||||
|
|
||||||
BList entries;
|
BObjectList<Entry> entries;
|
||||||
bool fetched;
|
bool fetched;
|
||||||
bool updated;
|
bool updated;
|
||||||
};
|
};
|
||||||
|
|
|
@ -237,7 +237,7 @@ FeedController::_ParseLoop(void* data)
|
||||||
while (true) {
|
while (true) {
|
||||||
int32 code = receive_data(&sender, (void*)feedBuffer, sizeof(Feed));
|
int32 code = receive_data(&sender, (void*)feedBuffer, sizeof(Feed));
|
||||||
|
|
||||||
BList entries;
|
BObjectList<Entry> entries;
|
||||||
int32 entriesCount;
|
int32 entriesCount;
|
||||||
BString feedTitle;
|
BString feedTitle;
|
||||||
BUrl feedUrl = feedBuffer->GetXmlUrl();
|
BUrl feedUrl = feedBuffer->GetXmlUrl();
|
||||||
|
|
|
@ -31,7 +31,7 @@ void
|
||||||
RssFeed::Parse()
|
RssFeed::Parse()
|
||||||
{
|
{
|
||||||
tinyxml2::XMLDocument xml;
|
tinyxml2::XMLDocument xml;
|
||||||
entries = BList();
|
entries = BObjectList<Entry>();
|
||||||
|
|
||||||
Feed::Parse();
|
Feed::Parse();
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ RssFeed::ParseEntries(tinyxml2::XMLElement* xchan)
|
||||||
xitem = xchan->FirstChildElement("item");
|
xitem = xchan->FirstChildElement("item");
|
||||||
|
|
||||||
int entryCount = xmlCountSiblings(xitem, "item");
|
int entryCount = xmlCountSiblings(xitem, "item");
|
||||||
entries = BList(entryCount);
|
entries = BObjectList<Entry>(entryCount);
|
||||||
|
|
||||||
std::cout << "\t-" << entryCount << " entries-\n";
|
std::cout << "\t-" << entryCount << " entries-\n";
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue