Commit fc2a5d7f authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

VCS: Preserve uncheckable files on submit editor refresh

Change-Id: I652b5a96c994a13f8d0c02d850b15c5846d56e64
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 9f72e43f
......@@ -61,7 +61,8 @@ public:
for (; j < source->rowCount(); ++j) {
CommitData::StateFilePair sourceStateFile = gitSource->stateFilePair(j);
if (stateFile == sourceStateFile) {
setChecked(i, source->checked(j));
if (isCheckable(i) && source->isCheckable(j))
setChecked(i, source->checked(j));
break;
} else if (stateFile < sourceStateFile) {
break;
......
......@@ -48,10 +48,12 @@ static QList<QStandardItem *> createFileRow(const QString &fileName, const QStri
CheckMode checked, const QVariant &v)
{
QStandardItem *statusItem = new QStandardItem(status);
statusItem->setCheckable(checked != Uncheckable);
if (checked != Uncheckable)
Qt::ItemFlags flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
if (checked != Uncheckable) {
flags |= Qt::ItemIsUserCheckable;
statusItem->setCheckState(checked == Checked ? Qt::Checked : Qt::Unchecked);
statusItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsUserCheckable|Qt::ItemIsEnabled);
}
statusItem->setFlags(flags);
statusItem->setData(v);
QStandardItem *fileItem = new QStandardItem(fileName);
fileItem->setFlags(Qt::ItemIsSelectable|Qt::ItemIsEnabled);
......@@ -103,6 +105,13 @@ QString SubmitFileModel::file(int row) const
return item(row, fileColumn)->text();
}
bool SubmitFileModel::isCheckable(int row) const
{
if (row < 0 || row >= rowCount())
return false;
return item(row)->isCheckable();
}
bool SubmitFileModel::checked(int row) const
{
if (row < 0 || row >= rowCount())
......@@ -166,7 +175,8 @@ void SubmitFileModel::updateSelections(SubmitFileModel *source)
// to test rows earlier than latest match found
for (int j = lastMatched; j < sourceRows; ++j) {
if (file(i) == source->file(j) && state(i) == source->state(j)) {
setChecked(i, source->checked(j));
if (isCheckable(i) && source->isCheckable(j))
setChecked(i, source->checked(j));
lastMatched = j + 1; // No duplicates, start on next entry
break;
}
......
......@@ -55,6 +55,7 @@ public:
QString state(int row) const;
QString file(int row) const;
bool isCheckable(int row) const;
bool checked(int row) const;
void setChecked(int row, bool check);
void setAllChecked(bool check);
......
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