mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-02-10 13:48:32 -06:00
dbhub: Fix updating branch list when database name is changed
This fixes a broken signal slot connection which is triggered when the name of the database in the Push dialog is changed. See issue #2359.
This commit is contained in:
@@ -51,38 +51,7 @@ RemotePushDialog::RemotePushDialog(QWidget* parent, const QString& host, const Q
|
||||
});
|
||||
|
||||
// Fetch list of exsisting branches
|
||||
QUrl url(m_host + "branch/list");
|
||||
QUrlQuery query;
|
||||
query.addQueryItem("username", RemoteNetwork::get().getInfoFromClientCert(m_clientCert, RemoteNetwork::CertInfoUser));
|
||||
query.addQueryItem("folder", "/");
|
||||
query.addQueryItem("dbname", ui->editName->text());
|
||||
url.setQuery(query);
|
||||
RemoteNetwork::get().fetch(url.toString(), RemoteNetwork::RequestTypeCustom, m_clientCert, [this, branch](const QByteArray& reply) {
|
||||
// Read and check results
|
||||
json obj = json::parse(reply, nullptr, false);
|
||||
if(obj.is_discarded() || !obj.is_object())
|
||||
return;
|
||||
json obj_branches = obj["branches"];
|
||||
|
||||
// Get default branch
|
||||
std::string default_branch = (obj.contains("default_branch") && !obj["default_branch"].empty()) ? obj["default_branch"] : "master";
|
||||
|
||||
// Clear branch list and add the default branch
|
||||
ui->comboBranch->clear();
|
||||
ui->comboBranch->addItem(QString::fromStdString(default_branch));
|
||||
|
||||
// Parse data and assemble branch list
|
||||
std::vector<std::string> branches;
|
||||
for(auto it=obj_branches.cbegin();it!=obj_branches.cend();++it)
|
||||
{
|
||||
if(it.key() != default_branch)
|
||||
ui->comboBranch->addItem(QString::fromStdString(it.key()));
|
||||
}
|
||||
|
||||
// If a branch was suggested, select it now
|
||||
if(!branch.isEmpty())
|
||||
ui->comboBranch->setCurrentIndex(ui->comboBranch->findText(branch));
|
||||
});
|
||||
reloadBranchList(branch);
|
||||
}
|
||||
|
||||
RemotePushDialog::~RemotePushDialog()
|
||||
@@ -153,3 +122,39 @@ bool RemotePushDialog::forcePush() const
|
||||
{
|
||||
return ui->checkForce->isChecked();
|
||||
}
|
||||
|
||||
void RemotePushDialog::reloadBranchList(const QString& select_branch)
|
||||
{
|
||||
QUrl url(m_host + "branch/list");
|
||||
QUrlQuery query;
|
||||
query.addQueryItem("username", RemoteNetwork::get().getInfoFromClientCert(m_clientCert, RemoteNetwork::CertInfoUser));
|
||||
query.addQueryItem("folder", "/");
|
||||
query.addQueryItem("dbname", ui->editName->text());
|
||||
url.setQuery(query);
|
||||
RemoteNetwork::get().fetch(url.toString(), RemoteNetwork::RequestTypeCustom, m_clientCert, [this, select_branch](const QByteArray& reply) {
|
||||
// Read and check results
|
||||
json obj = json::parse(reply, nullptr, false);
|
||||
if(obj.is_discarded() || !obj.is_object())
|
||||
return;
|
||||
json obj_branches = obj["branches"];
|
||||
|
||||
// Get default branch
|
||||
std::string default_branch = (obj.contains("default_branch") && !obj["default_branch"].empty()) ? obj["default_branch"] : "master";
|
||||
|
||||
// Clear branch list and add the default branch
|
||||
ui->comboBranch->clear();
|
||||
ui->comboBranch->addItem(QString::fromStdString(default_branch));
|
||||
|
||||
// Parse data and assemble branch list
|
||||
std::vector<std::string> branches;
|
||||
for(auto it=obj_branches.cbegin();it!=obj_branches.cend();++it)
|
||||
{
|
||||
if(it.key() != default_branch)
|
||||
ui->comboBranch->addItem(QString::fromStdString(it.key()));
|
||||
}
|
||||
|
||||
// If a branch was suggested, select it now
|
||||
if(!select_branch.isEmpty())
|
||||
ui->comboBranch->setCurrentIndex(ui->comboBranch->findText(select_branch));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ private:
|
||||
|
||||
protected slots:
|
||||
void checkInput();
|
||||
void reloadBranchList(const QString& select_branch = QString());
|
||||
void accept() override;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user