Skip to content

Commit 91c1358

Browse files
committed
dbhub: Add refresh button to both tool bars
This allows updating the data in case it has changed on the DBHub.io servers.
1 parent e3de43c commit 91c1358

3 files changed

Lines changed: 50 additions & 6 deletions

File tree

src/RemoteDock.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ RemoteDock::RemoteDock(MainWindow* parent)
4444
connect(&remoteDatabase, &RemoteDatabase::openFile, this, &RemoteDock::openFile);
4545

4646
// Reload the directory tree and the list of local checkouts when a database upload has finished
47-
connect(&remoteDatabase, &RemoteDatabase::uploadFinished, remoteModel, &RemoteModel::refresh);
48-
connect(&remoteDatabase, &RemoteDatabase::uploadFinished, this, &RemoteDock::refreshLocalFileList);
49-
connect(&remoteDatabase, &RemoteDatabase::uploadFinished, [this]() {
50-
if(!currently_opened_file_info.file.empty())
51-
refreshMetadata(currently_opened_file_info.user_name(), QString::fromStdString(currently_opened_file_info.name));
52-
});
47+
connect(&remoteDatabase, &RemoteDatabase::uploadFinished, this, &RemoteDock::refresh);
5348
connect(&remoteDatabase, &RemoteDatabase::openFile, this, &RemoteDock::refreshLocalFileList);
5449

5550
// 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()
209204
ui->buttonPushDatabase->setEnabled(db_opened && logged_in);
210205
ui->actionCloneDatabase->setEnabled(logged_in);
211206
ui->actionDatabaseOpenBrowser->setEnabled(db_opened && logged_in);
207+
ui->actionRefresh->setEnabled(logged_in);
212208
}
213209

214210
void RemoteDock::pushDatabase()
@@ -419,3 +415,16 @@ void RemoteDock::openCurrentDatabaseInBrowser() const
419415
{
420416
QDesktopServices::openUrl(ui->actionDatabaseOpenBrowser->data().toUrl());
421417
}
418+
419+
void RemoteDock::refresh()
420+
{
421+
// Refresh Remote tab
422+
remoteModel->refresh();
423+
424+
// Refresh Local tab
425+
refreshLocalFileList();
426+
427+
// Refresh Current Database tab
428+
if(!currently_opened_file_info.file.empty())
429+
refreshMetadata(currently_opened_file_info.user_name(), QString::fromStdString(currently_opened_file_info.name));
430+
}

src/RemoteDock.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ private slots:
4747
const std::string& default_branch, const std::string& web_page);
4848
void deleteLocalDatabase(const QModelIndex& index);
4949
void openCurrentDatabaseInBrowser() const;
50+
void refresh();
5051

5152
signals:
5253
void openFile(QString file);

src/RemoteDock.ui

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
<bool>false</bool>
9898
</property>
9999
<addaction name="actionCloneDatabase"/>
100+
<addaction name="actionRefresh"/>
100101
</widget>
101102
</item>
102103
<item>
@@ -160,6 +161,7 @@
160161
<bool>false</bool>
161162
</property>
162163
<addaction name="actionDatabaseOpenBrowser"/>
164+
<addaction name="actionRefresh"/>
163165
</widget>
164166
</item>
165167
<item>
@@ -392,6 +394,21 @@
392394
<string>Use this to download a remote database for local editing using a URL as provided on the web page of the database.</string>
393395
</property>
394396
</action>
397+
<action name="actionRefresh">
398+
<property name="icon">
399+
<iconset resource="icons/icons.qrc">
400+
<normaloff>:/icons/refresh</normaloff>:/icons/refresh</iconset>
401+
</property>
402+
<property name="text">
403+
<string>Refresh</string>
404+
</property>
405+
<property name="toolTip">
406+
<string>Reload all data and update the views</string>
407+
</property>
408+
<property name="shortcut">
409+
<string>F5</string>
410+
</property>
411+
</action>
395412
</widget>
396413
<tabstops>
397414
<tabstop>comboUser</tabstop>
@@ -519,6 +536,22 @@
519536
</hint>
520537
</hints>
521538
</connection>
539+
<connection>
540+
<sender>actionRefresh</sender>
541+
<signal>triggered()</signal>
542+
<receiver>RemoteDock</receiver>
543+
<slot>refresh()</slot>
544+
<hints>
545+
<hint type="sourcelabel">
546+
<x>51</x>
547+
<y>21</y>
548+
</hint>
549+
<hint type="destinationlabel">
550+
<x>266</x>
551+
<y>193</y>
552+
</hint>
553+
</hints>
554+
</connection>
522555
</connections>
523556
<slots>
524557
<slot>setNewIdentity(QString)</slot>
@@ -528,5 +561,6 @@
528561
<slot>openLocalFile(QModelIndex)</slot>
529562
<slot>fetchDatabase()</slot>
530563
<slot>openCurrentDatabaseInBrowser()</slot>
564+
<slot>refresh()</slot>
531565
</slots>
532566
</ui>

0 commit comments

Comments
 (0)