mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-19 12:40:49 +00:00
Scroll the selected row to the middle of the viewport.
This commit is contained in:
parent
4152086890
commit
16bf9716a3
@ -7,6 +7,7 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QMetaObject>
|
||||||
#include <QtCore/qnamespace.h>
|
#include <QtCore/qnamespace.h>
|
||||||
|
|
||||||
#include "../../model/doc/document.hpp"
|
#include "../../model/doc/document.hpp"
|
||||||
@ -744,6 +745,10 @@ std::vector< CSMWorld::UniversalId > CSVWorld::Table::getDraggedRecords() const
|
|||||||
return idToDrag;
|
return idToDrag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parent, start and end depend on the model sending the signal, in this case mProxyModel
|
||||||
|
//
|
||||||
|
// If, for example, mModel was used instead, then scrolTo() should use the index
|
||||||
|
// mProxyModel->mapFromSource(mModel->index(end, 0))
|
||||||
void CSVWorld::Table::rowsInsertedEvent(const QModelIndex& parent, int start, int end)
|
void CSVWorld::Table::rowsInsertedEvent(const QModelIndex& parent, int start, int end)
|
||||||
{
|
{
|
||||||
tableSizeUpdate();
|
tableSizeUpdate();
|
||||||
@ -752,17 +757,29 @@ void CSVWorld::Table::rowsInsertedEvent(const QModelIndex& parent, int start, in
|
|||||||
{
|
{
|
||||||
selectRow(end);
|
selectRow(end);
|
||||||
|
|
||||||
|
// without this delay the scroll works but goes to top for add/clone
|
||||||
|
QMetaObject::invokeMethod(this, "queuedScrollTo", Qt::QueuedConnection, Q_ARG(int, end));
|
||||||
|
|
||||||
if(mUnselectAfterJump)
|
if(mUnselectAfterJump)
|
||||||
clearSelection();
|
clearSelection();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVWorld::Table::queuedScrollTo(int row)
|
||||||
|
{
|
||||||
|
scrollTo(mProxyModel->index(row, 0), QAbstractItemView::PositionAtCenter);
|
||||||
|
}
|
||||||
|
|
||||||
void CSVWorld::Table::dataChangedEvent(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
void CSVWorld::Table::dataChangedEvent(const QModelIndex &topLeft, const QModelIndex &bottomRight)
|
||||||
{
|
{
|
||||||
tableSizeUpdate();
|
tableSizeUpdate();
|
||||||
|
|
||||||
if (mAutoJump)
|
if (mAutoJump)
|
||||||
|
{
|
||||||
selectRow(bottomRight.row());
|
selectRow(bottomRight.row());
|
||||||
|
scrollTo(mProxyModel->index(bottomRight.row(), 0), QAbstractItemView::PositionAtCenter);
|
||||||
|
//scrollTo(bottomRight, QAbstractItemView::PositionAtCenter); // alternative
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::Table::jumpAfterModChanged(int state)
|
void CSVWorld::Table::jumpAfterModChanged(int state)
|
||||||
|
@ -148,6 +148,8 @@ namespace CSVWorld
|
|||||||
void dataChangedEvent(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
void dataChangedEvent(const QModelIndex &topLeft, const QModelIndex &bottomRight);
|
||||||
|
|
||||||
void jumpAfterModChanged(int state);
|
void jumpAfterModChanged(int state);
|
||||||
|
|
||||||
|
void queuedScrollTo(int state);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user