24 #include "storagedummyimpl.h" 25 #include "feedstoragedummyimpl.h" 29 #include <tqstringlist.h> 34 class 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;
61 StorageDummyImpl::StorageDummyImpl() : d(new StorageDummyImplPrivate)
65 StorageDummyImpl::~StorageDummyImpl()
76 bool 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;
101 int StorageDummyImpl::unreadFor(
const TQString &url)
103 return d->feeds.contains(url) ? d->feeds[url].unread : 0;
106 void 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;
114 int StorageDummyImpl::totalCountFor(
const TQString &url)
116 return d->feeds.contains(url) ? d->feeds[url].totalCount : 0;
119 void 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;
127 int StorageDummyImpl::lastFetchFor(
const TQString& url)
129 return d->feeds.contains(url) ? d->feeds[url].lastFetch : 0;
132 void 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;
140 void 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;
182 TQString StorageDummyImpl::restoreFeedList()
const 187 void StorageDummyImpl::storeTagSet(
const TQString& xmlStr)
192 TQString StorageDummyImpl::restoreTagSet()
const 200 #include "storagedummyimpl.moc"
Storage is the main interface to the article archive.
virtual FeedStorage * archiveFor(const TQString &url)=0
virtual bool rollback()
Rollback changes made in feeds and articles, reverting to last committed values.
virtual bool close()
Closes storage, freeing all allocated resources.
virtual void initialize(const TQStringList ¶ms)
initializes the storage object with given parameters
virtual void clear()
deletes all feed storages in this archive
virtual TQStringList feeds() const
returns a list of all feeds (URLs) stored in this archive
virtual bool commit()
Commit changes made in feeds and articles, making them persistent.
virtual void storeFeedList(const TQString &opmlStr)
stores the feed list in the storage backend.
virtual TQStringList feeds() const =0
returns a list of all feeds (URLs) stored in this archive
virtual void add(Storage *source)
adds all feed storages from a source to this storage existing articles are replaced ...
virtual bool open(bool autoCommit=false)
Open storage and prepare it for work.
virtual FeedStorage * archiveFor(const TQString &url)