同步操作将从 陈炳煌/sqlitebrowser 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include <QPushButton>#include <QUrlQuery>#include <QRegExpValidator>#include "RemotePushDialog.h"#include "ui_RemotePushDialog.h"#include "RemoteDatabase.h"RemotePushDialog::RemotePushDialog(QWidget* parent, RemoteDatabase& remote, const QString& host, const QString& clientCert, const QString& name) :QDialog(parent),ui(new Ui::RemotePushDialog),m_host(host),m_clientCert(clientCert),remoteDatabase(remote),m_nameValidator(new QRegExpValidator(QRegExp("^[a-z,A-Z,0-9,\\.,\\-,\\_,\\(,\\),\\+,\\ ]+$"), this)),m_branchValidator(new QRegExpValidator(QRegExp("^[a-z,A-Z,0-9,\\^,\\.,\\-,\\_,\\/,\\(,\\),\\:,\\&,\\ )]+$"), this)){// Create UIui->setupUi(this);ui->editName->setValidator(m_nameValidator);ui->comboBranch->setValidator(m_branchValidator);// Set start valuesui->editName->setText(name);// Enable/disable accept buttoncheckInput();// Fetch list of available licencesconnect(&remoteDatabase, &RemoteDatabase::gotLicenceList, this, &RemotePushDialog::fillInLicences);remoteDatabase.fetch(host + "licence/list", RemoteDatabase::RequestTypeLicenceList, clientCert);// Prepare fetching list of available branchesconnect(&remoteDatabase, &RemoteDatabase::gotBranchList, this, &RemotePushDialog::fillInBranches);reloadBranchList();}RemotePushDialog::~RemotePushDialog(){delete ui;}void RemotePushDialog::checkInput(){// Update public/private check box textif(ui->checkPublic->isChecked())ui->checkPublic->setText(tr("Database will be public. Everyone has read access to it."));elseui->checkPublic->setText(tr("Database will be private. Only you have access to it."));// Update the foce push check box textif(ui->checkForce->isChecked())ui->checkForce->setText(tr("Use with care. This can cause remote commits to be deleted."));elseui->checkForce->setText(" "); // The space character here is required to avoid annoying resizes when toggling the checkbox// Check inputbool valid = true;if(ui->editName->text().trimmed().isEmpty())valid = false;if(ui->editCommitMessage->toPlainText().size() > 1024)valid = false;if(ui->comboBranch->currentText().size() < 1 || ui->comboBranch->currentText().size() > 32)valid = false;ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(valid);}void RemotePushDialog::accept(){QDialog::accept();}QString RemotePushDialog::name() const{return ui->editName->text().trimmed();}QString RemotePushDialog::commitMessage() const{return ui->editCommitMessage->toPlainText().trimmed();}QString RemotePushDialog::licence() const{return ui->comboLicence->currentData(Qt::UserRole).toString();}bool RemotePushDialog::isPublic() const{return ui->checkPublic->isChecked();}QString RemotePushDialog::branch() const{return ui->comboBranch->currentText();}bool RemotePushDialog::forcePush() const{return ui->checkForce->isChecked();}void RemotePushDialog::fillInLicences(const std::vector<std::pair<std::string, std::string>>& licences){// Clear licence listui->comboLicence->clear();// Parse licence list and fill combo box. Show the full name to the user and use the short name as user data.for(const auto& it : licences)ui->comboLicence->addItem(QString::fromStdString(it.second), QString::fromStdString(it.first));}void RemotePushDialog::fillInBranches(const std::vector<std::string>& branches, const std::string& default_branch){// Clear branch list and add the default branchui->comboBranch->clear();ui->comboBranch->addItem(QString::fromStdString(default_branch));// Add rest of the branch list to the combo boxfor(const std::string& branch : branches){if(branch != default_branch)ui->comboBranch->addItem(QString::fromStdString(branch));}}void RemotePushDialog::reloadBranchList(){// Assemble query URLQUrl url(m_host + "branch/list");QUrlQuery query;query.addQueryItem("username", remoteDatabase.getInfoFromClientCert(m_clientCert, RemoteDatabase::CertInfoUser));query.addQueryItem("folder", "/");query.addQueryItem("dbname", ui->editName->text());url.setQuery(query);// Send requestremoteDatabase.fetch(url.toString(), RemoteDatabase::RequestTypeBranchList, m_clientCert);}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。