/****************************************************************************
** Shared Class code from reading file 'KDbConnectionData.shared.h'
**
** Created
**      by: The Shared Data Compiler version 0.3
**
** WARNING! All changes made in this file will be lost!
*****************************************************************************/

#include "KDbConnectionData.h"
#include <QVariant>

KDbConnectionData::Data::Data(const QMap<QString, QString> &map, bool *ok)
{
    if (ok) {
        *ok = true;
    }
    databaseName = map[QLatin1String("databaseName")];
    caption = map[QLatin1String("caption")];
    description = map[QLatin1String("description")];
    driverId = map[QLatin1String("driverId")];
    userName = map[QLatin1String("userName")];
    hostName = map[QLatin1String("hostName")];
    bool portOk;
    port = map[QLatin1String("port")].toInt(&portOk);
    if (!portOk && ok) {
        *ok = false;
    }
    bool useLocalSocketFileOk;
    useLocalSocketFile = map[QLatin1String("useLocalSocketFile")].toInt(&useLocalSocketFileOk) == 1;
    if (!useLocalSocketFileOk && ok) {
        *ok = false;
    }
    localSocketFileName = map[QLatin1String("localSocketFileName")];
    password = map[QLatin1String("password")];
    bool savePasswordOk;
    savePassword = map[QLatin1String("savePassword")].toInt(&savePasswordOk) == 1;
    if (!savePasswordOk && ok) {
        *ok = false;
    }
}

QMap<QString, QString> KDbConnectionData::Data::toMap() const
{
    QMap<QString, QString> map;
    map[QLatin1String("databaseName")] = databaseName;
    map[QLatin1String("caption")] = caption;
    map[QLatin1String("description")] = description;
    map[QLatin1String("driverId")] = driverId;
    map[QLatin1String("userName")] = userName;
    map[QLatin1String("hostName")] = hostName;
    map[QLatin1String("port")] = QVariant(port).toString();
    map[QLatin1String("useLocalSocketFile")] = QString::number((int)useLocalSocketFile);
    map[QLatin1String("localSocketFileName")] = localSocketFileName;
    map[QLatin1String("password")] = password;
    map[QLatin1String("savePassword")] = QString::number((int)savePassword);
    return map;
}
