Commit 3cd635bd authored by Lukas Appelhans's avatar Lukas Appelhans
Browse files

Port to shareddatapointer

parent 8119b1d0
......@@ -207,10 +207,11 @@ void SQLiteConnection::Private::checkForErrors(int r)
}
class SQLiteResource::Private
class SQLiteResource::Private : public QSharedData
{
public:
Private(const QList<Row> &t) : table(t) {}
Private(const Private &p) : QSharedData(p), table(p.table) {}
~Private() {}
QList<Row> table;
......@@ -219,15 +220,24 @@ public:
/********** SQLiteResource **************/
SQLiteResource::SQLiteResource(QList<Row> table) : d(new Private(table)) {}
SQLiteResource::SQLiteResource(const SQLiteResource& other) : d(other.d)
{
}
SQLiteResource::~SQLiteResource()
{
delete d;
}
SQLiteResource& SQLiteResource::operator=(const SQLiteResource& other)
{
SQLiteResource res = SQLiteResource(other);
return res;
}
QList<QVariant> SQLiteResource::getColumn(const QString& columnName)
{
QList<QVariant> data;
for (QList<QVariantMap>::iterator it = d->table.begin(); it < d->table.end(); it++) {
QVariantMap map = (*it);
......
......@@ -27,6 +27,7 @@
#include <QByteArray>
#include <exception>
#include <QSharedDataPointer>
/*
* Stores the result of a query, so that the user can access it later.
......@@ -37,15 +38,17 @@ class SQLiteResource
typedef QVariantMap Row;
public:
SQLiteResource(QList<Row>);
SQLiteResource(const SQLiteResource &other);
~SQLiteResource();
QVariant getDataAt(int, QString const&);
QList<QVariant> getColumn(QString const&);
int getRowsCount();
SQLiteResource &operator=(const SQLiteResource &other);
private:
class Private;
Private *d;
QSharedDataPointer<Private> d;
};
/*
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment