bool DatabaseService::removeDiskDatabase() { QFile file(getDiskDatabasePath()); if (file.exists()) { qDebug() << __func__ << " - 'removing database file': " << file.fileName(); return file.remove(); } return false; }
bool DatabaseService::createDiskConnection() { QSqlDatabase dbDisk = QSqlDatabase::addDatabase("QSQLITE", "disk"); dbDisk.setDatabaseName(getDiskDatabasePath()); if (!dbDisk.open()) { QMessageBox::critical(0, QWidget::tr("Cannot open disk database"), QWidget::tr( "Unable to establish a database connection.\n" "This application needs SQLite support. Please read " "the Qt SQL driver documentation for information how " "to build it.\n\n" "Click Cancel to exit."), QMessageBox::Cancel); return false; } return true; }
bool DatabaseService::createDiskConnection() { QSqlDatabase dbDisk = QSqlDatabase::addDatabase("QSQLITE", "disk"); QString path = getDiskDatabasePath(); dbDisk.setDatabaseName(path); if (!dbDisk.open()) { QMessageBox::critical( 0, QWidget::tr("Cannot open disk database"), QWidget::tr( "Unable to establish a database connection with " "file '%1'.\nAre the folder and the file " "writeable?").arg(path), QMessageBox::Ok); return false; } return true; }