From 9a8bcafaf181a277bbabd6fbdea42abd3a2f53e1 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Tue, 21 Jul 2020 22:28:13 +0200 Subject: [PATCH] dbhub: Add refresh button to both tool bars This allows updating the data in case it has changed on the DBHub.io servers. --- src/RemoteDock.cpp | 21 +++++++++++++++------ src/RemoteDock.h | 1 + src/RemoteDock.ui | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/src/RemoteDock.cpp b/src/RemoteDock.cpp index 3c63dbdf..27643aea 100644 --- a/src/RemoteDock.cpp +++ b/src/RemoteDock.cpp @@ -44,12 +44,7 @@ RemoteDock::RemoteDock(MainWindow* parent) connect(&remoteDatabase, &RemoteDatabase::openFile, this, &RemoteDock::openFile); // Reload the directory tree and the list of local checkouts when a database upload has finished - connect(&remoteDatabase, &RemoteDatabase::uploadFinished, remoteModel, &RemoteModel::refresh); - connect(&remoteDatabase, &RemoteDatabase::uploadFinished, this, &RemoteDock::refreshLocalFileList); - connect(&remoteDatabase, &RemoteDatabase::uploadFinished, [this]() { - if(!currently_opened_file_info.file.empty()) - refreshMetadata(currently_opened_file_info.user_name(), QString::fromStdString(currently_opened_file_info.name)); - }); + connect(&remoteDatabase, &RemoteDatabase::uploadFinished, this, &RemoteDock::refresh); connect(&remoteDatabase, &RemoteDatabase::openFile, this, &RemoteDock::refreshLocalFileList); // Whenever a new directory listing has been parsed, check if it was a new root dir and, if so, open the user's directory @@ -209,6 +204,7 @@ void RemoteDock::enableButtons() ui->buttonPushDatabase->setEnabled(db_opened && logged_in); ui->actionCloneDatabase->setEnabled(logged_in); ui->actionDatabaseOpenBrowser->setEnabled(db_opened && logged_in); + ui->actionRefresh->setEnabled(logged_in); } void RemoteDock::pushDatabase() @@ -419,3 +415,16 @@ void RemoteDock::openCurrentDatabaseInBrowser() const { QDesktopServices::openUrl(ui->actionDatabaseOpenBrowser->data().toUrl()); } + +void RemoteDock::refresh() +{ + // Refresh Remote tab + remoteModel->refresh(); + + // Refresh Local tab + refreshLocalFileList(); + + // Refresh Current Database tab + if(!currently_opened_file_info.file.empty()) + refreshMetadata(currently_opened_file_info.user_name(), QString::fromStdString(currently_opened_file_info.name)); +} diff --git a/src/RemoteDock.h b/src/RemoteDock.h index 0f6d81b5..151e3861 100644 --- a/src/RemoteDock.h +++ b/src/RemoteDock.h @@ -47,6 +47,7 @@ private slots: const std::string& default_branch, const std::string& web_page); void deleteLocalDatabase(const QModelIndex& index); void openCurrentDatabaseInBrowser() const; + void refresh(); signals: void openFile(QString file); diff --git a/src/RemoteDock.ui b/src/RemoteDock.ui index c3b1f9db..b34c4e9e 100644 --- a/src/RemoteDock.ui +++ b/src/RemoteDock.ui @@ -127,6 +127,7 @@ false + @@ -190,6 +191,7 @@ false + @@ -434,6 +436,21 @@ Use this to download a remote database for local editing using a URL as provided on the web page of the database. + + + + :/icons/refresh:/icons/refresh + + + Refresh + + + Reload all data and update the views + + + F5 + + comboUser @@ -561,6 +578,22 @@ + + actionRefresh + triggered() + RemoteDock + refresh() + + + 51 + 21 + + + 266 + 193 + + + setNewIdentity(QString) @@ -570,5 +603,6 @@ openLocalFile(QModelIndex) fetchDatabase() openCurrentDatabaseInBrowser() + refresh()