complete migration, storage test passes

results still have to be converted in qmaps
This commit is contained in:
Marco Martin 2013-05-02 15:33:57 +02:00
parent b0530820ec
commit 5b648e5a23
4 changed files with 15 additions and 34 deletions

View File

@ -63,7 +63,8 @@ void StorageTest::retrieve()
if (storageJob) {
QVERIFY(storageJob->exec());
QVERIFY(storageJob->result().type() != QVariant::Bool);
QCOMPARE(storageJob->data(), m_data);
QVariantHash h = storageJob->result().value<QVariantHash>();
QCOMPARE(h, m_data);
}
}

View File

@ -96,7 +96,7 @@ void StorageThread::initializeDb(StorageJob *caller)
m_db.transaction();
}
void StorageThread::save(QWeakPointer<StorageJob> wcaller, const QVariantHash &params)
void StorageThread::save(QWeakPointer<StorageJob> wcaller, const QVariantMap &params)
{
StorageJob *caller = wcaller.data();
if (!caller) {
@ -198,7 +198,7 @@ void StorageThread::save(QWeakPointer<StorageJob> wcaller, const QVariantHash &p
emit newResult(caller, true);
}
void StorageThread::retrieve(QWeakPointer<StorageJob> wcaller, const QVariantHash &params)
void StorageThread::retrieve(QWeakPointer<StorageJob> wcaller, const QVariantMap &params)
{
StorageJob *caller = wcaller.data();
if (!caller) {
@ -263,7 +263,6 @@ void StorageThread::retrieve(QWeakPointer<StorageJob> wcaller, const QVariantHas
data.insert(key, v);
}
}
result = data;
} else {
result = false;
@ -272,7 +271,7 @@ void StorageThread::retrieve(QWeakPointer<StorageJob> wcaller, const QVariantHas
emit newResult(caller, result);
}
void StorageThread::deleteEntry(QWeakPointer<StorageJob> wcaller, const QVariantHash &params)
void StorageThread::deleteEntry(QWeakPointer<StorageJob> wcaller, const QVariantMap &params)
{
StorageJob *caller = wcaller.data();
if (!caller) {
@ -302,7 +301,7 @@ void StorageThread::deleteEntry(QWeakPointer<StorageJob> wcaller, const QVariant
emit newResult(caller, success);
}
void StorageThread::expire(QWeakPointer<StorageJob> wcaller, const QVariantHash &params)
void StorageThread::expire(QWeakPointer<StorageJob> wcaller, const QVariantMap &params)
{
StorageJob *caller = wcaller.data();
if (!caller) {

View File

@ -44,10 +44,10 @@ public:
void closeDb();
public Q_SLOTS:
void save(QWeakPointer<StorageJob> caller, const QVariantHash &parameters);
void retrieve(QWeakPointer<StorageJob> caller, const QVariantHash &parameters);
void deleteEntry(QWeakPointer<StorageJob> caller, const QVariantHash &parameters);
void expire(QWeakPointer<StorageJob> caller, const QVariantHash &parameters);
void save(QWeakPointer<StorageJob> caller, const QVariantMap &parameters);
void retrieve(QWeakPointer<StorageJob> caller, const QVariantMap &parameters);
void deleteEntry(QWeakPointer<StorageJob> caller, const QVariantMap &parameters);
void expire(QWeakPointer<StorageJob> caller, const QVariantMap &parameters);
Q_SIGNALS:
void newResult(StorageJob* caller, const QVariant &result);

View File

@ -76,9 +76,9 @@ void ConfigLoaderHandlerMap::addItem()
if (!m_groupsMap.contains(currentGroup())) {
m_groupsMap[currentGroup()] = QVariantMap();
m_groupsMap[currentGroup()]["_name"] = currentGroup();
}
if (type() == "bool") {
bool defaultVal = defaultValue().toLower() == "true";
m_groupsMap[currentGroup()][key()] = defaultVal;
@ -201,7 +201,7 @@ QString Service::destination() const
QStringList Service::operationNames() const
{
if (!d->operationsMap.keys().isEmpty()) {
if (d->operationsMap.keys().isEmpty()) {
#ifndef NDEBUG
kDebug() << "No valid operations scheme has been registered";
#endif
@ -213,7 +213,7 @@ QStringList Service::operationNames() const
QVariantMap Service::operationDescription(const QString &operationName)
{
if (!d->operationsMap.keys().isEmpty()) {
if (d->operationsMap.keys().isEmpty()) {
#ifndef NDEBUG
kDebug() << "No valid operations scheme has been registered";
#endif
@ -225,32 +225,13 @@ QVariantMap Service::operationDescription(const QString &operationName)
return d->operationsMap.value(operationName);
}
/*QHash<QString, QVariant> Service::parametersFromDescription(const KConfigGroup &description)
{
QHash<QString, QVariant> params;
if (!d->operationsMap.keys().isEmpty() || !description.isValid()) {
return params;
}
const QString op = description.name();
foreach (const QString &key, description.keyList()) {
KConfigSkeletonItem *item = d->config->findItem(op, key);
if (item) {
params.insert(key, description.readEntry(key, item->property()));
}
}
return params;
}*/
ServiceJob *Service::startOperationCall(const QVariantMap &description, QObject *parent)
{
// TODO: nested groups?
ServiceJob *job = 0;
const QString op = !description.isEmpty() ? description.value("_name").toString() : QString();
if (!d->operationsMap.keys().isEmpty()) {
if (d->operationsMap.keys().isEmpty()) {
#ifndef NDEBUG
kDebug() << "No valid operations scheme has been registered";
#endif
@ -325,7 +306,7 @@ void Service::setName(const QString &name)
void Service::setOperationEnabled(const QString &operation, bool enable)
{
if (!d->operationsMap.keys().isEmpty() || !d->operationsMap.contains(operation)) {
if (d->operationsMap.keys().isEmpty() || !d->operationsMap.contains(operation)) {
return;
}