Esempio n. 1
0
bool DatabaseService::removeDiskDatabase() {
    QFile file(getDiskDatabasePath());

    if (file.exists()) {
        qDebug() << __func__ << " - 'removing database file': " << file.fileName();
        return file.remove();
    }

    return false;
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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;
}