This commit is contained in:
Martin Rotter 2021-06-01 13:06:17 +02:00
parent e233deb549
commit a7410954a4
2 changed files with 7 additions and 2 deletions

View File

@ -26,7 +26,8 @@
#include <QTimer>
#include <QTimer>
MessagesView::MessagesView(QWidget* parent) : QTreeView(parent), m_contextMenu(nullptr), m_columnsAdjusted(false) {
MessagesView::MessagesView(QWidget* parent)
: QTreeView(parent), m_contextMenu(nullptr), m_columnsAdjusted(false), m_processingMouse(false) {
m_sourceModel = qApp->feedReader()->messagesModel();
m_proxyModel = qApp->feedReader()->messagesProxyModel();
@ -276,7 +277,9 @@ void MessagesView::initializeContextMenu() {
}
void MessagesView::mousePressEvent(QMouseEvent* event) {
m_processingMouse = true;
QTreeView::mousePressEvent(event);
m_processingMouse = false;
switch (event->button()) {
case Qt::MouseButton::LeftButton: {
@ -347,7 +350,8 @@ void MessagesView::selectionChanged(const QItemSelection& selected, const QItemS
emit currentMessageRemoved();
}
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()) {
if (!m_processingMouse &&
qApp->settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()) {
scrollTo(currentIndex(), QAbstractItemView::ScrollHint::PositionAtCenter);
}

View File

@ -103,6 +103,7 @@ class MessagesView : public QTreeView {
MessagesProxyModel* m_proxyModel;
MessagesModel* m_sourceModel;
bool m_columnsAdjusted;
bool m_processingMouse;
};
inline MessagesProxyModel* MessagesView::model() const {