1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Creator. 7 ** 8 ** Commercial License Usage 9 ** Licensees holding valid commercial Qt licenses may use this file in 10 ** accordance with the commercial license agreement provided with the 11 ** Software or, alternatively, in accordance with the terms contained in 12 ** a written agreement between you and The Qt Company. For licensing terms 13 ** and conditions see https://www.qt.io/terms-conditions. For further 14 ** information use the contact form at https://www.qt.io/contact-us. 15 ** 16 ** GNU General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU 18 ** General Public License version 3 as published by the Free Software 19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 20 ** included in the packaging of this file. Please review the following 21 ** information to ensure the GNU General Public License requirements will 22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 23 ** 24 ****************************************************************************/ 25 26 #include "subversionsubmiteditor.h" 27 #include "subversionplugin.h" 28 29 #include <coreplugin/idocument.h> 30 #include <vcsbase/submiteditorwidget.h> 31 #include <vcsbase/submitfilemodel.h> 32 33 using namespace Subversion::Internal; 34 SubversionSubmitEditor()35SubversionSubmitEditor::SubversionSubmitEditor() : 36 VcsBase::VcsBaseSubmitEditor(new VcsBase::SubmitEditorWidget) 37 { 38 document()->setPreferredDisplayName(tr("Subversion Submit")); 39 setDescriptionMandatory(false); 40 } 41 setStatusList(const QList<StatusFilePair> & statusOutput)42void SubversionSubmitEditor::setStatusList(const QList<StatusFilePair> &statusOutput) 43 { 44 auto model = new VcsBase::SubmitFileModel(this); 45 // Hack to allow completion in "description" field : completion needs a root repository, the 46 // checkScriptWorkingDirectory property is fine (at this point it was set by SubversionPlugin) 47 model->setRepositoryRoot(checkScriptWorkingDirectory()); 48 model->setFileStatusQualifier([](const QString &status, const QVariant &) 49 -> VcsBase::SubmitFileModel::FileStatusHint 50 { 51 const QByteArray statusC = status.toLatin1(); 52 if (statusC == FileConflictedC) 53 return VcsBase::SubmitFileModel::FileUnmerged; 54 if (statusC == FileAddedC) 55 return VcsBase::SubmitFileModel::FileAdded; 56 if (statusC == FileModifiedC) 57 return VcsBase::SubmitFileModel::FileModified; 58 if (statusC == FileDeletedC) 59 return VcsBase::SubmitFileModel::FileDeleted; 60 return VcsBase::SubmitFileModel::FileStatusUnknown; 61 } ); 62 63 for (const StatusFilePair &pair : statusOutput) { 64 const VcsBase::CheckMode checkMode = 65 (pair.first == QLatin1String(FileConflictedC)) 66 ? VcsBase::Uncheckable 67 : VcsBase::Unchecked; 68 model->addFile(pair.second, pair.first, checkMode); 69 } 70 setFileModel(model); 71 } 72 fileContents() const73QByteArray SubversionSubmitEditor::fileContents() const 74 { 75 return description().toUtf8(); 76 } 77 setFileContents(const QByteArray & contents)78bool SubversionSubmitEditor::setFileContents(const QByteArray &contents) 79 { 80 setDescription(QString::fromUtf8(contents)); 81 return true; 82 } 83