| 6 | static const QString DB_CONNECTION_NAME = "adaptix_connection"; |
| 7 | |
| 8 | Storage::Storage() |
| 9 | { |
| 10 | QString homeDirPath = QDir::homePath(); |
| 11 | bool appDirExists = false; |
| 12 | appDirPath = QDir(homeDirPath).filePath(".adaptix"); |
| 13 | |
| 14 | QDir appDir(appDirPath); |
| 15 | if ( appDir.exists() ) { |
| 16 | appDirExists = true; |
| 17 | } else { |
| 18 | if (appDir.mkpath(appDirPath)) |
| 19 | appDirExists = true; |
| 20 | else |
| 21 | LogError("Adaptix directory %s not created!\n", appDirPath.toStdString().c_str()); |
| 22 | } |
| 23 | |
| 24 | if( appDirExists ) { |
| 25 | dbFilePath = QDir(appDirPath).filePath("storage-v1.db"); |
| 26 | db = QSqlDatabase::addDatabase( "QSQLITE", DB_CONNECTION_NAME ); |
| 27 | db.setDatabaseName(dbFilePath); |
| 28 | if (db.open()) |
| 29 | this->checkDatabase(); |
| 30 | else |
| 31 | LogError("Adaptix Database did not opened: %s\n", db.lastError().text().toStdString().c_str()); |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | Storage::~Storage() |
| 36 | { |
nothing calls this directly
no test coverage detected