24#include "storagedummyimpl.h"
25#include "feedstoragedummyimpl.h"
29#include <tqstringlist.h>
34class StorageDummyImpl::StorageDummyImplPrivate
43 FeedStorage* feedStorage;
46 void addEntry(
const TQString& url,
int unread,
int totalCount,
int lastFetch)
49 entry.unread = unread;
50 entry.totalCount = totalCount;
51 entry.lastFetch = lastFetch;
52 entry.feedStorage = 0;
58 TQMap<TQString, Entry> feeds;
61StorageDummyImpl::StorageDummyImpl() : d(new StorageDummyImplPrivate)
65StorageDummyImpl::~StorageDummyImpl()
76bool StorageDummyImpl::autoCommit()
const
83 for (TQMap<TQString, StorageDummyImplPrivate::Entry>::ConstIterator it = d->feeds.begin(); it != d->feeds.end(); ++it)
85 (*it).feedStorage->close();
86 delete (*it).feedStorage;
101int StorageDummyImpl::unreadFor(
const TQString &url)
103 return d->feeds.contains(url) ? d->feeds[url].unread : 0;
106void StorageDummyImpl::setUnreadFor(
const TQString &url,
int unread)
108 if (!d->feeds.contains(url))
109 d->addEntry(url, unread, unread, 0);
111 d->feeds[url].unread = unread;
114int StorageDummyImpl::totalCountFor(
const TQString &url)
116 return d->feeds.contains(url) ? d->feeds[url].totalCount : 0;
119void StorageDummyImpl::setTotalCountFor(
const TQString &url,
int total)
121 if (!d->feeds.contains(url))
122 d->addEntry(url, 0, total, 0);
124 d->feeds[url].totalCount = total;
127int StorageDummyImpl::lastFetchFor(
const TQString& url)
129 return d->feeds.contains(url) ? d->feeds[url].lastFetch : 0;
132void StorageDummyImpl::setLastFetchFor(
const TQString& url,
int lastFetch)
134 if (!d->feeds.contains(url))
135 d->addEntry(url, 0, 0, lastFetch);
137 d->feeds[url].lastFetch = lastFetch;
140void StorageDummyImpl::slotCommit()
146 if (!d->feeds.contains(url))
147 d->feeds[url].feedStorage =
new FeedStorageDummyImpl(url,
this);
149 return d->feeds[url].feedStorage;
154 return d->feeds.keys();
160 for (TQStringList::ConstIterator it =
feeds.begin(); it !=
feeds.end(); ++it)
169 for (TQMap<TQString, StorageDummyImplPrivate::Entry>::ConstIterator it = d->feeds.begin(); it != d->feeds.end(); ++it)
171 delete (*it).feedStorage;
179 d->feedList = opmlStr;
182TQString StorageDummyImpl::restoreFeedList()
const
187void StorageDummyImpl::storeTagSet(
const TQString& xmlStr)
192TQString StorageDummyImpl::restoreTagSet()
const
200#include "storagedummyimpl.moc"
virtual bool commit()
Commit changes made in feeds and articles, making them persistent.
virtual void initialize(const TQStringList ¶ms)
initializes the storage object with given parameters
virtual FeedStorage * archiveFor(const TQString &url)
virtual bool open(bool autoCommit=false)
Open storage and prepare it for work.
virtual void storeFeedList(const TQString &opmlStr)
stores the feed list in the storage backend.
virtual bool close()
Closes storage, freeing all allocated resources.
virtual bool rollback()
Rollback changes made in feeds and articles, reverting to last committed values.
virtual void add(Storage *source)
adds all feed storages from a source to this storage existing articles are replaced
virtual TQStringList feeds() const
returns a list of all feeds (URLs) stored in this archive
virtual void clear()
deletes all feed storages in this archive
Storage is the main interface to the article archive.
virtual FeedStorage * archiveFor(const TQString &url)=0
virtual TQStringList feeds() const =0
returns a list of all feeds (URLs) stored in this archive