mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 11:00:44 -06:00
dbhub: Automatically generate a file name to save a database under
When fetching a remote database automatically generate a file name to save the database as instead of asking the user for a path and name. Also add a preferences option to set the directory for all cloned remote databases. This is obviously a trade-off: on the one hand this makes opening remote databases simpler (it's just a double click), on the other hand it takes control away from the users. The main reason for doing this, however, is to indicate to the user that the cloned databases are going to be controlled by DB4S. We have to keep track of the local databases in order to update them from the right place, push them back to the right place, etc. And because the local copies are under DB4S control we don't want the user to move, rename, or delete them.
This commit is contained in:
@@ -118,19 +118,20 @@ void RemoteDatabase::gotReply(QNetworkReply* reply)
|
||||
{
|
||||
case RequestTypeDatabase:
|
||||
{
|
||||
// It's a database file. Ask user where to store the database file.
|
||||
QString saveFileAs = FileDialog::getSaveFileName(0, qApp->applicationName(), FileDialog::getSqlDatabaseFileFilter(), reply->url().fileName());
|
||||
if(!saveFileAs.isEmpty())
|
||||
{
|
||||
// Save the downloaded data under the selected file name
|
||||
QFile file(saveFileAs);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(reply->readAll());
|
||||
file.close();
|
||||
// It's a database file.
|
||||
|
||||
// Tell the application to open this file
|
||||
emit openFile(saveFileAs);
|
||||
}
|
||||
// Generate a unique file name to save the file under
|
||||
QString saveFileAs = Settings::getSettingsValue("remote", "clonedirectory").toString() +
|
||||
QString("/%2_%1.remotedb").arg(QDateTime::currentMSecsSinceEpoch()).arg(reply->url().fileName());
|
||||
|
||||
// Save the downloaded data under the generated file name
|
||||
QFile file(saveFileAs);
|
||||
file.open(QIODevice::WriteOnly);
|
||||
file.write(reply->readAll());
|
||||
file.close();
|
||||
|
||||
// Tell the application to open this file
|
||||
emit openFile(saveFileAs);
|
||||
}
|
||||
break;
|
||||
case RequestTypeDirectory:
|
||||
|
||||
Reference in New Issue
Block a user