mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-22 22:33:34 -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/badger.mm
|
||||||
macosdockbadge/badgeview.h
|
macosdockbadge/badgeview.h
|
||||||
macosdockbadge/badgeview.mm
|
macosdockbadge/badgeview.mm
|
||||||
macutilities.h
|
|
||||||
macutilities.mm
|
|
||||||
macosshiftclickhandler.h
|
macosshiftclickhandler.h
|
||||||
macosshiftclickhandler.cpp
|
macosshiftclickhandler.cpp
|
||||||
|
macutilities.h
|
||||||
|
macutilities.mm
|
||||||
)
|
)
|
||||||
target_link_libraries(qbt_gui PRIVATE objc)
|
target_link_libraries(qbt_gui PRIVATE objc)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -42,7 +42,7 @@ bool MacOSShiftClickHandler::eventFilter(QObject *watched, QEvent *event)
|
||||||
{
|
{
|
||||||
if ((watched == m_treeView) && (event->type() == QEvent::MouseButtonPress))
|
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)
|
if (mouseEvent->button() != Qt::LeftButton)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -52,20 +52,20 @@ bool MacOSShiftClickHandler::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
|
||||||
const Qt::KeyboardModifiers modifiers = mouseEvent->modifiers();
|
const Qt::KeyboardModifiers modifiers = mouseEvent->modifiers();
|
||||||
const bool shiftPressed = modifiers.testFlag(Qt::ShiftModifier);
|
const bool shiftPressed = modifiers.testFlag(Qt::ShiftModifier);
|
||||||
const bool commandPressed = modifiers.testFlag(Qt::ControlModifier);
|
|
||||||
|
|
||||||
if (shiftPressed && m_lastClickedIndex.isValid())
|
if (shiftPressed && m_lastClickedIndex.isValid())
|
||||||
{
|
{
|
||||||
const QItemSelection selection(m_lastClickedIndex, clickedIndex);
|
const QItemSelection selection(m_lastClickedIndex, clickedIndex);
|
||||||
|
const bool commandPressed = modifiers.testFlag(Qt::ControlModifier);
|
||||||
if (commandPressed)
|
if (commandPressed)
|
||||||
m_treeView->selectionModel()->select(selection, QItemSelectionModel::Select | QItemSelectionModel::Rows);
|
m_treeView->selectionModel()->select(selection, (QItemSelectionModel::Select | QItemSelectionModel::Rows));
|
||||||
else
|
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);
|
m_treeView->selectionModel()->setCurrentIndex(clickedIndex, QItemSelectionModel::NoUpdate);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(modifiers & (Qt::AltModifier | Qt::MetaModifier)))
|
if (!modifiers.testFlags(Qt::AltModifier | Qt::MetaModifier))
|
||||||
m_lastClickedIndex = clickedIndex;
|
m_lastClickedIndex = clickedIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,6 @@ public:
|
||||||
private:
|
private:
|
||||||
bool eventFilter(QObject *watched, QEvent *event) override;
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
TransferListWidget *m_treeView;
|
TransferListWidget *m_treeView = nullptr;
|
||||||
QPersistentModelIndex m_lastClickedIndex;
|
QPersistentModelIndex m_lastClickedIndex;
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,8 +74,8 @@
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
#include "macutilities.h"
|
|
||||||
#include "macosshiftclickhandler.h"
|
#include "macosshiftclickhandler.h"
|
||||||
|
#include "macutilities.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue