mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 14:23:35 -07:00
Apply suggestions from code review (WIP)
Co-authored-by: Chocobo1 <Chocobo1@users.noreply.github.com>
This commit is contained in:
parent
2f3a0520a5
commit
ef71a36fc5
4 changed files with 10 additions and 10 deletions
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,6 @@ public:
|
|||
private:
|
||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||
|
||||
TransferListWidget *m_treeView;
|
||||
TransferListWidget *m_treeView = nullptr;
|
||||
QPersistentModelIndex m_lastClickedIndex;
|
||||
};
|
||||
|
|
|
@ -74,8 +74,8 @@
|
|||
#include "utils.h"
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
#include "macutilities.h"
|
||||
#include "macosshiftclickhandler.h"
|
||||
#include "macutilities.h"
|
||||
#endif
|
||||
|
||||
namespace
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue