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 "submitfilemodel.h"
|
||||||
#include "ui_submiteditorwidget.h"
|
#include "ui_submiteditorwidget.h"
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
@@ -117,18 +119,6 @@ public slots:
|
|||||||
|
|
||||||
// Helpers to retrieve model data
|
// Helpers to retrieve model data
|
||||||
// Convenience to extract a list of selected indexes
|
// 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
|
// ----------- SubmitEditorWidgetPrivate
|
||||||
|
|
||||||
struct SubmitEditorWidgetPrivate
|
struct SubmitEditorWidgetPrivate
|
||||||
@@ -463,7 +453,7 @@ Utils::CompletingTextEdit *SubmitEditorWidget::descriptionEdit() const
|
|||||||
|
|
||||||
void SubmitEditorWidget::triggerDiffSelected()
|
void SubmitEditorWidget::triggerDiffSelected()
|
||||||
{
|
{
|
||||||
const QList<int> sel = selectedRows(d->m_ui.fileView);
|
const QList<int> sel = selectedRows();
|
||||||
if (!sel.empty())
|
if (!sel.empty())
|
||||||
emit diffSelected(sel);
|
emit diffSelected(sel);
|
||||||
}
|
}
|
||||||
@@ -610,6 +600,22 @@ bool SubmitEditorWidget::updateInProgress() const
|
|||||||
return d->m_updateInProgress;
|
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
|
QString SubmitEditorWidget::commitName() const
|
||||||
{
|
{
|
||||||
return tr("&Commit");
|
return tr("&Commit");
|
||||||
|
@@ -100,6 +100,9 @@ public:
|
|||||||
void setUpdateInProgress(bool value);
|
void setUpdateInProgress(bool value);
|
||||||
bool updateInProgress() const;
|
bool updateInProgress() const;
|
||||||
|
|
||||||
|
QList<int> selectedRows() const;
|
||||||
|
void setSelectedRows(const QList<int> &rows);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateSubmitAction();
|
void updateSubmitAction();
|
||||||
|
|
||||||
|
@@ -411,10 +411,15 @@ void VcsBaseSubmitEditor::setFileModel(SubmitFileModel *model)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(model, return);
|
QTC_ASSERT(model, return);
|
||||||
SubmitFileModel *oldModel = d->m_widget->fileModel();
|
SubmitFileModel *oldModel = d->m_widget->fileModel();
|
||||||
if (oldModel)
|
QList<int> selected;
|
||||||
|
if (oldModel) {
|
||||||
model->updateSelections(oldModel);
|
model->updateSelections(oldModel);
|
||||||
|
selected = d->m_widget->selectedRows();
|
||||||
|
}
|
||||||
d->m_widget->setFileModel(model);
|
d->m_widget->setFileModel(model);
|
||||||
delete oldModel;
|
delete oldModel;
|
||||||
|
if (!selected.isEmpty())
|
||||||
|
d->m_widget->setSelectedRows(selected);
|
||||||
|
|
||||||
QSet<QString> uniqueSymbols;
|
QSet<QString> uniqueSymbols;
|
||||||
const CPlusPlus::Snapshot cppSnapShot = CppTools::CppModelManager::instance()->snapshot();
|
const CPlusPlus::Snapshot cppSnapShot = CppTools::CppModelManager::instance()->snapshot();
|
||||||
|
Reference in New Issue
Block a user