diff --git a/src/RemoteDatabase.cpp b/src/RemoteDatabase.cpp index 2acd9d81..d9980830 100644 --- a/src/RemoteDatabase.cpp +++ b/src/RemoteDatabase.cpp @@ -414,7 +414,7 @@ void RemoteDatabase::fetch(const QString& url, RequestType type, const QString& } void RemoteDatabase::push(const QString& filename, const QString& url, const QString& clientCert, const QString& remotename, - const QString& commitMessage, const QString& licence, bool isPublic, const QString& branch) + const QString& commitMessage, const QString& licence, bool isPublic, const QString& branch, bool forcePush) { // Check if network is accessible. If not, abort right here if(m_manager->networkAccessible() == QNetworkAccessManager::NotAccessible) @@ -445,6 +445,7 @@ void RemoteDatabase::push(const QString& filename, const QString& url, const QSt addPart(multipart, "public", isPublic ? "true" : "false"); addPart(multipart, "branch", branch); addPart(multipart, "commit", localLastCommitId(filename)); + addPart(multipart, "force", forcePush ? "true" : "false"); // Set SSL configuration when trying to access a file via the HTTPS protocol bool https = QUrl(url).scheme().compare("https", Qt::CaseInsensitive) == 0; diff --git a/src/RemoteDatabase.h b/src/RemoteDatabase.h index 5fc484f3..0247cf0f 100644 --- a/src/RemoteDatabase.h +++ b/src/RemoteDatabase.h @@ -46,7 +46,8 @@ public: void fetch(const QString& url, RequestType type, const QString& clientCert = QString(), QVariant userdata = QVariant()); void push(const QString& filename, const QString& url, const QString& clientCert, const QString& remotename, - const QString& commitMessage = QString(), const QString& licence = QString(), bool isPublic = false, const QString& branch = QString("master")); + const QString& commitMessage = QString(), const QString& licence = QString(), bool isPublic = false, + const QString& branch = QString("master"), bool forcePush = false); signals: // The openFile signal is emitted whenever a remote database file shall be opened in the main window. This happens when the diff --git a/src/RemoteDock.cpp b/src/RemoteDock.cpp index 122bdaf5..fb356b36 100644 --- a/src/RemoteDock.cpp +++ b/src/RemoteDock.cpp @@ -111,7 +111,7 @@ void RemoteDock::pushDatabase() // Push database remoteDatabase.push(mainWindow->getDb().currentFile(), url, remoteModel->currentClientCertificate(), pushDialog.name(), - pushDialog.commitMessage(), pushDialog.licence(), pushDialog.isPublic(), pushDialog.branch()); + pushDialog.commitMessage(), pushDialog.licence(), pushDialog.isPublic(), pushDialog.branch(), pushDialog.forcePush()); } void RemoteDock::newDirectoryNode(const QModelIndex& parent) diff --git a/src/RemotePushDialog.cpp b/src/RemotePushDialog.cpp index 4f655ee4..29166a3d 100644 --- a/src/RemotePushDialog.cpp +++ b/src/RemotePushDialog.cpp @@ -43,6 +43,12 @@ void RemotePushDialog::checkInput() else ui->checkPublic->setText(tr("Database will be private. Only you have access to it.")); + // Update the foce push check box text + if(ui->checkForce->isChecked()) + ui->checkForce->setText(tr("Use with care. This can cause remote commits to be deleted.")); + else + ui->checkForce->setText(" "); // The space character here is required to avoid annoying resizes when toggling the checkbox + // Check input bool valid = true; @@ -88,6 +94,11 @@ QString RemotePushDialog::branch() const return ui->comboBranch->currentText(); } +bool RemotePushDialog::forcePush() const +{ + return ui->checkForce->isChecked(); +} + void RemotePushDialog::fillInLicences(const QMap& licences) { // Clear licence list and add default item for unspecified licence diff --git a/src/RemotePushDialog.h b/src/RemotePushDialog.h index 030f2cff..0873fea2 100644 --- a/src/RemotePushDialog.h +++ b/src/RemotePushDialog.h @@ -22,6 +22,7 @@ public: QString licence() const; bool isPublic() const; QString branch() const; + bool forcePush() const; private: Ui::RemotePushDialog* ui; diff --git a/src/RemotePushDialog.ui b/src/RemotePushDialog.ui index 26ec75c6..752f53d9 100644 --- a/src/RemotePushDialog.ui +++ b/src/RemotePushDialog.ui @@ -6,8 +6,8 @@ 0 0 - 534 - 277 + 583 + 300 @@ -110,6 +110,19 @@ p, li { white-space: pre-wrap; } + + + + Force push + + + checkForce + + + + + + @@ -245,6 +258,22 @@ p, li { white-space: pre-wrap; } + + checkForce + toggled(bool) + RemotePushDialog + checkInput() + + + 168 + 240 + + + 62 + 229 + + + checkInput()