dbhub: Fix branch list in push dialog

The JSON format generated by the server has changed.
This commit is contained in:
Martin Kleusberg
2017-09-08 14:49:02 +02:00
parent c44e8ce9e0
commit 08e5f532ce
5 changed files with 15 additions and 8 deletions

View File

@@ -188,14 +188,18 @@ void RemoteDatabase::gotReply(QNetworkReply* reply)
if(json.isNull() || !json.isObject())
break;
QJsonObject obj = json.object();
QJsonObject obj_branches = obj["branches"].toObject();
// Parse data and assemble branch list
QStringList branches;
for(auto it=obj.constBegin();it!=obj.constEnd();++it)
for(auto it=obj_branches.constBegin();it!=obj_branches.constEnd();++it)
branches.append(it.key());
// Get default branch
QString default_branch = obj["default_branch"].toString("master");
// Send branch list to anyone who is interested
emit gotBranchList(branches);
emit gotBranchList(branches, default_branch);
break;
}
case RequestTypePush:

View File

@@ -58,7 +58,7 @@ signals:
void gotDirList(QString json, QVariant userdata);
void gotCurrentVersion(QString version, QString url);
void gotLicenceList(QMap<QString, QString> licences);
void gotBranchList(QStringList branches);
void gotBranchList(QStringList branches, QString default_branch);
// The uploadFinished() signal is emitted when a push() call is finished, i.e. a database upload has completed.
void uploadFinished(QString url);

View File

@@ -99,16 +99,16 @@ void RemotePushDialog::fillInLicences(const QMap<QString, QString>& licences)
ui->comboLicence->addItem(it.value(), it.key());
}
void RemotePushDialog::fillInBranches(const QStringList& branches)
void RemotePushDialog::fillInBranches(const QStringList& branches, const QString& default_branch)
{
// Clear branch list and add the default master branch
// Clear branch list and add the default branch
ui->comboBranch->clear();
ui->comboBranch->addItem("master");
ui->comboBranch->addItem(default_branch);
// Add rest of the branch list to the combo box
foreach(const QString& branch, branches)
{
if(branch != "master")
if(branch != default_branch)
ui->comboBranch->addItem(branch);
}
}

View File

@@ -40,7 +40,7 @@ protected slots:
void reloadBranchList();
void fillInLicences(const QMap<QString, QString>& licences);
void fillInBranches(const QStringList& branches);
void fillInBranches(const QStringList& branches, const QString& default_branch);
};
#endif

View File

@@ -105,6 +105,9 @@ p, li { white-space: pre-wrap; }
<property name="editable">
<bool>true</bool>
</property>
<property name="duplicatesEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>