void CMainWindow::on_actionCreateNewDatabase_activated() { if (anyDbOpened) { // ask if user is sure to close current DB and create new one // if YES - close current DB and open File dialog to create new DB file with given name int result = dbOpenedAlert(); switch(result) { case QMessageBox::Yes: db->closeDB(); anyDbOpened = false; createDBFile(); break; case QMessageBox::No: break; default: anyDbOpened = false; this->setWindowTitle(appname + no_opened_db); } } else { // open File dialog to create new DB file with given name createDBFile(); } setControlsState(anyDbOpened); }
void Database::initialize() { QString dbName("mails.sqlite"); QFile file(dbName); if (file.exists()) return; else createDBFile(dbName); }
_Tt_db_results _Tt_db_file::setTtDBFileDefaults (const _Tt_string &file, const _Tt_db_property_list_ptr &properties, const _Tt_db_access_ptr &access) { checkedDatabase = FALSE; directoryFlag = FALSE; dbFileCurrentAccess = new _Tt_db_access; dbFileObjects = new _Tt_string_list; dbFileObjectsCacheLevel = -1; dbFilePropertiesCacheLevel = -1; dbFilePtypes = new _Tt_string_list; dbResults = TT_DB_OK; if (access.is_null()) { dbFileAccess = new _Tt_db_access; } else { dbFileAccess = access; } if (properties.is_null()) { dbFileProperties = new _Tt_db_property_list; } else { dbFileProperties = properties; } if (file.len()) { _Tt_string local_path; if (_tt_is_network_path(file)) { dbFile = _tt_network_path_to_local_path(file); dbFileNetworkPath = file; (void)dbFileNetworkPath.split(':', dbFileHostname); } else { // Get the absoulte network information for the path _Tt_string temp_string; dbResults = _tt_db_network_path (file, dbFile, dbFileHostname, dbFilePartition, dbFileNetworkPath); } if ((dbResults == TT_DB_OK)) { if (!isFileInDatabase()) { if (dbResults != TT_DB_ERR_DB_OPEN_FAILED) { dbResults = createDBFile(); } } } } return dbResults; }