forked from qt-creator/qt-creator
VCS: Preserve selections in commit editor on refresh
Task-number: QTCREATORBUG-18483 Change-Id: I749f2d4d583f197e7b5b6f69116c3a196e85484b Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
caaf370660
commit
6c70f22ada
@@ -28,6 +28,8 @@
|
||||
#include "submitfilemodel.h"
|
||||
#include "ui_submiteditorwidget.h"
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
#include <QDebug>
|
||||
#include <QPointer>
|
||||
#include <QTextBlock>
|
||||
@@ -117,18 +119,6 @@ public slots:
|
||||
|
||||
// Helpers to retrieve model data
|
||||
// Convenience to extract a list of selected indexes
|
||||
QList<int> selectedRows(const QAbstractItemView *view)
|
||||
{
|
||||
const QModelIndexList indexList = view->selectionModel()->selectedRows(0);
|
||||
if (indexList.empty())
|
||||
return QList<int>();
|
||||
QList<int> rc;
|
||||
const QModelIndexList::const_iterator cend = indexList.constEnd();
|
||||
for (QModelIndexList::const_iterator it = indexList.constBegin(); it != cend; ++it)
|
||||
rc.push_back(it->row());
|
||||
return rc;
|
||||
}
|
||||
|
||||
// ----------- SubmitEditorWidgetPrivate
|
||||
|
||||
struct SubmitEditorWidgetPrivate
|
||||
@@ -463,7 +453,7 @@ Utils::CompletingTextEdit *SubmitEditorWidget::descriptionEdit() const
|
||||
|
||||
void SubmitEditorWidget::triggerDiffSelected()
|
||||
{
|
||||
const QList<int> sel = selectedRows(d->m_ui.fileView);
|
||||
const QList<int> sel = selectedRows();
|
||||
if (!sel.empty())
|
||||
emit diffSelected(sel);
|
||||
}
|
||||
@@ -610,6 +600,22 @@ bool SubmitEditorWidget::updateInProgress() const
|
||||
return d->m_updateInProgress;
|
||||
}
|
||||
|
||||
QList<int> SubmitEditorWidget::selectedRows() const
|
||||
{
|
||||
return Utils::transform(d->m_ui.fileView->selectionModel()->selectedRows(0), &QModelIndex::row);
|
||||
}
|
||||
|
||||
void SubmitEditorWidget::setSelectedRows(const QList<int> &rows)
|
||||
{
|
||||
if (const SubmitFileModel *model = fileModel()) {
|
||||
QItemSelectionModel *selectionModel = d->m_ui.fileView->selectionModel();
|
||||
for (int row : rows) {
|
||||
selectionModel->select(model->index(row, 0),
|
||||
QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString SubmitEditorWidget::commitName() const
|
||||
{
|
||||
return tr("&Commit");
|
||||
|
@@ -100,6 +100,9 @@ public:
|
||||
void setUpdateInProgress(bool value);
|
||||
bool updateInProgress() const;
|
||||
|
||||
QList<int> selectedRows() const;
|
||||
void setSelectedRows(const QList<int> &rows);
|
||||
|
||||
public slots:
|
||||
void updateSubmitAction();
|
||||
|
||||
|
@@ -411,10 +411,15 @@ void VcsBaseSubmitEditor::setFileModel(SubmitFileModel *model)
|
||||
{
|
||||
QTC_ASSERT(model, return);
|
||||
SubmitFileModel *oldModel = d->m_widget->fileModel();
|
||||
if (oldModel)
|
||||
QList<int> selected;
|
||||
if (oldModel) {
|
||||
model->updateSelections(oldModel);
|
||||
selected = d->m_widget->selectedRows();
|
||||
}
|
||||
d->m_widget->setFileModel(model);
|
||||
delete oldModel;
|
||||
if (!selected.isEmpty())
|
||||
d->m_widget->setSelectedRows(selected);
|
||||
|
||||
QSet<QString> uniqueSymbols;
|
||||
const CPlusPlus::Snapshot cppSnapShot = CppTools::CppModelManager::instance()->snapshot();
|
||||
|
Reference in New Issue
Block a user