~vonami/akregator-newsgator/trunk

« back to all changes in this revision

Viewing changes to plugins/mk4storage/storagemk4impl.cpp

  • Committer: kde-devel
  • Date: 2008-01-11 11:56:29 UTC
  • Revision ID: kde-devel@ws5-20080111115629-ygc2scg63jpblkyk
Add neccessary db fields for NG:
 - syncUrl and feed id for feeds
 - localChanges and article id for articles

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    public:
42
42
        StorageMK4ImplPrivate() : modified(false),
43
43
            purl("url"),
 
44
            pSyncUrl("syncUrl"),
 
45
            pfid("fid"),
44
46
            pFeedList("feedList"),
45
47
            pTagSet("tagSet"),
46
48
            punread("unread"),
54
56
        bool modified;
55
57
        mutable QMap<QString, Akregator::Backend::FeedStorageMK4Impl*> feeds;
56
58
        QStringList feedURLs;
57
 
        c4_StringProp purl, pFeedList, pTagSet;
 
59
        c4_StringProp purl, pSyncUrl, pfid, pFeedList, pTagSet;
58
60
        c4_IntProp punread, ptotalCount, plastFetch;
59
61
        QTimer* commitTimer;
60
62
        QString archivePath;
137
139
{
138
140
    QString filePath = d->archivePath +"/archiveindex.mk4";
139
141
    d->storage = new c4_Storage(filePath.toLocal8Bit(), true);
140
 
    d->archiveView = d->storage->GetAs("archive[url:S,unread:I,totalCount:I,lastFetch:I]");
 
142
    d->archiveView = d->storage->GetAs("archive[url:S,syncUrl:S,fid:S,unread:I,totalCount:I,lastFetch:I]");
141
143
    c4_View hash = d->storage->GetAs("archiveHash[_H:I,_R:I]");
142
144
    d->archiveView = d->archiveView.Hash(hash, 1); // hash on url
143
145
    d->autoCommit = autoCommit;
208
210
    return false;
209
211
}
210
212
 
 
213
QString Akregator::Backend::StorageMK4Impl::syncUrlFor(const QString& url) const
 
214
{
 
215
    c4_Row findrow;
 
216
    d->purl(findrow) = url.toAscii();
 
217
    int findidx = d->archiveView.Find(findrow);
 
218
    return findidx != -1 ? QString::fromUtf8(d->pSyncUrl(d->archiveView.GetAt(findidx))) : "";
 
219
}
 
220
 
 
221
void Akregator::Backend::StorageMK4Impl::setSyncUrlFor(const QString& url, const QString& syncUrl)
 
222
{
 
223
    c4_Row findrow;
 
224
    d->purl(findrow) = url.toAscii();
 
225
    int findidx = d->archiveView.Find(findrow);
 
226
    if (findidx == -1)
 
227
        return;
 
228
    findrow = d->archiveView.GetAt(findidx);
 
229
    d->pSyncUrl(findrow) = !syncUrl.isEmpty() ? syncUrl.toUtf8().data() : "";
 
230
    d->archiveView.SetAt(findidx, findrow);
 
231
    d->modified = true;
 
232
}
 
233
 
 
234
QString Akregator::Backend::StorageMK4Impl::fidFor(const QString& url) const
 
235
{
 
236
    c4_Row findrow;
 
237
    d->purl(findrow) = url.toAscii();
 
238
    int findidx = d->archiveView.Find(findrow);
 
239
    return findidx != -1 ? QString::fromUtf8(d->pfid(d->archiveView.GetAt(findidx))) : "";
 
240
}
 
241
 
 
242
void Akregator::Backend::StorageMK4Impl::setFidFor(const QString& url, const QString& fid)
 
243
{
 
244
    c4_Row findrow;
 
245
    d->purl(findrow) = url.toAscii();
 
246
    int findidx = d->archiveView.Find(findrow);
 
247
    if (findidx == -1)
 
248
        return;
 
249
    findrow = d->archiveView.GetAt(findidx);
 
250
    d->pfid(findrow) = !fid.isEmpty() ? fid.toUtf8().data() : "";
 
251
    d->archiveView.SetAt(findidx, findrow);
 
252
    d->modified = true;
 
253
}
 
254
 
211
255
int Akregator::Backend::StorageMK4Impl::unreadFor(const QString &url) const 
212
256
{
213
257
    c4_Row findrow;