#include "database.h"
#include "constants.h"
-#include "compatibility/pathsservice.h"
#include <QtDebug>
static const int DATABASE_VERSION = 1;
static Database *databaseInstance = 0;
Database::Database() {
- QString dataLocation = Paths::getDataLocation();
+ QString dataLocation = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
if (!QDir().mkpath(dataLocation)) {
qCritical() << "Failed to create directory " << dataLocation;
#ifdef APP_LINUX
// Qt5 changed its "data" path. Try to move the old db to the new path
- QString qt4DataLocation = Paths::getHomeLocation() + "/.local/share/data/" + Constants::ORG_NAME + "/" + Constants::NAME;
+ QString homeLocation = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+ QString qt4DataLocation = homeLocation + "/.local/share/data/" + Constants::ORG_NAME + "/" + Constants::NAME;
QString oldDbLocation = qt4DataLocation + "/" + dbName;
qDebug() << oldDbLocation;
if (QFile::exists(oldDbLocation)) {
// static
QString Database::getDbLocation() {
- return Paths::getDataLocation() + "/" + dbName;
+ return QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/" + dbName;
}
// static
fileExists = QFile::exists(getDbLocation());
#ifdef APP_LINUX
if (!fileExists) {
- QString qt4DataLocation = Paths::getHomeLocation() + "/.local/share/data/" + Constants::ORG_NAME + "/" + Constants::NAME;
+ QString homeLocation = QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
+ QString qt4DataLocation = homeLocation + "/.local/share/data/" + Constants::ORG_NAME + "/" + Constants::NAME;
QString oldDbLocation = qt4DataLocation + "/" + dbName;
- qDebug() << "asd" << oldDbLocation;
fileExists = QFile::exists(oldDbLocation);
}
#endif
}
void Database::closeConnections() {
- foreach(QSqlDatabase connection, connections.values()) {
+ foreach(QSqlDatabase connection, connections) {
// qDebug() << "Closing connection" << connection;
connection.close();
}