From e0a6af087e83d79b53ad5352511c7e02c557b93f Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sat, 4 Jul 2015 00:38:08 -0700 Subject: [PATCH] Qt: Adjust memory selection by shift-clicking --- src/platform/qt/MemoryModel.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/platform/qt/MemoryModel.cpp b/src/platform/qt/MemoryModel.cpp index 9da66021e..71372ccee 100644 --- a/src/platform/qt/MemoryModel.cpp +++ b/src/platform/qt/MemoryModel.cpp @@ -316,13 +316,21 @@ void MemoryModel::mousePressEvent(QMouseEvent* event) { } QPoint position(event->pos() - QPoint(m_margins.left(), m_margins.top())); - uint32_t address = - int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base; + uint32_t address = int(position.x() / m_cellSize.width()) + + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base; if (event->button() == Qt::RightButton && isInSelection(address)) { return; } - m_selectionAnchor = address & ~(m_align - 1); - m_selection = qMakePair(m_selectionAnchor, m_selectionAnchor + m_align); + if (event->modifiers() & Qt::ShiftModifier) { + if ((address & ~(m_align - 1)) < m_selectionAnchor) { + m_selection = qMakePair(address & ~(m_align - 1), m_selectionAnchor + m_align); + } else { + m_selection = qMakePair(m_selectionAnchor, (address & ~(m_align - 1)) + m_align); + } + } else { + m_selectionAnchor = address & ~(m_align - 1); + m_selection = qMakePair(m_selectionAnchor, m_selectionAnchor + m_align); + } m_buffer = 0; m_bufferedNybbles = 0; emit selectionChanged(m_selection.first, m_selection.second); @@ -336,8 +344,8 @@ void MemoryModel::mouseMoveEvent(QMouseEvent* event) { } QPoint position(event->pos() - QPoint(m_margins.left(), m_margins.top())); - uint32_t address = - int(position.x() / m_cellSize.width()) + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base; + uint32_t address = int(position.x() / m_cellSize.width()) + + (int(position.y() / m_cellSize.height()) + m_top) * 16 + m_base; if ((address & ~(m_align - 1)) < m_selectionAnchor) { m_selection = qMakePair(address & ~(m_align - 1), m_selectionAnchor + m_align); } else {