• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

akregator

  • sources
  • kde-4.14
  • kdepim
  • akregator
  • src
  • dummystorage
storagedummyimpl.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Akregator.
3 
4  Copyright 2005 Frank Osterfeld <osterfeld@kde.org>
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 
20  As a special exception, permission is given to link this program
21  with any edition of Qt, and distribute the resulting executable,
22  without including the source code for Qt in the source distribution.
23 */
24 #include "storagedummyimpl.h"
25 #include "feedstoragedummyimpl.h"
26 
27 #include <QHash>
28 #include <QString>
29 #include <QStringList>
30 
31 namespace Akregator {
32 namespace Backend {
33 
34 class StorageDummyImpl::StorageDummyImplPrivate
35 {
36  public:
37  class Entry
38  {
39  public:
40  int unread;
41  int totalCount;
42  int lastFetch;
43  FeedStorage* feedStorage;
44  };
45 
46  void addEntry(const QString& url, int unread, int totalCount, int lastFetch)
47  {
48  Entry entry;
49  entry.unread = unread;
50  entry.totalCount = totalCount;
51  entry.lastFetch = lastFetch;
52  entry.feedStorage = 0;
53  feeds[url] = entry;
54  }
55 
56  QString tagSet;
57  QString feedList;
58  QHash<QString, Entry> feeds;
59 };
60 
61 StorageDummyImpl::StorageDummyImpl() : d(new StorageDummyImplPrivate)
62 {
63 }
64 
65 StorageDummyImpl::~StorageDummyImpl()
66 {
67  delete d; d = 0;
68 }
69 void StorageDummyImpl::initialize(const QStringList&) {}
70 
71 bool StorageDummyImpl::open(bool /*autoCommit*/)
72 {
73  return true;
74 }
75 
76 bool StorageDummyImpl::autoCommit() const
77 {
78  return false;
79 }
80 
81 bool StorageDummyImpl::close()
82 {
83  for (QHash<QString, StorageDummyImplPrivate::Entry>::ConstIterator it = d->feeds.constBegin(); it != d->feeds.constEnd(); ++it)
84  {
85  (*it).feedStorage->close();
86  delete (*it).feedStorage;
87  }
88  return true;
89 }
90 
91 bool StorageDummyImpl::commit()
92 {
93  return true;
94 }
95 
96 bool StorageDummyImpl::rollback()
97 {
98  return true;
99 }
100 
101 int StorageDummyImpl::unreadFor(const QString &url) const
102 {
103  return d->feeds.contains(url) ? d->feeds[url].unread : 0;
104 }
105 
106 void StorageDummyImpl::setUnreadFor(const QString &url, int unread)
107 {
108  if (!d->feeds.contains(url))
109  d->addEntry(url, unread, unread, 0);
110  else
111  d->feeds[url].unread = unread;
112 }
113 
114 int StorageDummyImpl::totalCountFor(const QString &url) const
115 {
116  return d->feeds.contains(url) ? d->feeds[url].totalCount : 0;
117 }
118 
119 void StorageDummyImpl::setTotalCountFor(const QString &url, int total)
120 {
121  if (!d->feeds.contains(url))
122  d->addEntry(url, 0, total, 0);
123  else
124  d->feeds[url].totalCount = total;
125 }
126 
127 int StorageDummyImpl::lastFetchFor(const QString& url) const
128 {
129  return d->feeds.contains(url) ? d->feeds[url].lastFetch : 0;
130 }
131 
132 void StorageDummyImpl::setLastFetchFor(const QString& url, int lastFetch)
133 {
134  if (!d->feeds.contains(url))
135  d->addEntry(url, 0, 0, lastFetch);
136  else
137  d->feeds[url].lastFetch = lastFetch;
138 }
139 
140 void StorageDummyImpl::slotCommit()
141 {
142 }
143 
144 FeedStorage* StorageDummyImpl::archiveFor(const QString& url)
145 {
146  if (!d->feeds.contains(url))
147  d->feeds[url].feedStorage = new FeedStorageDummyImpl(url, this);
148 
149  return d->feeds[url].feedStorage;
150 }
151 
152 const FeedStorage* StorageDummyImpl::archiveFor(const QString& url) const
153 {
154  if (!d->feeds.contains(url))
155  d->feeds[url].feedStorage = new FeedStorageDummyImpl(url, const_cast<StorageDummyImpl*>( this ) );
156 
157  return d->feeds[url].feedStorage;
158 }
159 
160 QStringList StorageDummyImpl::feeds() const
161 {
162  return d->feeds.keys();
163 }
164 
165 void StorageDummyImpl::add(Storage* source)
166 {
167  QStringList feeds = source->feeds();
168  for (QStringList::ConstIterator it = feeds.constBegin(); it != feeds.constEnd(); ++it)
169  {
170  FeedStorage* fa = archiveFor(*it);
171  fa->add(source->archiveFor(*it));
172  }
173 }
174 
175 void StorageDummyImpl::clear()
176 {
177  for (QHash<QString, StorageDummyImplPrivate::Entry>::ConstIterator it = d->feeds.constBegin(); it != d->feeds.constEnd(); ++it)
178  {
179  delete (*it).feedStorage;
180  }
181  d->feeds.clear();
182 
183 }
184 
185 void StorageDummyImpl::storeFeedList(const QString& opmlStr)
186 {
187  d->feedList = opmlStr;
188 }
189 
190 QString StorageDummyImpl::restoreFeedList() const
191 {
192  return d->feedList;
193 }
194 
195 void StorageDummyImpl::storeTagSet(const QString& xmlStr)
196 {
197  d->tagSet = xmlStr;
198 }
199 
200 QString StorageDummyImpl::restoreTagSet() const
201 {
202  return d->tagSet;
203 }
204 
205 } // namespace Backend
206 } // namespace Akregator
207 
Akregator::Backend::StorageDummyImpl::archiveFor
FeedStorage * archiveFor(const QString &url)
Definition: storagedummyimpl.cpp:144
Akregator::Backend::StorageDummyImpl::setLastFetchFor
void setLastFetchFor(const QString &url, int lastFetch)
Definition: storagedummyimpl.cpp:132
Akregator::Backend::StorageDummyImpl::restoreTagSet
QString restoreTagSet() const
Definition: storagedummyimpl.cpp:200
Akregator::Backend::StorageDummyImpl::initialize
void initialize(const QStringList &params)
initializes the storage object with given parameters
Definition: storagedummyimpl.cpp:69
Akregator::Backend::StorageDummyImpl::setTotalCountFor
void setTotalCountFor(const QString &url, int total)
Definition: storagedummyimpl.cpp:119
Akregator::Backend::StorageDummyImpl::storeTagSet
void storeTagSet(const QString &xmlStr)
Definition: storagedummyimpl.cpp:195
Akregator::Backend::StorageDummyImpl::slotCommit
void slotCommit()
Definition: storagedummyimpl.cpp:140
Akregator::Backend::Storage
Storage is the main interface to the article archive.
Definition: storage.h:43
Akregator::Backend::StorageDummyImpl::rollback
bool rollback()
Rollback changes made in feeds and articles, reverting to last committed values.
Definition: storagedummyimpl.cpp:96
Akregator::Backend::StorageDummyImpl::close
bool close()
Closes storage, freeing all allocated resources.
Definition: storagedummyimpl.cpp:81
Akregator::Backend::StorageDummyImpl::storeFeedList
void storeFeedList(const QString &opmlStr)
stores the feed list in the storage backend.
Definition: storagedummyimpl.cpp:185
Akregator::Backend::StorageDummyImpl::clear
void clear()
deletes all feed storages in this archive
Definition: storagedummyimpl.cpp:175
Akregator::Backend::StorageDummyImpl::commit
bool commit()
Commit changes made in feeds and articles, making them persistent.
Definition: storagedummyimpl.cpp:91
QHash< QString, Entry >
feedstoragedummyimpl.h
Akregator::Backend::Storage::feeds
virtual QStringList feeds() const =0
returns a list of all feeds (URLs) stored in this archive
storagedummyimpl.h
Akregator::Backend::FeedStorage
Definition: feedstorage.h:66
QString
Akregator::Backend::StorageDummyImpl::unreadFor
int unreadFor(const QString &url) const
Definition: storagedummyimpl.cpp:101
QStringList
Akregator::Backend::FeedStorage::add
virtual void add(FeedStorage *source)=0
Appends all articles from another storage.
Akregator::Backend::StorageDummyImpl::setUnreadFor
void setUnreadFor(const QString &url, int unread)
Definition: storagedummyimpl.cpp:106
Akregator::Backend::StorageDummyImpl::feeds
QStringList feeds() const
returns a list of all feeds (URLs) stored in this archive
Definition: storagedummyimpl.cpp:160
Akregator::Backend::StorageDummyImpl::StorageDummyImpl
StorageDummyImpl()
Definition: storagedummyimpl.cpp:61
Akregator::Backend::StorageDummyImpl::~StorageDummyImpl
~StorageDummyImpl()
Definition: storagedummyimpl.cpp:65
Akregator::Backend::StorageDummyImpl::autoCommit
bool autoCommit() const
Definition: storagedummyimpl.cpp:76
Akregator::Backend::Storage::archiveFor
virtual FeedStorage * archiveFor(const QString &url)=0
QList::ConstIterator
typedef ConstIterator
Akregator::Backend::StorageDummyImpl::lastFetchFor
int lastFetchFor(const QString &url) const
Definition: storagedummyimpl.cpp:127
Akregator::Backend::StorageDummyImpl::restoreFeedList
QString restoreFeedList() const
Definition: storagedummyimpl.cpp:190
QList::constEnd
const_iterator constEnd() const
QList::constBegin
const_iterator constBegin() const
Akregator::Backend::StorageDummyImpl::add
void add(Storage *source)
adds all feed storages from a source to this storage existing articles are replaced ...
Definition: storagedummyimpl.cpp:165
Akregator::Backend::FeedStorageDummyImpl
Definition: feedstoragedummyimpl.h:33
Akregator::Backend::StorageDummyImpl::totalCountFor
int totalCountFor(const QString &url) const
Definition: storagedummyimpl.cpp:114
Akregator::Backend::StorageDummyImpl::open
bool open(bool autoCommit=false)
Open storage and prepare it for work.
Definition: storagedummyimpl.cpp:71
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:34:00 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akregator

Skip menu "akregator"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal