Commit 65b78743 authored by Orgad Shaneh's avatar Orgad Shaneh

Git: Prevent checking unmerged files in submit editor

Change-Id: Ic226638a522ca92f61b8b6736a325c1cc747ff62
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 30d548ea
......@@ -69,6 +69,6 @@ void CommitEditor::setFields(const QString &repositoryRoot,
m_fileModel = new VcsBase::SubmitFileModel(this);
foreach (const VcsBase::VcsBaseClient::StatusItem &item, repoStatus)
if (item.flags != QLatin1String("Unknown"))
m_fileModel->addFile(item.file, item.flags, true);
m_fileModel->addFile(item.file, item.flags);
setFileModel(m_fileModel, repositoryRoot);
}
......@@ -60,7 +60,7 @@ void ClearCaseSubmitEditor::setStatusList(const QStringList &statusOutput)
const ConstIterator cend = statusOutput.constEnd();
for (ConstIterator it = statusOutput.constBegin(); it != cend; ++it)
model->addFile(*it, QLatin1String("C"), true);
model->addFile(*it, QLatin1String("C"));
setFileModel(model, checkScriptWorkingDirectory());
if (statusOutput.count() > 1)
submitEditorWidget()->addKeep();
......
......@@ -65,6 +65,6 @@ void CvsSubmitEditor::setStateList(const StateFilePairs &statusOutput)
const ConstIterator cend = statusOutput.constEnd();
for (ConstIterator it = statusOutput.constBegin(); it != cend; ++it)
model->addFile(it->second, stateName(it->first), true);
model->addFile(it->second, stateName(it->first));
setFileModel(model);
}
......@@ -72,7 +72,14 @@ void GitSubmitEditor::setCommitData(const CommitData &d)
it != d.files.constEnd(); ++it) {
const FileStates state = it->first;
const QString file = it->second;
m_model->addFile(file, CommitData::stateDisplayName(state), state & StagedFile,
VcsBase::CheckMode checkMode;
if (state & UnmergedFile)
checkMode = VcsBase::Uncheckable;
else if (state & StagedFile)
checkMode = VcsBase::Checked;
else
checkMode = VcsBase::Unchecked;
m_model->addFile(file, CommitData::stateDisplayName(state), checkMode,
QVariant(static_cast<int>(state)));
}
}
......
......@@ -69,7 +69,7 @@ void CommitEditor::setFields(const QFileInfo &repositoryRoot, const QString &bra
if (item.flags == QLatin1String("Untracked"))
shouldTrack.append(item.file);
else
fileModel->addFile(item.file, item.flags, false);
fileModel->addFile(item.file, item.flags, VcsBase::Unchecked);
}
VcsBaseSubmitEditor::filterUntrackedFilesOfProject(repositoryRoot.absoluteFilePath(),
......@@ -78,7 +78,7 @@ void CommitEditor::setFields(const QFileInfo &repositoryRoot, const QString &bra
foreach (const QString &track, shouldTrack) {
foreach (const VcsBaseClient::StatusItem &item, repoStatus) {
if (item.file == track)
fileModel->addFile(item.file, item.flags, false);
fileModel->addFile(item.file, item.flags, VcsBase::Unchecked);
}
}
......
......@@ -50,7 +50,7 @@ void SubversionSubmitEditor::setStatusList(const QList<StatusFilePair> &statusOu
const ConstIterator cend = statusOutput.constEnd();
for (ConstIterator it = statusOutput.constBegin(); it != cend; ++it)
model->addFile(it->second, it->first, true);
model->addFile(it->second, it->first);
// Hack to allow completion in "description" field : completion needs a root repository, the
// checkScriptWorkingDirectory property is fine (at this point it was set by SubversionPlugin)
setFileModel(model, this->checkScriptWorkingDirectory());
......
......@@ -43,11 +43,12 @@ namespace VcsBase {
// --------------------------------------------------------------------------
static QList<QStandardItem *> createFileRow(const QString &fileName, const QString &status,
bool checked, const QVariant &v)
CheckMode checked, const QVariant &v)
{
QStandardItem *statusItem = new QStandardItem(status);
statusItem->setCheckable(true);
statusItem->setCheckState(checked ? Qt::Checked : Qt::Unchecked);
statusItem->setCheckable(checked != Uncheckable);
if (checked != Uncheckable)
statusItem->setCheckState(checked == Checked ? Qt::Checked : Qt::Unchecked);
statusItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
statusItem->setData(v);
QStandardItem *fileItem = new QStandardItem(fileName);
......@@ -78,10 +79,10 @@ SubmitFileModel::SubmitFileModel(QObject *parent) :
setHorizontalHeaderLabels(headerLabels);
}
QList<QStandardItem *> SubmitFileModel::addFile(const QString &fileName, const QString &status, bool checked,
QList<QStandardItem *> SubmitFileModel::addFile(const QString &fileName, const QString &status, CheckMode checkMode,
const QVariant &v)
{
const QList<QStandardItem *> row = createFileRow(fileName, status, checked, v);
const QList<QStandardItem *> row = createFileRow(fileName, status, checkMode, v);
appendRow(row);
return row;
}
......
......@@ -36,6 +36,13 @@
namespace VcsBase {
enum CheckMode
{
Unchecked,
Checked,
Uncheckable
};
class VCSBASE_EXPORT SubmitFileModel : public QStandardItemModel
{
Q_OBJECT
......@@ -44,7 +51,7 @@ public:
// Convenience to create and add rows containing a file plus status text.
QList<QStandardItem *> addFile(const QString &fileName, const QString &status = QString(),
bool checked = true, const QVariant &data = QVariant());
CheckMode checkMode = Checked, const QVariant &data = QVariant());
// Find convenience that returns the whole row (as opposed to QStandardItemModel::find).
QList<QStandardItem *> findRow(const QString &text, int column = 0) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment