Page MenuHomePhorge

statefile.cpp
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

statefile.cpp

/*
* Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "statefile.h"
#include <QSettings>
#include <qdebug.h>
Q_DECLARE_METATYPE(QList<qint64>)
StateFile::StateFile()
{
}
StateFile::StateFile(const QString &filename, const QString &user)
: mFilename(filename),
mUser(user)
{
}
QList< qint64 > StateFile::getMigratedUids(const QString& folder)
{
QSettings settings(mFilename, QSettings::IniFormat);
settings.beginGroup(mUser);
const QVariantList list = settings.value(folder).toList();
settings.endGroup();
QList<qint64> uids;
foreach (const QVariant &var, list) {
uids << var.value<qint64>();
}
return uids;
}
void StateFile::setMigratedUids(const QString& folder, const QList<qint64> &uids)
{
QSettings settings(mFilename, QSettings::IniFormat);
settings.beginGroup(mUser);
QVariantList variantList;
foreach (qint64 uid, uids) {
qDebug() << uid;
variantList << uid;
}
settings.setValue(folder, variantList);
settings.endGroup();
}
void StateFile::appendMigratedUids(const QString& folder, const QList< qint64 >& uids)
{
QList<qint64> list = getMigratedUids(folder);
list.append(uids);
setMigratedUids(folder, list);
}
bool StateFile::isValid()
{
return (!mFilename.isEmpty() && !mUser.isEmpty());
}

File Metadata

Mime Type
text/x-c
Expires
Mon, Apr 6, 2:53 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18832111
Default Alt Text
statefile.cpp (1 KB)

Event Timeline