Apply suggestions from code review (WIP)

Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
This commit is contained in:
Luke Memet 2025-02-15 15:54:09 -05:00 committed by GitHub
commit ef71a36fc5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 10 additions and 10 deletions

View file

@ -287,10 +287,10 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
macosdockbadge/badger.mm
macosdockbadge/badgeview.h
macosdockbadge/badgeview.mm
macutilities.h
macutilities.mm
macosshiftclickhandler.h
macosshiftclickhandler.cpp
macutilities.h
macutilities.mm
)
target_link_libraries(qbt_gui PRIVATE objc)
endif()

View file

@ -42,7 +42,7 @@ bool MacOSShiftClickHandler::eventFilter(QObject *watched, QEvent *event)
{
if ((watched == m_treeView) && (event->type() == QEvent::MouseButtonPress))
{
auto *mouseEvent = static_cast<QMouseEvent *>(event);
const auto *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() != Qt::LeftButton)
return false;
@ -52,20 +52,20 @@ bool MacOSShiftClickHandler::eventFilter(QObject *watched, QEvent *event)
const Qt::KeyboardModifiers modifiers = mouseEvent->modifiers();
const bool shiftPressed = modifiers.testFlag(Qt::ShiftModifier);
const bool commandPressed = modifiers.testFlag(Qt::ControlModifier);
if (shiftPressed && m_lastClickedIndex.isValid())
{
const QItemSelection selection(m_lastClickedIndex, clickedIndex);
const bool commandPressed = modifiers.testFlag(Qt::ControlModifier);
if (commandPressed)
m_treeView->selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
m_treeView->selectionModel()->select(selection, (QItemSelectionModel::Select | QItemSelectionModel::Rows));
else
m_treeView->selectionModel()->select(selection, QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
m_treeView->selectionModel()->select(selection, (QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows));
m_treeView->selectionModel()->setCurrentIndex(clickedIndex, QItemSelectionModel::NoUpdate);
return true;
}
if (!(modifiers & (Qt::AltModifier | Qt::MetaModifier)))
if (!modifiers.testFlags(Qt::AltModifier | Qt::MetaModifier))
m_lastClickedIndex = clickedIndex;
}

View file

@ -45,6 +45,6 @@ public:
private:
bool eventFilter(QObject *watched, QEvent *event) override;
TransferListWidget *m_treeView;
TransferListWidget *m_treeView = nullptr;
QPersistentModelIndex m_lastClickedIndex;
};

View file

@ -74,8 +74,8 @@
#include "utils.h"
#ifdef Q_OS_MACOS
#include "macutilities.h"
#include "macosshiftclickhandler.h"
#include "macutilities.h"
#endif
namespace