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()
69 void StorageDummyImpl::initialize(
const TQStringList&) {}
71 bool StorageDummyImpl::open(
bool )
76 bool StorageDummyImpl::autoCommit()
const
81 bool StorageDummyImpl::close()
83 for (TQMap<TQString, StorageDummyImplPrivate::Entry>::ConstIterator it = d->feeds.begin(); it != d->feeds.end(); ++it)
85 (*it).feedStorage->close();
86 delete (*it).feedStorage;
91 bool StorageDummyImpl::commit()
96 bool StorageDummyImpl::rollback()
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()
144 FeedStorage* StorageDummyImpl::archiveFor(
const TQString& url)
146 if (!d->feeds.contains(url))
147 d->feeds[url].feedStorage =
new FeedStorageDummyImpl(url,
this);
149 return d->feeds[url].feedStorage;
152 TQStringList StorageDummyImpl::feeds()
const
154 return d->feeds.keys();
159 TQStringList feeds = source->
feeds();
160 for (TQStringList::ConstIterator it = feeds.begin(); it != feeds.end(); ++it)
162 FeedStorage* fa = archiveFor(*it);
167 void StorageDummyImpl::clear()
169 for (TQMap<TQString, StorageDummyImplPrivate::Entry>::ConstIterator it = d->feeds.begin(); it != d->feeds.end(); ++it)
171 delete (*it).feedStorage;
177 void StorageDummyImpl::storeFeedList(
const TQString& opmlStr)
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"
virtual TQStringList feeds() const
returns a list of all feeds (URLs) stored 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